]> git.ipfire.org Git - thirdparty/systemd.git/commit
stat-util: fix dir_is_empty() with hidden/backup files
authorLennart Poettering <lennart@poettering.net>
Wed, 4 May 2022 08:53:00 +0000 (10:53 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 4 May 2022 11:29:14 +0000 (13:29 +0200)
commitdb55bbf29b8d0268884348bf3270b8b2a2db3b31
treef17d57f6f02880a87ac4fb067768b797a0fe1d7b
parent080b8c2ace2dcc4ee3faf5b0ee95f5117aa27dab
stat-util: fix dir_is_empty() with hidden/backup files

This is a follow-up for f470cb6d13558fc06131dc677d54a089a0b07359 which in
turn is a follow-up for a068aceafbffcba85398cce636c25d659265087a.

The latter started to honour hidden files when deciding whether a
directory is empty. The former reverted to the old behaviour to fix
issue #23220.

It introduced a bug though: when a directory contains a larger number of
hidden entries the getdents64() buffer will not suffice to read them,
since we just allocate three entries for it (which is definitely enough
if we just ignore the . + .. entries, but not ig we ignore more).

I think it's a bit confusing that dir_is_empty() can return true even if
rmdir() on the dir would return ENOTEMPTY. Hence, let's rework the
function to make it optional whether hidden files are ignored or not.
After all, I looking at the users of this function I am pretty sure in
more cases we want to honour hidden files.
18 files changed:
src/basic/stat-util.c
src/basic/stat-util.h
src/boot/bootctl.c
src/core/main.c
src/core/manager.c
src/core/path.c
src/core/unit.c
src/gpt-auto-generator/gpt-auto-generator.c
src/home/homework-cifs.c
src/home/user-record-util.c
src/nspawn/nspawn-network.c
src/nspawn/nspawn.c
src/shared/condition.c
src/shared/copy.c
src/shared/dissect-image.c
src/shared/tpm2-util.c
src/sysext/sysext.c
src/test/test-stat-util.c