Re: [PATCH] find: make pred_empty safer and avoid fd leaks

2019-02-20 Thread Bernhard Voelker
On 2/19/19 6:38 PM, James Youngman wrote: > Thanks for this fix. > > But, I think the the code I originally I wrote here is broken in a way > that's not completely fixed by your patch. The case is where the > type of a file changes between directory and non-directory. The code > as it is now w

Re: [PATCH] find: make pred_empty safer and avoid fd leaks

2019-02-19 Thread James Youngman
Thanks for this fix. But, I think the the code I originally I wrote here is broken in a way that's not completely fixed by your patch. The case is where the type of a file changes between directory and non-directory. The code as it is now will issue an error whose message corresponds to ENOTDI

[PATCH] find: make pred_empty safer and avoid fd leaks

2019-02-09 Thread Bernhard Voelker
There is a small race condition between the previous stat call and openat/fdopendir (which cannot be avoided): if the directory got replaced by another file type, then openat would succeed but the subsequent fdopendir would fail with ENOTDIR. Detect this earlier by passing the O_DIRECTORY flag. Fu