chiark / gitweb /
util: conf_files_list() return list as parameter
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 28 Apr 2011 21:51:24 +0000 (23:51 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Thu, 28 Apr 2011 21:51:24 +0000 (23:51 +0200)
TODO
src/binfmt.c
src/dbus.c
src/modules-load.c
src/sysctl.c
src/tmpfiles.c
src/util.c
src/util.h

diff --git a/TODO b/TODO
index 3f26e2ea5f966cb1c121c2f4c2e1b8fc75c306a6..4ba66efec326a9ccd572ff6a3291addfdc550226 100644 (file)
--- a/TODO
+++ b/TODO
@@ -63,7 +63,7 @@ Features:
 
 * maybe add tiny dbus services similar to hostnamed for locale and wallclock/timezone?
 
-* allow port = 0 in .socket units
+* allow port=0 in .socket units
 
 * rename systemd-logger to systemd-stdio-syslog-bridge
 
@@ -123,6 +123,8 @@ Features:
   about policy loading. Probably check for available selinux in /proc/filesystems,
   and check for active selinux with getcon_raw() == "kernel"
 
+* move /selinux to /sys/fs/selinux
+
 * Support --test based on current system state
 
 * systemctl enable as D-Bus call
@@ -231,7 +233,7 @@ External:
 
 * make cryptsetup lower --iter-time
 
-* patch kernel for xattr support in /dev, /proc/, /sys and /sys/fs/cgroup.
+* patch kernel for xattr support in /dev, /proc/, /sys and /sys/fs/cgroup?
 
 * patch kernel for cpu feature modalias for autoloading aes/kvm/...
     http://git.kernel.org/?p=linux/kernel/git/ak/linux-misc-2.6.git;a=shortlog;h=refs/heads/cpuid-match
index 619f6e4aa781b37c1e36d4c6c4489dc68b2865f9..be1f1ff0979e1832d3d722d00e46ab48a6808815 100644 (file)
@@ -135,11 +135,16 @@ int main(int argc, char *argv[]) {
                 /* Flush out all rules */
                 write_one_line_file("/proc/sys/fs/binfmt_misc/status", "-1");
 
-                files = conf_files_list(".conf",
-                                        "/run/binfmt.d",
-                                        "/etc/binfmt.d",
-                                        "/usr/lib/binfmt.d",
-                                        NULL);
+                r = conf_files_list(&files, ".conf",
+                                    "/run/binfmt.d",
+                                    "/etc/binfmt.d",
+                                    "/usr/lib/binfmt.d",
+                                    NULL);
+
+                if (r < 0) {
+                        log_error("Failed to enumerate binfmt.d files: %s", strerror(-r));
+                        goto finish;
+                }
 
                 STRV_FOREACH(f, files) {
                         int k;
@@ -151,5 +156,6 @@ int main(int argc, char *argv[]) {
 
                 strv_free(files);
         }
+finish:
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }
index 8ea768c5a782f7f94d2bcb238767887e35315d7f..187ed303b465647ecf7d3c627a420fe05375d6ef 100644 (file)
@@ -1322,7 +1322,7 @@ int bus_fdset_add_all(Manager *m, FDSet *fds) {
          * set to pass over to the newly executed systemd. They won't
          * be used there however, except that they are closed at the
          * very end of deserialization, those making it possible for
-         * clients to synchronously wait for systemd to reexec buy
+         * clients to synchronously wait for systemd to reexec by
          * simply waiting for disconnection */
 
         SET_FOREACH(c, m->bus_connections_for_dispatch, i) {
index fac4511816011f7e6e65d089c223c5b07cbeeac4..7efd81f75b925e798f2a2df410ffb9ed6ddc4b92 100644 (file)
@@ -53,13 +53,12 @@ int main(int argc, char *argv[]) {
 
         n_arguments = n_allocated = 3;
 
-        files = conf_files_list(".conf",
-                                "/run/modules-load.d",
-                                "/etc/modules-load.d",
-                                "/usr/lib/modules-load.d",
-                                NULL);
-        if (files == NULL) {
-                log_error("Failed to enumerate modules-load.d files: %m");
+        if (conf_files_list(&files, ".conf",
+                            "/run/modules-load.d",
+                            "/etc/modules-load.d",
+                            "/usr/lib/modules-load.d",
+                            NULL) < 0) {
+                log_error("Failed to enumerate modules-load.d files: %s", strerror(-r));
                 goto finish;
         }
 
index 1d42e9378b7d060d4c1dcd912dc00b123144c33b..814cfea592743606d56d5012c60688ef4be40bc6 100644 (file)
@@ -138,13 +138,17 @@ int main(int argc, char *argv[]) {
         else {
                 char **files, **f;
 
-                r = apply_file("/etc/sysctl.conf", true);
-
-                files = conf_files_list(".conf",
-                                        "/run/sysctl.d",
-                                        "/etc/sysctl.d",
-                                        "/usr/lib/sysctl.d",
-                                        NULL);
+                apply_file("/etc/sysctl.conf", true);
+
+                r = conf_files_list(&files, ".conf",
+                                    "/run/sysctl.d",
+                                    "/etc/sysctl.d",
+                                    "/usr/lib/sysctl.d",
+                                    NULL);
+                if (r < 0) {
+                        log_error("Failed to enumerate sysctl.d files: %s", strerror(-r));
+                        goto finish;
+                }
 
                 STRV_FOREACH(f, files) {
                         int k;
@@ -156,6 +160,6 @@ int main(int argc, char *argv[]) {
 
                 strv_free(files);
         }
-
+finish:
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }
index 1574a199fbf3ab50e54e01b4adf2766b9f136913..f36a75f8f2f9e2e6ee05cdb20bb41700e34e8e3b 100644 (file)
@@ -963,11 +963,16 @@ int main(int argc, char *argv[]) {
         } else {
                 char **files, **f;
 
-                files = conf_files_list(".conf",
-                                        "/run/tmpfiles.d",
-                                        "/etc/tmpfiles.d",
-                                        "/usr/lib/tmpfiles.d",
-                                        NULL);
+                r = conf_files_list(&files, ".conf",
+                                    "/run/tmpfiles.d",
+                                    "/etc/tmpfiles.d",
+                                    "/usr/lib/tmpfiles.d",
+                                    NULL);
+                if (r < 0) {
+                        r = EXIT_FAILURE;
+                        log_error("Failed to enumerate tmpfiles.d files: %s", strerror(-r));
+                        goto finish;
+                }
 
                 STRV_FOREACH(f, files) {
                         if (read_config_file(*f, true) < 0)
index 6037455f705fd3e6f0dd40eb8f9091dc7fb8bf55..b337778d0ef96524447b4a3231588b1371a734b4 100644 (file)
@@ -4606,15 +4606,15 @@ static int base_cmp(const void *a, const void *b) {
         return strcmp(file_name_from_path(s1), file_name_from_path(s2));
 }
 
-char **conf_files_list(const char *suffix, const char *dir, ...) {
+int conf_files_list(char ***strv, const char *suffix, const char *dir, ...) {
         Hashmap *fh;
         char **files = NULL;
         va_list ap;
-        int e = 0;
+        int r = 0;
 
         fh = hashmap_new(string_hash_func, string_compare_func);
         if (!fh) {
-                e = ENOMEM;
+                r = -ENOMEM;
                 goto finish;
         }
 
@@ -4622,7 +4622,7 @@ char **conf_files_list(const char *suffix, const char *dir, ...) {
         while (dir) {
                 if (files_add(fh, dir, suffix) < 0) {
                         log_error("Failed to search for files.");
-                        e = EINVAL;
+                        r = -EINVAL;
                         goto finish;
                 }
                 dir = va_arg(ap, const char *);
@@ -4632,13 +4632,13 @@ char **conf_files_list(const char *suffix, const char *dir, ...) {
         files = hashmap_get_strv(fh);
         if (files == NULL) {
                 log_error("Failed to compose list of files.");
-                e = ENOMEM;
+                r = -ENOMEM;
                 goto finish;
         }
 
         qsort(files, hashmap_size(fh), sizeof(char *), base_cmp);
 finish:
         hashmap_free(fh);
-        errno = e;
-        return files;
+        *strv = files;
+        return r;
 }
index ff294745028534e9a8ab69fc0a2a5b80216fe679..5f6325b9e4a7b68b35af6e389c86fa0da5758e3d 100644 (file)
@@ -442,5 +442,5 @@ int signal_from_string(const char *s);
 
 int signal_from_string_try_harder(const char *s);
 
-char **conf_files_list(const char *suffix, const char *dir, ...);
+int conf_files_list(char ***strv, const char *suffix, const char *dir, ...);
 #endif