return ordered_hashmap_get(c->will_process, name);
}
+static int install_info_may_process(UnitFileInstallInfo *i, const LookupPaths *paths) {
+ assert(i);
+ assert(paths);
+
+ /* 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 == UNIT_FILE_TYPE_MASKED)
+ return -ESHUTDOWN;
+ if (path_is_generator(paths, i->path))
+ return -EADDRNOTAVAIL;
+ if (path_is_transient(paths, i->path))
+ return -EADDRNOTAVAIL;
+
+ return 0;
+}
+
static int install_info_add(
InstallContext *c,
const char *name,
r = install_info_discover(scope, &c, &paths, target, SEARCH_FOLLOW_CONFIG_SYMLINKS, &target_info);
if (r < 0)
return r;
- if (target_info->type == UNIT_FILE_TYPE_MASKED)
- return -ESHUTDOWN;
- if (path_is_generator(&paths, target_info->path))
- return -EADDRNOTAVAIL;
- if (path_is_transient(&paths, target_info->path))
- return -EADDRNOTAVAIL;
+ r = install_info_may_process(target_info, &paths);
+ if (r < 0)
+ return r;
assert(target_info->type == UNIT_FILE_TYPE_REGULAR);
r = install_info_discover(scope, &c, &paths, *f, SEARCH_FOLLOW_CONFIG_SYMLINKS, &i);
if (r < 0)
return r;
- if (i->type == UNIT_FILE_TYPE_MASKED)
- return -ESHUTDOWN;
- if (path_is_generator(&paths, i->path))
- return -EADDRNOTAVAIL;
- if (path_is_transient(&paths, i->path))
- return -EADDRNOTAVAIL;
+ r = install_info_may_process(i, &paths);
+ if (r < 0)
+ return r;
assert(i->type == UNIT_FILE_TYPE_REGULAR);
r = install_info_discover(scope, &c, &paths, *f, SEARCH_LOAD, &i);
if (r < 0)
return r;
- if (i->type == UNIT_FILE_TYPE_MASKED)
- return -ESHUTDOWN;
- if (path_is_generator(&paths, i->path))
- return -EADDRNOTAVAIL;
- if (path_is_transient(&paths, i->path))
- return -EADDRNOTAVAIL;
+ r = install_info_may_process(i, &paths);
+ if (r < 0)
+ return r;
assert(i->type == UNIT_FILE_TYPE_REGULAR);
}
r = install_info_discover(scope, &c, &paths, name, 0, &i);
if (r < 0)
return r;
- if (i->type == UNIT_FILE_TYPE_MASKED)
- return -ESHUTDOWN;
- if (path_is_generator(&paths, i->path))
- return -EADDRNOTAVAIL;
- if (path_is_transient(&paths, i->path))
- return -EADDRNOTAVAIL;
+ r = install_info_may_process(i, &paths);
+ if (r < 0)
+ return r;
old_path = skip_root(&paths, i->path);
new_path = strjoina(paths.persistent_config, "/" SPECIAL_DEFAULT_TARGET);
r = install_info_discover(scope, &c, &paths, SPECIAL_DEFAULT_TARGET, SEARCH_FOLLOW_CONFIG_SYMLINKS, &i);
if (r < 0)
return r;
- if (i->type == UNIT_FILE_TYPE_MASKED)
- return -ESHUTDOWN;
+ r = install_info_may_process(i, &paths);
+ if (r < 0)
+ return r;
n = strdup(i->name);
if (!n)
if (r < 0)
return r;
- if (i->type == UNIT_FILE_TYPE_MASKED)
- return -ESHUTDOWN;
- if (path_is_generator(paths, i->path))
- return -EADDRNOTAVAIL;
- if (path_is_transient(paths, i->path))
- return -EADDRNOTAVAIL;
+ r = install_info_may_process(i, paths);
+ if (r < 0)
+ return r;
} else
r = install_info_discover(scope, minus, paths, name, SEARCH_FOLLOW_CONFIG_SYMLINKS, &i);