]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/load-dropin.c
tree-wide: remove Emacs lines from all files
[thirdparty/systemd.git] / src / core / load-dropin.c
1 /***
2 This file is part of systemd.
3
4 Copyright 2010 Lennart Poettering
5
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19
20
21 #include "conf-parser.h"
22 #include "load-dropin.h"
23 #include "load-fragment.h"
24 #include "log.h"
25 #include "strv.h"
26 #include "unit-name.h"
27 #include "unit.h"
28
29 static int add_dependency_consumer(
30 UnitDependency dependency,
31 const char *entry,
32 const char* filepath,
33 void *arg) {
34 Unit *u = arg;
35 int r;
36
37 assert(u);
38
39 r = unit_add_dependency_by_name(u, dependency, entry, filepath, true);
40 if (r < 0)
41 log_error_errno(r, "Cannot add dependency %s to %s, ignoring: %m", entry, u->id);
42
43 return 0;
44 }
45
46 int unit_load_dropin(Unit *u) {
47 Iterator i;
48 char *t, **f;
49 int r;
50
51 assert(u);
52
53 /* Load dependencies from supplementary drop-in directories */
54
55 SET_FOREACH(t, u->names, i) {
56 char **p;
57
58 STRV_FOREACH(p, u->manager->lookup_paths.unit_path) {
59 unit_file_process_dir(u->manager->unit_path_cache, *p, t, ".wants", UNIT_WANTS,
60 add_dependency_consumer, u, NULL);
61 unit_file_process_dir(u->manager->unit_path_cache, *p, t, ".requires", UNIT_REQUIRES,
62 add_dependency_consumer, u, NULL);
63 }
64 }
65
66 u->dropin_paths = strv_free(u->dropin_paths);
67 r = unit_find_dropin_paths(u, &u->dropin_paths);
68 if (r <= 0)
69 return 0;
70
71 STRV_FOREACH(f, u->dropin_paths) {
72 config_parse(u->id, *f, NULL,
73 UNIT_VTABLE(u)->sections,
74 config_item_perf_lookup, load_fragment_gperf_lookup,
75 false, false, false, u);
76 }
77
78 u->dropin_mtime = now(CLOCK_REALTIME);
79
80 return 0;
81 }