emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Renaming: permission denied" file-error in Windows


From: LynX
Subject: Re: "Renaming: permission denied" file-error in Windows
Date: Sun, 25 Dec 2011 09:33:34 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

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):

--- w32.c.orig  2011-11-26 05:20:20.000000000 +0200
+++ w32.c       2011-12-25 09:22:37.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,31 @@
      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);
+      && 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;

   return result;
 }

Fix is done as you proposed:

Maybe to fix it in Windows we need to check rename error code not only
for EXDEV but for EACCES also.
No, we should modify sys_rename (in w32.c) to return EXDEV in these
cases.

I've tested it (Windows XP sp3) and was able to move the directories between different storage devices.

Regards,
LX

11.12.2011 23:31, Eli Zaretskii пишет:
Date: Sun, 11 Dec 2011 21:45:02 +0000
From: LynX<address@hidden>
CC: address@hidden, address@hidden

Thank you for you response.
If you don't mind I would like to try to fix it.
It just would take some time to prepare my environment to build Emacs.

Do I need to provide bug report in such case either?

It is better to do that, so that we have a record of the problem.

Thanks.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]