summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5d0ae62)
Previously systemctl died with message
-bash-4.2# systemctl --root /rawhi list-unit-files
(src/systemctl/systemctl.c:868) Out of memory.
in the case that no unit files were found in the --root
or the directory did not exist.
So lets return ENOENT in the case that --root does not exist
and empty list in the case that there are no unit files.
if (root_dir && scope != UNIT_FILE_SYSTEM)
return -EINVAL;
if (root_dir && scope != UNIT_FILE_SYSTEM)
return -EINVAL;
+ if (root_dir) {
+ r = access(root_dir, F_OK);
+ if (r < 0)
+ return -errno;
+ }
+
r = lookup_paths_init_from_scope(&paths, scope, root_dir);
if (r < 0)
return r;
r = lookup_paths_init_from_scope(&paths, scope, root_dir);
if (r < 0)
return r;
}
n_units = hashmap_size(h);
}
n_units = hashmap_size(h);
+
+ if (n_units == 0)
+ return 0;
+
units = new(UnitFileList, n_units);
if (!units) {
unit_file_list_free(h);
units = new(UnitFileList, n_units);
if (!units) {
unit_file_list_free(h);