From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#10284: "Renaming: permission denied" file-error in Windows Date: Sun, 25 Dec 2011 04:39:18 -0500 Message-ID: References: <4EE3F66D.2050003@bk.ru> <83vcpnllo3.fsf@gnu.org> <4EE46AA1.9010700@cs.ucla.edu> <4EE504C3.3090701@bk.ru> <83obvfkmt6.fsf@gnu.org> <4EE5245E.3090803@bk.ru> <83liqilrs0.fsf@gnu.org> <4EF6D1CE.7020101@bk.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1324805990 25380 80.91.229.12 (25 Dec 2011 09:39:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 25 Dec 2011 09:39:50 +0000 (UTC) Cc: 10284@debbugs.gnu.org, eggert@cs.ucla.edu To: LynX <_LynX@bk.ru> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 25 10:39:42 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RekYQ-0004iX-Kc for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Dec 2011 10:39:42 +0100 Original-Received: from localhost ([::1]:33929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RekYP-0004r3-Nj for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Dec 2011 04:39:41 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:44774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RekYM-0004qj-0m for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 04:39:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RekYK-0005Yr-Dh for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 04:39:37 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RekYK-0005Yn-Bm for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 04:39:36 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Rekag-0005ft-9q for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 04:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Dec 2011 09:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10284 X-GNU-PR-Package: emacs,w32 X-GNU-PR-Keywords: Original-Received: via spool by 10284-submit@debbugs.gnu.org id=B10284.132480610821794 (code B ref 10284); Sun, 25 Dec 2011 09:42:02 +0000 Original-Received: (at 10284) by debbugs.gnu.org; 25 Dec 2011 09:41:48 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RekaS-0005fT-BO for submit@debbugs.gnu.org; Sun, 25 Dec 2011 04:41:48 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RekaP-0005fG-JK for 10284@debbugs.gnu.org; Sun, 25 Dec 2011 04:41:46 -0500 Original-Received: from eliz by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1RekY2-0003bL-89; Sun, 25 Dec 2011 04:39:18 -0500 In-reply-to: <4EF6D1CE.7020101@bk.ru> (message from LynX on Sun, 25 Dec 2011 09:33:34 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 25 Dec 2011 04:42:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55183 Archived-At: [Redirected to the bug tracker, to keep the entire discussion archived.] > Date: Sun, 25 Dec 2011 09:33:34 +0200 > From: LynX <_LynX@bk.ru> > CC: emacs-devel@gnu.org, eggert@cs.ucla.edu > > I've opened a bug report here: > > 10284: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10284 Thanks. > result = rename (temp, newname); > > if (result < 0 > - && errno == EEXIST > - && _chmod (newname, 0666) == 0 > - && _unlink (newname) == 0) > - result = rename (temp, newname); > + && errno == EEXIST) > + { > + if (_chmod (newname, 0666) != 0) > + return result; > + if (_unlink (newname) != 0) > + return result; > + result = rename (temp, newname); > + } > + > + /* The implementation of `rename' on Windows does not return > + errno = EXDEV when you are moving a directory to a different > + storage device (ex. logical disk). It returns EACCES > + instead. So here we handle such situations and return EXDEV. */ > + > + if (result < 0 > + && errno == EACCES > + && newname_dev != oldname_dev) > + errno = EXDEV; This first removes the target, and only then compares the device numbers. Wouldn't it be better to do it the other way around, at least when the target is a directory? That way, the target is left intact if the caller doesn't want to copy over the target, and also the filesystem is left in the same state as on Posix hosts in this case, i.e. the contract of `rename' is preserved on all systems. Thanks for working on this.