diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-02-25 01:44:30 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-04-12 13:43:30 +0200 |
commit | cd64fd56134ef00cce0651e741d4ebda3791d97b (patch) | |
tree | db1476a36d5f19cb423c3219e9fb3c26798e8eef /src/shared/path-lookup.c | |
parent | 39591351391de3ef2fd23cc5aea5bdd6ab712db6 (diff) |
path-lookup: split out logic for mkdir/rmdir of generator dirs in their own functions
Diffstat (limited to 'src/shared/path-lookup.c')
-rw-r--r-- | src/shared/path-lookup.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index f437de370c..083e467475 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -26,6 +26,7 @@ #include "install.h" #include "log.h" #include "macro.h" +#include "mkdir.h" #include "path-lookup.h" #include "path-util.h" #include "stat-util.h" @@ -457,8 +458,7 @@ int lookup_paths_init( if (r < 0 && r != -EOPNOTSUPP && r != -ENXIO) return r; - /* First priority is whatever has been passed to us via env - * vars */ + /* First priority is whatever has been passed to us via env vars */ e = getenv("SYSTEMD_UNIT_PATH"); if (e) { const char *k; @@ -633,3 +633,36 @@ void lookup_paths_free(LookupPaths *p) { p->root_dir = mfree(p->root_dir); } + +int lookup_paths_mkdir_generator(LookupPaths *p) { + int r, q; + + assert(p); + + r = mkdir_p_label(p->generator, 0755); + + q = mkdir_p_label(p->generator_early, 0755); + if (q < 0 && r >= 0) + r = q; + + q = mkdir_p_label(p->generator_late, 0755); + if (q < 0 && r >= 0) + r = q; + + return r; +} + +void lookup_paths_trim_generator(LookupPaths *p) { + assert(p); + + /* Trim empty dirs */ + + if (p->generator) + (void) rmdir(p->generator); + + if (p->generator_early) + (void) rmdir(p->generator_early); + + if (p->generator_late) + (void) rmdir(p->generator_late); +} |