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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user