Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a269c7c3 authored by Tom Cherry's avatar Tom Cherry Committed by Gerrit Code Review
Browse files

Merge changes I9d6dde2c,I38bfcba5

* changes:
  logd: separate LogStatistics from LogBuffer
  logd: remove LogFindWorst
parents a227c19e 64e90163
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ cc_library_static {


    cflags: [
    cflags: [
        "-Wextra",
        "-Wextra",
        "-Wthread-safety",
    ] + event_flag,
    ] + event_flag,
}
}


+7 −6
Original line number Original line Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include "CommandListener.h"

#include <arpa/inet.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <ctype.h>
#include <dirent.h>
#include <dirent.h>
@@ -35,12 +37,11 @@
#include <private/android_filesystem_config.h>
#include <private/android_filesystem_config.h>
#include <sysutils/SocketClient.h>
#include <sysutils/SocketClient.h>


#include "CommandListener.h"
#include "LogCommand.h"
#include "LogUtils.h"
#include "LogUtils.h"


CommandListener::CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune)
CommandListener::CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune,
    : FrameworkListener(getLogSocket()), buf_(buf), tags_(tags), prune_(prune) {
                                 LogStatistics* stats)
    : FrameworkListener(getLogSocket()), buf_(buf), tags_(tags), prune_(prune), stats_(stats) {
    registerCmd(new ClearCmd(this));
    registerCmd(new ClearCmd(this));
    registerCmd(new GetBufSizeCmd(this));
    registerCmd(new GetBufSizeCmd(this));
    registerCmd(new SetBufSizeCmd(this));
    registerCmd(new SetBufSizeCmd(this));
@@ -148,7 +149,7 @@ int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient* cli, int argc,
        return 0;
        return 0;
    }
    }


    unsigned long size = buf()->getSizeUsed((log_id_t)id);
    unsigned long size = stats()->Sizes((log_id_t)id);
    char buf[512];
    char buf[512];
    snprintf(buf, sizeof(buf), "%lu", size);
    snprintf(buf, sizeof(buf), "%lu", size);
    cli->sendMsg(buf);
    cli->sendMsg(buf);
@@ -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;
    return 0;
}
}


+17 −14
Original line number Original line Diff line number Diff line
@@ -22,12 +22,13 @@
#include "LogCommand.h"
#include "LogCommand.h"
#include "LogListener.h"
#include "LogListener.h"
#include "LogReader.h"
#include "LogReader.h"
#include "LogStatistics.h"
#include "LogTags.h"
#include "LogTags.h"
#include "LogWhiteBlackList.h"
#include "LogWhiteBlackList.h"


class CommandListener : public FrameworkListener {
class CommandListener : public FrameworkListener {
  public:
  public:
    CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune);
    CommandListener(LogBuffer* buf, LogTags* tags, PruneList* prune, LogStatistics* log_statistics);
    virtual ~CommandListener() {}
    virtual ~CommandListener() {}


  private:
  private:
@@ -36,6 +37,7 @@ class CommandListener : public FrameworkListener {
    LogBuffer* buf_;
    LogBuffer* buf_;
    LogTags* tags_;
    LogTags* tags_;
    PruneList* prune_;
    PruneList* prune_;
    LogStatistics* stats_;


#define LogCmd(name, command_string)                             \
#define LogCmd(name, command_string)                             \
    class name##Cmd : public LogCommand {                        \
    class name##Cmd : public LogCommand {                        \
@@ -49,6 +51,7 @@ class CommandListener : public FrameworkListener {
        LogBuffer* buf() const { return parent_->buf_; }         \
        LogBuffer* buf() const { return parent_->buf_; }         \
        LogTags* tags() const { return parent_->tags_; }         \
        LogTags* tags() const { return parent_->tags_; }         \
        PruneList* prune() const { return parent_->prune_; }     \
        PruneList* prune() const { return parent_->prune_; }     \
        LogStatistics* stats() const { return parent_->stats_; } \
        CommandListener* parent_;                                \
        CommandListener* parent_;                                \
    }
    }


+9 −14
Original line number Original line Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include "LogAudit.h"

#include <ctype.h>
#include <ctype.h>
#include <endian.h>
#include <endian.h>
#include <errno.h>
#include <errno.h>
@@ -34,8 +36,6 @@
#include <private/android_filesystem_config.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>
#include <private/android_logger.h>


#include "LogAudit.h"
#include "LogBuffer.h"
#include "LogKlog.h"
#include "LogKlog.h"
#include "LogReader.h"
#include "LogReader.h"
#include "LogUtils.h"
#include "LogUtils.h"
@@ -45,16 +45,15 @@
    '<', '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) / 10, \
    '<', '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) / 10, \
        '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),
    : SocketListener(getLogSocket(), false),
      logbuf(buf),
      logbuf(buf),
      reader(reader),
      reader(reader),
      fdDmesg(fdDmesg),
      fdDmesg(fdDmesg),
      main(__android_logger_property_get_bool("ro.logd.auditd.main",
      main(__android_logger_property_get_bool("ro.logd.auditd.main", BOOL_DEFAULT_TRUE)),
                                              BOOL_DEFAULT_TRUE)),
      events(__android_logger_property_get_bool("ro.logd.auditd.events", BOOL_DEFAULT_TRUE)),
      events(__android_logger_property_get_bool("ro.logd.auditd.events",
      initialized(false),
                                                BOOL_DEFAULT_TRUE)),
      stats_(stats) {
      initialized(false) {
    static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO),
    static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO),
                                           'l',
                                           'l',
                                           'o',
                                           'o',
@@ -211,9 +210,7 @@ int LogAudit::logPrint(const char* fmt, ...) {
            ++cp;
            ++cp;
        }
        }
        tid = pid;
        tid = pid;
        logbuf->wrlock();
        uid = stats_->PidToUid(pid);
        uid = logbuf->pidToUid(pid);
        logbuf->unlock();
        memmove(pidptr, cp, strlen(cp) + 1);
        memmove(pidptr, cp, strlen(cp) + 1);
    }
    }


@@ -301,9 +298,7 @@ int LogAudit::logPrint(const char* fmt, ...) {
        pid = tid;
        pid = tid;
        comm = "auditd";
        comm = "auditd";
    } else {
    } else {
        logbuf->wrlock();
        comm = commfree = stats_->PidToName(pid);
        comm = commfree = logbuf->pidToName(pid);
        logbuf->unlock();
        if (!comm) {
        if (!comm) {
            comm = "unknown";
            comm = "unknown";
        }
        }
+8 −8
Original line number Original line Diff line number Diff line
@@ -14,14 +14,14 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#ifndef _LOGD_LOG_AUDIT_H__
#pragma once
#define _LOGD_LOG_AUDIT_H__


#include <map>
#include <map>


#include <sysutils/SocketListener.h>
#include <sysutils/SocketListener.h>


#include "LogBuffer.h"
#include "LogBuffer.h"
#include "LogStatistics.h"


class LogReader;
class LogReader;


@@ -34,7 +34,7 @@ class LogAudit : public SocketListener {
    bool initialized;
    bool initialized;


  public:
  public:
    LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg);
    LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg, LogStatistics* stats);
    int log(char* buf, size_t len);
    int log(char* buf, size_t len);


  protected:
  protected:
@@ -48,6 +48,6 @@ class LogAudit : public SocketListener {
    void auditParse(const std::string& string, uid_t uid, std::string* bug_num);
    void auditParse(const std::string& string, uid_t uid, std::string* bug_num);
    int logPrint(const char* fmt, ...)
    int logPrint(const char* fmt, ...)
        __attribute__((__format__(__printf__, 2, 3)));
        __attribute__((__format__(__printf__, 2, 3)));
};


#endif
    LogStatistics* stats_;
};
Loading