summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2014-07-01 10:57:16 -0700
committerNick Kralevich <nnk@google.com>2014-07-01 12:22:04 -0700
commit2a4d05a4e38b84cf287bb2d2266c07b6f10c9dee (patch)
treebb95963902a6a2a6e3c1ae093c3802a17b90f2f8 /liblog
parent5a53ee0502c198fb114bbf7bb34643d9682ba9b8 (diff)
downloadsystem_core-2a4d05a4e38b84cf287bb2d2266c07b6f10c9dee.zip
system_core-2a4d05a4e38b84cf287bb2d2266c07b6f10c9dee.tar.gz
system_core-2a4d05a4e38b84cf287bb2d2266c07b6f10c9dee.tar.bz2
implement LOG_EVENT_STRING
Implement LOG_EVENT_STRING, so that native code can create new event log entries. This is needed to support logging SELinux denials to the event log. Change-Id: I6a269a832bc2f5e5da6c9dbd169ed2f901b49166
Diffstat (limited to 'liblog')
-rw-r--r--liblog/logd_write.c22
-rw-r--r--liblog/logd_write_kern.c22
2 files changed, 44 insertions, 0 deletions
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index f10eb8e..1da55ab 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -473,3 +473,25 @@ int __android_log_btwrite(int32_t tag, char type, const void *payload,
return write_to_log(LOG_ID_EVENTS, vec, 3);
}
+
+/*
+ * Like __android_log_bwrite, but used for writing strings to the
+ * event log.
+ */
+int __android_log_bswrite(int32_t tag, const char *payload)
+{
+ struct iovec vec[4];
+ char type = EVENT_TYPE_STRING;
+ uint32_t len = strlen(payload);
+
+ vec[0].iov_base = &tag;
+ vec[0].iov_len = sizeof(tag);
+ vec[1].iov_base = &type;
+ vec[1].iov_len = sizeof(type);
+ vec[2].iov_base = &len;
+ vec[2].iov_len = sizeof(len);
+ vec[3].iov_base = (void*)payload;
+ vec[3].iov_len = len;
+
+ return write_to_log(LOG_ID_EVENTS, vec, 4);
+}
diff --git a/liblog/logd_write_kern.c b/liblog/logd_write_kern.c
index 1d10748..1ed5ecf 100644
--- a/liblog/logd_write_kern.c
+++ b/liblog/logd_write_kern.c
@@ -317,3 +317,25 @@ int __android_log_btwrite(int32_t tag, char type, const void *payload,
return write_to_log(LOG_ID_EVENTS, vec, 3);
}
+
+/*
+ * Like __android_log_bwrite, but used for writing strings to the
+ * event log.
+ */
+int __android_log_bswrite(int32_t tag, const char *payload)
+{
+ struct iovec vec[4];
+ char type = EVENT_TYPE_STRING;
+ uint32_t len = strlen(payload);
+
+ vec[0].iov_base = &tag;
+ vec[0].iov_len = sizeof(tag);
+ vec[1].iov_base = &type;
+ vec[1].iov_len = sizeof(type);
+ vec[2].iov_base = &len;
+ vec[2].iov_len = sizeof(len);
+ vec[3].iov_base = (void*)payload;
+ vec[3].iov_len = len;
+
+ return write_to_log(LOG_ID_EVENTS, vec, 4);
+}