diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-12 09:39:28 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-12 12:05:21 +0200 |
commit | 8f0ea0efd9342e98c90189edb79b3a2bfdf77a8a (patch) | |
tree | 4027c72d06ee720347cbf5cfea2a9e8c9bbff58c /src/timedate/timedated.c | |
parent | 8f7123731d2a269ee9985cc265b6e69af63c1b6b (diff) | |
download | systemd-8f0ea0efd9342e98c90189edb79b3a2bfdf77a8a.tar.gz |
timedated: make ntp_synced() static
No need to have this in basic.
Diffstat (limited to 'src/timedate/timedated.c')
-rw-r--r-- | src/timedate/timedated.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 6e0f91dec4..66b454269d 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -2,6 +2,7 @@ #include <errno.h> #include <sys/stat.h> +#include <sys/timex.h> #include <sys/types.h> #include <unistd.h> @@ -556,6 +557,18 @@ static int unit_enable_or_disable(UnitStatusInfo *u, sd_bus *bus, sd_bus_error * return 0; } +static bool ntp_synced(void) { + struct timex txc = {}; + + if (adjtimex(&txc) < 0) + return false; + + /* Consider the system clock synchronized if the reported maximum error is smaller than the maximum + * value (16 seconds). Ignore the STA_UNSYNC flag as it may have been set to prevent the kernel from + * touching the RTC. */ + return txc.maxerror < 16000000; +} + static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_time, "t", now(CLOCK_REALTIME)); static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_ntp_sync, "b", ntp_synced()); |