From: David van Moolenbroek Date: Mon, 5 Dec 2011 09:55:50 +0000 (+0100) Subject: init: write boot entry to root wtmp X-Git-Tag: v3.2.0~204 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-keygen.html?a=commitdiff_plain;h=01015cc0e2409958ea22165cf4c4d9223542c0f6;p=minix.git init: write boot entry to root wtmp This unbreaks the fsck check on startup. --- 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