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

Commit 6605b0b2 authored by Elliott Hughes's avatar Elliott Hughes Committed by android-build-merger
Browse files

Merge \\\"Make klog_fd thread-safe and make klog_init a no-op.\\\" am: 588b7700 am: 73d363bb

am: 7288ac39

Change-Id: I46bbcb64eecc01ec7bd8bb502237c1b9057befc4
parents 5f7ecd95 7288ac39
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -85,7 +85,6 @@ int main(int argc, char *argv[])
    char *fstab_file=NULL;
    struct fstab *fstab=NULL;

    klog_init();
    klog_set_level(6);

    parse_options(argc, argv, &a_flag, &u_flag, &n_flag, &n_name, &n_blk_dev);
@@ -111,4 +110,3 @@ int main(int argc, char *argv[])
    /* Should not get here */
    exit(1);
}
+0 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ __BEGIN_DECLS
void klog_init(void);
int  klog_get_level(void);
void klog_set_level(int level);
/* TODO: void klog_close(void); - and make klog_fd users thread safe. */

void klog_write(int level, const char *fmt, ...)
    __attribute__ ((format(printf, 2, 3)));
+0 −1
Original line number Diff line number Diff line
@@ -477,7 +477,6 @@ int main(int argc, char** argv) {
    // kmsg and null, otherwise we won't be able to remount / read-only
    // later on. Now that tmpfs is mounted on /dev, we can actually talk
    // to the outside world.
    open_devnull_stdio();
    InitKernelLogging(argv);

    LOG(INFO) << "init " << (is_first_stage ? "first stage" : "second stage") << " started!";
+16 −2
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

#include "log.h"

#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>

#include <selinux/selinux.h>
@@ -51,9 +54,20 @@ static void KernelLogger(android::base::LogId, android::base::LogSeverity severi
}

void InitKernelLogging(char* argv[]) {
    // Make stdin/stdout/stderr all point to /dev/null.
    int fd = open("/sys/fs/selinux/null", O_RDWR);
    if (fd == -1) {
        int saved_errno = errno;
        android::base::InitLogging(argv, &KernelLogger);
        errno = saved_errno;
        PLOG(FATAL) << "Couldn't open /sys/fs/selinux/null";
    }
    dup2(fd, 0);
    dup2(fd, 1);
    dup2(fd, 2);
    if (fd > 2) close(fd);

    klog_init();
    android::base::InitLogging(argv, &KernelLogger);
    klog_set_level(KLOG_NOTICE_LEVEL);
}

+2 −2
Original line number Diff line number Diff line
@@ -518,5 +518,5 @@ Alternatively, use the emulator:

  emulator -partition-size 1024 -verbose -show-kernel -no-window

You might want to call klog_set_level(6) after the klog_init() call
so you see the kernel logging in dmesg (or the emulator output).
You might want to change the klog_set_level call so you see all the kernel
logging in dmesg (or the emulator output).
Loading