Mercurial > emacs
changeset 22115:b7efc1e72e26
(get_boot_time): Scan the whole wtmp file
to find the most recent reboot.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 18 May 1998 00:17:38 +0000 |
parents | 0fbcff056c0f |
children | 09efd6a94b4b |
files | src/filelock.c |
diffstat | 1 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/filelock.c Sun May 17 22:02:49 1998 +0000 +++ b/src/filelock.c Mon May 18 00:17:38 1998 +0000 @@ -104,13 +104,27 @@ return boot_time; utmpname ("/var/log/wtmp"); - ut.ut_type = BOOT_TIME; - utp = getutid (&ut); + setutent (); + boot_time = 1; + while (1) + { + /* Find the next reboot record. */ + ut.ut_type = BOOT_TIME; + utp = getutid (&ut); + if (! utp) + break; + /* Compare reboot times and use the newest one. */ + if (utp->ut_time > boot_time) + boot_time = utp->ut_time; + /* Advance on element in the file + so that getutid won't repeat the same one. */ + utp = getutent (); + if (! utp) + break; + } endutent (); - if (!utp) - return boot_time = 1; - return boot_time = utp->ut_time; + return boot_time; #else return 0; #endif