mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
(get_boot_time): Scan the whole wtmp file
to find the most recent reboot.
This commit is contained in:
parent
c519f68fa9
commit
c321b1908b
1 changed files with 19 additions and 5 deletions
|
|
@ -104,13 +104,27 @@ get_boot_time ()
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue