]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/load-dropin.c
tree-wide: remove Emacs lines from all files
[thirdparty/systemd.git] / src / core / load-dropin.c
CommitLineData
a7334b09
LP
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
5430f7f2
LP
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
a7334b09
LP
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
5430f7f2 14 Lesser General Public License for more details.
a7334b09 15
5430f7f2 16 You should have received a copy of the GNU Lesser General Public License
a7334b09
LP
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18***/
19
0301abf4 20
cf0fbc49 21#include "conf-parser.h"
5cb5a6ff 22#include "load-dropin.h"
cf0fbc49 23#include "load-fragment.h"
b952f2e1 24#include "log.h"
036643a2 25#include "strv.h"
9e2f7c11 26#include "unit-name.h"
cf0fbc49 27#include "unit.h"
8afbb8e1 28
1a7f1b38 29static int add_dependency_consumer(
aa96c6cb 30 UnitDependency dependency,
1a7f1b38
ZJS
31 const char *entry,
32 const char* filepath,
33 void *arg) {
34 Unit *u = arg;
9e2f7c11
LP
35 int r;
36
99f08d14 37 assert(u);
9e2f7c11 38
1a7f1b38
ZJS
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);
9e2f7c11 42
8afbb8e1 43 return 0;
9e2f7c11 44}
5cb5a6ff 45
ae7a7182
OS
46int unit_load_dropin(Unit *u) {
47 Iterator i;
48 char *t, **f;
1a7f1b38 49 int r;
99f08d14
LP
50
51 assert(u);
52
53 /* Load dependencies from supplementary drop-in directories */
036643a2 54
ac155bb8 55 SET_FOREACH(t, u->names, i) {
99f08d14
LP
56 char **p;
57
ac155bb8 58 STRV_FOREACH(p, u->manager->lookup_paths.unit_path) {
1a7f1b38
ZJS
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);
036643a2 63 }
0301abf4
LP
64 }
65
bffd87bb 66 u->dropin_paths = strv_free(u->dropin_paths);
1a7f1b38
ZJS
67 r = unit_find_dropin_paths(u, &u->dropin_paths);
68 if (r <= 0)
ae7a7182 69 return 0;
5926ccca 70
ae7a7182 71 STRV_FOREACH(f, u->dropin_paths) {
bcd816bd 72 config_parse(u->id, *f, NULL,
36f822c4
ZJS
73 UNIT_VTABLE(u)->sections,
74 config_item_perf_lookup, load_fragment_gperf_lookup,
75 false, false, false, u);
5926ccca
LP
76 }
77
ae7a7182
OS
78 u->dropin_mtime = now(CLOCK_REALTIME);
79
5cb5a6ff
LP
80 return 0;
81}