diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-05-04 10:53:00 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-05-04 13:29:14 +0200 |
commit | db55bbf29b8d0268884348bf3270b8b2a2db3b31 (patch) | |
tree | f17d57f6f02880a87ac4fb067768b797a0fe1d7b /src/nspawn | |
parent | Merge pull request #23260 from yuwata/libsystemd-network-raw-size (diff) | |
download | systemd-db55bbf29b8d0268884348bf3270b8b2a2db3b31.tar.xz systemd-db55bbf29b8d0268884348bf3270b8b2a2db3b31.zip |
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.
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn-network.c | 2 | ||||
-rw-r--r-- | src/nspawn/nspawn.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c index fab4eb9609..f3d7f403f9 100644 --- a/src/nspawn/nspawn-network.c +++ b/src/nspawn/nspawn-network.c @@ -449,7 +449,7 @@ int remove_bridge(const char *bridge_name) { path = strjoina("/sys/class/net/", bridge_name, "/brif"); - r = dir_is_empty(path); + r = dir_is_empty(path, /* ignore_hidden_or_backup= */ false); if (r == -ENOENT) /* Already gone? */ return 0; if (r < 0) diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 59768bcc0b..c5fd978395 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -2680,7 +2680,7 @@ static int setup_journal(const char *directory) { } else if (access(p, F_OK) < 0) return 0; - if (dir_is_empty(q) == 0) + if (dir_is_empty(q, /* ignore_hidden_or_backup= */ false) == 0) log_warning("%s is not empty, proceeding anyway.", q); r = userns_mkdir(directory, p, 0755, 0, 0); |