]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Create src/shared/unit-file.[ch] for unit-file related ops
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 4 Jul 2019 13:46:16 +0000 (15:46 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Jul 2019 14:51:14 +0000 (16:51 +0200)
So far we put such functinos in install.[ch], but that is tied too closely
to enable/disable. Let's start moving things to a place with a better name.

17 files changed:
src/core/bpf-firewall.c
src/core/dbus-job.c
src/core/dbus-unit.c
src/core/dynamic-user.c
src/core/manager.c
src/core/transaction.c
src/core/unit.c
src/core/unit.h
src/environment-d-generator/environment-d-generator.c
src/portable/portable.c
src/shared/install.c
src/shared/install.h
src/shared/meson.build
src/shared/path-lookup.h
src/shared/unit-file.c [new file with mode: 0644]
src/shared/unit-file.h [new file with mode: 0644]
src/test/test-engine.c

index 7a8b848fb34ab68a31a315eff62a3c3a6e002872..a637437a5a6abb2d7cacc7f57e1780dcb7f9a399 100644 (file)
@@ -23,6 +23,7 @@
 #include "memory-util.h"
 #include "missing_syscall.h"
 #include "unit.h"
+#include "strv.h"
 #include "virt.h"
 
 enum {
index d11e58b51ddd5cde5a0a23ed8f6842416984634f..a7d342257b58f9cb16489c53d1e58b7fd8ce3cd4 100644 (file)
@@ -10,6 +10,7 @@
 #include "log.h"
 #include "selinux-access.h"
 #include "string-util.h"
+#include "strv.h"
 
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, job_type, JobType);
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_state, job_state, JobState);
index 220b4c237248b459819a306aee7b2bcae7c22a71..ef434fb9f1f0e6604043abe51f9e181dd6463c67 100644 (file)
@@ -12,6 +12,7 @@
 #include "dbus-util.h"
 #include "dbus.h"
 #include "fd-util.h"
+#include "install.h"
 #include "locale-util.h"
 #include "log.h"
 #include "path-util.h"
index fb0a7943487c486889dbb04be6b064ade15ba593..e7a2f645251650ffebda76267cf9efc97a35a1bb 100644 (file)
@@ -20,6 +20,7 @@
 #include "socket-util.h"
 #include "stdio-util.h"
 #include "string-util.h"
+#include "strv.h"
 #include "user-util.h"
 
 /* Takes a value generated randomly or by hashing and turns it into a UID in the right range */
index 3d3c3b0cbac6570ccc71afced59558ce37d0e3c1..c176309edf33dbceb40aa33002f1df208048f1a5 100644 (file)
@@ -46,6 +46,7 @@
 #include "fs-util.h"
 #include "hashmap.h"
 #include "io-util.h"
+#include "install.h"
 #include "label.h"
 #include "locale-setup.h"
 #include "log.h"
index d1bf2e64c915df861469655e396b0e6636c4121f..a0825c595cabb65bf505381d1c69a51845381246 100644 (file)
@@ -6,9 +6,10 @@
 #include "alloc-util.h"
 #include "bus-common-errors.h"
 #include "bus-error.h"
+#include "dbus-unit.h"
+#include "strv.h"
 #include "terminal-util.h"
 #include "transaction.h"
-#include "dbus-unit.h"
 
 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
 
index 2cd58c47044f3a18812276abd80138768f472a91..fa89bd4a4d4bbdc475831158d58abbcfc648fa17 100644 (file)
@@ -28,6 +28,7 @@
 #include "fs-util.h"
 #include "id128-util.h"
 #include "io-util.h"
+#include "install.h"
 #include "load-dropin.h"
 #include "load-fragment.h"
 #include "log.h"
index 094a451f3ca5ebb710b3f2325084e9dab3c830fb..47ec9877a67ad042555017abfee252332b33d8f2 100644 (file)
@@ -8,10 +8,9 @@
 #include "bpf-program.h"
 #include "condition.h"
 #include "emergency-action.h"
-#include "install.h"
 #include "list.h"
 #include "set.h"
-#include "unit-name.h"
+#include "unit-file.h"
 #include "cgroup.h"
 
 typedef struct UnitRef UnitRef;
index b2558f0c842892b40e821fdb2828938c3985517b..d1293eff168118da48d0f6029c785b544fb0d50d 100644 (file)
@@ -8,6 +8,7 @@
 #include "escape.h"
 #include "log.h"
 #include "path-lookup.h"
+#include "strv.h"
 
 static int environment_dirs(char ***ret) {
         _cleanup_strv_free_ char **dirs = NULL;
index 4956ae7310a5843e00286b5efa21c33285e61b0f..d37880cfd1d8fbe27666fdfdb26cd7a6ee2a4aa7 100644 (file)
@@ -10,6 +10,7 @@
 #include "fd-util.h"
 #include "fileio.h"
 #include "fs-util.h"
+#include "install.h"
 #include "io-util.h"
 #include "locale-util.h"
 #include "loop-util.h"
index 68ffd12f03c4da1c3638777976ca2af5f6e24256..dfb60361910d13f73f17858ccd262783a0f5694c 100644 (file)
@@ -37,7 +37,7 @@
 #include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
-#include "unit-name.h"
+#include "unit-file.h"
 
 #define UNIT_FILE_FOLLOW_SYMLINK_MAX 64
 
@@ -98,25 +98,6 @@ static void presets_freep(Presets *p) {
         p->n_rules = 0;
 }
 
-bool unit_type_may_alias(UnitType type) {
-        return IN_SET(type,
-                      UNIT_SERVICE,
-                      UNIT_SOCKET,
-                      UNIT_TARGET,
-                      UNIT_DEVICE,
-                      UNIT_TIMER,
-                      UNIT_PATH);
-}
-
-bool unit_type_may_template(UnitType type) {
-        return IN_SET(type,
-                      UNIT_SERVICE,
-                      UNIT_SOCKET,
-                      UNIT_TARGET,
-                      UNIT_TIMER,
-                      UNIT_PATH);
-}
-
 static const char *const unit_file_type_table[_UNIT_FILE_TYPE_MAX] = {
         [UNIT_FILE_TYPE_REGULAR] = "regular",
         [UNIT_FILE_TYPE_SYMLINK] = "symlink",
index e452940991743a4aab89c5fe9e380912a6670ea4..b2ad9c4a71e3e346fc84759fd9f48c68cd346b3f 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
-typedef enum UnitFileScope UnitFileScope;
-typedef enum UnitFileState UnitFileState;
 typedef enum UnitFilePresetMode UnitFilePresetMode;
 typedef enum UnitFileChangeType UnitFileChangeType;
 typedef enum UnitFileFlags UnitFileFlags;
@@ -19,31 +17,6 @@ typedef struct UnitFileInstallInfo UnitFileInstallInfo;
 #include "strv.h"
 #include "unit-name.h"
 
-enum UnitFileScope {
-        UNIT_FILE_SYSTEM,
-        UNIT_FILE_GLOBAL,
-        UNIT_FILE_USER,
-        _UNIT_FILE_SCOPE_MAX,
-        _UNIT_FILE_SCOPE_INVALID = -1
-};
-
-enum UnitFileState {
-        UNIT_FILE_ENABLED,
-        UNIT_FILE_ENABLED_RUNTIME,
-        UNIT_FILE_LINKED,
-        UNIT_FILE_LINKED_RUNTIME,
-        UNIT_FILE_MASKED,
-        UNIT_FILE_MASKED_RUNTIME,
-        UNIT_FILE_STATIC,
-        UNIT_FILE_DISABLED,
-        UNIT_FILE_INDIRECT,
-        UNIT_FILE_GENERATED,
-        UNIT_FILE_TRANSIENT,
-        UNIT_FILE_BAD,
-        _UNIT_FILE_STATE_MAX,
-        _UNIT_FILE_STATE_INVALID = -1
-};
-
 enum UnitFilePresetMode {
         UNIT_FILE_PRESET_FULL,
         UNIT_FILE_PRESET_ENABLE_ONLY,
@@ -114,9 +87,6 @@ struct UnitFileInstallInfo {
         bool auxiliary;
 };
 
-bool unit_type_may_alias(UnitType type) _const_;
-bool unit_type_may_template(UnitType type) _const_;
-
 int unit_file_enable(
                 UnitFileScope scope,
                 UnitFileFlags flags,
index bdd823bbd1565e42f434af8d3d76f5003b16c8c4..ca24d15eabf9682bea15f51fc14a01f8b3a5a040 100644 (file)
@@ -170,6 +170,8 @@ shared_sources = files('''
         udev-util.h
         uid-range.c
         uid-range.h
+        unit-file.h
+        unit-file.c
         utmp-wtmp.h
         varlink.c
         varlink.h
index cb7d4d537f9cb20f98768b7d6f279e0331c22b3a..7070b9424983d3b4bc29b126c68c94354e122195 100644 (file)
@@ -5,7 +5,7 @@
 
 typedef struct LookupPaths LookupPaths;
 
-#include "install.h"
+#include "unit-file.h"
 #include "macro.h"
 
 typedef enum LookupPathsFlags {
diff --git a/src/shared/unit-file.c b/src/shared/unit-file.c
new file mode 100644 (file)
index 0000000..deed7dc
--- /dev/null
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include "macro.h"
+#include "unit-file.h"
+
+bool unit_type_may_alias(UnitType type) {
+        return IN_SET(type,
+                      UNIT_SERVICE,
+                      UNIT_SOCKET,
+                      UNIT_TARGET,
+                      UNIT_DEVICE,
+                      UNIT_TIMER,
+                      UNIT_PATH);
+}
+
+bool unit_type_may_template(UnitType type) {
+        return IN_SET(type,
+                      UNIT_SERVICE,
+                      UNIT_SOCKET,
+                      UNIT_TARGET,
+                      UNIT_TIMER,
+                      UNIT_PATH);
+}
diff --git a/src/shared/unit-file.h b/src/shared/unit-file.h
new file mode 100644 (file)
index 0000000..2b9df65
--- /dev/null
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
+
+#include <stdbool.h>
+
+#include "unit-name.h"
+
+typedef enum UnitFileState UnitFileState;
+typedef enum UnitFileScope UnitFileScope;
+
+enum UnitFileState {
+        UNIT_FILE_ENABLED,
+        UNIT_FILE_ENABLED_RUNTIME,
+        UNIT_FILE_LINKED,
+        UNIT_FILE_LINKED_RUNTIME,
+        UNIT_FILE_MASKED,
+        UNIT_FILE_MASKED_RUNTIME,
+        UNIT_FILE_STATIC,
+        UNIT_FILE_DISABLED,
+        UNIT_FILE_INDIRECT,
+        UNIT_FILE_GENERATED,
+        UNIT_FILE_TRANSIENT,
+        UNIT_FILE_BAD,
+        _UNIT_FILE_STATE_MAX,
+        _UNIT_FILE_STATE_INVALID = -1
+};
+
+enum UnitFileScope {
+        UNIT_FILE_SYSTEM,
+        UNIT_FILE_GLOBAL,
+        UNIT_FILE_USER,
+        _UNIT_FILE_SCOPE_MAX,
+        _UNIT_FILE_SCOPE_INVALID = -1
+};
+
+bool unit_type_may_alias(UnitType type) _const_;
+bool unit_type_may_template(UnitType type) _const_;
index 9809d408f641457ee2be26cc16a1dd28de422843..633cc425345d8d8bc7e0da8ef5797d58480e0583 100644 (file)
@@ -7,6 +7,7 @@
 #include "bus-util.h"
 #include "manager.h"
 #include "rm-rf.h"
+#include "strv.h"
 #include "test-helper.h"
 #include "tests.h"
 #include "service.h"