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

From: Michael Albinus <[email-masked]>
Date: Fri, 24 Feb 2012 13:54:16 +0100

Thierry Volpiatto <[email-masked]> writes:

> --- a/lisp/files.el
> +++ b/lisp/files.el
> +(defun files-equal-p (file1 file2)
> +
> +(defun file-subdir-of-p (dir1 dir2)

For both functions, please check for a file name handler, and call it if
available. It doesn't matter that they are not implemented yet; there is
the fallback to the native implementation in that case.

With this check, I could start to implement the file name handlers in
Tramp's upstream repository.

> +(defun files-equal-p (file1 file2)
> +  "Return non-nil if FILE1 and FILE2 name the same file."
> +  (and (equal (file-remote-p file1) (file-remote-p file2))
> +       (equal (file-attributes (file-truename file1))
> +              (file-attributes (file-truename file2)))))

This implementation requires, that inode number and filesystem device
number are always unique. This is true for local files, if you run a
Unix-like system. It is not guaranteed for remote files. And it is even
not guaranted, if the local system is Windows: on mounted drives, the
returned inode number is 0:

(file-attributes "y:/.emacs")
=> (nil 1 101567 513 (20295 15877) (20234 46272) (20234 46272) 33083 "-rw-rw-rw-" nil 0 (47631 . 5881))

Best regards, Michael.