#define FORMAT_TIMESPAN_MAX 64
int parse_timestamp(const char *t, usec_t *usec);
-int get_boot_time(struct timeval *boot_time);
#endif /* UTIL_LINUX_TIME_UTIL_H */
return 0;
}
-
-int get_boot_time(struct timeval *boot_time)
-{
- struct timespec hires_uptime;
- struct timeval lores_uptime, now;
- struct sysinfo info;
-
- if (gettimeofday(&now, NULL) != 0) {
- warn(_("gettimeofday failed"));
- return -errno;
- }
-#ifdef CLOCK_BOOTTIME
- if (clock_gettime(CLOCK_BOOTTIME, &hires_uptime) == 0) {
- TIMESPEC_TO_TIMEVAL(&lores_uptime, &hires_uptime);
- timersub(&now, &lores_uptime, boot_time);
- return 0;
- }
-#endif
- /* fallback */
- if (sysinfo(&info) != 0)
- warn(_("sysinfo failed"));
-
- boot_time->tv_sec = now.tv_sec - info.uptime;
- boot_time->tv_usec = 0;
- return 0;
-}
dist_man_MANS += \
login-utils/last.1 \
login-utils/lastb.1
-last_SOURCES = login-utils/last.c lib/strutils.c
-last_LDADD = $(LDADD) libcommon.la
+last_SOURCES = login-utils/last.c lib/boottime.c
+last_LDADD = $(LDADD) libcommon.la -lrt
install-exec-hook-last:
cd $(DESTDIR)$(usrbin_execdir) && ln -sf last lastb
#
bin_PROGRAMS += dmesg
dist_man_MANS += sys-utils/dmesg.1
-dmesg_SOURCES = sys-utils/dmesg.c
+dmesg_SOURCES = sys-utils/dmesg.c lib/boottime.c
dmesg_LDADD = $(LDADD) libcommon.la -lrt
sbin_PROGRAMS += ctrlaltdel