all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: 27986@debbugs.gnu.org
Subject: bug#27986: 26.0.50; `rename-file' can rename files without confirmation
Date: Mon, 14 Aug 2017 20:22:10 +0300	[thread overview]
Message-ID: <83k226gj3x.fsf@gnu.org> (raw)
In-Reply-To: <CAArVCkQH5xUfZ83xHnGTQ07Cm=4==KP8T2M24eO2+uT2bZADXQ@mail.gmail.com> (message from Philipp Stephani on Mon, 14 Aug 2017 17:09:35 +0000)

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Mon, 14 Aug 2017 17:09:35 +0000
> Cc: 27986@debbugs.gnu.org
> 
>  > Note how `rename-file' has silently overwritten `ß'. This is because on
>  > macOS, `ß' and `ẞ' are different file names, but Emacs treats them as
>  > equal. Probably the test for case-insensitive file names should be
>  > removed altogether
> 
>  Which one? there are two of them.
> 
> I guess all of them where correctness would depend on the outcome.

But then we lose a feature which just a few releases ago was deemed
valuable enough to have.

> As this example shows, there are cases where two case-insensitive filenames are considered equivalent by
> Emacs, but different by the actual filesystem. This is unavoidable, because the definition of "case-insensitive"
> changes all the time, both in Emacs and in the filesystems. Generally it's impossible to detect whether two
> filenames would refer to the same file without actually creating the file.

Wouldn't trying to rename it actually tell you that, by failing with EEXIST?
(On Windows, it simply succeeds and changes the letter-case silently,
but I understand that is not what happens on macOS.)

>  If the former,
>  then at least on MS-Windows we have a race anyway, because the
>  underlying system APIs are not atomic.
> 
> Wouldn't MoveFileExW with MOVE_FILE_REPLACE_EXISTING be atomic?

No, it isn't guaranteed to be atomic.  No documentation says that,
certainly not any official documentation.  If I had access to the
sources, I could have looked there, but I don't.  Failing that, my
assumption is that it isn't atomic, because meta-data of more than one
file needs to be touched in this case.

> Yes, I mean the functions described in section 2 of the man page. link(2) is a common markup for this.

My point was that GNU coding standards frown on use of such markup.

>  More to the point, how can this strategy work on a case-insensitive
>  filesystem? What am I missing?
> 
> IIUC link(2) + unlink(2) would, if successful, guarantee enough atomicity in the sense that the old file is now
> guaranteed to be the new file, and the call is guaranteed to fail if the new file already exists.

I actually think that if the old and the new name are equal but for
the letter-case, and the filesystem is case-insensitive, doing that
will delete the file, so you are left with nothing.

> I don't think anything can help with the case-changing problem; I
> think we just have to live with an occasional false positive signal
> in this case.

That'd be an unfortunate regression, IMO.  It isn't right for us to
back out changes we just introduced, which were considered important
when we did that.  We ought to find a solution that doesn't remove
this feature, not even on macOS.





  reply	other threads:[~2017-08-14 17:22 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-06 15:40 bug#27986: 26.0.50; `rename-file' can rename files without confirmation Philipp
2017-08-06 17:05 ` Eli Zaretskii
2017-08-14 17:09   ` Philipp Stephani
2017-08-14 17:22     ` Eli Zaretskii [this message]
2017-08-11  8:15 ` bug#27986: 26.0.50; 'rename-file' " Paul Eggert
2017-08-13 22:42   ` Paul Eggert
2017-08-14 15:40     ` Eli Zaretskii
2017-08-14 23:31       ` Paul Eggert
2017-08-15 16:04         ` Eli Zaretskii
2017-08-15 17:24           ` Paul Eggert
2017-08-15 17:42             ` Eli Zaretskii
2017-08-15 19:27               ` Paul Eggert
2017-08-16  2:36                 ` Eli Zaretskii
2017-08-16  5:06                   ` Paul Eggert
2017-08-16 14:21                     ` Eli Zaretskii
2017-08-16 15:15                       ` Paul Eggert
2017-08-16 16:06                         ` Eli Zaretskii
2017-08-16 17:19                           ` Paul Eggert
2017-08-16 17:30                             ` Eli Zaretskii
2017-08-16 18:06                               ` Glenn Morris
2017-08-16 22:31                               ` Stefan Monnier
2017-08-16 23:56                                 ` Paul Eggert
2017-08-17  0:04                                   ` Stefan Monnier
2017-08-19  6:54                                 ` Eli Zaretskii
2017-09-10 22:49                                   ` Paul Eggert
2017-09-11  6:07                                     ` Paul Eggert
2017-09-11 14:47                                       ` Eli Zaretskii
2017-09-11 16:45                                         ` Paul Eggert
2017-09-11 17:09                                           ` Eli Zaretskii
2017-09-11 17:25                                             ` Paul Eggert
2017-09-12  9:25                                       ` Michael Albinus
2017-08-13 23:48   ` Paul Eggert
2017-08-14 13:44     ` Ken Brown
2017-08-14 15:21       ` Eli Zaretskii
2017-08-14 15:34     ` Eli Zaretskii
2017-08-14 16:33       ` Eli Zaretskii
2017-08-14 16:58       ` Philipp Stephani
2017-08-14 17:04         ` Eli Zaretskii
2017-08-14 16:50     ` Philipp Stephani
2017-08-14 23:03       ` Paul Eggert
2017-08-15  1:19         ` Paul Eggert
2017-08-15  2:35         ` Eli Zaretskii
2017-08-15  7:00           ` Paul Eggert
2017-08-15 16:08             ` Eli Zaretskii
2017-08-16 19:33         ` Ken Brown
2017-08-19 21:30           ` Ken Brown
2017-08-19 21:37             ` Paul Eggert
2017-08-19 22:04               ` Ken Brown
2017-08-19 22:38                 ` Paul Eggert
2017-08-15 12:45 ` Andy Moreton
2017-08-15 16:18   ` Eli Zaretskii
2017-08-19 21:33 ` bug#27986: 26.0.50; 'rename-file' can rename files without Richard Stallman
2017-08-20  2:37   ` Eli Zaretskii
2017-08-25 20:33     ` John Wiegley
2017-08-26  7:30       ` 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

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

  git send-email \
    --in-reply-to=83k226gj3x.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=27986@debbugs.gnu.org \
    --cc=p.stephani2@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.