summaryrefslogtreecommitdiffstats
path: root/src/basic/recurse-dir.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-11-09 11:31:15 +0100
committerLennart Poettering <lennart@poettering.net>2022-11-09 18:55:58 +0100
commitb21ec07b540b7d1f2b83a97f373536dcecaf95f1 (patch)
tree9ab601e1c1807a121ff7dc9376b2d5427170a7a7 /src/basic/recurse-dir.h
parentrandom-seed: make sure to load machine id even if the seed file is missing (diff)
downloadsystemd-b21ec07b540b7d1f2b83a97f373536dcecaf95f1.tar.xz
systemd-b21ec07b540b7d1f2b83a97f373536dcecaf95f1.zip
recurse-dir: optionally, call callback when entering/leaving toplevel dir, too
So far recurse_dir() will call the callback whenever we enter a directory, and then pass the struct dirent for that directory, and an fd for the directory the dirent is part of (i.e. the parent of the directory we call things for). For the top-level dir the function is invoked for we will not call the callback however, because we have no dirent for that, and not fd for the directory the top-level dir is part of. Let's add a flag to call it anyway, and in that case pass a NULL dirent and -1 as directory fd. This is useful when we want to treat the top-level dir the same as any dir further down. This is done opt-in since the callback must be ablet to handle a NULL dirent and a -1 directory fd.
Diffstat (limited to 'src/basic/recurse-dir.h')
-rw-r--r--src/basic/recurse-dir.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/basic/recurse-dir.h b/src/basic/recurse-dir.h
index 779c91e905..c10c8ddc9d 100644
--- a/src/basic/recurse-dir.h
+++ b/src/basic/recurse-dir.h
@@ -65,6 +65,7 @@ typedef enum RecurseDirFlags {
RECURSE_DIR_ENSURE_TYPE = 1 << 2, /* guarantees that 'd_type' field of 'de' is not DT_UNKNOWN */
RECURSE_DIR_SAME_MOUNT = 1 << 3, /* skips over subdirectories that are submounts */
RECURSE_DIR_INODE_FD = 1 << 4, /* passes an opened inode fd (O_DIRECTORY fd in case of dirs, O_PATH otherwise) */
+ RECURSE_DIR_TOPLEVEL = 1 << 5, /* call RECURSE_DIR_ENTER/RECURSE_DIR_LEAVE once for top-level dir, too, with dir_fd=-1 and NULL dirent */
} RecurseDirFlags;
typedef struct DirectoryEntries {