unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: LynX <_LynX@bk.ru>
Cc: 10284@debbugs.gnu.org, eggert@cs.ucla.edu
Subject: bug#10284: "Renaming: permission denied" file-error in Windows
Date: Sun, 25 Dec 2011 04:39:18 -0500	[thread overview]
Message-ID: <E1RekY2-0003bL-89@fencepost.gnu.org> (raw)
In-Reply-To: <4EF6D1CE.7020101@bk.ru> (message from LynX on Sun, 25 Dec 2011 09:33:34 +0200)

[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.





       reply	other threads:[~2011-12-25  9:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4EE3F66D.2050003@bk.ru>
     [not found] ` <83vcpnllo3.fsf@gnu.org>
     [not found]   ` <4EE46AA1.9010700@cs.ucla.edu>
     [not found]     ` <E1RZisW-0000Ok-0C@fencepost.gnu.org>
     [not found]       ` <4EE504C3.3090701@bk.ru>
     [not found]         ` <83obvfkmt6.fsf@gnu.org>
     [not found]           ` <4EE5245E.3090803@bk.ru>
     [not found]             ` <83liqilrs0.fsf@gnu.org>
     [not found]               ` <4EF6D1CE.7020101@bk.ru>
2011-12-25  9:39                 ` Eli Zaretskii [this message]
     [not found]                 ` <E1RekZY-0003jE-FO@fencepost.gnu.org>
2011-12-28 19:53                   ` bug#10284: "Renaming: permission denied" file-error in Windows LynX
2011-12-29  6:18                     ` Eli Zaretskii
2011-12-30 19:31                       ` LynX
2011-12-30 20:23                         ` Eli Zaretskii
2011-12-30 21:35                           ` LynX
2011-12-31  6:48                             ` Eli Zaretskii
2012-01-06 20:46                               ` LynX
2012-01-07  9:54                                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1RekY2-0003bL-89@fencepost.gnu.org \
    --to=eliz@gnu.org \
    --cc=10284@debbugs.gnu.org \
    --cc=_LynX@bk.ru \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).