]> git.ipfire.org Git - thirdparty/systemd.git/commit
recurse-dir: optionally, call callback when entering/leaving toplevel dir, too
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Nov 2022 10:31:15 +0000 (11:31 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Nov 2022 17:55:58 +0000 (18:55 +0100)
commitb21ec07b540b7d1f2b83a97f373536dcecaf95f1
tree9ab601e1c1807a121ff7dc9376b2d5427170a7a7
parenta2f0dbb81004685d17f71fed48dc50027ccadb82
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.
src/basic/recurse-dir.c
src/basic/recurse-dir.h