Fix early init logging.
Remove the /dev/__kmsg__ workarounds (which can then be removed
from sepolicy), and fix confusion in the translation between
android-base logging and kernel logging priorities (in particular,
where 'notice' comes in the hierarchy).
Bug: http://b/30317429
Change-Id: I6eaf9919904b6b55bc402c20bf1a4ae269014bc7
Test: adb shell dmesg | grep init
diff --git a/init/init.cpp b/init/init.cpp
index fc3e80f..78d71a8 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -29,6 +29,7 @@
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
@@ -487,12 +488,11 @@
mount("proc", "/proc", "proc", 0, "hidepid=2,gid=" MAKE_STR(AID_READPROC));
mount("sysfs", "/sys", "sysfs", 0, NULL);
mount("selinuxfs", "/sys/fs/selinux", "selinuxfs", 0, NULL);
+ mknod("/dev/kmsg", S_IFCHR | 0600, makedev(1, 11));
}
- // We must have some place other than / to create the device nodes for
- // 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.
+ // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually
+ // talk to the outside world...
InitKernelLogging(argv);
LOG(INFO) << "init " << (is_first_stage ? "first stage" : "second stage") << " started!";
@@ -536,6 +536,7 @@
// This must happen before /dev is populated by ueventd.
LOG(INFO) << "Running restorecon...";
restorecon("/dev");
+ restorecon("/dev/kmsg");
restorecon("/dev/socket");
restorecon("/dev/__properties__");
restorecon("/property_contexts");