From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: Re: backup-buffer-copy loops if old backup can't be deleted Date: Tue, 21 Aug 2007 17:50:59 -0400 Message-ID: <16sl6cy2t8.fsf@fencepost.gnu.org> References: <46CAD810.3050904@gmx.net> <46CAF8AC.9070809@gmx.at> <46CAFBEF.2040606@gmx.net> <46CB529F.7010008@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1187732819 24456 80.91.229.12 (21 Aug 2007 21:46:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 21 Aug 2007 21:46:59 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org, Martin von Gagern To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 21 23:46:57 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1INbYu-0002Rq-0A for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Aug 2007 23:46:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INbYt-0003M4-EW for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Aug 2007 17:46:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1INbYr-0003KG-Hc for bug-gnu-emacs@gnu.org; Tue, 21 Aug 2007 17:46:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1INbYp-0003Gf-Bz for bug-gnu-emacs@gnu.org; Tue, 21 Aug 2007 17:46:52 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1INbYp-0003GH-65 for bug-gnu-emacs@gnu.org; Tue, 21 Aug 2007 17:46:51 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1INbYo-0006Tk-U2 for bug-gnu-emacs@gnu.org; Tue, 21 Aug 2007 17:46:51 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1INbcp-00065v-Dx; Tue, 21 Aug 2007 17:50:59 -0400 X-Spook: Albania Uzi red noise David John Oates FIPS140 virus PGP X-Ran: %7"U]3"z0D$C"|`0]\S=z0xJ?[rzJ4|pj;_P(Xi)qKbY@91xW:krJsO=`&0QMltZyd_Z$> X-Hue: black X-Attribution: GM User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16414 Archived-At: martin rudalics wrote: > Why can't we use > > (copy-file from-name to-name t t) > > here as in Emacs 21? What was the rationale for this loop? I know no more than it says in the comment. rms added the loop 20050423, copied from make-temp-file I think. I think looping makes more sense in that context, not sure it makes any sense in this context. I'll ask on emacs-devel. But if what it says in the existing comment is possible, then I guess we would actually need something like this: *** files.el 8 Aug 2007 14:06:01 -0000 1.896.2.15 --- files.el 21 Aug 2007 21:26:02 -0000 *************** *** 3120,3126 **** (file-error nil)))))) (defun backup-buffer-copy (from-name to-name modes) ! (let ((umask (default-file-modes))) (unwind-protect (progn ;; Create temp files with strict access rights. It's easy to --- 3120,3131 ---- (file-error nil)))))) (defun backup-buffer-copy (from-name to-name modes) ! (let ((umask (default-file-modes)) ! (dir (or (file-name-directory to-name) ! default-directory))) ! ;; Can't delete or create files in a read-only directory. ! (unless (file-writable-p dir) ! (signal 'file-error (list "Directory is not writable" dir))) (unwind-protect (progn ;; Create temp files with strict access rights. It's easy to *************** *** 3129,3134 **** --- 3134,3144 ---- (set-default-file-modes ?\700) (while (condition-case () (progn + ;; If we allow for the possibility of something + ;; creating the file between delete and copy + ;; (below), we must also allow for the + ;; possibility of something deleting it between + ;; a file-exists-p check and a delete. (condition-case nil (delete-file to-name) (file-error nil)) *************** *** 3137,3142 **** --- 3147,3154 ---- (file-already-exists t)) ;; The file was somehow created by someone else between ;; `delete-file' and `copy-file', so let's try again. + ;; FIXME does that every actually happen in practice? + ;; This is a potential infloop, which seems bad... nil)) ;; Reset the umask. (set-default-file-modes umask)))