summaryrefslogtreecommitdiff
path: root/src/shared/install.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-08-26 10:11:13 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-10-13 19:44:47 +0200
commit91810c8ffc34d3e324c1ef85a3135780d15fd013 (patch)
tree5da89cbaffd3ccffa75de9c1b09cac865b504644 /src/shared/install.c
parent318031fdb2ef0d74bc526b245bdade7e92e1c39e (diff)
downloadsystemd-91810c8ffc34d3e324c1ef85a3135780d15fd013.tar.gz
shared/install: rename UnitFileInstallInfo.type to .install_mode
Diffstat (limited to 'src/shared/install.c')
-rw-r--r--src/shared/install.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index 8375d99735..31894b882e 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1084,7 +1084,7 @@ static int install_info_may_process(
/* Checks whether the loaded unit file is one we should process, or is masked,
* transient or generated and thus not subject to enable/disable operations. */
- if (i->type == INSTALL_MODE_MASKED) {
+ if (i->install_mode == INSTALL_MODE_MASKED) {
install_changes_add(changes, n_changes, -ERFKILL, i->path, NULL);
return -ERFKILL;
}
@@ -1141,7 +1141,7 @@ static int install_info_add(
return -ENOMEM;
*i = (UnitFileInstallInfo) {
- .type = _INSTALL_MODE_INVALID,
+ .install_mode = _INSTALL_MODE_INVALID,
.auxiliary = auxiliary,
};
@@ -1344,9 +1344,9 @@ static int unit_file_load(
return -errno;
if (null_or_empty(&st))
- info->type = INSTALL_MODE_MASKED;
+ info->install_mode = INSTALL_MODE_MASKED;
else if (S_ISREG(st.st_mode))
- info->type = INSTALL_MODE_REGULAR;
+ info->install_mode = INSTALL_MODE_REGULAR;
else if (S_ISLNK(st.st_mode))
return -ELOOP;
else if (S_ISDIR(st.st_mode))
@@ -1376,7 +1376,7 @@ static int unit_file_load(
if (null_or_empty(&st)) {
if ((flags & SEARCH_DROPIN) == 0)
- info->type = INSTALL_MODE_MASKED;
+ info->install_mode = INSTALL_MODE_MASKED;
return 0;
}
@@ -1413,7 +1413,7 @@ static int unit_file_load(
return log_debug_errno(r, "Failed to parse \"%s\": %m", info->name);
if ((flags & SEARCH_DROPIN) == 0)
- info->type = INSTALL_MODE_REGULAR;
+ info->install_mode = INSTALL_MODE_REGULAR;
return
(int) strv_length(info->aliases) +
@@ -1445,11 +1445,11 @@ static int unit_file_load_or_readlink(
if (r < 0 && r != -ENOENT)
return log_debug_errno(r, "Failed to stat %s: %m", info->symlink_target);
if (r > 0)
- info->type = INSTALL_MODE_MASKED;
+ info->install_mode = INSTALL_MODE_MASKED;
else if (outside_search_path)
- info->type = INSTALL_MODE_LINKED;
+ info->install_mode = INSTALL_MODE_LINKED;
else
- info->type = INSTALL_MODE_ALIAS;
+ info->install_mode = INSTALL_MODE_ALIAS;
return 0;
}
@@ -1470,7 +1470,7 @@ static int unit_file_search(
assert(lp);
/* Was this unit already loaded? */
- if (info->type != _INSTALL_MODE_INVALID)
+ if (info->install_mode != _INSTALL_MODE_INVALID)
return 0;
if (info->path)
@@ -1530,7 +1530,7 @@ static int unit_file_search(
"Cannot find unit %s%s%s.",
info->name, template ? " or " : "", strempty(template));
- if (info->type == INSTALL_MODE_MASKED)
+ if (info->install_mode == INSTALL_MODE_MASKED)
return result;
/* Search for drop-in directories */
@@ -1588,7 +1588,7 @@ static int install_info_follow(
assert(ctx);
assert(info);
- if (!IN_SET(info->type, INSTALL_MODE_ALIAS, INSTALL_MODE_LINKED))
+ if (!IN_SET(info->install_mode, INSTALL_MODE_ALIAS, INSTALL_MODE_LINKED))
return -EINVAL;
if (!info->symlink_target)
return -EINVAL;
@@ -1599,7 +1599,7 @@ static int install_info_follow(
return -EXDEV;
free_and_replace(info->path, info->symlink_target);
- info->type = _INSTALL_MODE_INVALID;
+ info->install_mode = _INSTALL_MODE_INVALID;
return unit_file_load_or_readlink(ctx, info, info->path, lp, flags);
}
@@ -1628,7 +1628,7 @@ static int install_info_traverse(
return r;
i = start;
- while (IN_SET(i->type, INSTALL_MODE_ALIAS, INSTALL_MODE_LINKED)) {
+ while (IN_SET(i->install_mode, INSTALL_MODE_ALIAS, INSTALL_MODE_LINKED)) {
/* Follow the symlink */
if (++k > UNIT_FILE_FOLLOW_SYMLINK_MAX)
@@ -1644,7 +1644,7 @@ static int install_info_traverse(
r = install_info_follow(ctx, i, lp, flags,
/* If linked, don't look at the target name */
- /* ignore_different_name= */ i->type == INSTALL_MODE_LINKED);
+ /* ignore_different_name= */ i->install_mode == INSTALL_MODE_LINKED);
if (r == -EXDEV) {
_cleanup_free_ char *buffer = NULL;
const char *bn;
@@ -1942,7 +1942,7 @@ static int install_info_symlink_wants(
else if (info->default_instance) {
UnitFileInstallInfo instance = {
- .type = _INSTALL_MODE_INVALID,
+ .install_mode = _INSTALL_MODE_INVALID,
};
_cleanup_free_ char *path = NULL;
@@ -1959,7 +1959,7 @@ static int install_info_symlink_wants(
path = TAKE_PTR(instance.path);
- if (instance.type == INSTALL_MODE_MASKED) {
+ if (instance.install_mode == INSTALL_MODE_MASKED) {
install_changes_add(changes, n_changes, -ERFKILL, path, NULL);
return -ERFKILL;
}
@@ -2064,7 +2064,7 @@ static int install_info_apply(
assert(lp);
assert(config_path);
- if (info->type != INSTALL_MODE_REGULAR)
+ if (info->install_mode != INSTALL_MODE_REGULAR)
return 0;
bool force = file_flags & UNIT_FILE_FORCE;
@@ -2135,7 +2135,7 @@ static int install_context_apply(
/* We can attempt to process a masked unit when a different unit
* that we were processing specifies it in Also=. */
- if (i->type == INSTALL_MODE_MASKED) {
+ if (i->install_mode == INSTALL_MODE_MASKED) {
install_changes_add(changes, n_changes, UNIT_FILE_IS_MASKED, i->path, NULL);
if (r >= 0)
/* Assume that something *could* have been enabled here,
@@ -2144,7 +2144,7 @@ static int install_context_apply(
continue;
}
- if (i->type != INSTALL_MODE_REGULAR)
+ if (i->install_mode != INSTALL_MODE_REGULAR)
continue;
q = install_info_apply(ctx->scope, file_flags, i, lp, config_path, changes, n_changes);
@@ -2205,12 +2205,13 @@ static int install_context_mark_for_removal(
} else if (r < 0) {
log_debug_errno(r, "Failed to find unit %s, removing name: %m", i->name);
install_changes_add(changes, n_changes, r, i->path ?: i->name, NULL);
- } else if (i->type == INSTALL_MODE_MASKED) {
+ } else if (i->install_mode == INSTALL_MODE_MASKED) {
log_debug("Unit file %s is masked, ignoring.", i->name);
install_changes_add(changes, n_changes, UNIT_FILE_IS_MASKED, i->path ?: i->name, NULL);
continue;
- } else if (i->type != INSTALL_MODE_REGULAR) {
- log_debug("Unit %s has type %s, ignoring.", i->name, install_mode_to_string(i->type) ?: "invalid");
+ } else if (i->install_mode != INSTALL_MODE_REGULAR) {
+ log_debug("Unit %s has install mode %s, ignoring.",
+ i->name, install_mode_to_string(i->install_mode) ?: "invalid");
continue;
}
@@ -2650,7 +2651,7 @@ int unit_file_add_dependency(
if (r < 0)
return r;
- assert(target_info->type == INSTALL_MODE_REGULAR);
+ assert(target_info->install_mode == INSTALL_MODE_REGULAR);
STRV_FOREACH(name, names) {
char ***l;
@@ -2661,7 +2662,7 @@ int unit_file_add_dependency(
if (r < 0)
return r;
- assert(info->type == INSTALL_MODE_REGULAR);
+ assert(info->install_mode == INSTALL_MODE_REGULAR);
/* We didn't actually load anything from the unit
* file, but instead just add in our new symlink to
@@ -2702,7 +2703,7 @@ static int do_unit_file_enable(
if (r < 0)
return r;
- assert(info->type == INSTALL_MODE_REGULAR);
+ assert(info->install_mode == INSTALL_MODE_REGULAR);
}
/* This will return the number of symlink rules that were
@@ -2980,15 +2981,15 @@ int unit_file_lookup_state(
if (r < 0)
return log_debug_errno(r, "Failed to discover unit %s: %m", name);
- assert(IN_SET(info->type, INSTALL_MODE_REGULAR, INSTALL_MODE_MASKED));
+ assert(IN_SET(info->install_mode, INSTALL_MODE_REGULAR, INSTALL_MODE_MASKED));
log_debug("Found unit %s at %s (%s)", name, strna(info->path),
- info->type == INSTALL_MODE_REGULAR ? "regular file" : "mask");
+ info->install_mode == INSTALL_MODE_REGULAR ? "regular file" : "mask");
/* Shortcut things, if the caller just wants to know if this unit exists. */
if (!ret)
return 0;
- switch (info->type) {
+ switch (info->install_mode) {
case INSTALL_MODE_MASKED:
r = path_is_runtime(lp, info->path, true);