[systemd-commits] 7 commits - Makefile.am TODO src/core src/journal src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Mon Mar 3 12:57:00 PST 2014


 Makefile.am                           |    4 
 TODO                                  |    4 
 src/core/load-fragment-gperf.gperf.m4 |   10 -
 src/core/load-fragment.c              |  144 ++++++++++++++++
 src/core/load-fragment.h              |    2 
 src/core/main.c                       |   51 ++++-
 src/core/manager.h                    |    1 
 src/core/namespace.c                  |    2 
 src/journal/journald-gperf.gperf      |   46 ++---
 src/shared/conf-parser.c              |  294 ++++++----------------------------
 src/shared/conf-parser.h              |    7 
 src/shared/exit-status.c              |   17 -
 src/shared/exit-status.h              |   14 -
 13 files changed, 281 insertions(+), 315 deletions(-)

New commits:
commit 18633feaaee617e25c401617926a83a37ba5a7d9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Mar 3 21:55:41 2014 +0100

    update TODO

diff --git a/TODO b/TODO
index 3bc8c39..fe01ac3 100644
--- a/TODO
+++ b/TODO
@@ -27,6 +27,8 @@ External:
 
 Features:
 
+* Imply DevicePolicy=closed when PrivateDevices= is used
+
 * add an "input" group to udev logic and add all input devices to it
 
 * libsystemd-login: implement getpeer_unit(), get_peer_slice(), ...
@@ -120,8 +122,6 @@ Features:
 
 * rfkill,backlight: we probably should run the load tools inside of the udev rules so that the state is properly initialized by the time other software sees it
 
-* move config_parse_path_strv() out of conf-parser.c
-
 * After coming back from hibernation reset hibernation swap partition using the /dev/snapshot ioctl APIs
 
 * If we try to find a unit via a dangling symlink, generate a clean

commit 8f2665a463ffb2b822c1e3effdb292d2bddf72be
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Mar 3 21:53:19 2014 +0100

    conf-parser: minor optimization in config_parse_string()

diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 1ad2b4f..86435d3 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -565,57 +565,55 @@ int config_parse_bool(const char* unit,
         return 0;
 }
 
-int config_parse_string(const char *unit,
-                        const char *filename,
-                        unsigned line,
-                        const char *section,
-                        unsigned section_line,
-                        const char *lvalue,
-                        int ltype,
-                        const char *rvalue,
-                        void *data,
-                        void *userdata) {
-
-        char **s = data;
-        char *n;
+int config_parse_string(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        char **s = data, *n;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
-        n = strdup(rvalue);
-        if (!n)
-                return log_oom();
-
-        if (!utf8_is_valid(n)) {
-                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "String is not UTF-8 clean, ignoring assignment: %s", rvalue);
-                free(n);
+        if (!utf8_is_valid(rvalue)) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "String is not UTF-8 clean, ignoring assignment: %s", rvalue);
                 return 0;
         }
 
-        free(*s);
-        if (*n)
-                *s = n;
+        if (isempty(rvalue))
+                n = NULL;
         else {
-                free(n);
-                *s = NULL;
+                n = strdup(rvalue);
+                if (!n)
+                        return log_oom();
         }
 
+        free(*s);
+        *s = n;
+
         return 0;
 }
 
-int config_parse_path(const char *unit,
-                      const char *filename,
-                      unsigned line,
-                      const char *section,
-                      unsigned section_line,
-                      const char *lvalue,
-                      int ltype,
-                      const char *rvalue,
-                      void *data,
-                      void *userdata) {
+int config_parse_path(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
 
         char **s = data, *n;
 

commit 3b43629240c82bf270542dc3ea13868980b30f07
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Mar 3 21:42:38 2014 +0100

    conf-parser: drop special casing in config_parse_path()
    
    The code checked for two lvalues that aren't even using
    config_parse_path(), so let's drop these checks and make the function
    completely generic again.

diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index f0bbbc3..1ad2b4f 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -617,9 +617,7 @@ int config_parse_path(const char *unit,
                       void *data,
                       void *userdata) {
 
-        char **s = data;
-        char *n;
-        int offset;
+        char **s = data, *n;
 
         assert(filename);
         assert(lvalue);
@@ -627,16 +625,12 @@ int config_parse_path(const char *unit,
         assert(data);
 
         if (!utf8_is_valid(rvalue)) {
-                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Path is not UTF-8 clean, ignoring assignment: %s", rvalue);
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Path is not UTF-8 clean, ignoring assignment: %s", rvalue);
                 return 0;
         }
 
-        offset = rvalue[0] == '-' && (streq(lvalue, "InaccessibleDirectories") ||
-                                      streq(lvalue, "ReadOnlyDirectories"));
-        if (!path_is_absolute(rvalue + offset)) {
-                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Not an absolute path, ignoring: %s", rvalue);
+        if (!path_is_absolute(rvalue)) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Not an absolute path, ignoring: %s", rvalue);
                 return 0;
         }
 

commit 94828d2ddc89c9dba3d6f386e55b6c9310d8f627
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Mar 3 21:40:55 2014 +0100

    conf-parser: config_parse_path_strv() is not generic, so let's move it into load-fragment.c
    
    The parse code actually checked for specific lvalue names, which is
    really wrong for supposedly generic parsers...

diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index be0a517..7bdee13 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -74,9 +74,9 @@ $1.LimitMSGQUEUE,                config_parse_limit,                 RLIMIT_MSGQ
 $1.LimitNICE,                    config_parse_limit,                 RLIMIT_NICE,                   offsetof($1, exec_context.rlimit)
 $1.LimitRTPRIO,                  config_parse_limit,                 RLIMIT_RTPRIO,                 offsetof($1, exec_context.rlimit)
 $1.LimitRTTIME,                  config_parse_limit,                 RLIMIT_RTTIME,                 offsetof($1, exec_context.rlimit)
-$1.ReadWriteDirectories,         config_parse_path_strv,             0,                             offsetof($1, exec_context.read_write_dirs)
-$1.ReadOnlyDirectories,          config_parse_path_strv,             0,                             offsetof($1, exec_context.read_only_dirs)
-$1.InaccessibleDirectories,      config_parse_path_strv,             0,                             offsetof($1, exec_context.inaccessible_dirs)
+$1.ReadWriteDirectories,         config_parse_namespace_path_strv,   0,                             offsetof($1, exec_context.read_write_dirs)
+$1.ReadOnlyDirectories,          config_parse_namespace_path_strv,   0,                             offsetof($1, exec_context.read_only_dirs)
+$1.InaccessibleDirectories,      config_parse_namespace_path_strv,   0,                             offsetof($1, exec_context.inaccessible_dirs)
 $1.PrivateTmp,                   config_parse_bool,                  0,                             offsetof($1, exec_context.private_tmp)
 $1.PrivateNetwork,               config_parse_bool,                  0,                             offsetof($1, exec_context.private_network)
 $1.PrivateDevices,               config_parse_bool,                  0,                             offsetof($1, exec_context.private_devices)
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index d34160a..d77bf5c 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2848,6 +2848,65 @@ int config_parse_set_status(
         return 0;
 }
 
+int config_parse_namespace_path_strv(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        char*** sv = data, *w, *state;
+        size_t l;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        if (isempty(rvalue)) {
+                /* Empty assignment resets the list */
+                strv_free(*sv);
+                *sv = NULL;
+                return 0;
+        }
+
+        FOREACH_WORD_QUOTED(w, l, rvalue, state) {
+                _cleanup_free_ char *n;
+                int offset;
+
+                n = strndup(w, l);
+                if (!n)
+                        return log_oom();
+
+                if (!utf8_is_valid(n)) {
+                        log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Path is not UTF-8 clean, ignoring assignment: %s", rvalue);
+                        continue;
+                }
+
+                offset = n[0] == '-';
+                if (!path_is_absolute(n + offset)) {
+                        log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Not an absolute path, ignoring: %s", rvalue);
+                        continue;
+                }
+
+                path_kill_slashes(n);
+
+                r = strv_push(sv, n);
+                if (r < 0)
+                        return log_oom();
+
+                n = NULL;
+        }
+
+        return 0;
+}
+
 #define FOLLOW_MAX 8
 
 static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
@@ -3206,7 +3265,7 @@ void unit_dump_config_items(FILE *f) {
                 { config_parse_socket_bindtodevice,   "NETWORKINTERFACE" },
                 { config_parse_sec,                   "SECONDS" },
                 { config_parse_nsec,                  "NANOSECONDS" },
-                { config_parse_path_strv,             "PATH [...]" },
+                { config_parse_namespace_path_strv,   "PATH [...]" },
                 { config_parse_unit_requires_mounts_for, "PATH [...]" },
                 { config_parse_exec_mount_flags,      "MOUNTFLAG [...]" },
                 { config_parse_unit_string_printf,    "STRING" },
diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
index 95485db..73f6db7 100644
--- a/src/core/load-fragment.h
+++ b/src/core/load-fragment.h
@@ -93,6 +93,7 @@ int config_parse_exec_apparmor_profile(const char *unit, const char *filename, u
 int config_parse_address_families(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_runtime_directory(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_set_status(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_namespace_path_strv(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 
 /* gperf prototypes */
 const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, unsigned length);
diff --git a/src/core/namespace.c b/src/core/namespace.c
index c034bfd..3694368 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -69,7 +69,7 @@ static int append_mounts(BindMount **p, char **strv, MountMode mode) {
 
                 (*p)->ignore = false;
 
-                if ((mode == INACCESSIBLE || mode == READONLY) && (*i)[0] == '-') {
+                if ((mode == INACCESSIBLE || mode == READONLY || mode == READWRITE) && (*i)[0] == '-') {
                         (*p)->ignore = true;
                         (*i)++;
                 }
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 161f6ad..f0bbbc3 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -709,64 +709,6 @@ int config_parse_strv(const char *unit,
         return 0;
 }
 
-int config_parse_path_strv(const char *unit,
-                           const char *filename,
-                           unsigned line,
-                           const char *section,
-                           unsigned section_line,
-                           const char *lvalue,
-                           int ltype,
-                           const char *rvalue,
-                           void *data,
-                           void *userdata) {
-
-        char*** sv = data, *w, *state;
-        size_t l;
-        int r;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        if (isempty(rvalue)) {
-                /* Empty assignment resets the list */
-                strv_free(*sv);
-                *sv = NULL;
-                return 0;
-        }
-
-        FOREACH_WORD_QUOTED(w, l, rvalue, state) {
-                _cleanup_free_ char *n;
-                int offset;
-
-                n = strndup(w, l);
-                if (!n)
-                        return log_oom();
-
-                if (!utf8_is_valid(n)) {
-                        log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                                   "Path is not UTF-8 clean, ignoring assignment: %s", rvalue);
-                        continue;
-                }
-
-                offset = n[0] == '-' && (streq(lvalue, "InaccessibleDirectories") ||
-                                         streq(lvalue, "ReadOnlyDirectories"));
-                if (!path_is_absolute(n + offset)) {
-                        log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                                   "Not an absolute path, ignoring: %s", rvalue);
-                        continue;
-                }
-
-                path_kill_slashes(n);
-                r = strv_extend(sv, n);
-                if (r < 0)
-                        return log_oom();
-        }
-
-        return 0;
-}
-
 int config_parse_mode(const char *unit,
                       const char *filename,
                       unsigned line,
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index b7f4429..e1c7ab4 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -104,7 +104,6 @@ int config_parse_bool(const char *unit, const char *filename, unsigned line, con
 int config_parse_string(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_path(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_strv(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_path_strv(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_sec(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_nsec(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);

commit 3af00fb85a26a1d812363fbf88c045311fd05376
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Mar 3 21:26:53 2014 +0100

    core: move config_parse_set_status() into load-fragment.c
    
    Let's keep specific config parsers close to where they are needed. Only
    the really generic ones should be defined in conf-parser.[ch].

diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 902b905..d34160a 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2769,6 +2769,85 @@ int config_parse_runtime_directory(
         return 0;
 }
 
+int config_parse_set_status(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        char *w;
+        size_t l;
+        char *state;
+        int r;
+        ExitStatusSet *status_set = data;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        if (isempty(rvalue)) {
+                /* Empty assignment resets the list */
+
+                set_free(status_set->signal);
+                set_free(status_set->code);
+
+                status_set->signal = status_set->code = NULL;
+                return 0;
+        }
+
+        FOREACH_WORD(w, l, rvalue, state) {
+                _cleanup_free_ char *temp;
+                int val;
+
+                temp = strndup(w, l);
+                if (!temp)
+                        return log_oom();
+
+                r = safe_atoi(temp, &val);
+                if (r < 0) {
+                        val = signal_from_string_try_harder(temp);
+
+                        if (val > 0) {
+                                r = set_ensure_allocated(&status_set->signal, trivial_hash_func, trivial_compare_func);
+                                if (r < 0)
+                                        return log_oom();
+
+                                r = set_put(status_set->signal, INT_TO_PTR(val));
+                                if (r < 0) {
+                                        log_syntax(unit, LOG_ERR, filename, line, -r, "Unable to store: %s", w);
+                                        return r;
+                                }
+                        } else {
+                                log_syntax(unit, LOG_ERR, filename, line, -val, "Failed to parse value, ignoring: %s", w);
+                                return 0;
+                        }
+                } else {
+                        if (val < 0 || val > 255)
+                                log_syntax(unit, LOG_ERR, filename, line, ERANGE, "Value %d is outside range 0-255, ignoring", val);
+                        else {
+                                r = set_ensure_allocated(&status_set->code, trivial_hash_func, trivial_compare_func);
+                                if (r < 0)
+                                        return log_oom();
+
+                                r = set_put(status_set->code, INT_TO_PTR(val));
+                                if (r < 0) {
+                                        log_syntax(unit, LOG_ERR, filename, line, -r, "Unable to store: %s", w);
+                                        return r;
+                                }
+                        }
+                }
+        }
+
+        return 0;
+}
+
 #define FOLLOW_MAX 8
 
 static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
index 5488f1d..95485db 100644
--- a/src/core/load-fragment.h
+++ b/src/core/load-fragment.h
@@ -92,6 +92,7 @@ int config_parse_personality(const char *unit, const char *filename, unsigned li
 int config_parse_exec_apparmor_profile(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_address_families(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_runtime_directory(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_set_status(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 
 /* gperf prototypes */
 const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, unsigned length);
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index accbdac..161f6ad 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -867,88 +867,3 @@ int config_parse_log_level(
         *o = (*o & LOG_FACMASK) | x;
         return 0;
 }
-
-int config_parse_set_status(const char *unit,
-                            const char *filename,
-                            unsigned line,
-                            const char *section,
-                            unsigned section_line,
-                            const char *lvalue,
-                            int ltype,
-                            const char *rvalue,
-                            void *data,
-                            void *userdata) {
-
-        char *w;
-        size_t l;
-        char *state;
-        int r;
-        ExitStatusSet *status_set = data;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        if (isempty(rvalue)) {
-                /* Empty assignment resets the list */
-
-                set_free(status_set->signal);
-                set_free(status_set->code);
-
-                status_set->signal = status_set->code = NULL;
-                return 0;
-        }
-
-        FOREACH_WORD(w, l, rvalue, state) {
-                int val;
-                char *temp;
-
-                temp = strndup(w, l);
-                if (!temp)
-                        return log_oom();
-
-                r = safe_atoi(temp, &val);
-                if (r < 0) {
-                        val = signal_from_string_try_harder(temp);
-                        free(temp);
-
-                        if (val > 0) {
-                                r = set_ensure_allocated(&status_set->signal, trivial_hash_func, trivial_compare_func);
-                                if (r < 0)
-                                        return log_oom();
-
-                                r = set_put(status_set->signal, INT_TO_PTR(val));
-                                if (r < 0) {
-                                        log_syntax(unit, LOG_ERR, filename, line, -r,
-                                                   "Unable to store: %s", w);
-                                        return r;
-                                }
-                        } else {
-                                log_syntax(unit, LOG_ERR, filename, line, -val,
-                                           "Failed to parse value, ignoring: %s", w);
-                                return 0;
-                        }
-                } else {
-                        free(temp);
-
-                        if (val < 0 || val > 255)
-                                log_syntax(unit, LOG_ERR, filename, line, ERANGE,
-                                           "Value %d is outside range 0-255, ignoring", val);
-                        else {
-                                r = set_ensure_allocated(&status_set->code, trivial_hash_func, trivial_compare_func);
-                                if (r < 0)
-                                        return log_oom();
-
-                                r = set_put(status_set->code, INT_TO_PTR(val));
-                                if (r < 0) {
-                                        log_syntax(unit, LOG_ERR, filename, line, -r,
-                                                   "Unable to store: %s", w);
-                                        return r;
-                                }
-                        }
-                }
-        }
-
-        return 0;
-}
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 50e9270..b7f4429 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -110,7 +110,6 @@ int config_parse_nsec(const char *unit, const char *filename, unsigned line, con
 int config_parse_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_log_facility(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_log_level(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_set_status(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 
 int log_syntax_internal(const char *unit, int level,
                         const char *file, unsigned line, const char *func,

commit 4d7213b2747ddd87002f970ccc60b1a9ab637136
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Mar 3 21:23:12 2014 +0100

    core: move ShowStatus type into the core
    
    Let's make the scope of the show-status stuff a bit smaller, and make it
    private to the core, rather than shared API in shared/.

diff --git a/Makefile.am b/Makefile.am
index 3eafcff..5a02d1e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1018,7 +1018,9 @@ libsystemd_core_la_SOURCES = \
 	src/core/audit-fd.c \
 	src/core/audit-fd.h \
 	src/core/async.c \
-	src/core/async.h
+	src/core/async.h \
+	src/core/show-status.c \
+	src/core/show-status.h
 
 if HAVE_KMOD
 libsystemd_core_la_SOURCES += \
diff --git a/src/core/main.c b/src/core/main.c
index 71ec607..4ca847c 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -468,16 +468,17 @@ DEFINE_SETTER(config_parse_target, log_set_target_from_string, "target")
 DEFINE_SETTER(config_parse_color, log_show_color_from_string, "color" )
 DEFINE_SETTER(config_parse_location, log_show_location_from_string, "location")
 
-static int config_parse_cpu_affinity2(const char *unit,
-                                      const char *filename,
-                                      unsigned line,
-                                      const char *section,
-                                      unsigned section_line,
-                                      const char *lvalue,
-                                      int ltype,
-                                      const char *rvalue,
-                                      void *data,
-                                      void *userdata) {
+static int config_parse_cpu_affinity2(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
 
         char *w;
         size_t l;
@@ -524,6 +525,36 @@ static int config_parse_cpu_affinity2(const char *unit,
         return 0;
 }
 
+static int config_parse_show_status(
+                const char* unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        int k;
+        ShowStatus *b = data;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        k = parse_show_status(rvalue, b);
+        if (k < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, -k,
+                           "Failed to parse show status setting, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        return 0;
+}
+
 static void strv_free_free(char ***l) {
         char ***i;
 
diff --git a/src/core/manager.h b/src/core/manager.h
index 3192b63..92985ca 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -58,6 +58,7 @@ typedef enum ManagerExitCode {
 #include "execute.h"
 #include "unit-name.h"
 #include "exit-status.h"
+#include "show-status.h"
 
 struct Manager {
         /* Note that the set of units we know of is allowed to be
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index f39a4cd..accbdac 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -565,35 +565,6 @@ int config_parse_bool(const char* unit,
         return 0;
 }
 
-int config_parse_show_status(const char* unit,
-                             const char *filename,
-                             unsigned line,
-                             const char *section,
-                             unsigned section_line,
-                             const char *lvalue,
-                             int ltype,
-                             const char *rvalue,
-                             void *data,
-                             void *userdata) {
-
-        int k;
-        ShowStatus *b = data;
-
-        assert(filename);
-        assert(lvalue);
-        assert(rvalue);
-        assert(data);
-
-        k = parse_show_status(rvalue, b);
-        if (k < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, -k,
-                           "Failed to parse show status setting, ignoring: %s", rvalue);
-                return 0;
-        }
-
-        return 0;
-}
-
 int config_parse_string(const char *unit,
                         const char *filename,
                         unsigned line,
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 7948465..50e9270 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -101,7 +101,6 @@ int config_parse_iec_size(const char *unit, const char *filename, unsigned line,
 int config_parse_si_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_iec_off(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_bool(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_show_status(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_string(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_path(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_strv(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
diff --git a/src/shared/exit-status.c b/src/shared/exit-status.c
index c1c0861..d860b55 100644
--- a/src/shared/exit-status.c
+++ b/src/shared/exit-status.c
@@ -205,20 +205,3 @@ bool is_clean_exit_lsb(int code, int status, ExitStatusSet *success_status) {
                 code == CLD_EXITED &&
                 (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED);
 }
-
-int parse_show_status(const char *v, ShowStatus *ret) {
-        int r;
-
-        assert(v);
-        assert(ret);
-
-        if (streq(v, "auto")) {
-                *ret = SHOW_STATUS_AUTO;
-                return 0;
-        }
-        r = parse_boolean(v);
-        if (r < 0)
-                return r;
-        *ret = r ? SHOW_STATUS_YES : SHOW_STATUS_NO;
-        return 0;
-}
diff --git a/src/shared/exit-status.h b/src/shared/exit-status.h
index 9dc3fce..385d6de 100644
--- a/src/shared/exit-status.h
+++ b/src/shared/exit-status.h
@@ -22,7 +22,9 @@
 ***/
 
 #include <stdbool.h>
+
 #include "set.h"
+
 typedef enum ExitStatus {
         /* EXIT_SUCCESS defined by libc */
         /* EXIT_FAILURE defined by libc */
@@ -91,15 +93,3 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) _con
 
 bool is_clean_exit(int code, int status, ExitStatusSet *success_status);
 bool is_clean_exit_lsb(int code, int status, ExitStatusSet *success_status);
-
-/* Manager status */
-
-typedef enum ShowStatus {
-        _SHOW_STATUS_UNSET = -2,
-        SHOW_STATUS_AUTO = -1,
-        SHOW_STATUS_NO = 0,
-        SHOW_STATUS_YES = 1,
-        SHOW_STATUS_TEMPORARY = 2,
-} ShowStatus;
-
-int parse_show_status(const char *v, ShowStatus *ret);

commit ca37242e52cbf90d6cdb3b26b2986b11ed1d5e91
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Mar 3 21:14:07 2014 +0100

    conf-parse: rename config_parse_level() to config_parse_log_level()
    
    "level" is a bit too generic, let's clarify what kind of level we are
    referring to here.

diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index c9ab5c3..be0a517 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -41,8 +41,8 @@ $1.TTYReset,                     config_parse_bool,                  0,
 $1.TTYVHangup,                   config_parse_bool,                  0,                             offsetof($1, exec_context.tty_vhangup)
 $1.TTYVTDisallocate,             config_parse_bool,                  0,                             offsetof($1, exec_context.tty_vt_disallocate)
 $1.SyslogIdentifier,             config_parse_unit_string_printf,    0,                             offsetof($1, exec_context.syslog_identifier)
-$1.SyslogFacility,               config_parse_facility,              0,                             offsetof($1, exec_context.syslog_priority)
-$1.SyslogLevel,                  config_parse_level,                 0,                             offsetof($1, exec_context.syslog_priority)
+$1.SyslogFacility,               config_parse_log_facility,          0,                             offsetof($1, exec_context.syslog_priority)
+$1.SyslogLevel,                  config_parse_log_level,             0,                             offsetof($1, exec_context.syslog_priority)
 $1.SyslogLevelPrefix,            config_parse_bool,                  0,                             offsetof($1, exec_context.syslog_level_prefix)
 $1.Capabilities,                 config_parse_exec_capabilities,     0,                             offsetof($1, exec_context)
 $1.SecureBits,                   config_parse_exec_secure_bits,      0,                             offsetof($1, exec_context)
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 6f0027b..902b905 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3107,8 +3107,8 @@ void unit_dump_config_items(FILE *f) {
                 { config_parse_unit_env_file,         "FILE" },
                 { config_parse_output,                "OUTPUT" },
                 { config_parse_input,                 "INPUT" },
-                { config_parse_facility,              "FACILITY" },
-                { config_parse_level,                 "LEVEL" },
+                { config_parse_log_facility,          "FACILITY" },
+                { config_parse_log_level,             "LEVEL" },
                 { config_parse_exec_capabilities,     "CAPABILITIES" },
                 { config_parse_exec_secure_bits,      "SECUREBITS" },
                 { config_parse_bounding_set,          "BOUNDINGSET" },
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 84efee3..83bbbc8 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -15,26 +15,26 @@ struct ConfigPerfItem;
 %struct-type
 %includes
 %%
-Journal.Storage,            config_parse_storage,   0, offsetof(Server, storage)
-Journal.Compress,           config_parse_bool,      0, offsetof(Server, compress)
-Journal.Seal,               config_parse_bool,      0, offsetof(Server, seal)
-Journal.SyncIntervalSec,    config_parse_sec,       0, offsetof(Server, sync_interval_usec)
-Journal.RateLimitInterval,  config_parse_sec,       0, offsetof(Server, rate_limit_interval)
-Journal.RateLimitBurst,     config_parse_unsigned,  0, offsetof(Server, rate_limit_burst)
-Journal.SystemMaxUse,       config_parse_iec_off,   0, offsetof(Server, system_metrics.max_use)
-Journal.SystemMaxFileSize,  config_parse_iec_off,   0, offsetof(Server, system_metrics.max_size)
-Journal.SystemKeepFree,     config_parse_iec_off,   0, offsetof(Server, system_metrics.keep_free)
-Journal.RuntimeMaxUse,      config_parse_iec_off,   0, offsetof(Server, runtime_metrics.max_use)
-Journal.RuntimeMaxFileSize, config_parse_iec_off,   0, offsetof(Server, runtime_metrics.max_size)
-Journal.RuntimeKeepFree,    config_parse_iec_off,   0, offsetof(Server, runtime_metrics.keep_free)
-Journal.MaxRetentionSec,    config_parse_sec,       0, offsetof(Server, max_retention_usec)
-Journal.MaxFileSec,         config_parse_sec,       0, offsetof(Server, max_file_usec)
-Journal.ForwardToSyslog,    config_parse_bool,      0, offsetof(Server, forward_to_syslog)
-Journal.ForwardToKMsg,      config_parse_bool,      0, offsetof(Server, forward_to_kmsg)
-Journal.ForwardToConsole,   config_parse_bool,      0, offsetof(Server, forward_to_console)
-Journal.TTYPath,            config_parse_path,      0, offsetof(Server, tty_path)
-Journal.MaxLevelStore,      config_parse_level,     0, offsetof(Server, max_level_store)
-Journal.MaxLevelSyslog,     config_parse_level,     0, offsetof(Server, max_level_syslog)
-Journal.MaxLevelKMsg,       config_parse_level,     0, offsetof(Server, max_level_kmsg)
-Journal.MaxLevelConsole,    config_parse_level,     0, offsetof(Server, max_level_console)
-Journal.SplitMode,          config_parse_split_mode,0, offsetof(Server, split_mode)
+Journal.Storage,            config_parse_storage,    0, offsetof(Server, storage)
+Journal.Compress,           config_parse_bool,       0, offsetof(Server, compress)
+Journal.Seal,               config_parse_bool,       0, offsetof(Server, seal)
+Journal.SyncIntervalSec,    config_parse_sec,        0, offsetof(Server, sync_interval_usec)
+Journal.RateLimitInterval,  config_parse_sec,        0, offsetof(Server, rate_limit_interval)
+Journal.RateLimitBurst,     config_parse_unsigned,   0, offsetof(Server, rate_limit_burst)
+Journal.SystemMaxUse,       config_parse_iec_off,    0, offsetof(Server, system_metrics.max_use)
+Journal.SystemMaxFileSize,  config_parse_iec_off,    0, offsetof(Server, system_metrics.max_size)
+Journal.SystemKeepFree,     config_parse_iec_off,    0, offsetof(Server, system_metrics.keep_free)
+Journal.RuntimeMaxUse,      config_parse_iec_off,    0, offsetof(Server, runtime_metrics.max_use)
+Journal.RuntimeMaxFileSize, config_parse_iec_off,    0, offsetof(Server, runtime_metrics.max_size)
+Journal.RuntimeKeepFree,    config_parse_iec_off,    0, offsetof(Server, runtime_metrics.keep_free)
+Journal.MaxRetentionSec,    config_parse_sec,        0, offsetof(Server, max_retention_usec)
+Journal.MaxFileSec,         config_parse_sec,        0, offsetof(Server, max_file_usec)
+Journal.ForwardToSyslog,    config_parse_bool,       0, offsetof(Server, forward_to_syslog)
+Journal.ForwardToKMsg,      config_parse_bool,       0, offsetof(Server, forward_to_kmsg)
+Journal.ForwardToConsole,   config_parse_bool,       0, offsetof(Server, forward_to_console)
+Journal.TTYPath,            config_parse_path,       0, offsetof(Server, tty_path)
+Journal.MaxLevelStore,      config_parse_log_level,  0, offsetof(Server, max_level_store)
+Journal.MaxLevelSyslog,     config_parse_log_level,  0, offsetof(Server, max_level_syslog)
+Journal.MaxLevelKMsg,       config_parse_log_level,  0, offsetof(Server, max_level_kmsg)
+Journal.MaxLevelConsole,    config_parse_log_level,  0, offsetof(Server, max_level_console)
+Journal.SplitMode,          config_parse_split_mode, 0, offsetof(Server, split_mode)
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index cfa669b..f39a4cd 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -834,16 +834,17 @@ int config_parse_mode(const char *unit,
         return 0;
 }
 
-int config_parse_facility(const char *unit,
-                          const char *filename,
-                          unsigned line,
-                          const char *section,
-                          unsigned section_line,
-                          const char *lvalue,
-                          int ltype,
-                          const char *rvalue,
-                          void *data,
-                          void *userdata) {
+int config_parse_log_facility(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
 
 
         int *o = data, x;
@@ -865,16 +866,17 @@ int config_parse_facility(const char *unit,
         return 0;
 }
 
-int config_parse_level(const char *unit,
-                       const char *filename,
-                       unsigned line,
-                       const char *section,
-                       unsigned section_line,
-                       const char *lvalue,
-                       int ltype,
-                       const char *rvalue,
-                       void *data,
-                       void *userdata) {
+int config_parse_log_level(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
 
 
         int *o = data, x;
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 4ccdadd..7948465 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -109,8 +109,8 @@ int config_parse_path_strv(const char *unit, const char *filename, unsigned line
 int config_parse_sec(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_nsec(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_facility(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_level(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_log_facility(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_log_level(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_set_status(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 
 int log_syntax_internal(const char *unit, int level,



More information about the systemd-commits mailing list