diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-02-24 15:44:46 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-04-12 13:43:29 +0200 |
commit | f413930863ab3b98cb7bf9e761081b4e88a5d7d9 (patch) | |
tree | a4d28ddb420d31374f37b0624047be0a4c129674 /src/shared/install.c | |
parent | core: rework generator dir logic, move the dirs into LookupPaths structure (diff) | |
download | systemd-f413930863ab3b98cb7bf9e761081b4e88a5d7d9.tar.xz systemd-f413930863ab3b98cb7bf9e761081b4e88a5d7d9.zip |
core: add a new unit file state "generated"
Now that we store the generator directories in LookupPaths we can use this to
intrdouce a new unit file state called "generated", for units in these
directories.
Fixes: #2348
Diffstat (limited to 'src/shared/install.c')
-rw-r--r-- | src/shared/install.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/shared/install.c b/src/shared/install.c index e232d76dd7..202d16e129 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -82,6 +82,20 @@ static int in_search_path(const char *path, char **search) { return false; } +static int unit_file_is_generated(const LookupPaths *p, const char *path) { + _cleanup_free_ char *parent = NULL; + + assert(path); + + parent = dirname_malloc(path); + if (!parent) + return -ENOMEM; + + return path_equal(p->generator, parent) || + path_equal(p->generator_early, parent) || + path_equal(p->generator_late, parent); +} + static int get_config_path(UnitFileScope scope, bool runtime, const char *root_dir, char **ret) { char *p = NULL; int r; @@ -2023,6 +2037,14 @@ int unit_file_lookup_state( break; case UNIT_FILE_TYPE_REGULAR: + r = unit_file_is_generated(paths, i->path); + if (r < 0) + return r; + if (r > 0) { + state = UNIT_FILE_GENERATED; + break; + } + r = find_symlinks_in_scope(scope, root_dir, i->name, &state); if (r < 0) return r; @@ -2453,6 +2475,7 @@ static const char* const unit_file_state_table[_UNIT_FILE_STATE_MAX] = { [UNIT_FILE_STATIC] = "static", [UNIT_FILE_DISABLED] = "disabled", [UNIT_FILE_INDIRECT] = "indirect", + [UNIT_FILE_GENERATED] = "generated", [UNIT_FILE_BAD] = "bad", }; |