}
_public_ int sd_get_seats(char ***seats) {
- return get_files_in_directory("/run/systemd/seats/", seats);
+ int r;
+
+ r = get_files_in_directory("/run/systemd/seats/", seats);
+ if (r == -ENOENT) {
+ if (seats)
+ *seats = NULL;
+ return 0;
+ }
+ return r;
}
_public_ int sd_get_sessions(char ***sessions) {
- return get_files_in_directory("/run/systemd/sessions/", sessions);
+ int r;
+
+ r = get_files_in_directory("/run/systemd/sessions/", sessions);
+ if (r == -ENOENT) {
+ if (sessions)
+ *sessions = NULL;
+ return 0;
+ }
+ return r;
}
_public_ int sd_get_uids(uid_t **users) {
_cleanup_free_ uid_t *l = NULL;
d = opendir("/run/systemd/users/");
- if (!d)
+ if (!d) {
+ if (errno == ENOENT) {
+ if (users)
+ *users = NULL;
+ return 0;
+ }
return -errno;
+ }
FOREACH_DIRENT_ALL(de, d, return -errno) {
int k;
}
_public_ int sd_get_machine_names(char ***machines) {
- char **l = NULL, **a, **b;
+ char **l, **a, **b;
int r;
- assert_return(machines, -EINVAL);
-
r = get_files_in_directory("/run/systemd/machines/", &l);
if (r == -ENOENT) {
- *machines = NULL;
+ if (machines)
+ *machines = NULL;
return 0;
}
if (r < 0)
r = 0;
/* Filter out the unit: symlinks */
- for (a = l, b = l; *a; a++) {
+ for (a = b = l; *a; a++) {
if (startswith(*a, "unit:") || !machine_name_is_valid(*a))
free(*a);
else {
*b = NULL;
}
- *machines = l;
+ if (machines)
+ *machines = l;
return r;
}