This way it can be used in install.c in subsequent commit.
"Automount\0"
"Install\0",
- .no_alias = true,
.no_instances = true,
.init = automount_init,
"Install\0",
.private_section = "BusName",
- .no_alias = true,
.no_instances = true,
.init = busname_init,
/* 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;
}
"Install\0",
.private_section = "Mount",
- .no_alias = true,
.no_instances = true,
.init = mount_init,
"Install\0",
.private_section = "Scope",
- .no_alias = true,
.no_instances = true,
.can_transient = true,
"Install\0",
.private_section = "Slice",
- .no_alias = true,
.no_instances = true,
.can_transient = true,
"Install\0",
.private_section = "Swap",
- .no_alias = true,
.no_instances = true,
.init = swap_init,
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)
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 &&
/* 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;
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;
return !strv_isempty(i->also);
}
+bool unit_type_may_alias(UnitType type) _const_;
+
int unit_file_enable(
UnitFileScope scope,
bool runtime,