1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

path-lookup, systemctl: export lookup_paths_init_from_scope() from shared/install.c and use it

This commit is contained in:
Ivan Shapovalov 2014-12-19 17:08:07 +03:00 committed by Zbigniew Jędrzejewski-Szmek
parent 69c4e2771e
commit 60d27f1916
4 changed files with 21 additions and 21 deletions

View File

@ -58,22 +58,6 @@ static int in_search_path(const char *path, char **search) {
return strv_contains(search, parent);
}
static 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);
}
static int get_config_path(UnitFileScope scope, bool runtime, const char *root_dir, char **ret) {
char *p = NULL;
int r;

View File

@ -398,3 +398,19 @@ void lookup_paths_free(LookupPaths *p) {
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);
}

View File

@ -22,6 +22,7 @@
***/
#include "macro.h"
#include "install.h"
typedef struct LookupPaths {
char **unit_path;
@ -49,5 +50,8 @@ int lookup_paths_init(LookupPaths *p,
const char *generator_early,
const char *generator_late);
void lookup_paths_free(LookupPaths *p);
int lookup_paths_init_from_scope(LookupPaths *paths,
UnitFileScope scope,
const char *root_dir);
#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)

View File

@ -4515,11 +4515,7 @@ static int init_home_and_lookup_paths(char **user_home, char **user_runtime, Loo
return log_error_errno(ENOTDIR, "Cannot find units: $XDG_RUNTIME_DIR is not set.");
}
r = lookup_paths_init(lp,
arg_scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER,
arg_scope == UNIT_FILE_USER,
arg_root,
NULL, NULL, NULL);
r = lookup_paths_init_from_scope(lp, arg_scope, arg_root);
if (r < 0)
return log_error_errno(r, "Failed to lookup unit lookup paths: %m");