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: Thu, 29 Dec 2011 01:18:02 -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> <4EFB73C3.7070203@bk.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1325139505 32539 80.91.229.12 (29 Dec 2011 06:18:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 29 Dec 2011 06:18:25 +0000 (UTC) Cc: 10284@debbugs.gnu.org To: LynX <_LynX@bk.ru> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 29 07:18:21 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 1Rg9Jj-0001cE-6q for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Dec 2011 07:18:19 +0100 Original-Received: from localhost ([::1]:48272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rg9Ji-00087J-LM for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Dec 2011 01:18:18 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:60700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rg9Jg-00086p-7j for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 01:18:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rg9Je-0002uN-17 for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 01:18:16 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rg9Jd-0002uG-Uf for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 01:18:13 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Rg9MM-0005vk-3J for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 01:21: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: Thu, 29 Dec 2011 06:21: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.132513965222781 (code B ref 10284); Thu, 29 Dec 2011 06:21:02 +0000 Original-Received: (at 10284) by debbugs.gnu.org; 29 Dec 2011 06:20:52 +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 1Rg9MC-0005vO-Hm for submit@debbugs.gnu.org; Thu, 29 Dec 2011 01:20:52 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rg9MB-0005vH-7V for 10284@debbugs.gnu.org; Thu, 29 Dec 2011 01:20:51 -0500 Original-Received: from eliz by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Rg9JS-0000mS-8c; Thu, 29 Dec 2011 01:18:02 -0500 In-reply-to: <4EFB73C3.7070203@bk.ru> (message from LynX on Wed, 28 Dec 2011 21:53:39 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 29 Dec 2011 01:21: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:55262 Archived-At: > Date: Wed, 28 Dec 2011 21:53:39 +0200 > From: LynX <_LynX@bk.ru> > > > 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. > > You mean that before setting errno to EXDEV we also need to check that > target is a directory (since files are moved correctly)? Yes, but that's not the important part of my comment above. The important part is to move the check for different devices _before_ the call to _unlink which removes the target file/directory if it exists. In other words, we should fail and report EXDEV without risking the removal of the target, and let the caller decide what to do with the failure. (If the caller decides to leave things unchanged, it will not be The Right Thing for us to remove the target.)