when determining unit file list, include invalid unit names in an "invalid" state
This commit is contained in:
+16
-16
@@ -1999,29 +1999,28 @@ int unit_file_get_list(
|
||||
}
|
||||
|
||||
r = find_symlinks_in_scope(scope, root_dir, de->d_name, &f->state);
|
||||
if (r < 0) {
|
||||
free(f->path);
|
||||
free(f);
|
||||
goto finish;
|
||||
} else if (r > 0)
|
||||
goto found;
|
||||
|
||||
r = unit_file_can_install(&paths, root_dir, f->path, true);
|
||||
if (r < 0) {
|
||||
free(f->path);
|
||||
free(f);
|
||||
goto finish;
|
||||
} else if (r > 0) {
|
||||
f->state = UNIT_FILE_DISABLED;
|
||||
goto found;
|
||||
} else {
|
||||
f->state = UNIT_FILE_STATIC;
|
||||
f->state = UNIT_FILE_ENABLED;
|
||||
goto found;
|
||||
}
|
||||
|
||||
free(f->path);
|
||||
free(f);
|
||||
continue;
|
||||
r = unit_file_can_install(&paths, root_dir, f->path, true);
|
||||
if (r == -EINVAL || /* Invalid setting? */
|
||||
r == -EBADMSG || /* Invalid format? */
|
||||
r == -ENOENT /* Included file not found? */)
|
||||
f->state = UNIT_FILE_INVALID;
|
||||
else if (r < 0) {
|
||||
free(f->path);
|
||||
free(f);
|
||||
goto finish;
|
||||
} else if (r > 0)
|
||||
f->state = UNIT_FILE_DISABLED;
|
||||
else
|
||||
f->state = UNIT_FILE_STATIC;
|
||||
|
||||
found:
|
||||
r = hashmap_put(h, path_get_file_name(f->path), f);
|
||||
@@ -2051,7 +2050,8 @@ static const char* const unit_file_state_table[_UNIT_FILE_STATE_MAX] = {
|
||||
[UNIT_FILE_MASKED] = "masked",
|
||||
[UNIT_FILE_MASKED_RUNTIME] = "masked-runtime",
|
||||
[UNIT_FILE_STATIC] = "static",
|
||||
[UNIT_FILE_DISABLED] = "disabled"
|
||||
[UNIT_FILE_DISABLED] = "disabled",
|
||||
[UNIT_FILE_INVALID] = "invalid",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(unit_file_state, UnitFileState);
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef enum UnitFileState {
|
||||
UNIT_FILE_MASKED_RUNTIME,
|
||||
UNIT_FILE_STATIC,
|
||||
UNIT_FILE_DISABLED,
|
||||
UNIT_FILE_INVALID,
|
||||
_UNIT_FILE_STATE_MAX,
|
||||
_UNIT_FILE_STATE_INVALID = -1
|
||||
} UnitFileState;
|
||||
|
||||
Reference in New Issue
Block a user