#include "cgroup-util.h"
#include "path-util.h"
#include "audit-fd.h"
-#include "efivars.h"
+#include "boot-timestamps.h"
#include "env-util.h"
/* As soon as 5s passed since a unit was added to our GC queue, make sure to run a gc sweep */
}
static int manager_default_environment(Manager *m) {
- const char *path = "PATH=" DEFAULT_PATH;
-
assert(m);
if (m->running_as == SYSTEMD_SYSTEM) {
* The initial passed environ is untouched to keep
* /proc/self/environ valid; it is used for tagging
* the init process inside containers. */
- m->environment = strv_new(path, NULL);
+ m->environment = strv_new("PATH=" DEFAULT_PATH,
+ NULL);
/* Import locale variables LC_*= from configuration */
locale_setup(&m->environment);
#ifdef ENABLE_EFI
if (detect_container(NULL) <= 0)
- efi_get_boot_timestamps(&m->userspace_timestamp, &m->firmware_timestamp, &m->loader_timestamp);
+ boot_timestamps(&m->userspace_timestamp, &m->firmware_timestamp, &m->loader_timestamp);
#endif
m->running_as = running_as;
for (i = 0; i < RLIMIT_NLIMITS; i++)
free(m->rlimit[i]);
+ assert(hashmap_isempty(m->units_requiring_mounts_for));
+ hashmap_free(m->units_requiring_mounts_for);
+
free(m);
}
/* Let's ask every type to load all units from disk/kernel
* that it might know */
for (c = 0; c < _UNIT_TYPE_MAX; c++)
- if (unit_vtable[c]->enumerate)
- if ((q = unit_vtable[c]->enumerate(m)) < 0)
+ if (unit_vtable[c]->enumerate) {
+ q = unit_vtable[c]->enumerate(m);
+ if (q < 0)
r = q;
+ }
manager_dispatch_load_queue(m);
return r;
va_end(ap);
}
+int manager_get_unit_by_path(Manager *m, const char *path, const char *suffix, Unit **_found) {
+ _cleanup_free_ char *p = NULL;
+ Unit *found;
+
+ assert(m);
+ assert(path);
+ assert(suffix);
+ assert(_found);
+
+ p = unit_name_from_path(path, suffix);
+ if (!p)
+ return -ENOMEM;
+
+ found = manager_get_unit(m, p);
+ if (!found) {
+ *_found = NULL;
+ return 0;
+ }
+
+ *_found = found;
+ return 1;
+}
+
+Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path) {
+ char p[strlen(path)+1];
+
+ assert(m);
+ assert(path);
+
+ strcpy(p, path);
+ path_kill_slashes(p);
+
+ return hashmap_get(m->units_requiring_mounts_for, streq(p, "/") ? "" : p);
+}
+
void watch_init(Watch *w) {
assert(w);