rm -r fails to delete entire hierarchy when path goes in and out of it

Isaac Dunham ibid.ag at gmail.com
Thu Sep 18 01:01:28 UTC 2014


On Wed, Sep 17, 2014 at 06:08:45PM -0400, Joshua Judson Rosen wrote:
> On 2014-09-17 12:52, Cathey, Jim wrote:
> >Pretty sure 'our' upstream rm (in a prior life) expressly
> >prohibited -r on starting paths that contained .. members.
> >Too many weirdo cases where you would get into trouble.
> 
> GNU rm opens the top-level directory and uses unlinkat(), fstatat(), etc. to remove
> files and subdirectories without having to resolve the paths for every
> file/directory processed; so it runs into the problem (that some ".." link no
> longer exists) only when it finally reaches that top-level directory.
> It still refuses to operate on paths that _end_ in "/.." (or "/.").

This is explicitly required by POSIX.
Which implies that determining a canonical name should not be done.

HTH,
Isaac Dunham



More information about the busybox mailing list