recurse-dir: optionally, only enumerate dentries of a specific type

At various places we filter directory enumerations by inode type. Let's
add explicit support for that, so that the "struct dirent" array we
return already suppresses them.

This shortens code and makes things more robust.
This commit is contained in:
Lennart Poettering
2026-06-22 14:40:16 +02:00
parent fe83c5be7f
commit 90d285ade7
9 changed files with 129 additions and 55 deletions
+1 -4
View File
@@ -279,7 +279,7 @@ static int process_unit_credentials(const char *credentials_dir) {
assert(credentials_dir);
r = readdir_all_at(AT_FDCWD, credentials_dir, RECURSE_DIR_SORT|RECURSE_DIR_IGNORE_DOT|RECURSE_DIR_ENSURE_TYPE, &des);
r = readdir_all_at(AT_FDCWD, credentials_dir, RECURSE_DIR_SORT|RECURSE_DIR_IGNORE_DOT|RECURSE_DIR_MUST_BE_REGULAR, &des);
if (r < 0)
return log_error_errno(r, "Failed to enumerate credentials from credentials directory '%s': %m", credentials_dir);
@@ -287,9 +287,6 @@ static int process_unit_credentials(const char *credentials_dir) {
struct dirent *de = *i;
const char *unit, *dropin;
if (de->d_type != DT_REG)
continue;
unit = startswith(de->d_name, "systemd.extra-unit.");
dropin = startswith(de->d_name, "systemd.unit-dropin.");