klog: don't unconditionally call mknod()
If /dev/kmsg already exists, it's unnecessary for klog_init() to create it's own copy. This avoids needing to grant the mknod permission to everyone who uses kmsg. Typically the only time /dev/kmsg doesn't exist is before ueventd starts. Bug: 21242418 Change-Id: I0c88d80feca6899fcdbc8c9f2f99448ee0a3422d
This commit is contained in:
parent
d92fd41f69
commit
4d32a486fe
|
@ -40,6 +40,11 @@ void klog_set_level(int level) {
|
|||
void klog_init(void) {
|
||||
if (klog_fd >= 0) return; /* Already initialized */
|
||||
|
||||
klog_fd = open("/dev/kmsg", O_WRONLY | O_CLOEXEC);
|
||||
if (klog_fd >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
static const char* name = "/dev/__kmsg__";
|
||||
if (mknod(name, S_IFCHR | 0600, (1 << 8) | 11) == 0) {
|
||||
klog_fd = open(name, O_WRONLY | O_CLOEXEC);
|
||||
|
|
Loading…
Reference in New Issue