chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a 'b' option to cgtop, equivalent to the same option in top
[elogind.git]
/
src
/
timedate
/
timedated.c
diff --git
a/src/timedate/timedated.c
b/src/timedate/timedated.c
index 4be7c3a9973d4b671846cf27f1a7c8cca5ca4fbc..09fd8083324d7ff2079e651443f0f5427da35607 100644
(file)
--- a/
src/timedate/timedated.c
+++ b/
src/timedate/timedated.c
@@
-31,6
+31,7
@@
#include "polkit.h"
#include "def.h"
#include "hwclock.h"
#include "polkit.h"
#include "def.h"
#include "hwclock.h"
+#include "conf-files.h"
#define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
#define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
#define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
#define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
@@
-152,7
+153,7
@@
static void verify_timezone(void) {
p = strappend("/usr/share/zoneinfo/", tz.zone);
if (!p) {
p = strappend("/usr/share/zoneinfo/", tz.zone);
if (!p) {
- log_
error("Out of memory"
);
+ log_
oom(
);
return;
}
return;
}
@@
-218,10
+219,8
@@
static int write_data_timezone(void) {
}
p = strappend("/usr/share/zoneinfo/", tz.zone);
}
p = strappend("/usr/share/zoneinfo/", tz.zone);
- if (!p) {
- log_error("Out of memory");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
r = symlink_or_copy_atomic(p, "/etc/localtime");
free(p);
r = symlink_or_copy_atomic(p, "/etc/localtime");
free(p);
@@
-304,42
+303,56
@@
static int write_data_local_rtc(void) {
}
static char** get_ntp_services(void) {
}
static char** get_ntp_services(void) {
- char **r = NULL;
- FILE *f;
-
- f = fopen(SYSTEMD_NTP_UNITS, "re");
- if (!f)
+ char **r = NULL, **files, **i;
+ int k;
+
+ k = conf_files_list(&files, ".list",
+ "/etc/systemd/ntp-units.d",
+ "/run/systemd/ntp-units.d",
+ "/usr/local/lib/systemd/ntp-units.d",
+ "/usr/lib/systemd/ntp-units.d",
+ NULL);
+ if (k < 0)
return NULL;
return NULL;
-
for (;;
) {
-
char line[PATH_MAX], *l, **q
;
+
STRV_FOREACH(i, files
) {
+
FILE *f
;
- if (!fgets(line, sizeof(line), f)) {
+ f = fopen(*i, "re");
+ if (!f)
+ continue;
- if (ferror(f))
-
log_error("Failed to read NTP units file: %m")
;
+ for (;;) {
+
char line[PATH_MAX], *l, **q
;
- break;
- }
+ if (!fgets(line, sizeof(line), f)) {
- l = strstrip(line);
- if (l[0] == 0 || l[0] == '#')
- continue;
+ if (ferror(f))
+ log_error("Failed to read NTP units file: %m");
+ break;
+ }
- q = strv_append(r, l);
- if (!q) {
- log_error("Out of memory");
- break;
+ l = strstrip(line);
+ if (l[0] == 0 || l[0] == '#')
+ continue;
+
+ q = strv_append(r, l);
+ if (!q) {
+ log_oom();
+ break;
+ }
+
+ strv_free(r);
+ r = q;
}
}
- strv_free(r);
- r = q;
+ fclose(f);
}
}
-
fclose(f
);
+
strv_free(files
);
- return
r
;
+ return
strv_uniq(r)
;
}
static int read_ntp(DBusConnection *bus) {
}
static int read_ntp(DBusConnection *bus) {
@@
-364,16
+377,14
@@
static int read_ntp(DBusConnection *bus) {
"org.freedesktop.systemd1.Manager",
"GetUnitFileState");
if (!m) {
"org.freedesktop.systemd1.Manager",
"GetUnitFileState");
if (!m) {
- log_error("Out of memory");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
if (!dbus_message_append_args(m,
DBUS_TYPE_STRING, i,
DBUS_TYPE_INVALID)) {
goto finish;
}
if (!dbus_message_append_args(m,
DBUS_TYPE_STRING, i,
DBUS_TYPE_INVALID)) {
- log_error("Could not append arguments to message.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
goto finish;
}
@@
-928,8
+939,7
@@
static int connect_bus(DBusConnection **_bus) {
if (!dbus_connection_register_object_path(bus, "/org/freedesktop/timedate1", &timedate_vtable, NULL) ||
!dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
if (!dbus_connection_register_object_path(bus, "/org/freedesktop/timedate1", &timedate_vtable, NULL) ||
!dbus_connection_add_filter(bus, bus_exit_idle_filter, &remain_until, NULL)) {
- log_error("Not enough memory");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
goto fail;
}