From unknown Wed Sep 10 19:14:58 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#10284 <10284@debbugs.gnu.org> To: bug#10284 <10284@debbugs.gnu.org> Subject: Status: 23.2; "Renaming: permission denied" file-error in Windows Reply-To: bug#10284 <10284@debbugs.gnu.org> Date: Thu, 11 Sep 2025 02:14:58 +0000 retitle 10284 23.2; "Renaming: permission denied" file-error in Windows reassign 10284 emacs,w32 submitter 10284 LynX <_LynX@bk.ru> severity 10284 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 12 15:44:25 2011 Received: (at submit) by debbugs.gnu.org; 12 Dec 2011 20:44:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RaCjX-0003Jq-IT for submit@debbugs.gnu.org; Mon, 12 Dec 2011 15:44:24 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <_LynX@bk.ru>) id 1RaCco-00039l-Pa for submit@debbugs.gnu.org; Mon, 12 Dec 2011 15:37:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <_LynX@bk.ru>) id 1RaCbb-0003J1-8m for submit@debbugs.gnu.org; Mon, 12 Dec 2011 15:36:12 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:43490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <_LynX@bk.ru>) id 1RaCbb-0003Ix-78 for submit@debbugs.gnu.org; Mon, 12 Dec 2011 15:36:11 -0500 Received: from eggs.gnu.org ([140.186.70.92]:45362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <_LynX@bk.ru>) id 1RaCba-0001pG-26 for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2011 15:36:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <_LynX@bk.ru>) id 1RaCbY-0003IN-M0 for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2011 15:36:10 -0500 Received: from smtp27.mail.ru ([94.100.176.180]:41409) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <_LynX@bk.ru>) id 1RaCbX-0003Hi-Ip for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2011 15:36:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Content-Transfer-Encoding:Content-Type:Subject:To:MIME-Version:From:Date:Message-ID; bh=8JvOeNZmQh2vFqp3IELpGTVvzC9MWP3SHnipwRLd0Fs=; b=s7iQjc74bH0bZQfkfuAlxUQX0U1SkTyq+RdeyVmAth1f2drwJxitPLvXbSkVUrpSL2L2uc0UwGLPgdqPgPxrz8VBbxzvJg4kKLhpOg4O/5ZRtcYGpNzzWCn2SvvLrWup; Received: from [109.200.244.220] (port=19474 helo=[109.200.244.220]) by smtp27.mail.ru with asmtp id 1RaCbU-00038Q-00 for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2011 00:36:04 +0400 Message-ID: <4EE6658A.1030602@bk.ru> Date: Mon, 12 Dec 2011 22:35:22 +0200 From: LynX <_LynX@bk.ru> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: 23.2; "Renaming: permission denied" file-error in Windows Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: Not detected X-Mras: Ok X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 12 Dec 2011 15:44:22 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) Hello, I found that dired in Windows does not provide you possibility to move a directory to a new location if this new location resides on a different logical disk. For instance you have two opened dired buffers: `c:\dir1' and `f:\dir2'. To move some files from `dir1' to `dir2' you can use "R", but if you try to move some directory from `dir1' to `dir2' you will get `Renaming: permission denied' error message. For more details and temporary workaround please refer to the emacs-devel mail list: http://lists.gnu.org/archive/html/emacs-devel/2011-12/msg00253.html Regards, LX In GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600) of 2010-05-08 on G41R2F1 Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/xpm/include' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: RUS value of $XMODIFIERS: nil locale-coding-system: cp1251 default enable-multibyte-characters: t Major mode: Fundamental Minor modes in effect: tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t blink-cursor-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: M-x r e p o r t - Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Making completion list... call-interactively: End of buffer [2 times] Load-path shadows: None found. Features: (shadow sort mail-extr message ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1 hex-util hashcash mail-utils emacsbug help-mode easymenu view tooltip ediff-hook vc-hooks lisp-float-type mwheel dos-w32 disp-table ls-lisp w32-win w32-vars tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process multi-tty emacs) From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 25 04:41:48 2011 Received: (at 10284) by debbugs.gnu.org; 25 Dec 2011 09:41:48 +0000 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 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 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 Date: Sun, 25 Dec 2011 04:39:18 -0500 Message-Id: From: Eli Zaretskii To: LynX <_LynX@bk.ru> In-reply-to: <4EF6D1CE.7020101@bk.ru> (message from LynX on Sun, 25 Dec 2011 09:33:34 +0200) Subject: Re: "Renaming: permission denied" file-error in Windows 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> X-Spam-Score: -6.6 (------) X-Debbugs-Envelope-To: 10284 Cc: 10284@debbugs.gnu.org, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) [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. From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 29 00:17:09 2011 Received: (at 10284) by debbugs.gnu.org; 29 Dec 2011 05:17:09 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rg8MT-0004RH-Rl for submit@debbugs.gnu.org; Thu, 29 Dec 2011 00:17:09 -0500 Received: from smtp15.mail.ru ([94.100.176.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <_LynX@bk.ru>) id 1Rfzcj-0006sd-HS for 10284@debbugs.gnu.org; Wed, 28 Dec 2011 14:57:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Subject:To:MIME-Version:From:Date:Message-ID; bh=HNpUUlwzaj26UPRBDaHry8MLgQJFfAfGjk9mLs9pJ6Y=; b=0UX5FaOQJaGVV2RnHObvqSF4LcIt91kswZAn5ltNNh61iovroFz+Yp/2eOGuSW7D2l6cbnzFwZDTxJX1kJdO48ECSzDOrcbzAfiJF7Nd8+ydOvUvyc021dwsyeZo7fed; Received: from [109.200.244.155] (port=23275) by smtp15.mail.ru with esmtpa (envelope-from <_LynX@bk.ru>) id 1Rfza2-0004sx-Ej for 10284@debbugs.gnu.org; Wed, 28 Dec 2011 23:54:30 +0400 Message-ID: <4EFB73C3.7070203@bk.ru> Date: Wed, 28 Dec 2011 21:53:39 +0200 From: LynX <_LynX@bk.ru> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 10284@debbugs.gnu.org Subject: Re: "Renaming: permission denied" file-error in Windows 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> In-Reply-To: Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 8bit X-Mru-NR: 1 X-Mru-UID: 10796556 X-Spam: Not detected X-Mras: Ok X-Mru-Karma: 0 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: 10284 X-Mailman-Approved-At: Thu, 29 Dec 2011 00:17:02 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.7 (---) Dear Eli, Thank you for your response. I just want to double check that I understood you right. > 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)? Regards, LX 25.12.2011 11:40, Eli Zaretskii пишет: >> Date: Sun, 25 Dec 2011 09:33:34 +0200 >> From: LynX<_LynX@bk.ru> >> Cc: eggert@cs.ucla.edu, emacs-devel@gnu.org >> >> Dear Eli, >> >> I've opened a bug report here: >> >> 10284: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10284 >> >> Here is the patch for this issue (it is done for the latest source >> package emacs-23.3b.tar.bz2): > > I've redirected this discussion to the bug tracker, > 10284@debbugs.gnu.org. > > Please respond there, not here. > > From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 29 01:20:52 2011 Received: (at 10284) by debbugs.gnu.org; 29 Dec 2011 06:20:52 +0000 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 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 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 Date: Thu, 29 Dec 2011 01:18:02 -0500 Message-Id: From: Eli Zaretskii To: LynX <_LynX@bk.ru> In-reply-to: <4EFB73C3.7070203@bk.ru> (message from LynX on Wed, 28 Dec 2011 21:53:39 +0200) Subject: Re: bug#10284: "Renaming: permission denied" file-error in Windows 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> X-Spam-Score: -6.6 (------) X-Debbugs-Envelope-To: 10284 Cc: 10284@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) > 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.) From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 30 14:35:20 2011 Received: (at 10284) by debbugs.gnu.org; 30 Dec 2011 19:35:21 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgiEa-00062t-Lg for submit@debbugs.gnu.org; Fri, 30 Dec 2011 14:35:20 -0500 Received: from smtp8.mail.ru ([94.100.176.53]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <_LynX@bk.ru>) id 1RgiEW-00062h-9b for 10284@debbugs.gnu.org; Fri, 30 Dec 2011 14:35:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Content-Type:In-Reply-To:References:Subject:To:MIME-Version:From:Date:Message-ID; bh=KdsIKEpbzgAS8ttNBPDE5pW1JiyB45dGolbg1z/5ano=; b=MWh8hmp43y5TybYscClIHcggosezx2V6OC0494N0QCs88vWea24w0OW0f2SQnoMc0QpzRWC56PYV2rSffAbZ3b9LPcqc3c6flYRfWdS/u5lftHPHd7F4IC/7GA0m3Tp8; Received: from [213.231.61.71] (port=1371) by smtp8.mail.ru with esmtpa (envelope-from <_LynX@bk.ru>) id 1RgiBd-0005DP-EU for 10284@debbugs.gnu.org; Fri, 30 Dec 2011 23:32:17 +0400 Message-ID: <4EFE118E.5040800@bk.ru> Date: Fri, 30 Dec 2011 21:31:26 +0200 From: LynX <_LynX@bk.ru> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 10284@debbugs.gnu.org Subject: Re: bug#10284: "Renaming: permission denied" file-error in Windows 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> In-Reply-To: Content-Type: multipart/mixed; boundary="------------030407080800030400040706" X-Mru-NR: 1 X-Mru-UID: 10796556 X-Spam: Not detected X-Mras: Ok X-Mru-Karma: 0 X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 10284 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) This is a multi-part message in MIME format. --------------030407080800030400040706 Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 8bit Hello Eli, Thank you for the clarification. Please review this patch. --- w32.c.orig 2011-11-26 05:20:20.000000000 +0200 +++ w32.c 2011-12-30 21:22:56.734375000 +0200 @@ -2857,6 +2857,8 @@ { BOOL result; char temp[MAX_PATH]; + int newname_dev; + int oldname_dev; /* MoveFile on Windows 95 doesn't correctly change the short file name alias in a number of circumstances (it is not easy to predict when @@ -2873,6 +2875,9 @@ strcpy (temp, map_w32_filename (oldname, NULL)); + /* volume_info is set indirectly by map_w32_filename */ + oldname_dev = volume_info.serialnum; + if (os_subtype == OS_WIN95) { char * o; @@ -2916,13 +2921,36 @@ all the permutations of shared or subst'd drives, etc.) */ newname = map_w32_filename (newname, NULL); + + /* volume_info is set indirectly by map_w32_filename */ + newname_dev = volume_info.serialnum; + result = rename (temp, newname); - if (result < 0 - && errno == EEXIST - && _chmod (newname, 0666) == 0 - && _unlink (newname) == 0) - result = rename (temp, newname); + if (result < 0) + { + + if (errno == EACCES + && newname_dev != oldname_dev) + { + /* 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. */ + DWORD attributes; + if ((attributes = GetFileAttributes(temp)) != -1 + && attributes & FILE_ATTRIBUTE_DIRECTORY) + errno = EXDEV; + } + else if (errno == EEXIST) + { + if (_chmod (newname, 0666) != 0) + return result; + if (_unlink (newname) != 0) + return result; + result = rename (temp, newname); + } + } return result; } I've added check whether it is a directory or not, and moved all this before the unlink operation. Regards, LX 29.12.2011 8:18, Eli Zaretskii пишет: >> 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.) > > --------------030407080800030400040706 Content-Type: text/plain; name="w32.c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="w32.c.patch" --- w32.c.orig 2011-11-26 05:20:20.000000000 +0200 +++ w32.c 2011-12-30 21:22:56.734375000 +0200 @@ -2857,6 +2857,8 @@ { BOOL result; char temp[MAX_PATH]; + int newname_dev; + int oldname_dev; /* MoveFile on Windows 95 doesn't correctly change the short file name alias in a number of circumstances (it is not easy to predict when @@ -2873,6 +2875,9 @@ strcpy (temp, map_w32_filename (oldname, NULL)); + /* volume_info is set indirectly by map_w32_filename */ + oldname_dev = volume_info.serialnum; + if (os_subtype == OS_WIN95) { char * o; @@ -2916,13 +2921,36 @@ all the permutations of shared or subst'd drives, etc.) */ newname = map_w32_filename (newname, NULL); + + /* volume_info is set indirectly by map_w32_filename */ + newname_dev = volume_info.serialnum; + result = rename (temp, newname); - if (result < 0 - && errno == EEXIST - && _chmod (newname, 0666) == 0 - && _unlink (newname) == 0) - result = rename (temp, newname); + if (result < 0) + { + + if (errno == EACCES + && newname_dev != oldname_dev) + { + /* 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. */ + DWORD attributes; + if ((attributes = GetFileAttributes(temp)) != -1 + && attributes & FILE_ATTRIBUTE_DIRECTORY) + errno = EXDEV; + } + else if (errno == EEXIST) + { + if (_chmod (newname, 0666) != 0) + return result; + if (_unlink (newname) != 0) + return result; + result = rename (temp, newname); + } + } return result; } --------------030407080800030400040706-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 30 15:27:21 2011 Received: (at 10284) by debbugs.gnu.org; 30 Dec 2011 20:27:21 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rgj2u-0007LI-Kq for submit@debbugs.gnu.org; Fri, 30 Dec 2011 15:27:20 -0500 Received: from mtaout20.012.net.il ([80.179.55.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rgj2q-0007L8-OR for 10284@debbugs.gnu.org; Fri, 30 Dec 2011 15:27:18 -0500 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LX100B009QBQK00@a-mtaout20.012.net.il> for 10284@debbugs.gnu.org; Fri, 30 Dec 2011 22:23:02 +0200 (IST) Received: from HOME-C4E4A596F7 ([77.126.18.76]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LX100A7D9YD6GQ0@a-mtaout20.012.net.il>; Fri, 30 Dec 2011 22:23:02 +0200 (IST) Date: Fri, 30 Dec 2011 22:23:04 +0200 From: Eli Zaretskii Subject: Re: bug#10284: "Renaming: permission denied" file-error in Windows In-reply-to: <4EFE118E.5040800@bk.ru> X-012-Sender: halo1@inter.net.il To: LynX <_LynX@bk.ru> Message-id: <83boqpu7vb.fsf@gnu.org> 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> <4EFE118E.5040800@bk.ru> X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 10284 Cc: 10284@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > Date: Fri, 30 Dec 2011 21:31:26 +0200 > From: LynX <_LynX@bk.ru> > > Please review this patch. Looks good, thanks. Did you test it with UNC filenames, btw? From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 30 16:39:31 2011 Received: (at 10284) by debbugs.gnu.org; 30 Dec 2011 21:39:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgkAl-0000iF-Ee for submit@debbugs.gnu.org; Fri, 30 Dec 2011 16:39:31 -0500 Received: from smtp28.mail.ru ([94.100.176.181]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <_LynX@bk.ru>) id 1RgkAi-0000i1-N7 for 10284@debbugs.gnu.org; Fri, 30 Dec 2011 16:39:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Subject:To:MIME-Version:From:Date:Message-ID; bh=cKZ/j+4KAxjNyPcORK6PFbHzPR2QvLyd4F0CEDz50j8=; b=Jq14BmLer+owT80rruxOU7EjnXqvUUiP7P8sEtxM+WgziuiTsa3AysHeGW6iGn0svqfnCKFe/vXkoAwlF3b6dx2A6Y5C3dzINSvUrAn0Gpy5IKVOUpkU+sfjyxFlrEh5; Received: from [109.200.224.150] (port=10108) by smtp28.mail.ru with esmtpa (envelope-from <_LynX@bk.ru>) id 1Rgk7p-0007Oa-QZ for 10284@debbugs.gnu.org; Sat, 31 Dec 2011 01:36:30 +0400 Message-ID: <4EFE2EAA.1010808@bk.ru> Date: Fri, 30 Dec 2011 23:35:38 +0200 From: LynX <_LynX@bk.ru> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 10284@debbugs.gnu.org Subject: Re: bug#10284: "Renaming: permission denied" file-error in Windows 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> <4EFE118E.5040800@bk.ru> <83boqpu7vb.fsf@gnu.org> In-Reply-To: <83boqpu7vb.fsf@gnu.org> Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit X-Mru-NR: 1 X-Mru-UID: 10796556 X-Spam: Not detected X-Mras: Ok X-Mru-Karma: 0 X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: 10284 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.3 (---) Dear Eli, > Did you test it with UNC filenames, btw? Nope, but I tried it now with Cyrillic names and it worked. If you asked this because of GetFileAttributes, I think that it is mapped somewhere to GetFileAttributesW (since when I tried GetFileAttributesA with Cyrillic names it failed :). Regards, LX From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 31 01:51:55 2011 Received: (at 10284) by debbugs.gnu.org; 31 Dec 2011 06:51:55 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgsnL-0005tv-HQ for submit@debbugs.gnu.org; Sat, 31 Dec 2011 01:51:55 -0500 Received: from mtaout22.012.net.il ([80.179.55.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgsnI-0005tk-LJ for 10284@debbugs.gnu.org; Sat, 31 Dec 2011 01:51:53 -0500 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0LX200I002HUS500@a-mtaout22.012.net.il> for 10284@debbugs.gnu.org; Sat, 31 Dec 2011 08:48:48 +0200 (IST) Received: from HOME-C4E4A596F7 ([77.126.18.76]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LX200D9K2XBPFW1@a-mtaout22.012.net.il>; Sat, 31 Dec 2011 08:48:48 +0200 (IST) Date: Sat, 31 Dec 2011 08:48:50 +0200 From: Eli Zaretskii Subject: Re: bug#10284: "Renaming: permission denied" file-error in Windows In-reply-to: <4EFE2EAA.1010808@bk.ru> X-012-Sender: halo1@inter.net.il To: LynX <_LynX@bk.ru> Message-id: <837h1dtewd.fsf@gnu.org> 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> <4EFE118E.5040800@bk.ru> <83boqpu7vb.fsf@gnu.org> <4EFE2EAA.1010808@bk.ru> X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 10284 Cc: 10284@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > Date: Fri, 30 Dec 2011 23:35:38 +0200 > From: LynX <_LynX@bk.ru> > > > Did you test it with UNC filenames, btw? > > Nope, but I tried it now with Cyrillic names and it worked. Thanks. But "UNC" doesn't mean "Unicode", it means "Universal Naming Convention", and refers to the \\server\share\foo style of file names on remote machines. > If you asked this because of GetFileAttributes, I think that it is > mapped somewhere to GetFileAttributesW (since when I tried > GetFileAttributesA with Cyrillic names it failed :). No, I was thinking about what volume_info.serialnum will give you for UNC filenames. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 06 15:50:37 2012 Received: (at 10284) by debbugs.gnu.org; 6 Jan 2012 20:50:38 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RjGkH-0001cG-53 for submit@debbugs.gnu.org; Fri, 06 Jan 2012 15:50:37 -0500 Received: from smtp14.mail.ru ([94.100.176.91]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from <_LynX@bk.ru>) id 1RjGkD-0001c7-Kg for 10284@debbugs.gnu.org; Fri, 06 Jan 2012 15:50:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Subject:To:MIME-Version:From:Date:Message-ID; bh=IjtgZu5wcqN486xEeEDHXWoLz5sXSSRdZu+BoGCNvCk=; b=HvW714vu7PFTt2H54WHrZDluhoG4ywHEKACFTaVtogDDHoZtKcYzyoh0ZDjdeGS/MxMGC+ddbc23oCZ9TnAY3h34AUvHKl0UORwHBaPmUqkQAXDXVhumSg1tLT/JLYNn; Received: from [109.200.236.14] (port=10392) by smtp14.mail.ru with esmtpa (envelope-from <_LynX@bk.ru>) id 1RjGgg-0005jI-Ku for 10284@debbugs.gnu.org; Sat, 07 Jan 2012 00:46:54 +0400 Message-ID: <4F075D88.8030901@bk.ru> Date: Fri, 06 Jan 2012 22:46:00 +0200 From: LynX <_LynX@bk.ru> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: 10284@debbugs.gnu.org Subject: Re: bug#10284: "Renaming: permission denied" file-error in Windows 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> <4EFE118E.5040800@bk.ru> <83boqpu7vb.fsf@gnu.org> <4EFE2EAA.1010808@bk.ru> <837h1dtewd.fsf@gnu.org> In-Reply-To: <837h1dtewd.fsf@gnu.org> Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit X-Mru-NR: 1 X-Mru-UID: 10796556 X-Spam: Not detected X-Mras: Ok X-Mru-Karma: 0 X-Spam-Score: -3.2 (---) X-Debbugs-Envelope-To: 10284 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.1 (---) Dear Eli, > Thanks. But "UNC" doesn't mean "Unicode", it means "Universal Naming > Convention", and refers to the \\server\share\foo style of file names > on remote machines. Sorry now I got it :) Today I tested it and it worked fine. I was able to move non-empty directory to remote shared directory (\\remote_host\shared) and then moved it back successfuly. Regards, LX From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 04:56:01 2012 Received: (at 10284-done) by debbugs.gnu.org; 7 Jan 2012 09:56:01 +0000 Received: from localhost ([127.0.0.1]:47738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RjT0L-0000B7-GC for submit@debbugs.gnu.org; Sat, 07 Jan 2012 04:56:01 -0500 Received: from mtaout21.012.net.il ([80.179.55.169]:36555) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RjT0I-0000Ae-BK for 10284-done@debbugs.gnu.org; Sat, 07 Jan 2012 04:56:00 -0500 Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0LXF00H00A29TB00@a-mtaout21.012.net.il> for 10284-done@debbugs.gnu.org; Sat, 07 Jan 2012 11:54:29 +0200 (IST) Received: from HOME-C4E4A596F7 ([84.229.156.26]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LXF00HXRA6SNL80@a-mtaout21.012.net.il>; Sat, 07 Jan 2012 11:54:29 +0200 (IST) Date: Sat, 07 Jan 2012 11:54:28 +0200 From: Eli Zaretskii Subject: Re: bug#10284: "Renaming: permission denied" file-error in Windows In-reply-to: <4F075D88.8030901@bk.ru> X-012-Sender: halo1@inter.net.il To: LynX <_LynX@bk.ru> Message-id: <8339brhm7f.fsf@gnu.org> 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> <4EFE118E.5040800@bk.ru> <83boqpu7vb.fsf@gnu.org> <4EFE2EAA.1010808@bk.ru> <837h1dtewd.fsf@gnu.org> <4F075D88.8030901@bk.ru> X-Spam-Score: -1.2 (-) X-Debbugs-Envelope-To: 10284-done Cc: 10284-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) > Date: Fri, 06 Jan 2012 22:46:00 +0200 > From: LynX <_LynX@bk.ru> > > > Thanks. But "UNC" doesn't mean "Unicode", it means "Universal Naming > > Convention", and refers to the \\server\share\foo style of file names > > on remote machines. > > Sorry now I got it :) > > Today I tested it and it worked fine. I was able to move non-empty > directory to remote shared directory (\\remote_host\shared) and then > moved it back successfuly. Thanks. I committed the changes for you (as trunk revision 106818), and I'm closing this bug. Note that this patch is as much as we can accept from you without legal papers, so if you want to continue contributing to Emacs, I encourage you to sign legal papers that assign copyright for your changes to the FSF. Thanks again for working on this. From unknown Wed Sep 10 19:14:58 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 04 Feb 2012 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator