summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Thibault2015-01-18 22:44:54 +0100
committerSami Kerola2015-01-23 20:57:22 +0100
commit87ee2658353836478af81ca2d8ae5133f4669e31 (patch)
tree32d37bdff1227570c98e4f9df90aa13d7148165a
parentlibfdisk: accept Start offset in {B,M,G..}iB in sfdisk scripts (diff)
downloadkernel-qcow2-util-linux-87ee2658353836478af81ca2d8ae5133f4669e31.tar.gz
kernel-qcow2-util-linux-87ee2658353836478af81ca2d8ae5133f4669e31.tar.xz
kernel-qcow2-util-linux-87ee2658353836478af81ca2d8ae5133f4669e31.zip
logger: check availability of ntp_gettime()
Make compilation to work in systems which don't have sys/timex.h and its ntp_gettime(). Reviewed-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Samuel Thibault <sthibault@debian.org>
-rw-r--r--configure.ac1
-rw-r--r--misc-utils/logger.c9
2 files changed, 9 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 3d77307fb..fce7e0e78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,6 +230,7 @@ AC_CHECK_HEADERS([ \
sys/swap.h \
sys/syscall.h \
sys/time.h \
+ sys/timex.h \
sys/ttydefaults.h \
sys/types.h \
sys/un.h \
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 35caf9d9d..03031dac9 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -44,7 +44,6 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
-#include <sys/timex.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -67,6 +66,10 @@
# include <systemd/sd-journal.h>
#endif
+#ifdef HAVE_SYS_TIMEX_H
+# include <sys/timex.h>
+#endif
+
enum {
TYPE_UDP = (1 << 1),
TYPE_TCP = (1 << 2),
@@ -325,7 +328,9 @@ static void syslog_rfc5424(const struct logger_ctl *ctl, const char *msg)
{
char *buf, *tag = NULL, *hostname = NULL;
char pid[32], time[64], timeq[80];
+#ifdef HAVE_SYS_TIMEX_H
struct ntptimeval ntptv;
+#endif
struct timeval tv;
struct tm *tm;
int len;
@@ -364,11 +369,13 @@ static void syslog_rfc5424(const struct logger_ctl *ctl, const char *msg)
snprintf(pid, sizeof(pid), " %d", ctl->pid);
if (ctl->rfc5424_tq) {
+#ifdef HAVE_SYS_TIMEX_H
if (ntp_gettime(&ntptv) == TIME_OK)
snprintf(timeq, sizeof(timeq),
" [timeQuality tzKnown=\"1\" isSynced=\"1\" syncAccuracy=\"%ld\"]",
ntptv.maxerror);
else
+#endif
snprintf(timeq, sizeof(timeq),
" [timeQuality tzKnown=\"1\" isSynced=\"0\"]");
}