return 0;
}
-int user_runtime(char **user_runtime_path) {
+int user_runtime_dir(char **runtime_dir) {
const char *e;
char *r;
if (!r)
return -ENOMEM;
- *user_runtime_path = r;
+ *runtime_dir = r;
return 1;
}
};
const char *home, *e;
- _cleanup_free_ char *config_home = NULL, *user_runtime_dir = NULL, *data_home = NULL;
+ _cleanup_free_ char *config_home = NULL, *runtime_dir = NULL, *data_home = NULL;
_cleanup_strv_free_ char **config_dirs = NULL, **data_dirs = NULL;
char **r = NULL;
if (user_config_home(&config_home) < 0)
goto fail;
- if (user_runtime(&user_runtime_dir) < 0)
+ if (user_runtime_dir(&runtime_dir) < 0)
goto fail;
home = getenv("HOME");
if (strv_extend(&r, config_home) < 0)
goto fail;
- if (user_runtime_dir)
- if (strv_extend(&r, user_runtime_dir) < 0)
+ if (!strv_isempty(config_dirs))
+ if (strv_extend_strv_concat(&r, config_dirs, "/systemd/user") < 0)
goto fail;
- if (strv_extend(&r, runtime_unit_path) < 0)
+ if (strv_extend_strv(&r, (char**) config_unit_paths) < 0)
goto fail;
- if (!strv_isempty(config_dirs))
- if (strv_extend_strv_concat(&r, config_dirs, "/systemd/user") < 0)
+ if (runtime_dir)
+ if (strv_extend(&r, runtime_dir) < 0)
goto fail;
- if (strv_extend_strv(&r, (char**) config_unit_paths) < 0)
+ if (strv_extend(&r, runtime_unit_path) < 0)
goto fail;
if (generator)
p->sysvinit_path = p->sysvrcnd_path = NULL;
#endif
}
+
+int lookup_paths_init_from_scope(LookupPaths *paths,
+ UnitFileScope scope,
+ const char *root_dir) {
+ assert(paths);
+ assert(scope >= 0);
+ assert(scope < _UNIT_FILE_SCOPE_MAX);
+
+ zero(*paths);
+
+ return lookup_paths_init(paths,
+ scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER,
+ scope == UNIT_FILE_USER,
+ root_dir,
+ NULL, NULL, NULL);
+}