From 01015cc0e2409958ea22165cf4c4d9223542c0f6 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Mon, 5 Dec 2011 10:55:50 +0100 Subject: [PATCH] init: write boot entry to root wtmp This unbreaks the fsck check on startup. --- servers/init/init.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/servers/init/init.c b/servers/init/init.c index f2abc0893..445eaf88e 100644 --- a/servers/init/init.c +++ b/servers/init/init.c @@ -42,6 +42,7 @@ struct ttyent TT_REBOOT = { "console", "-", REBOOT_CMD, NULL }; char PATH_UTMP[] = "/etc/utmp"; /* current logins */ char PATH_WTMP[] = "/usr/adm/wtmp"; /* login/logout history */ +char PATH_ROOT_WTMP[] = "/etc/wtmp"; /* wtmp for system up/down events */ #define PIDSLOTS 32 /* first this many ttys can be on */ @@ -473,6 +474,14 @@ pid_t pid; /* pid of process */ switch (type) { case BOOT_TIME: + /* Add new root wtmp entry. */ + if ((fd = open(PATH_ROOT_WTMP, O_WRONLY | O_APPEND)) < 0 + || write(fd, &utmp, sizeof(utmp)) == -1 + ) { + if (errno != ENOENT) report(2, PATH_ROOT_WTMP); + } + if (fd != -1) close(fd); + /* fall-through */ case DEAD_PROCESS: /* Add new wtmp entry. */ if ((fd = open(PATH_WTMP, O_WRONLY | O_APPEND)) < 0 -- 2.44.0