summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-29 19:31:41 +0100
committerLennart Poettering <lennart@poettering.net>2013-10-29 19:34:59 +0100
commit88e262b667df1cd9873c45f0062ae79735f41ae6 (patch)
treea6e0c8d4a20bb47fadd2cba0361dfa4927c08e1e
parent29f8d1f21ab5341361adcc2533fcda24a7fcf490 (diff)
timedate: handle more nicely if something or somebody keeps open /dev/rtc and thus blocks out everybody else
chrony is appears to keep the RTC open continuously these days which is a bad idea, and /dev/rtc is a single-user device, which is a bad idea too. Together both bad ideas mean that nobody else can access the RTC anymore. That's something to fix, but in the meantime we should handle this more gracefully.
-rw-r--r--src/timedate/timedated.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 809c80bad1..3d450ca3fa 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -467,12 +467,14 @@ static int property_get_rtc_time(
zero(tm);
r = hwclock_get_time(&tm);
- if (r < 0) {
+ if (r == -EBUSY) {
+ log_warning("/dev/rtc is busy, is somebody keeping it open continously? That's not a good idea... Returning a bogus RTC timestamp.");
+ t = 0;
+ } else if (r < 0) {
sd_bus_error_set_errnof(error, -r, "Failed to read RTC: %s", strerror(-r));
return r;
- }
-
- t = (usec_t) mktime(&tm) * USEC_PER_SEC;
+ } else
+ t = (usec_t) mktime(&tm) * USEC_PER_SEC;
r = sd_bus_message_append(reply, "t", t);
if (r < 0)