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

Commit 73d363bb 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

Change-Id: I884276a8f8b8209f6e956c5fb410e8265184e1b5
parents fcf3ed51 588b7700
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -85,7 +85,6 @@ int main(int argc, char *argv[])
    char *fstab_file=NULL;
    char *fstab_file=NULL;
    struct fstab *fstab=NULL;
    struct fstab *fstab=NULL;


    klog_init();
    klog_set_level(6);
    klog_set_level(6);


    parse_options(argc, argv, &a_flag, &u_flag, &n_flag, &n_name, &n_blk_dev);
    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 */
    /* Should not get here */
    exit(1);
    exit(1);
}
}
+0 −1
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@ __BEGIN_DECLS
void klog_init(void);
void klog_init(void);
int  klog_get_level(void);
int  klog_get_level(void);
void klog_set_level(int level);
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, ...)
void klog_write(int level, const char *fmt, ...)
    __attribute__ ((format(printf, 2, 3)));
    __attribute__ ((format(printf, 2, 3)));
+0 −1
Original line number Original line 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
    // 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
    // later on. Now that tmpfs is mounted on /dev, we can actually talk
    // to the outside world.
    // to the outside world.
    open_devnull_stdio();
    InitKernelLogging(argv);
    InitKernelLogging(argv);


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


#include "log.h"
#include "log.h"


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


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


void InitKernelLogging(char* argv[]) {
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);
        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);
    klog_set_level(KLOG_NOTICE_LEVEL);
}
}


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


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


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