logd: Add klogd
- Add a klogd to collect the kernel logs and place them into a
new kernel log buffer
- Parse priority, tag and message from the kernel log messages.
- Turn off pruning for worst UID for the kernel log buffer
- Sniff for 'PM: suspend exit', 'PM: suspend enter' and
'Suspended for' messages and correct the internal definition
time correction against monotonic dynamically.
- Discern if we have monotonic or real time (delineation 1980) in
audit messages.
- perform appropriate math to correct the timestamp to be real time
- filter out any external sources of kernel logging
Change-Id: I8d4c7c5ac19f1f3218079ee3a05a50e2ca55f60d
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index 4511e0b..9756b2d 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -41,8 +41,8 @@
// caller must own and free character string
char *pidToName(pid_t pid) {
char *retval = NULL;
- if (pid == 0) { // special case from auditd for kernel
- retval = strdup("logd.auditd");
+ if (pid == 0) { // special case from auditd/klogd for kernel
+ retval = strdup("logd");
} else {
char buffer[512];
snprintf(buffer, sizeof(buffer), "/proc/%u/cmdline", pid);
@@ -70,11 +70,15 @@
mSizes[log_id] += size;
++mElements[log_id];
- uidTable[log_id].add(e->getUid(), e);
-
mSizesTotal[log_id] += size;
++mElementsTotal[log_id];
+ if (log_id == LOG_ID_KERNEL) {
+ return;
+ }
+
+ uidTable[log_id].add(e->getUid(), e);
+
if (!enable) {
return;
}
@@ -93,6 +97,10 @@
mSizes[log_id] -= size;
--mElements[log_id];
+ if (log_id == LOG_ID_KERNEL) {
+ return;
+ }
+
uidTable[log_id].subtract(e->getUid(), e);
if (!enable) {