diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-05-29 12:39:16 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-05-29 16:33:06 +0200 |
commit | 2a7ff45f09c983000d5ffd3869064e1f81a43669 (patch) | |
tree | 9dd95671e4400300288a538ca080bd2e017e047e /src/timedate/timedated.c | |
parent | timedated: show the short timezone name when changing timezones in logs (diff) | |
download | systemd-2a7ff45f09c983000d5ffd3869064e1f81a43669.tar.xz systemd-2a7ff45f09c983000d5ffd3869064e1f81a43669.zip |
timedated: add some debug logging when a number of kernel calls fail
Diffstat (limited to 'src/timedate/timedated.c')
-rw-r--r-- | src/timedate/timedated.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index b7a2091062..d504f7c6f9 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -556,7 +556,9 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error * tzset(); /* 3. Tell the kernel our timezone */ - clock_set_timezone(NULL); + r = clock_set_timezone(NULL); + if (r < 0) + log_debug_errno(r, "Failed to tell kernel about timezone, ignoring: %m"); if (c->local_rtc) { struct timespec ts; @@ -565,7 +567,10 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error * /* 4. Sync RTC from system clock, with the new delta */ assert_se(clock_gettime(CLOCK_REALTIME, &ts) == 0); assert_se(tm = localtime(&ts.tv_sec)); - clock_set_hwclock(tm); + + r = clock_set_hwclock(tm); + if (r < 0) + log_debug_errno(r, "Failed to sync time to hardware clock, ignoring: %m"); } log_struct(LOG_INFO, @@ -621,7 +626,9 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error } /* 2. Tell the kernel our timezone */ - clock_set_timezone(NULL); + r = clock_set_timezone(NULL); + if (r < 0) + log_debug_errno(r, "Failed to tell kernel about timezone, ignoring: %m"); /* 3. Synchronize clocks */ assert_se(clock_gettime(CLOCK_REALTIME, &ts) == 0); @@ -629,27 +636,25 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error if (fix_system) { struct tm tm; - /* Sync system clock from RTC; first, - * initialize the timezone fields of - * struct tm. */ + /* Sync system clock from RTC; first, initialize the timezone fields of struct tm. */ if (c->local_rtc) tm = *localtime(&ts.tv_sec); else tm = *gmtime(&ts.tv_sec); - /* Override the main fields of - * struct tm, but not the timezone - * fields */ - if (clock_get_hwclock(&tm) >= 0) { - - /* And set the system clock - * with this */ + /* Override the main fields of struct tm, but not the timezone fields */ + r = clock_get_hwclock(&tm); + if (r < 0) + log_debug_errno(r, "Failed to get hardware clock, ignoring: %m"); + else { + /* And set the system clock with this */ if (c->local_rtc) ts.tv_sec = mktime(&tm); else ts.tv_sec = timegm(&tm); - clock_settime(CLOCK_REALTIME, &ts); + if (clock_settime(CLOCK_REALTIME, &ts) < 0) + log_debug_errno(errno, "Failed to update system clock, ignoring: %m"); } } else { @@ -661,7 +666,9 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error else tm = gmtime(&ts.tv_sec); - clock_set_hwclock(tm); + r = clock_set_hwclock(tm); + if (r < 0) + log_debug_errno(r, "Failed to sync time to hardware clock, ignoring: %m"); } log_info("RTC configured to %s time.", c->local_rtc ? "local" : "UTC"); @@ -750,7 +757,10 @@ static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *erro tm = localtime(&ts.tv_sec); else tm = gmtime(&ts.tv_sec); - clock_set_hwclock(tm); + + r = clock_set_hwclock(tm); + if (r < 0) + log_debug_errno(r, "Failed to update hardware clock, ignoring: %m"); log_struct(LOG_INFO, "MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR, |