|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The POSIX spec for readdir() [1] says:
> If a file is removed from or added to the directory after the most
> recent call to opendir() or rewinddir(), whether a subsequent call
> to readdir() returns an entry for that file is unspecified.
which implies that a loop of readdir()/unlink()/creat() may continue to
return new files unendingly. This was even observed on a Linux 6.6
tmpfs mount [2].
It's not clear whether find(1) is also permitted to loop endlessly in
this case, but in case it is, let's avoid the whole problem by limiting
the -exec to happen at most once.
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html
[2]: https://lore.kernel.org/linux-fsdevel/20231113180616.2831430-1-tavianator@tavianator.com/
|