summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2015-01-26 11:59:10 +0100
committerKarel Zak2015-01-26 11:59:10 +0100
commitc580b554c9d0c5f49993379528bba9c61b253cc1 (patch)
treef0d1aefcceda4511f7efc9cc6f626e49bf4a0bd9
parentcfdisk: actually translate the table headers and the bottom line (diff)
parentlogger: check availability of ntp_gettime() (diff)
downloadkernel-qcow2-util-linux-c580b554c9d0c5f49993379528bba9c61b253cc1.tar.gz
kernel-qcow2-util-linux-c580b554c9d0c5f49993379528bba9c61b253cc1.tar.xz
kernel-qcow2-util-linux-c580b554c9d0c5f49993379528bba9c61b253cc1.zip
Merge branch 'timex' of https://github.com/kerolasa/lelux-utiliteetit
* 'timex' of https://github.com/kerolasa/lelux-utiliteetit: logger: check availability of ntp_gettime()
-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 a0d57631a..1c5c15ea3 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 5fbf148eb..21b56bf1e 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\"]");
}