summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2014-10-13 11:59:37 -0500
committerMark Salyzyn2014-12-05 14:56:44 -0600
commiteb06de716b4f33e9fdb1c41f0cce61084545bfd5 (patch)
treea27f67c9f70ef4c694216f5f7b503e738dc7d456 /logd/main.cpp
parente0a5ab5d56a3488377262e8fd14d3a90b7d74696 (diff)
downloadplatform-system-core-eb06de716b4f33e9fdb1c41f0cce61084545bfd5.tar.gz
platform-system-core-eb06de716b4f33e9fdb1c41f0cce61084545bfd5.tar.xz
platform-system-core-eb06de716b4f33e9fdb1c41f0cce61084545bfd5.zip
logd: auditd remove logDmesg method
- logDmesg method consumes considerable memory resources (typically 128KB depending on kernel) - In the future (eg: klogd, syslogd) there may be need to feed multiple logs or threads with the retrieved data. - By moving the actions of logDmesg into the mainline that instantiates the thread objects, we can leverage a single allocation of the the kernel log allocation. - logDmesg (private) is replaced with log (public) which has a more useful and descriptive purpose for the class. Change-Id: Ie2dd0370661493c1e596a7e486904a0e8caab9ff
Diffstat (limited to 'logd/main.cpp')
-rw-r--r--logd/main.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/logd/main.cpp b/logd/main.cpp
index 54da7e3cd..946a9a0f7 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -22,6 +22,7 @@
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24#include <sys/capability.h> 24#include <sys/capability.h>
25#include <sys/klog.h>
25#include <sys/prctl.h> 26#include <sys/prctl.h>
26#include <sys/stat.h> 27#include <sys/stat.h>
27#include <sys/types.h> 28#include <sys/types.h>
@@ -195,6 +196,23 @@ int main() {
195 if (auditd) { 196 if (auditd) {
196 // failure is an option ... messages are in dmesg (required by standard) 197 // failure is an option ... messages are in dmesg (required by standard)
197 LogAudit *al = new LogAudit(logBuf, reader, fdDmesg); 198 LogAudit *al = new LogAudit(logBuf, reader, fdDmesg);
199
200 int len = klogctl(KLOG_SIZE_BUFFER, NULL, 0);
201 if (len > 0) {
202 len++;
203 char buf[len];
204
205 int rc = klogctl(KLOG_READ_ALL, buf, len);
206
207 buf[len - 1] = '\0';
208
209 for(char *ptr, *tok = buf;
210 (rc >= 0) && ((tok = strtok_r(tok, "\r\n", &ptr)));
211 tok = NULL) {
212 rc = al->log(tok);
213 }
214 }
215
198 if (al->startListener()) { 216 if (al->startListener()) {
199 delete al; 217 delete al;
200 close(fdDmesg); 218 close(fdDmesg);