load-dropin.c revision 737563e4bb1606cae1dd0e9484f9e82da466fe76
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <dirent.h>
#include <errno.h>
#include "unit.h"
#include "load-dropin.h"
#include "log.h"
#include "strv.h"
#include "unit-name.h"
#include "conf-parser.h"
#include "load-fragment.h"
#include "conf-files.h"
int r;
assert(u);
/* The config directories are special, since the order of the
* drop-ins matters */
if (dependency < 0) {
if (r < 0)
return log_oom();
return 0;
}
if (!d) {
return 0;
return -errno;
}
for (;;) {
union dirent_storage buf;
_cleanup_free_ char *f = NULL;
int k;
if (k != 0) {
return -k;
}
if (!de)
break;
continue;
if (!f)
return log_oom();
if (r < 0)
}
return 0;
}
static int process_dir(Unit *u, const char *unit_path, const char *name, const char *suffix, UnitDependency dependency, char ***strv) {
int r;
char *path;
assert(u);
if (!path)
return -ENOMEM;
if (u->manager->unit_path_cache &&
r = 0;
else
if (r < 0)
return r;
if (u->instance) {
char *template;
/* Also try the template dir */
if (!template)
return -ENOMEM;
if (!path)
return -ENOMEM;
if (u->manager->unit_path_cache &&
r = 0;
else
if (r < 0)
return r;
}
return 0;
}
char **unit_find_dropin_paths(Unit *u) {
Iterator i;
char *t;
int r;
assert(u);
SET_FOREACH(t, u->names, i) {
char **p;
/* This loads the drop-in config snippets */
if (r < 0)
return NULL;
}
}
if (!strv_isempty(strv)) {
if (r < 0) {
return NULL;
}
}
return configs;
}
int unit_load_dropin(Unit *u) {
Iterator i;
char *t, **f;
int r;
assert(u);
/* Load dependencies from supplementary drop-in directories */
SET_FOREACH(t, u->names, i) {
char **p;
if (r < 0)
return r;
if (r < 0)
return r;
}
}
u->dropin_paths = unit_find_dropin_paths(u);
if (! u->dropin_paths)
return 0;
STRV_FOREACH(f, u->dropin_paths) {
r = config_parse(*f, NULL, UNIT_VTABLE(u)->sections, config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, u);
if (r < 0)
return r;
}
return 0;
}