emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

find-buffer-visiting: Patch.


From: Luc Teirlinck
Subject: find-buffer-visiting: Patch.
Date: Tue, 27 Aug 2002 22:02:52 -0500 (CDT)

find-buffer-visiting malfunctions if a symbolic link is made to one of
two hard-linked files.  This is not a really contorted situation.
Hard links seem to be used extensively for operating system files.  If
one makes a symbolic link to such a file, one is in the described
situation.

First, a description of the problem.

Let us create a new file "original".

C-x C-f original.

Type say "a", C-x C-s.

C-x d.

Hard-link "original" to "hardlink", using the dired command H.

Symlink "hardlink" to "symhard", using S.

Visit symhard, using dired and then visit original (using C-x C-f or
using dired, makes no difference).  symhard and original are not
recognized as the same file and we get two different buffers.  Kill
both.  Now visit both files again, but reverse the order, visit
original first and then symhard.  Now they actually are the same file
and we get one single buffer.

This makes no sense: symhard and original are the same file, but
original and symhard are different files.  This is not merely ugly and
nonsensical.  I believe it is important to point out to the user that
symhard and original are (indirectly) linked, because hard links are
tricky and easily broken, especially since Emacs uses backup by
renaming as its default.

The problem lies with the function find-buffer-visiting and is trivial
to fix by adding four letters (replacing one occurrence of
buffer-file-name with buffer-file-truename, so that symbolic links to
hard links are accounted for).

I include a changelog and a diff for the latest CVS version of
emacs21.3.50.

Change log:

         *files.el: (find-buffer-visiting): compare file attributes
          using buffer-file-truename.

Diff:


===File ~/filesdiff=========================================
cd /usr/local/share/emacs/21.3.50/lisp/
diff -c /usr/local/share/emacs/21.3.50/lisp/oldfiles.el 
/usr/local/share/emacs/21.3.50/lisp/files.el
*** /usr/local/share/emacs/21.3.50/lisp/oldfiles.el     Tue Aug 27 16:42:27 2002
--- /usr/local/share/emacs/21.3.50/lisp/files.el        Tue Aug 27 21:05:52 2002
***************
*** 1076,1082 ****
                            ;; Verify this buffer's file number
                            ;; still belongs to its file.
                            (file-exists-p buffer-file-name)
!                           (equal (file-attributes buffer-file-name)
                                   attributes))
                       (setq found (car list))))
                 (setq list (cdr list))))
--- 1076,1082 ----
                            ;; Verify this buffer's file number
                            ;; still belongs to its file.
                            (file-exists-p buffer-file-name)
!                           (equal (file-attributes buffer-file-truename)
                                   attributes))
                       (setq found (car list))))
                 (setq list (cdr list))))

Diff finished at Tue Aug 27 21:08:08
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]