summaryrefslogtreecommitdiff
path: root/src/login/sd-login.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-06-20 04:03:38 +0200
committerLennart Poettering <lennart@poettering.net>2013-06-20 04:03:38 +0200
commitba73ed858f27355d088fe2d96cb8c7e9eb75ff0c (patch)
tree724090efc518eae0026fd502e8753916b600d606 /src/login/sd-login.c
parent5caef0fc192e88b2d965da50900567046e186ce1 (diff)
sd-login: update machine enumeration/notifications APIs for new /run/systemd/machines/
Diffstat (limited to 'src/login/sd-login.c')
-rw-r--r--src/login/sd-login.c48
1 files changed, 2 insertions, 46 deletions
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index d2e95034e1..875d134efc 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -592,40 +592,7 @@ _public_ int sd_get_uids(uid_t **users) {
}
_public_ int sd_get_machine_names(char ***machines) {
- _cleanup_closedir_ DIR *d = NULL;
- _cleanup_strv_free_ char **l = NULL;
- _cleanup_free_ char *md = NULL;
- char *n;
- int c = 0, r;
-
- r = cg_get_root_path(&md);
- if (r < 0)
- return r;
-
- r = cg_enumerate_subgroups(SYSTEMD_CGROUP_CONTROLLER, md, &d);
- if (r < 0)
- return r;
-
- while ((r = cg_read_subgroup(d, &n)) > 0) {
-
- r = strv_push(&l, n);
- if (r < 0) {
- free(n);
- return -ENOMEM;
- }
-
- c++;
- }
-
- if (r < 0)
- return r;
-
- if (machines) {
- *machines = l;
- l = NULL;
- }
-
- return c;
+ return get_files_in_directory("/run/systemd/machines/", machines);
}
static inline int MONITOR_TO_FD(sd_login_monitor *m) {
@@ -678,18 +645,7 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) {
}
if (!category || streq(category, "machine")) {
- _cleanup_free_ char *md = NULL, *p = NULL;
- int r;
-
- r = cg_get_root_path(&md);
- if (r < 0)
- return r;
-
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, md, NULL, &p);
- if (r < 0)
- return r;
-
- k = inotify_add_watch(fd, p, IN_MOVED_TO|IN_CREATE|IN_DELETE);
+ k = inotify_add_watch(fd, "/run/systemd/machines/", IN_MOVED_TO|IN_DELETE);
if (k < 0) {
close_nointr_nofail(fd);
return -errno;