]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: move config_get_dropin_files to conf-files
authorMike Yuan <me@yhndnzj.com>
Fri, 12 May 2023 18:38:41 +0000 (02:38 +0800)
committerMike Yuan <me@yhndnzj.com>
Sun, 21 May 2023 07:46:25 +0000 (15:46 +0800)
src/basic/conf-files.c
src/basic/conf-files.h
src/shared/conf-parser.c

index c31fe79ebdaaae922cbdb39e2fba4ad5d3318930..a56f82f8a3e8f309e592006ead319626598b13d4 100644 (file)
@@ -350,3 +350,25 @@ int conf_files_list_with_replacement(
 
         return 0;
 }
+
+int conf_files_list_dropins(
+                char ***ret,
+                const char *dropin_dirname,
+                const char *root,
+                const char * const *dirs) {
+
+        _cleanup_strv_free_ char **dropin_dirs = NULL;
+        const char *suffix;
+        int r;
+
+        assert(ret);
+        assert(dropin_dirname);
+        assert(dirs);
+
+        suffix = strjoina("/", dropin_dirname);
+        r = strv_extend_strv_concat(&dropin_dirs, (char**) dirs, suffix);
+        if (r < 0)
+                return r;
+
+        return conf_files_list_strv(ret, ".conf", root, 0, (const char* const*) dropin_dirs);
+}
index 547c2fc137f0debca34a4d0d48c1c70601d14676..566cc8fda4623f4c16bf6500583c75daa406f0ba 100644 (file)
@@ -24,3 +24,8 @@ int conf_files_list_with_replacement(
                 const char *replacement,
                 char ***files,
                 char **replace_file);
+int conf_files_list_dropins(
+                char ***ret,
+                const char *dropin_dirname,
+                const char *root,
+                const char * const *dirs);
index 21ba7f691497e6fa9a33b6a139ab7ad47a059f27..10bef002b01e62289d15a3a7a0c3e00a48ddca3d 100644 (file)
@@ -581,28 +581,6 @@ int config_parse_config_file(
                                        sections, lookup, table, flags, userdata, NULL);
 }
 
-static int config_get_dropin_files(
-                const char* const* conf_file_dirs,
-                const char *dropin_dirname,
-                const char *root,
-                char ***ret) {
-
-        _cleanup_strv_free_ char **dropin_dirs = NULL;
-        const char *suffix;
-        int r;
-
-        assert(conf_file_dirs);
-        assert(dropin_dirname);
-        assert(ret);
-
-        suffix = strjoina("/", dropin_dirname);
-        r = strv_extend_strv_concat(&dropin_dirs, (char**) conf_file_dirs, suffix);
-        if (r < 0)
-                return r;
-
-        return conf_files_list_strv(ret, ".conf", root, 0, (const char* const*) dropin_dirs);
-}
-
 /* Parse each config file in the directories specified as strv. */
 int config_parse_many(
                 const char* const* conf_files,
@@ -625,7 +603,7 @@ int config_parse_many(
         assert(sections);
         assert(table);
 
-        r = config_get_dropin_files(conf_file_dirs, dropin_dirname, root, &files);
+        r = conf_files_list_dropins(&files, dropin_dirname, root, conf_file_dirs);
         if (r < 0)
                 return r;
 
@@ -661,7 +639,7 @@ static int dropins_get_stats_by_path(
         if (!strextend(&dropin_dirname, ".d"))
                 return -ENOMEM;
 
-        r = config_get_dropin_files(conf_file_dirs, dropin_dirname, /* root = */ NULL, &files);
+        r = conf_files_list_dropins(&files, dropin_dirname, /* root = */ NULL, conf_file_dirs);
         if (r < 0)
                 return r;