chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
timedatectl: port to sd-bus
[elogind.git]
/
src
/
timedate
/
timedated.c
diff --git
a/src/timedate/timedated.c
b/src/timedate/timedated.c
index 2ead4b99993b91c44f099b0e25a52ee7d0bf8cf0..9858f5694c79a329c9a921daceebd7d88f710744 100644
(file)
--- a/
src/timedate/timedated.c
+++ b/
src/timedate/timedated.c
@@
-45,8
+45,8
@@
typedef struct Context {
char *zone;
bool local_rtc;
typedef struct Context {
char *zone;
bool local_rtc;
-
int
can_ntp;
-
int
use_ntp;
+
unsigned
can_ntp;
+
unsigned
use_ntp;
Hashmap *polkit_registry;
} Context;
Hashmap *polkit_registry;
} Context;
@@
-248,6
+248,9
@@
static char** get_ntp_services(void) {
"/run/systemd/ntp-units.d",
"/usr/local/lib/systemd/ntp-units.d",
"/usr/lib/systemd/ntp-units.d",
"/run/systemd/ntp-units.d",
"/usr/local/lib/systemd/ntp-units.d",
"/usr/lib/systemd/ntp-units.d",
+#ifdef HAVE_SPLIT_USR
+ "/lib/systemd/ntp-units.d",
+#endif
NULL);
if (k < 0)
return NULL;
NULL);
if (k < 0)
return NULL;
@@
-467,12
+470,14
@@
static int property_get_rtc_time(
zero(tm);
r = hwclock_get_time(&tm);
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;
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)
r = sd_bus_message_append(reply, "t", t);
if (r < 0)
@@
-521,7
+526,7
@@
static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
Context *c = userdata;
const char *z;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
Context *c = userdata;
const char *z;
-
bool
interactive;
+
unsigned
interactive;
char *t;
int r;
char *t;
int r;
@@
-585,7
+590,7
@@
static int method_set_timezone(sd_bus *bus, sd_bus_message *m, void *userdata) {
static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-
bool
lrtc, fix_system, interactive;
+
unsigned
lrtc, fix_system, interactive;
Context *c = userdata;
struct timespec ts;
int r;
Context *c = userdata;
struct timespec ts;
int r;
@@
-669,7
+674,7
@@
static int method_set_local_rtc(sd_bus *bus, sd_bus_message *m, void *userdata)
static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-
bool
relative, interactive;
+
unsigned
relative, interactive;
Context *c = userdata;
int64_t utc;
struct timespec ts;
Context *c = userdata;
int64_t utc;
struct timespec ts;
@@
-735,7
+740,7
@@
static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata) {
static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-
bool
ntp, interactive;
+
unsigned
ntp, interactive;
Context *c = userdata;
int r;
Context *c = userdata;
int r;