[PATCH] (against 1.4.2) prevent cp of dir into itself (reprise)

Denys Vlasenko vda.linux at googlemail.com
Mon Aug 27 16:47:34 UTC 2007


On Monday 27 August 2007 14:52, S H wrote:
> vda:
>
> The patch you proposed handles most test cases, but leads to the creation
> of many-nested directories under the following scenario:
>
> % mkdir -p sub/dir dir
> % ln -s sub/dir dir/ldir
> % busybox_vda cp -R dir sub sub [XXX]
> cp: skipping 'dir/lsub/lsub' - recursive copying detected
> cp: skipping 'sub/dir/lsub' - recursive copying detected
>
> (long delay while sub/sub/sub/sub/sub/sub ... etc. is created)
>
> sub/sub/sub/sub/sub/sub/.../sub/sub/sub: No such file or directory
>
> It works fine for the other test cases I have:
>
> % busybox_vda cp -R sub sub  [OK]
> % busybox_vda cp -R dir sub [OK]
> % busybox_vda cp -R sub lsub [OK]
> % busybox_vda cp -R lsub sub [OK]
> % busybox_vda cp -R sub dir [OK]
>
> I think the patch you provided doesn't work in this situation because it
> remembers only the top level directory; in this case, dir has a
> subdirectory that points to within the destination -- which was not
> remembered?
>
> The patch that I provided against 1.4.2 is resiliant against the above
> scenario. I think that the "tree depth" problem would apply to the normal
> use for the hashtable as well (i.e., the link table). You're right -- my
> patch should definitely not try to copy every single pathname into the
> hashtable. I intended only to copy directory paths.
>
> Attached is a revised patch against trunk svn (r19704) which only copies
> dir pathnames into the ino_dev_hashtable; it was tested against the
> previous testcases I've mentioned and the scenarios described above.

Applied with minor changes, thanks. Can you test current svn?
--
vda



More information about the busybox mailing list