-static int process_dir(
- Unit *u,
- const char *unit_path,
- const char *name,
- const char *suffix,
- UnitDependency dependency,
- char ***strv) {
-
- _cleanup_free_ char *path = NULL;
-
- assert(u);
- assert(unit_path);
- assert(name);
- assert(suffix);
-
- path = strjoin(unit_path, "/", name, suffix, NULL);
- if (!path)
- return log_oom();
-
- if (!u->manager->unit_path_cache || set_get(u->manager->unit_path_cache, path))
- iterate_dir(u, path, dependency, strv);
-
- if (u->instance) {
- _cleanup_free_ char *template = NULL, *p = NULL;
- /* Also try the template dir */
-
- template = unit_name_template(name);
- if (!template)
- return log_oom();
-
- p = strjoin(unit_path, "/", template, suffix, NULL);
- if (!p)
- return log_oom();
-
- if (!u->manager->unit_path_cache || set_get(u->manager->unit_path_cache, p))
- iterate_dir(u, p, dependency, strv);
- }
-
- return 0;
-}
-
-char **unit_find_dropin_paths(Unit *u) {
- _cleanup_strv_free_ char **strv = NULL;
- char **configs = NULL;
- Iterator i;
- char *t;
- int r;
-
- assert(u);
-
- SET_FOREACH(t, u->names, i) {
- char **p;
-
- STRV_FOREACH(p, u->manager->lookup_paths.unit_path)
- process_dir(u, *p, t, ".d", _UNIT_DEPENDENCY_INVALID, &strv);
- }
-
- if (strv_isempty(strv))
- return NULL;
-
- r = conf_files_list_strv(&configs, ".conf", NULL, (const char**) strv);
- if (r < 0) {
- log_error_errno(r, "Failed to get list of configuration files: %m");
- strv_free(configs);
- return NULL;
- }
-
- return configs;
-}
-