Loading logd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ cc_library_static { cflags: [ "-Wextra", "-Wthread-safety", ] + event_flag, } Loading logd/CommandListener.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #include "CommandListener.h" #include <arpa/inet.h> #include <ctype.h> #include <dirent.h> Loading @@ -35,12 +37,11 @@ #include <private/android_filesystem_config.h> #include <sysutils/SocketClient.h> #include "CommandListener.h" #include "LogCommand.h" #include "LogUtils.h" CommandListener::CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune) : FrameworkListener(getLogSocket()), buf_(buf), tags_(tags), prune_(prune) { CommandListener::CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune, LogStatistics* stats) : FrameworkListener(getLogSocket()), buf_(buf), tags_(tags), prune_(prune), stats_(stats) { registerCmd(new ClearCmd(this)); registerCmd(new GetBufSizeCmd(this)); registerCmd(new SetBufSizeCmd(this)); Loading Loading @@ -148,7 +149,7 @@ int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient* cli, int argc, return 0; } unsigned long size = buf()->getSizeUsed((log_id_t)id); unsigned long size = stats()->Sizes((log_id_t)id); char buf[512]; snprintf(buf, sizeof(buf), "%lu", size); cli->sendMsg(buf); Loading Loading @@ -209,7 +210,7 @@ int CommandListener::GetStatisticsCmd::runCommand(SocketClient* cli, int argc, } } cli->sendMsg(PackageString(buf()->formatStatistics(uid, pid, logMask)).c_str()); cli->sendMsg(PackageString(stats()->Format(uid, pid, logMask)).c_str()); return 0; } Loading logd/CommandListener.h +17 −14 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ #include "LogCommand.h" #include "LogListener.h" #include "LogReader.h" #include "LogStatistics.h" #include "LogTags.h" #include "LogWhiteBlackList.h" class CommandListener : public FrameworkListener { public: CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune); CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune, LogStatistics* log_statistics); virtual ~CommandListener() {} private: Loading @@ -36,6 +37,7 @@ class CommandListener : public FrameworkListener { LogBuffer* buf_; LogTags* tags_; PruneList* prune_; LogStatistics* stats_; #define LogCmd(name, command_string) \ class name##Cmd : public LogCommand { \ Loading @@ -49,6 +51,7 @@ class CommandListener : public FrameworkListener { LogBuffer* buf() const { return parent_->buf_; } \ LogTags* tags() const { return parent_->tags_; } \ PruneList* prune() const { return parent_->prune_; } \ LogStatistics* stats() const { return parent_->stats_; } \ CommandListener* parent_; \ } Loading logd/LogAudit.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #include "LogAudit.h" #include <ctype.h> #include <endian.h> #include <errno.h> Loading @@ -34,8 +36,6 @@ #include <private/android_filesystem_config.h> #include <private/android_logger.h> #include "LogAudit.h" #include "LogBuffer.h" #include "LogKlog.h" #include "LogReader.h" #include "LogUtils.h" Loading @@ -45,16 +45,15 @@ '<', '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) / 10, \ '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) % 10, '>' LogAudit::LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg) LogAudit::LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg, LogStatistics* stats) : SocketListener(getLogSocket(), false), logbuf(buf), reader(reader), fdDmesg(fdDmesg), main(__android_logger_property_get_bool("ro.logd.auditd.main", BOOL_DEFAULT_TRUE)), events(__android_logger_property_get_bool("ro.logd.auditd.events", BOOL_DEFAULT_TRUE)), initialized(false) { main(__android_logger_property_get_bool("ro.logd.auditd.main", BOOL_DEFAULT_TRUE)), events(__android_logger_property_get_bool("ro.logd.auditd.events", BOOL_DEFAULT_TRUE)), initialized(false), stats_(stats) { static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO), 'l', 'o', Loading Loading @@ -211,9 +210,7 @@ int LogAudit::logPrint(const char* fmt, ...) { ++cp; } tid = pid; logbuf->wrlock(); uid = logbuf->pidToUid(pid); logbuf->unlock(); uid = stats_->PidToUid(pid); memmove(pidptr, cp, strlen(cp) + 1); } Loading Loading @@ -301,9 +298,7 @@ int LogAudit::logPrint(const char* fmt, ...) { pid = tid; comm = "auditd"; } else { logbuf->wrlock(); comm = commfree = logbuf->pidToName(pid); logbuf->unlock(); comm = commfree = stats_->PidToName(pid); if (!comm) { comm = "unknown"; } Loading logd/LogAudit.h +8 −8 Original line number Diff line number Diff line Loading @@ -14,14 +14,14 @@ * limitations under the License. */ #ifndef _LOGD_LOG_AUDIT_H__ #define _LOGD_LOG_AUDIT_H__ #pragma once #include <map> #include <sysutils/SocketListener.h> #include "LogBuffer.h" #include "LogStatistics.h" class LogReader; Loading @@ -34,7 +34,7 @@ class LogAudit : public SocketListener { bool initialized; public: LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg); LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg, LogStatistics* stats); int log(char* buf, size_t len); protected: Loading @@ -48,6 +48,6 @@ class LogAudit : public SocketListener { void auditParse(const std::string& string, uid_t uid, std::string* bug_num); int logPrint(const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3))); }; #endif LogStatistics* stats_; }; Loading
logd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ cc_library_static { cflags: [ "-Wextra", "-Wthread-safety", ] + event_flag, } Loading
logd/CommandListener.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #include "CommandListener.h" #include <arpa/inet.h> #include <ctype.h> #include <dirent.h> Loading @@ -35,12 +37,11 @@ #include <private/android_filesystem_config.h> #include <sysutils/SocketClient.h> #include "CommandListener.h" #include "LogCommand.h" #include "LogUtils.h" CommandListener::CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune) : FrameworkListener(getLogSocket()), buf_(buf), tags_(tags), prune_(prune) { CommandListener::CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune, LogStatistics* stats) : FrameworkListener(getLogSocket()), buf_(buf), tags_(tags), prune_(prune), stats_(stats) { registerCmd(new ClearCmd(this)); registerCmd(new GetBufSizeCmd(this)); registerCmd(new SetBufSizeCmd(this)); Loading Loading @@ -148,7 +149,7 @@ int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient* cli, int argc, return 0; } unsigned long size = buf()->getSizeUsed((log_id_t)id); unsigned long size = stats()->Sizes((log_id_t)id); char buf[512]; snprintf(buf, sizeof(buf), "%lu", size); cli->sendMsg(buf); Loading Loading @@ -209,7 +210,7 @@ int CommandListener::GetStatisticsCmd::runCommand(SocketClient* cli, int argc, } } cli->sendMsg(PackageString(buf()->formatStatistics(uid, pid, logMask)).c_str()); cli->sendMsg(PackageString(stats()->Format(uid, pid, logMask)).c_str()); return 0; } Loading
logd/CommandListener.h +17 −14 Original line number Diff line number Diff line Loading @@ -22,12 +22,13 @@ #include "LogCommand.h" #include "LogListener.h" #include "LogReader.h" #include "LogStatistics.h" #include "LogTags.h" #include "LogWhiteBlackList.h" class CommandListener : public FrameworkListener { public: CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune); CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune, LogStatistics* log_statistics); virtual ~CommandListener() {} private: Loading @@ -36,6 +37,7 @@ class CommandListener : public FrameworkListener { LogBuffer* buf_; LogTags* tags_; PruneList* prune_; LogStatistics* stats_; #define LogCmd(name, command_string) \ class name##Cmd : public LogCommand { \ Loading @@ -49,6 +51,7 @@ class CommandListener : public FrameworkListener { LogBuffer* buf() const { return parent_->buf_; } \ LogTags* tags() const { return parent_->tags_; } \ PruneList* prune() const { return parent_->prune_; } \ LogStatistics* stats() const { return parent_->stats_; } \ CommandListener* parent_; \ } Loading
logd/LogAudit.cpp +9 −14 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #include "LogAudit.h" #include <ctype.h> #include <endian.h> #include <errno.h> Loading @@ -34,8 +36,6 @@ #include <private/android_filesystem_config.h> #include <private/android_logger.h> #include "LogAudit.h" #include "LogBuffer.h" #include "LogKlog.h" #include "LogReader.h" #include "LogUtils.h" Loading @@ -45,16 +45,15 @@ '<', '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) / 10, \ '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) % 10, '>' LogAudit::LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg) LogAudit::LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg, LogStatistics* stats) : SocketListener(getLogSocket(), false), logbuf(buf), reader(reader), fdDmesg(fdDmesg), main(__android_logger_property_get_bool("ro.logd.auditd.main", BOOL_DEFAULT_TRUE)), events(__android_logger_property_get_bool("ro.logd.auditd.events", BOOL_DEFAULT_TRUE)), initialized(false) { main(__android_logger_property_get_bool("ro.logd.auditd.main", BOOL_DEFAULT_TRUE)), events(__android_logger_property_get_bool("ro.logd.auditd.events", BOOL_DEFAULT_TRUE)), initialized(false), stats_(stats) { static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO), 'l', 'o', Loading Loading @@ -211,9 +210,7 @@ int LogAudit::logPrint(const char* fmt, ...) { ++cp; } tid = pid; logbuf->wrlock(); uid = logbuf->pidToUid(pid); logbuf->unlock(); uid = stats_->PidToUid(pid); memmove(pidptr, cp, strlen(cp) + 1); } Loading Loading @@ -301,9 +298,7 @@ int LogAudit::logPrint(const char* fmt, ...) { pid = tid; comm = "auditd"; } else { logbuf->wrlock(); comm = commfree = logbuf->pidToName(pid); logbuf->unlock(); comm = commfree = stats_->PidToName(pid); if (!comm) { comm = "unknown"; } Loading
logd/LogAudit.h +8 −8 Original line number Diff line number Diff line Loading @@ -14,14 +14,14 @@ * limitations under the License. */ #ifndef _LOGD_LOG_AUDIT_H__ #define _LOGD_LOG_AUDIT_H__ #pragma once #include <map> #include <sysutils/SocketListener.h> #include "LogBuffer.h" #include "LogStatistics.h" class LogReader; Loading @@ -34,7 +34,7 @@ class LogAudit : public SocketListener { bool initialized; public: LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg); LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg, LogStatistics* stats); int log(char* buf, size_t len); protected: Loading @@ -48,6 +48,6 @@ class LogAudit : public SocketListener { void auditParse(const std::string& string, uid_t uid, std::string* bug_num); int logPrint(const char* fmt, ...) __attribute__((__format__(__printf__, 2, 3))); }; #endif LogStatistics* stats_; };