Merge "Check Trusty log driver version before opening" am: 83985071c8

Original change: https://android-review.googlesource.com/c/platform/system/logging/+/1972968

Change-Id: Id9b8102e60281fc7e637cefe0b52e6c5d71a0888
diff --git a/logd/TrustyLog.cpp b/logd/TrustyLog.cpp
index 7d6b8b3..83ecc4c 100644
--- a/logd/TrustyLog.cpp
+++ b/logd/TrustyLog.cpp
@@ -21,6 +21,7 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #define TRUSTY_LINE_BUFFER_SIZE 256
 static const char trustyprefix[] = "trusty";
@@ -28,6 +29,11 @@
 TrustyLog::TrustyLog(LogBuffer* buf, int fdRead) : SocketListener(fdRead, false), logbuf(buf) {}
 
 void TrustyLog::create(LogBuffer* buf) {
+    if (access("/sys/module/trusty_log/parameters/log_size", F_OK)) {
+        /* this device has the old driver which doesn't support poll() */
+        return;
+    }
+
     int fd = TEMP_FAILURE_RETRY(open("/dev/trusty-log0", O_RDONLY | O_NDELAY | O_CLOEXEC));
     if (fd >= 0) {
         TrustyLog* tl = new TrustyLog(buf, fd);