dirent-util: add FOREACH macro for iterating through getdents64() buffers

We already have a similar loop twice, let's make it easier to read via
an iteration macro.

(The new macro is a bit more careful even, as it verifies the full
dirent fits into the remaining buffer when returning it)
This commit is contained in:
Lennart Poettering
2021-10-25 21:51:37 +02:00
parent ca664db258
commit a4e70ef7ba
3 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ typedef struct DirectoryEntries {
size_t n_entries;
struct dirent** entries;
size_t buffer_size;
uint8_t buffer[] _alignas_(struct dirent);
struct dirent buffer[];
} DirectoryEntries;
int readdir_all(int dir_fd, RecurseDirFlags flags, DirectoryEntries **ret);