Article View: gnu.emacs.bug
Article #99863Re: Lock-files not working properly on three machine network
From: Joe Wells
Date: Tue, 24 Apr 1990 20:57
Date: Tue, 24 Apr 1990 20:57
105 lines
5494 bytes
5494 bytes
In article <9004241559.AA03206@laila.lysator.liu.se> linus@elinor.lysator.liu.se writes:
Almost all files are shared and so the emacs lock-directory.
This won't do you any good, since emacs stores process ids in the lock
files, so that it can check if the lock holder has died. Suppose person A
on machine A is using emacs (process id Q) to edit a file by pathname P.
Then suppose you, person B, want to edit the same file on machine B with
the same pathname. Your emacs will look in the lock file for pathname P
and will find Q, the pid of the process that locked the file. Then it
will check if a process exists on machine B with pid Q. There probably
will not be any such process, so your emacs will improperly steal the
lock.
Almost every participant in the project has his own shortcut to the
src and so the lock file for the same file are different.
This behavior can be remedied. I'm including my fix for this after my
signature. Of course, fixing will still not help if you're editing the
same file from multiple machines.
--
Joe Wells <jbw@bu.edu>
jbw%bucsf.bu.edu@cs.bu.edu
...!harvard!bu-cs!bucsf!jbw
----------------------------------------------------------------------
;; symlink-fix: Fix to remove symbolic links from file pathnames.
;; Copyright (C) 1989 Free Software Foundation, Inc.
;; This file is not officially part of GNU Emacs, but is being donated
;; to the Free Software Foundation.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY. No author or distributor
;; accepts responsibility to anyone for the consequences of using it
;; or for whether it serves any particular purpose or works at all,
;; unless he says so in writing. Refer to the GNU Emacs General Public
;; License for full details.
;; Everyone is granted permission to copy, modify and redistribute
;; GNU Emacs, but only under the conditions described in the
;; GNU Emacs General Public License. A copy of this license is
;; supposed to have been given to you along with GNU Emacs so you
;; can know your rights and responsibilities. It should be in a
;; file named COPYING. Among other things, the copyright notice
;; and this notice must be preserved on all copies.
;; Created by: Joe Wells, jbw@bucsf
;; Created on: summer 1988
;; Last modified by: Joe Wells, jbw@bucsf
;; Last modified on: Sat Apr 21 21:10:47 1990
;; Filename: symlink-fix.el
;; Purpose: remove symbolic links from pathnames
(or (fboundp 'original-expand-file-name)
(fset 'original-expand-file-name
(symbol-function 'expand-file-name)))
(defun expand-file-name (file-name &optional directory)
"Convert FILENAME to absolute, and canonicalize it.
Second arg DEFAULT is directory to start with if FILENAME is relative
\(does not start with slash); if DEFAULT is nil or missing,
the current buffer's value of default-directory is used.
Filenames containing . or .. as components are simplified;
initial ~ is expanded. See also the function substitute-in-file-name.
This has been modified to resolve all symbolic links from FILENAME.
The original function definition is stored on original-expand-file-name."
(let (left right split link)
(setq right (original-expand-file-name file-name directory))
(setq left "")
(while (not (equal right ""))
(setq split (split-file-name right))
(setq left (concat left (car split)))
(setq right (cdr split))
(setq link (file-symlink-p left))
(if (null link)
nil
(if (eq 0 (length link)) (setq link "."))
(cond ((not (eq (aref link 0) ?/))
(setq split (split-file-name link))
(setq left (hack-local-link left (car split)))
(setq right (concat (cdr split) right)))
(t
(setq right (concat link right))
(setq left "")))))
(original-expand-file-name left)))
(defun split-file-name (file-name)
"Splits FILENAME into two strings, and returns a list of the two
strings. The first string will be the first filename component in
FILENAME, plus any leading slashes, and the second string will be the rest
of FILENAME, possibly a string of length 0."
(if (string-match "\\`\\(/*[^/]+\\)\\(/.+\\)\\'" file-name)
(cons (substring file-name (match-beginning 1) (match-end 1))
(substring file-name (match-beginning 2) (match-end 2)))
(cons file-name "")))
(defun hack-local-link (file-name link)
"Takes FILENAME and LINK and returns a string which substitutes LINK
for the last component of FILENAME."
(string-match "\\`\\(.*/\\)[^/]+\\'" file-name)
(concat (substring file-name (match-beginning 1) (match-end 1))
link))
(provide 'symlink-fix)
Technical Details
Message-ID:
<JBW.90Apr24165725@bucsf.bu.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!samsung!think!snorkelwacker!bu.edu!nntp-read!jbwReferences:
<9004241559.AA03206@laila.lysator.liu.se>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,c0aa16db9a3233f,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-04-24 23:44:56 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!samsung!think!snorkelwacker!bu.edu!nntp-read!jbw From: jbw@bucsf.bu.edu (Joe Wells) Newsgroups: gnu.emacs.bug Subject: Re: Lock-files not working properly on three machine network Message-ID: <JBW.90Apr24165725@bucsf.bu.edu> Date: 24 Apr 90 20:57:25 GMT References: <9004241559.AA03206@laila.lysator.liu.se> Sender: news@bu.edu.bu.edu Distribution: gnu Organization: Boston University Computer Science Department Lines: 105 Posted: Tue Apr 24 21:57:25 1990 In-reply-to: linus@elinor.lysator.liu.se's message of 24 Apr 90 15:59:06 GMT