diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-03-07 19:07:30 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-04-12 13:43:31 +0200 |
commit | e4fca67ff02c44216780c5a61b1ab66cb6c09752 (patch) | |
tree | 60ceb4be28c9cbafaa763e90a0af632d9d32ede3 /src/shared/install.c | |
parent | 401017e04d3d1ac41fabb939278984acc8298ddb (diff) |
install: introduce a new unit file state "transient"
Now, that the search path logic knows the unit path for transient units we also
can introduce an explicit unit file state "transient" that clarifies to the
user what kind of unit file he is encountering.
Diffstat (limited to 'src/shared/install.c')
-rw-r--r-- | src/shared/install.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/shared/install.c b/src/shared/install.c index 6c5d3ce7d1..c19c85a3b5 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -119,6 +119,19 @@ static int path_is_generator(const LookupPaths *p, const char *path) { path_equal(p->generator_late, parent); } +static int path_is_transient(const LookupPaths *p, const char *path) { + _cleanup_free_ char *parent = NULL; + + assert(p); + assert(path); + + parent = dirname_malloc(path); + if (!parent) + return -ENOMEM; + + return path_equal(p->transient, parent); +} + static int path_is_config(const LookupPaths *p, const char *path) { _cleanup_free_ char *parent = NULL; const char *rpath; @@ -1710,6 +1723,8 @@ int unit_file_add_dependency( return -ESHUTDOWN; if (path_is_generator(&paths, target_info->path)) return -EADDRNOTAVAIL; + if (path_is_transient(&paths, target_info->path)) + return -EADDRNOTAVAIL; assert(target_info->type == UNIT_FILE_TYPE_REGULAR); @@ -1723,6 +1738,8 @@ int unit_file_add_dependency( return -ESHUTDOWN; if (path_is_generator(&paths, i->path)) return -EADDRNOTAVAIL; + if (path_is_transient(&paths, i->path)) + return -EADDRNOTAVAIL; assert(i->type == UNIT_FILE_TYPE_REGULAR); @@ -1777,6 +1794,8 @@ int unit_file_enable( return -ESHUTDOWN; if (path_is_generator(&paths, i->path)) return -EADDRNOTAVAIL; + if (path_is_transient(&paths, i->path)) + return -EADDRNOTAVAIL; assert(i->type == UNIT_FILE_TYPE_REGULAR); } @@ -1891,6 +1910,8 @@ int unit_file_set_default( return -ESHUTDOWN; if (path_is_generator(&paths, i->path)) return -EADDRNOTAVAIL; + if (path_is_transient(&paths, i->path)) + return -EADDRNOTAVAIL; old_path = skip_root(&paths, i->path); new_path = strjoina(paths.persistent_config, "/" SPECIAL_DEFAULT_TARGET); @@ -1975,6 +1996,14 @@ int unit_file_lookup_state( break; } + r = path_is_transient(paths, i->path); + if (r < 0) + return r; + if (r > 0) { + state = UNIT_FILE_TRANSIENT; + break; + } + r = find_symlinks_in_scope(scope, paths, i->name, &state); if (r < 0) return r; @@ -2176,6 +2205,8 @@ static int preset_prepare_one( return -ESHUTDOWN; if (path_is_generator(paths, i->path)) return -EADDRNOTAVAIL; + if (path_is_transient(paths, i->path)) + return -EADDRNOTAVAIL; } else r = install_info_discover(scope, minus, paths, name, SEARCH_FOLLOW_CONFIG_SYMLINKS, &i); @@ -2372,6 +2403,7 @@ static const char* const unit_file_state_table[_UNIT_FILE_STATE_MAX] = { [UNIT_FILE_DISABLED] = "disabled", [UNIT_FILE_INDIRECT] = "indirect", [UNIT_FILE_GENERATED] = "generated", + [UNIT_FILE_TRANSIENT] = "transient", [UNIT_FILE_BAD] = "bad", }; |