summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shared/install-printf.c10
-rw-r--r--src/shared/install-printf.h3
-rw-r--r--src/shared/install.c36
-rw-r--r--src/shared/install.h36
-rw-r--r--src/shared/path-lookup.h7
-rw-r--r--src/test/test-unit-file.c8
6 files changed, 55 insertions, 45 deletions
diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c
index 7c25d36931..cbe984d2fb 100644
--- a/src/shared/install-printf.c
+++ b/src/shared/install-printf.c
@@ -28,7 +28,7 @@
#include "formats-util.h"
static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) {
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
assert(i);
@@ -36,7 +36,7 @@ static int specifier_prefix_and_instance(char specifier, void *data, void *userd
}
static int specifier_prefix(char specifier, void *data, void *userdata, char **ret) {
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
assert(i);
@@ -44,7 +44,7 @@ static int specifier_prefix(char specifier, void *data, void *userdata, char **r
}
static int specifier_instance(char specifier, void *data, void *userdata, char **ret) {
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
char *instance;
int r;
@@ -65,7 +65,7 @@ static int specifier_instance(char specifier, void *data, void *userdata, char *
}
static int specifier_user_name(char specifier, void *data, void *userdata, char **ret) {
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
const char *username;
_cleanup_free_ char *tmp = NULL;
char *printed = NULL;
@@ -102,7 +102,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
}
-int install_full_printf(InstallInfo *i, const char *format, char **ret) {
+int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret) {
/* This is similar to unit_full_printf() but does not support
* anything path-related.
diff --git a/src/shared/install-printf.h b/src/shared/install-printf.h
index 6ffa488b1b..6550337824 100644
--- a/src/shared/install-printf.h
+++ b/src/shared/install-printf.h
@@ -22,4 +22,5 @@
#pragma once
#include "install.h"
-int install_full_printf(InstallInfo *i, const char *format, char **ret);
+
+int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret);
diff --git a/src/shared/install.c b/src/shared/install.c
index 9648c641d7..dc4cc62ffe 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -809,7 +809,7 @@ void unit_file_changes_free(UnitFileChange *changes, unsigned n_changes) {
free(changes);
}
-static void install_info_free(InstallInfo *i) {
+static void install_info_free(UnitFileInstallInfo *i) {
assert(i);
free(i->name);
@@ -823,7 +823,7 @@ static void install_info_free(InstallInfo *i) {
}
static void install_info_hashmap_free(OrderedHashmap *m) {
- InstallInfo *i;
+ UnitFileInstallInfo *i;
if (!m)
return;
@@ -847,7 +847,7 @@ static int install_info_add(
InstallContext *c,
const char *name,
const char *path) {
- InstallInfo *i = NULL;
+ UnitFileInstallInfo *i = NULL;
int r;
assert(c);
@@ -867,7 +867,7 @@ static int install_info_add(
if (r < 0)
return r;
- i = new0(InstallInfo, 1);
+ i = new0(UnitFileInstallInfo, 1);
if (!i)
return -ENOMEM;
@@ -926,7 +926,7 @@ static int config_parse_also(
size_t l;
const char *word, *state;
InstallContext *c = data;
- InstallInfo *i = userdata;
+ UnitFileInstallInfo *i = userdata;
assert(filename);
assert(lvalue);
@@ -967,7 +967,7 @@ static int config_parse_user(
void *data,
void *userdata) {
- InstallInfo *i = data;
+ UnitFileInstallInfo *i = data;
char *printed;
int r;
@@ -997,7 +997,7 @@ static int config_parse_default_instance(
void *data,
void *userdata) {
- InstallInfo *i = data;
+ UnitFileInstallInfo *i = data;
char *printed;
int r;
@@ -1022,7 +1022,7 @@ static int config_parse_default_instance(
static int unit_file_load(
InstallContext *c,
- InstallInfo *info,
+ UnitFileInstallInfo *info,
const char *path,
const char *root_dir,
bool allow_symlink,
@@ -1082,7 +1082,7 @@ static int unit_file_load(
static int unit_file_search(
InstallContext *c,
- InstallInfo *info,
+ UnitFileInstallInfo *info,
const LookupPaths *paths,
const char *root_dir,
bool allow_symlink,
@@ -1159,7 +1159,7 @@ static int unit_file_can_install(
bool *also) {
_cleanup_(install_context_done) InstallContext c = {};
- InstallInfo *i;
+ UnitFileInstallInfo *i;
int r;
assert(paths);
@@ -1226,7 +1226,7 @@ static int create_symlink(
}
static int install_info_symlink_alias(
- InstallInfo *i,
+ UnitFileInstallInfo *i,
const char *config_path,
bool force,
UnitFileChange **changes,
@@ -1258,7 +1258,7 @@ static int install_info_symlink_alias(
}
static int install_info_symlink_wants(
- InstallInfo *i,
+ UnitFileInstallInfo *i,
const char *config_path,
char **list,
const char *suffix,
@@ -1315,7 +1315,7 @@ static int install_info_symlink_wants(
}
static int install_info_symlink_link(
- InstallInfo *i,
+ UnitFileInstallInfo *i,
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
@@ -1343,7 +1343,7 @@ static int install_info_symlink_link(
}
static int install_info_apply(
- InstallInfo *i,
+ UnitFileInstallInfo *i,
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
@@ -1383,7 +1383,7 @@ static int install_context_apply(
UnitFileChange **changes,
unsigned *n_changes) {
- InstallInfo *i;
+ UnitFileInstallInfo *i;
int r, q;
assert(c);
@@ -1428,7 +1428,7 @@ static int install_context_mark_for_removal(
const char *config_path,
const char *root_dir) {
- InstallInfo *i;
+ UnitFileInstallInfo *i;
int r, q;
assert(c);
@@ -1513,7 +1513,7 @@ int unit_file_add_dependency(
_cleanup_free_ char *config_path = NULL;
char **i;
int r;
- InstallInfo *info;
+ UnitFileInstallInfo *info;
assert(scope >= 0);
assert(scope < _UNIT_FILE_SCOPE_MAX);
@@ -1702,7 +1702,7 @@ int unit_file_set_default(
_cleanup_free_ char *config_path = NULL;
char *path;
int r;
- InstallInfo *i = NULL;
+ UnitFileInstallInfo *i = NULL;
assert(scope >= 0);
assert(scope < _UNIT_FILE_SCOPE_MAX);
diff --git a/src/shared/install.h b/src/shared/install.h
index 3ca39397e6..45eca42662 100644
--- a/src/shared/install.h
+++ b/src/shared/install.h
@@ -21,19 +21,27 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+typedef enum UnitFileScope UnitFileScope;
+typedef enum UnitFileState UnitFileState;
+typedef enum UnitFilePresetMode UnitFilePresetMode;
+typedef enum UnitFileChangeType UnitFileChangeType;
+typedef struct UnitFileChange UnitFileChange;
+typedef struct UnitFileList UnitFileList;
+typedef struct UnitFileInstallInfo UnitFileInstallInfo;
+
#include "hashmap.h"
#include "unit-name.h"
#include "path-lookup.h"
-typedef enum UnitFileScope {
+enum UnitFileScope {
UNIT_FILE_SYSTEM,
UNIT_FILE_GLOBAL,
UNIT_FILE_USER,
_UNIT_FILE_SCOPE_MAX,
_UNIT_FILE_SCOPE_INVALID = -1
-} UnitFileScope;
+};
-typedef enum UnitFileState {
+enum UnitFileState {
UNIT_FILE_ENABLED,
UNIT_FILE_ENABLED_RUNTIME,
UNIT_FILE_LINKED,
@@ -46,35 +54,35 @@ typedef enum UnitFileState {
UNIT_FILE_INVALID,
_UNIT_FILE_STATE_MAX,
_UNIT_FILE_STATE_INVALID = -1
-} UnitFileState;
+};
-typedef enum UnitFilePresetMode {
+enum UnitFilePresetMode {
UNIT_FILE_PRESET_FULL,
UNIT_FILE_PRESET_ENABLE_ONLY,
UNIT_FILE_PRESET_DISABLE_ONLY,
_UNIT_FILE_PRESET_MAX,
_UNIT_FILE_PRESET_INVALID = -1
-} UnitFilePresetMode;
+};
-typedef enum UnitFileChangeType {
+enum UnitFileChangeType {
UNIT_FILE_SYMLINK,
UNIT_FILE_UNLINK,
_UNIT_FILE_CHANGE_TYPE_MAX,
_UNIT_FILE_CHANGE_TYPE_INVALID = -1
-} UnitFileChangeType;
+};
-typedef struct UnitFileChange {
+struct UnitFileChange {
UnitFileChangeType type;
char *path;
char *source;
-} UnitFileChange;
+};
-typedef struct UnitFileList {
+struct UnitFileList {
char *path;
UnitFileState state;
-} UnitFileList;
+};
-typedef struct {
+struct UnitFileInstallInfo {
char *name;
char *path;
char *user;
@@ -85,7 +93,7 @@ typedef struct {
char **also;
char *default_instance;
-} InstallInfo;
+};
int unit_file_enable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
int unit_file_disable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index 31b2df3c14..e35c8d3c04 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -23,8 +23,6 @@
#include "macro.h"
-typedef enum UnitFileScope UnitFileScope;
-
typedef struct LookupPaths {
char **unit_path;
#ifdef HAVE_SYSV_COMPAT
@@ -52,9 +50,12 @@ int lookup_paths_init(LookupPaths *p,
const char *generator,
const char *generator_early,
const char *generator_late);
-void lookup_paths_free(LookupPaths *p);
+
+#include "install.h"
+
int lookup_paths_init_from_scope(LookupPaths *paths,
UnitFileScope scope,
const char *root_dir);
+void lookup_paths_free(LookupPaths *p);
#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 5a9796df58..f3f6c29f75 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -453,12 +453,12 @@ static void test_install_printf(void) {
char name[] = "name.service",
path[] = "/run/systemd/system/name.service",
user[] = "xxxx-no-such-user";
- InstallInfo i = {name, path, user};
- InstallInfo i2 = {name, path, NULL};
+ UnitFileInstallInfo i = {name, path, user};
+ UnitFileInstallInfo i2 = {name, path, NULL};
char name3[] = "name@inst.service",
path3[] = "/run/systemd/system/name.service";
- InstallInfo i3 = {name3, path3, user};
- InstallInfo i4 = {name3, path3, NULL};
+ UnitFileInstallInfo i3 = {name3, path3, user};
+ UnitFileInstallInfo i4 = {name3, path3, NULL};
_cleanup_free_ char *mid, *bid, *host;