summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-04 15:46:16 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-19 16:51:14 +0200
commit5cfa33e0bc36ffe962501f67259044a636e15707 (patch)
treec799790d2bdaf766742bcbcc5f3e281e676d295b
parent47a0011186757f55a747df22f05557d90990a95d (diff)
downloadsystemd-5cfa33e0bc36ffe962501f67259044a636e15707.tar.gz
Create src/shared/unit-file.[ch] for unit-file related ops
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.
-rw-r--r--src/core/bpf-firewall.c1
-rw-r--r--src/core/dbus-job.c1
-rw-r--r--src/core/dbus-unit.c1
-rw-r--r--src/core/dynamic-user.c1
-rw-r--r--src/core/manager.c1
-rw-r--r--src/core/transaction.c3
-rw-r--r--src/core/unit.c1
-rw-r--r--src/core/unit.h3
-rw-r--r--src/environment-d-generator/environment-d-generator.c1
-rw-r--r--src/portable/portable.c1
-rw-r--r--src/shared/install.c21
-rw-r--r--src/shared/install.h30
-rw-r--r--src/shared/meson.build2
-rw-r--r--src/shared/path-lookup.h2
-rw-r--r--src/shared/unit-file.c23
-rw-r--r--src/shared/unit-file.h37
-rw-r--r--src/test/test-engine.c1
17 files changed, 76 insertions, 54 deletions
diff --git a/src/core/bpf-firewall.c b/src/core/bpf-firewall.c
index 7a8b848fb3..a637437a5a 100644
--- a/src/core/bpf-firewall.c
+++ b/src/core/bpf-firewall.c
@@ -23,6 +23,7 @@
#include "memory-util.h"
#include "missing_syscall.h"
#include "unit.h"
+#include "strv.h"
#include "virt.h"
enum {
diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c
index d11e58b51d..a7d342257b 100644
--- a/src/core/dbus-job.c
+++ b/src/core/dbus-job.c
@@ -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);
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 220b4c2372..ef434fb9f1 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -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"
diff --git a/src/core/dynamic-user.c b/src/core/dynamic-user.c
index fb0a794348..e7a2f64525 100644
--- a/src/core/dynamic-user.c
+++ b/src/core/dynamic-user.c
@@ -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 */
diff --git a/src/core/manager.c b/src/core/manager.c
index 3d3c3b0cba..c176309edf 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -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"
diff --git a/src/core/transaction.c b/src/core/transaction.c
index d1bf2e64c9..a0825c595c 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -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);
diff --git a/src/core/unit.c b/src/core/unit.c
index 2cd58c4704..fa89bd4a4d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -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"
diff --git a/src/core/unit.h b/src/core/unit.h
index 094a451f3c..47ec9877a6 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -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;
diff --git a/src/environment-d-generator/environment-d-generator.c b/src/environment-d-generator/environment-d-generator.c
index b2558f0c84..d1293eff16 100644
--- a/src/environment-d-generator/environment-d-generator.c
+++ b/src/environment-d-generator/environment-d-generator.c
@@ -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;
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 4956ae7310..d37880cfd1 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -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"
diff --git a/src/shared/install.c b/src/shared/install.c
index 68ffd12f03..dfb6036191 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -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",
diff --git a/src/shared/install.h b/src/shared/install.h
index e452940991..b2ad9c4a71 100644
--- a/src/shared/install.h
+++ b/src/shared/install.h
@@ -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,
diff --git a/src/shared/meson.build b/src/shared/meson.build
index bdd823bbd1..ca24d15eab 100644
--- a/src/shared/meson.build
+++ b/src/shared/meson.build
@@ -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
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index cb7d4d537f..7070b94249 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -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
index 0000000000..deed7dcf09
--- /dev/null
+++ b/src/shared/unit-file.c
@@ -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
index 0000000000..2b9df655ee
--- /dev/null
+++ b/src/shared/unit-file.h
@@ -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_;
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index 9809d408f6..633cc42534 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -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"