]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/timeutils: remove get_boot_time from libcommon
authorKarel Zak <kzak@redhat.com>
Tue, 6 May 2014 11:16:05 +0000 (13:16 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 6 May 2014 11:16:05 +0000 (13:16 +0200)
clock_gettime() needs -lrt, so let's keep this stuff
outside libcommon.la

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
include/Makemodule.am
include/timeutils.h
lib/timeutils.c
login-utils/Makemodule.am
login-utils/last.c
sys-utils/Makemodule.am
sys-utils/dmesg.c

index 2cc9fb5af0ba9a52ccb3fb15bde36468ad5f1c68..7f461c6fe9669400474a2e71e618a1c0678a5215 100644 (file)
@@ -4,6 +4,7 @@ dist_noinst_HEADERS += \
        include/at.h \
        include/bitops.h \
        include/blkdev.h \
+       include/boottime.h \
        include/c.h \
        include/canonicalize.h \
        include/carefulputc.h \
index b9ba0f78320eb547b7f722b90563203089a93ee0..bcae6137cfdcaa8b85cc74e4480440d665266925 100644 (file)
@@ -51,6 +51,5 @@ typedef uint64_t nsec_t;
 #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 */
index d542c2f2733537f0b249844767ac7216c427a4dc..b811041e453b6feff4a480553b5bdce2ef1b2f88 100644 (file)
@@ -340,29 +340,3 @@ int parse_timestamp(const char *t, usec_t *usec)
 
        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;
-}
index aca028a29138b0b0866da8ca2b7914f81beae10b..49fde454440c407ca8441531cdfdc170940be881 100644 (file)
@@ -4,8 +4,8 @@ usrbin_exec_PROGRAMS += last
 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
index ed1058652d7c4c6c1a5db95f69bbd0144f1188f4..7848dd0da32cbb46942577b02bebffb5b3e707aa 100644 (file)
@@ -50,6 +50,7 @@
 #include "carefulputc.h"
 #include "strutils.h"
 #include "timeutils.h"
+#include "boottime.h"
 
 #if defined(_HAVE_UT_TV)
 # define UL_UT_TIME ut_tv.tv_sec
index a19d58b84a4d6bee17e88c453ea0d0c82be1a7fa..eb78176cccdf97fc0e90f28c1dadf3d5f08a32c2 100644 (file)
@@ -70,7 +70,7 @@ if LINUX
 #
 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
index 3d58623c236abbb3674c6dac0f17dcf1d193ac15..73b246e0b65ea6d25d94bf73fd8aa94b74e86536 100644 (file)
@@ -33,6 +33,7 @@
 #include "closestream.h"
 #include "optutils.h"
 #include "timeutils.h"
+#include "boottime.h"
 #include "mangle.h"
 #include "pager.h"