]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: split out VolatileMode definitions
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Dec 2016 23:28:05 +0000 (00:28 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 20 Dec 2016 19:00:08 +0000 (20:00 +0100)
This moves the VolatileMode enum and its helper functions to src/shared/. This
is useful to then reuse them to implement systemd.volatile= in a later commit.

Makefile.am
src/nspawn/nspawn-mount.c
src/nspawn/nspawn-mount.h
src/shared/volatile-util.c [new file with mode: 0644]
src/shared/volatile-util.h [new file with mode: 0644]

index d75807a9f924498c94c6658761bdb356ac3daabb..56b8aa3fe8f43d60b85017b4b36b5fafc9c91231 100644 (file)
@@ -1065,7 +1065,9 @@ libshared_la_SOURCES = \
        src/shared/nsflags.h \
        src/shared/nsflags.c \
        src/shared/dissect-image.c \
-       src/shared/dissect-image.h
+       src/shared/dissect-image.h \
+       src/shared/volatile-util.c \
+       src/shared/volatile-util.h
 
 if HAVE_UTMP
 libshared_la_SOURCES += \
index aaa64a7ba84622fdd1c6394f5f34b8b688ebdc1e..72c007f204c657472dc153f3b247bb6f0a5cc025 100644 (file)
@@ -1349,21 +1349,3 @@ fail:
         (void) rmdir(template);
         return r;
 }
-
-VolatileMode volatile_mode_from_string(const char *s) {
-        int b;
-
-        if (isempty(s))
-                return _VOLATILE_MODE_INVALID;
-
-        b = parse_boolean(s);
-        if (b > 0)
-                return VOLATILE_YES;
-        if (b == 0)
-                return VOLATILE_NO;
-
-        if (streq(s, "state"))
-                return VOLATILE_STATE;
-
-        return _VOLATILE_MODE_INVALID;
-}
index 467082a737729aee845eb400c6bf966eb0fe0b7f..6b33fbff5766f8d25af445e9379932bb6c1f8021 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdbool.h>
 
 #include "cgroup-util.h"
+#include "volatile-util.h"
 
 typedef enum MountSettingsMask {
         MOUNT_FATAL              = 1 << 0, /* if set, a mount error is considered fatal */
@@ -32,14 +33,6 @@ typedef enum MountSettingsMask {
                                               Works only if MOUNT_APPLY_APIVFS_RO is also set. */
 } MountSettingsMask;
 
-typedef enum VolatileMode {
-        VOLATILE_NO,
-        VOLATILE_YES,
-        VOLATILE_STATE,
-        _VOLATILE_MODE_MAX,
-        _VOLATILE_MODE_INVALID = -1
-} VolatileMode;
-
 typedef enum CustomMountType {
         CUSTOM_MOUNT_BIND,
         CUSTOM_MOUNT_TMPFS,
@@ -77,5 +70,3 @@ int mount_custom(const char *dest, CustomMount *mounts, unsigned n, bool userns,
 
 int setup_volatile(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
 int setup_volatile_state(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
-
-VolatileMode volatile_mode_from_string(const char *s);
diff --git a/src/shared/volatile-util.c b/src/shared/volatile-util.c
new file mode 100644 (file)
index 0000000..1329b51
--- /dev/null
@@ -0,0 +1,41 @@
+/***
+  This file is part of systemd.
+
+  Copyright 2015 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  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 "macro.h"
+#include "parse-util.h"
+#include "string-util.h"
+#include "volatile-util.h"
+
+VolatileMode volatile_mode_from_string(const char *s) {
+        int b;
+
+        if (isempty(s))
+                return _VOLATILE_MODE_INVALID;
+
+        b = parse_boolean(s);
+        if (b > 0)
+                return VOLATILE_YES;
+        if (b == 0)
+                return VOLATILE_NO;
+
+        if (streq(s, "state"))
+                return VOLATILE_STATE;
+
+        return _VOLATILE_MODE_INVALID;
+}
diff --git a/src/shared/volatile-util.h b/src/shared/volatile-util.h
new file mode 100644 (file)
index 0000000..d012940
--- /dev/null
@@ -0,0 +1,30 @@
+#pragma once
+
+/***
+  This file is part of systemd.
+
+  Copyright 2016 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  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/>.
+***/
+
+typedef enum VolatileMode {
+        VOLATILE_NO,
+        VOLATILE_YES,
+        VOLATILE_STATE,
+        _VOLATILE_MODE_MAX,
+        _VOLATILE_MODE_INVALID = -1
+} VolatileMode;
+
+VolatileMode volatile_mode_from_string(const char *s);