From 8a993b61d1cd46a9c48d36fb67818883d80d9bc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 30 Apr 2016 16:21:41 -0400 Subject: [PATCH] Move no_alias information to shared/ This way it can be used in install.c in subsequent commit. --- src/core/automount.c | 1 - src/core/busname.c | 1 - src/core/load-fragment.c | 2 +- src/core/mount.c | 1 - src/core/scope.c | 1 - src/core/slice.c | 1 - src/core/swap.c | 1 - src/core/unit.c | 4 ++-- src/core/unit.h | 3 --- src/shared/install.c | 10 ++++++++++ src/shared/install.h | 2 ++ 11 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/core/automount.c b/src/core/automount.c index 7c55d7b..7374d50 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -1050,7 +1050,6 @@ const UnitVTable automount_vtable = { "Automount\0" "Install\0", - .no_alias = true, .no_instances = true, .init = automount_init, diff --git a/src/core/busname.c b/src/core/busname.c index f4f4333..4d43bd2 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -1028,7 +1028,6 @@ const UnitVTable busname_vtable = { "Install\0", .private_section = "BusName", - .no_alias = true, .no_instances = true, .init = busname_init, diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 31b995a..1a8c039 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3612,7 +3612,7 @@ static int load_from_path(Unit *u, const char *path) { /* Hmm, no suitable file found? */ return 0; - if (UNIT_VTABLE(u)->no_alias && set_size(symlink_names) > 1) { + if (!unit_type_may_alias(u->type) && set_size(symlink_names) > 1) { log_unit_warning(u, "Unit type of %s does not support alias names, refusing loading via symlink.", u->id); return -ELOOP; } diff --git a/src/core/mount.c b/src/core/mount.c index cc07873..adc74c3 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1839,7 +1839,6 @@ const UnitVTable mount_vtable = { "Install\0", .private_section = "Mount", - .no_alias = true, .no_instances = true, .init = mount_init, diff --git a/src/core/scope.c b/src/core/scope.c index 7078d1f..3915e5c 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -569,7 +569,6 @@ const UnitVTable scope_vtable = { "Install\0", .private_section = "Scope", - .no_alias = true, .no_instances = true, .can_transient = true, diff --git a/src/core/slice.c b/src/core/slice.c index 63a77c9..96c7c74 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -309,7 +309,6 @@ const UnitVTable slice_vtable = { "Install\0", .private_section = "Slice", - .no_alias = true, .no_instances = true, .can_transient = true, diff --git a/src/core/swap.c b/src/core/swap.c index d880247..f486a44 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -1465,7 +1465,6 @@ const UnitVTable swap_vtable = { "Install\0", .private_section = "Swap", - .no_alias = true, .no_instances = true, .init = swap_init, diff --git a/src/core/unit.c b/src/core/unit.c index 4a129ff..0313ee2 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -202,7 +202,7 @@ int unit_add_name(Unit *u, const char *text) { if (u->type != _UNIT_TYPE_INVALID && !u->instance != !i) return -EINVAL; - if (unit_vtable[t]->no_alias && !set_isempty(u->names)) + if (!unit_type_may_alias(t) && !set_isempty(u->names)) return -EEXIST; if (hashmap_size(u->manager->units) >= MANAGER_MAX_NAMES) @@ -720,7 +720,7 @@ int unit_merge(Unit *u, Unit *other) { if (!u->instance != !other->instance) return -EINVAL; - if (UNIT_VTABLE(u)->no_alias) /* Merging only applies to unit names that support aliases */ + if (!unit_type_may_alias(u->type)) /* Merging only applies to unit names that support aliases */ return -EEXIST; if (other->load_state != UNIT_STUB && diff --git a/src/core/unit.h b/src/core/unit.h index 5909652..6ac925a 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -416,9 +416,6 @@ struct UnitVTable { /* The strings to print in status messages */ UnitStatusMessageFormats status_message_formats; - /* Can units of this type have multiple names? */ - bool no_alias:1; - /* Instances make no sense for this type */ bool no_instances:1; diff --git a/src/shared/install.c b/src/shared/install.c index 931d3e2..b92afbc 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -68,6 +68,16 @@ typedef struct { static int unit_file_lookup_state(UnitFileScope scope, const LookupPaths *paths, const char *name, UnitFileState *ret); +bool unit_type_may_alias(UnitType type) { + return IN_SET(type, + UNIT_SERVICE, + UNIT_SOCKET, + UNIT_TARGET, + UNIT_DEVICE, + UNIT_TIMER, + UNIT_PATH); +} + static int in_search_path(const LookupPaths *p, const char *path) { _cleanup_free_ char *parent = NULL; char **i; diff --git a/src/shared/install.h b/src/shared/install.h index 4ffc5a2..8a8bd09 100644 --- a/src/shared/install.h +++ b/src/shared/install.h @@ -138,6 +138,8 @@ static inline bool UNIT_FILE_INSTALL_INFO_HAS_ALSO(UnitFileInstallInfo *i) { return !strv_isempty(i->also); } +bool unit_type_may_alias(UnitType type) _const_; + int unit_file_enable( UnitFileScope scope, bool runtime, -- 2.7.4