timedated: expose time and NTP sync flag via the bus

This way, timedatectl can be run over the network and determine all
properties correctly from the server rather than the client.
This commit is contained in:
Lennart Poettering
2013-10-17 01:03:39 +02:00
parent aacf3b483b
commit 03cc26dda4
4 changed files with 53 additions and 12 deletions
+13
View File
@@ -21,6 +21,7 @@
#include <time.h>
#include <string.h>
#include <sys/timex.h>
#include "util.h"
#include "time-util.h"
@@ -792,3 +793,15 @@ int parse_nsec(const char *t, nsec_t *nsec) {
return 0;
}
bool ntp_synced(void) {
struct timex txc = {};
if (adjtimex(&txc) < 0)
return false;
if (txc.status & STA_UNSYNC)
return false;
return true;
}
+2
View File
@@ -84,3 +84,5 @@ int parse_timestamp(const char *t, usec_t *usec);
int parse_sec(const char *t, usec_t *usec);
int parse_nsec(const char *t, nsec_t *nsec);
bool ntp_synced(void);