summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2012-02-21 15:48:53 -0800
committerNick Kralevich <nnk@google.com>2012-03-20 16:21:22 -0700
commit56c3065b7968e2cf00ffc4914d5f2fe86b98ae15 (patch)
treeec62041114e276c8aa01a72ebe9a9389773bd7b4 /include
parente8886740744d761d399c426321de3a7bba1c20ae (diff)
downloadsystem_core-56c3065b7968e2cf00ffc4914d5f2fe86b98ae15.zip
system_core-56c3065b7968e2cf00ffc4914d5f2fe86b98ae15.tar.gz
system_core-56c3065b7968e2cf00ffc4914d5f2fe86b98ae15.tar.bz2
logger: Add the update kernel struct to userspace
Android's kernel logger can optionally return UID information in addition to the previously returned information. This information is available by telling the kernel to use the updated structure via the newly introduced LOGGER_SET_VERSION ioctl. int fd = open("/dev/log/main", O_RDONLY); int version = 2; ioctl(fd, LOGGER_SET_VERSION, &version); Change-Id: I3914be41de55342c2918f8978fcd4d2b96a09288
Diffstat (limited to 'include')
-rw-r--r--include/cutils/logger.h41
1 files changed, 38 insertions, 3 deletions
diff --git a/include/cutils/logger.h b/include/cutils/logger.h
index b60f7ad..ccb0cac 100644
--- a/include/cutils/logger.h
+++ b/include/cutils/logger.h
@@ -11,7 +11,13 @@
#define _UTILS_LOGGER_H
#include <stdint.h>
+#include <sys/types.h>
+/*
+ * The userspace structure for version 1 of the logger_entry ABI.
+ * This structure is returned to userspace by the kernel logger
+ * driver unless an upgrade to a newer ABI version is requested.
+ */
struct logger_entry {
uint16_t len; /* length of the payload */
uint16_t __pad; /* no matter what, we get 2 bytes of padding */
@@ -22,14 +28,41 @@ struct logger_entry {
char msg[0]; /* the entry's payload */
};
+/*
+ * The userspace structure for version 2 of the logger_entry ABI.
+ * This structure is returned to userspace if ioctl(LOGGER_SET_VERSION)
+ * is called with version==2
+ */
+struct logger_entry_v2 {
+ uint16_t len; /* length of the payload */
+ uint16_t hdr_size; /* sizeof(struct logger_entry_v2) */
+ int32_t pid; /* generating process's pid */
+ int32_t tid; /* generating process's tid */
+ int32_t sec; /* seconds since Epoch */
+ int32_t nsec; /* nanoseconds */
+ uid_t euid; /* effective UID of logger */
+ char msg[0]; /* the entry's payload */
+};
+
#define LOGGER_LOG_MAIN "log/main"
#define LOGGER_LOG_RADIO "log/radio"
#define LOGGER_LOG_EVENTS "log/events"
#define LOGGER_LOG_SYSTEM "log/system"
-#define LOGGER_ENTRY_MAX_LEN (4*1024)
-#define LOGGER_ENTRY_MAX_PAYLOAD \
- (LOGGER_ENTRY_MAX_LEN - sizeof(struct logger_entry))
+/*
+ * The maximum size of the log entry payload that can be
+ * written to the kernel logger driver. An attempt to write
+ * more than this amount to /dev/log/* will result in a
+ * truncated log entry.
+ */
+#define LOGGER_ENTRY_MAX_PAYLOAD 4076
+
+/*
+ * The maximum size of a log entry which can be read from the
+ * kernel logger driver. An attempt to read less than this amount
+ * may result in read() returning EINVAL.
+ */
+#define LOGGER_ENTRY_MAX_LEN (5*1024)
#ifdef HAVE_IOCTL
@@ -41,6 +74,8 @@ struct logger_entry {
#define LOGGER_GET_LOG_LEN _IO(__LOGGERIO, 2) /* used log len */
#define LOGGER_GET_NEXT_ENTRY_LEN _IO(__LOGGERIO, 3) /* next entry len */
#define LOGGER_FLUSH_LOG _IO(__LOGGERIO, 4) /* flush log */
+#define LOGGER_GET_VERSION _IO(__LOGGERIO, 5) /* abi version */
+#define LOGGER_SET_VERSION _IO(__LOGGERIO, 6) /* abi version */
#endif // HAVE_IOCTL