Hi Petr,

Thanks for the proposed patch.

> When FTS_TIGHT_CYCLE_CHECK is enabled, fts_build() leaves directory and
> then re-enters it again with updated stat information, which leads to
> double hash removal of the same directory in a case the second call to
> fstat() fails as then the directory is not reentered, but the caller
> of fts_build(), the function fts_add(), stil removes it upon fts_build()
> return. This commonly happens on /proc filesystem where permission to
> stat process files and directories depends on that process euid and
> ptraceability configuration.
> 
> Rework the code to not remove the old entry until the new entry is
> succesfully inserted to the hash table, as a similar problem could
> arise also when the updated entry insertion fails (on a cycle or memory
> allocation failure).

It is good that you explain the rationale. But the essential part of these
explanations ought to be contained in the code, since 10 years from now,
people will read the code, not the ChangeLog entry or git history. Therefore,
can you please add sensible comments in the code?

Also, since the problem occurs only in a particular situation (/proc file
system and FTS_TIGHT_CYCLE_CHECK), can you please submit a unit test as well?
Ideally, as a new file tests/test-fts-2.c.

Thanks!

Bruno




Reply via email to