Subject: Re: bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy

From: Stefan Monnier <[email-masked]>
Date: Wed, 22 Feb 2012 17:00:08 -0500

> Ok, that is true for the solutions you propose below, but what's wrong
> with the solution I have proposed:
> Just checking if the destination directory is a subdirectory of the
> directory we want to copy.

It's not a bad plan, but it's difficult to make it catch all cases
because it's difficult to figure out if "the destination directory is
a subdirectory of the directory we want to copy".
[ e.g. because of ignored cases differences, or use of different names
  to refer to the same directory, because of MICROS~1 mangling.  ]

Of course checking if two directories are one and the same isn't that
easy to do it reliably either (e.g. for lack of inodes on Windows
systems, and actually I'm not sure what happens if we refer to the same
dir via two different mount points, using GNU/Linux's "bind" mounts, or
mounting dirs multiple times).

I guess the two options aren't mutually exclusive, so it's probably
worth doing a first check before starting the whole operation (trying
to find out if the destination is a parent of the source based on
file-truename), and then adding another check in the recursive loop to
try and detect inf-loops.

        Stefan