>>108337962
How to break almost every filesystem scanning tool:
#define _GNU_SOURCE
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main() {
int fd = open("/tmp", O_PATH | O_DIRECTORY | O_CLOEXEC);
if (fd == -1) {
perror("open");
return 1;
}
for (int i = 0; i < 1000000; i++) {
int res = mkdirat(fd, "a", 0755);
if (res == -1) {
perror("mkdirat");
return 1;
}
int nfd = openat(fd, "a", O_PATH | O_DIRECTORY | O_CLOEXEC);
if (nfd == -1) {
perror("openat");
return 1;
}
close(fd);
fd = nfd;
}
return 0;
}