*
* If resolve_destination_target is true, an absolute path will be returned.
* If not, an absolute path is returned for linked unit files, and a relative
- * path otherwise. */
+ * path otherwise.
+ *
+ * Returns an error, false if this is an alias, true if it's a linked unit file. */
assert(filename);
assert(ret_destination);
}
*ret_destination = TAKE_PTR(dst);
- return 0;
+ return !tail; /* true if linked unit file */
}
int unit_file_build_name_map(
static const char *const unit_file_type_table[_UNIT_FILE_TYPE_MAX] = {
[UNIT_FILE_TYPE_REGULAR] = "regular",
- [UNIT_FILE_TYPE_SYMLINK] = "symlink",
- [UNIT_FILE_TYPE_MASKED] = "masked",
+ [UNIT_FILE_TYPE_LINKED] = "linked",
+ [UNIT_FILE_TYPE_ALIAS] = "alias",
+ [UNIT_FILE_TYPE_MASKED] = "masked",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(unit_file_type, UnitFileType);
true, &info->symlink_target);
if (r < 0)
return r;
+ bool outside_search_path = r > 0;
r = null_or_empty_path_with_root(info->symlink_target, lp->root_dir);
if (r < 0 && r != -ENOENT)
return log_debug_errno(r, "Failed to stat %s: %m", info->symlink_target);
if (r > 0)
info->type = UNIT_FILE_TYPE_MASKED;
+ else if (outside_search_path)
+ info->type = UNIT_FILE_TYPE_LINKED;
else
- info->type = UNIT_FILE_TYPE_SYMLINK;
+ info->type = UNIT_FILE_TYPE_ALIAS;
return 0;
}
assert(ctx);
assert(info);
- if (info->type != UNIT_FILE_TYPE_SYMLINK)
+ if (!IN_SET(info->type, UNIT_FILE_TYPE_ALIAS, UNIT_FILE_TYPE_LINKED))
return -EINVAL;
if (!info->symlink_target)
return -EINVAL;
return r;
i = start;
- while (i->type == UNIT_FILE_TYPE_SYMLINK) {
+ while (IN_SET(i->type, UNIT_FILE_TYPE_ALIAS, UNIT_FILE_TYPE_LINKED)) {
/* Follow the symlink */
if (++k > UNIT_FILE_FOLLOW_SYMLINK_MAX)