aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/filelock.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/filelock.c b/src/filelock.c
index 819516d04bd..6876cbdb5c1 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -104,13 +104,27 @@ get_boot_time ()
104 return boot_time; 104 return boot_time;
105 105
106 utmpname ("/var/log/wtmp"); 106 utmpname ("/var/log/wtmp");
107 ut.ut_type = BOOT_TIME; 107 setutent ();
108 utp = getutid (&ut); 108 boot_time = 1;
109 while (1)
110 {
111 /* Find the next reboot record. */
112 ut.ut_type = BOOT_TIME;
113 utp = getutid (&ut);
114 if (! utp)
115 break;
116 /* Compare reboot times and use the newest one. */
117 if (utp->ut_time > boot_time)
118 boot_time = utp->ut_time;
119 /* Advance on element in the file
120 so that getutid won't repeat the same one. */
121 utp = getutent ();
122 if (! utp)
123 break;
124 }
109 endutent (); 125 endutent ();
110 126
111 if (!utp) 127 return boot_time;
112 return boot_time = 1;
113 return boot_time = utp->ut_time;
114#else 128#else
115 return 0; 129 return 0;
116#endif 130#endif