udev: String substitutions can be done in ENV, too
[systemd_ALT.git] / src / core / generator-setup.c
blob00d6ad61fa0d9b2dea4c648a453a82f082225c5c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 #include <unistd.h>
5 #include "generator-setup.h"
6 #include "macro.h"
7 #include "mkdir-label.h"
8 #include "rm-rf.h"
10 int lookup_paths_mkdir_generator(LookupPaths *p) {
11 int r, q;
13 assert(p);
15 if (!p->generator || !p->generator_early || !p->generator_late)
16 return -EINVAL;
18 r = mkdir_p_label(p->generator, 0755);
20 q = mkdir_p_label(p->generator_early, 0755);
21 if (q < 0 && r >= 0)
22 r = q;
24 q = mkdir_p_label(p->generator_late, 0755);
25 if (q < 0 && r >= 0)
26 r = q;
28 return r;
31 void lookup_paths_trim_generator(LookupPaths *p) {
32 assert(p);
34 /* Trim empty dirs */
36 if (p->generator)
37 (void) rmdir(p->generator);
38 if (p->generator_early)
39 (void) rmdir(p->generator_early);
40 if (p->generator_late)
41 (void) rmdir(p->generator_late);
44 void lookup_paths_flush_generator(LookupPaths *p) {
45 assert(p);
47 /* Flush the generated unit files in full */
49 if (p->generator)
50 (void) rm_rf(p->generator, REMOVE_ROOT|REMOVE_PHYSICAL);
51 if (p->generator_early)
52 (void) rm_rf(p->generator_early, REMOVE_ROOT|REMOVE_PHYSICAL);
53 if (p->generator_late)
54 (void) rm_rf(p->generator_late, REMOVE_ROOT|REMOVE_PHYSICAL);
56 if (p->temporary_dir)
57 (void) rm_rf(p->temporary_dir, REMOVE_ROOT|REMOVE_PHYSICAL);