stat-util: ignore hidden_or_backup_file when checking if dir is empty

Commit https://github.com/systemd/systemd/commit/a068aceafbf
changed dir_is_emtpy_at to use FOREACH_DIRENT_IN_BUFFER instead of
FOREACH_DIRENT, but used dot_or_dotdot which just checks if the name
is literally '.' or '..' which is not enough, previous behaviour was
to ignore all hidden files, so restore that and add a test case.

Fixes https://github.com/systemd/systemd/issues/23220
This commit is contained in:
Luca Boccassi
2022-04-30 17:47:56 +01:00
committed by Yu Watanabe
parent dfd672f84b
commit f470cb6d13
2 changed files with 8 additions and 2 deletions

View File

@@ -106,7 +106,7 @@ int dir_is_empty_at(int dir_fd, const char *path) {
msan_unpoison(&buffer, n);
FOREACH_DIRENT_IN_BUFFER(de, &buffer.de, n)
if (!dot_or_dot_dot(de->d_name))
if (!hidden_or_backup_file(de->d_name))
return 0;
return 1;