Fix incorrect kmsg path

/proc/kmsg -> /dev/kmsg
This commit is contained in:
topjohnwu 2019-11-25 19:09:02 -05:00
parent e373e59661
commit 276535dad6

View File

@ -38,23 +38,22 @@ static int vprintk(const char *fmt, va_list ap) {
} }
void setup_klog() { void setup_klog() {
// Shut down first 3 fds // Shut down first 3 fds
int null; int fd;
if (access("/dev/null", W_OK) == 0) { if (access("/dev/null", W_OK) == 0) {
null = xopen("/dev/null", O_RDWR | O_CLOEXEC); fd = xopen("/dev/null", O_RDWR | O_CLOEXEC);
} else { } else {
mknod("/null", S_IFCHR | 0666, makedev(1, 3)); mknod("/null", S_IFCHR | 0666, makedev(1, 3));
null = xopen("/null", O_RDWR | O_CLOEXEC); fd = xopen("/null", O_RDWR | O_CLOEXEC);
unlink("/null"); unlink("/null");
} }
xdup3(null, STDIN_FILENO, O_CLOEXEC); xdup3(fd, STDIN_FILENO, O_CLOEXEC);
xdup3(null, STDOUT_FILENO, O_CLOEXEC); xdup3(fd, STDOUT_FILENO, O_CLOEXEC);
xdup3(null, STDERR_FILENO, O_CLOEXEC); xdup3(fd, STDERR_FILENO, O_CLOEXEC);
if (null > STDERR_FILENO) if (fd > STDERR_FILENO)
close(null); close(fd);
int fd; if (access("/dev/kmsg", W_OK) == 0) {
if (access("/proc/kmsg", W_OK) == 0) { fd = xopen("/dev/kmsg", O_WRONLY | O_CLOEXEC);
fd = xopen("/proc/kmsg", O_WRONLY | O_CLOEXEC);
} else { } else {
mknod("/kmsg", S_IFCHR | 0666, makedev(1, 11)); mknod("/kmsg", S_IFCHR | 0666, makedev(1, 11));
fd = xopen("/kmsg", O_WRONLY | O_CLOEXEC); fd = xopen("/kmsg", O_WRONLY | O_CLOEXEC);