From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#27986: 26.0.50; `rename-file' can rename files without confirmation Date: Mon, 14 Aug 2017 20:22:10 +0300 Message-ID: <83k226gj3x.fsf@gnu.org> References: <83poc8tynu.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1502731396 19187 195.159.176.226 (14 Aug 2017 17:23:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 14 Aug 2017 17:23:16 +0000 (UTC) Cc: 27986@debbugs.gnu.org To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 14 19:23:12 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhJ51-0004VP-Mi for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Aug 2017 19:23:07 +0200 Original-Received: from localhost ([::1]:36723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhJ58-0007VM-4V for geb-bug-gnu-emacs@m.gmane.org; Mon, 14 Aug 2017 13:23:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhJ51-0007U6-Ik for bug-gnu-emacs@gnu.org; Mon, 14 Aug 2017 13:23:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhJ4w-0003qz-KQ for bug-gnu-emacs@gnu.org; Mon, 14 Aug 2017 13:23:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55571) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dhJ4w-0003qi-H6 for bug-gnu-emacs@gnu.org; Mon, 14 Aug 2017 13:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dhJ4v-0005SP-L9 for bug-gnu-emacs@gnu.org; Mon, 14 Aug 2017 13:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Aug 2017 17:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27986 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 27986-submit@debbugs.gnu.org id=B27986.150273134820969 (code B ref 27986); Mon, 14 Aug 2017 17:23:01 +0000 Original-Received: (at 27986) by debbugs.gnu.org; 14 Aug 2017 17:22:28 +0000 Original-Received: from localhost ([127.0.0.1]:36018 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhJ4N-0005S9-ON for submit@debbugs.gnu.org; Mon, 14 Aug 2017 13:22:27 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56491) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhJ4M-0005S3-1x for 27986@debbugs.gnu.org; Mon, 14 Aug 2017 13:22:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhJ4B-0003UK-VF for 27986@debbugs.gnu.org; Mon, 14 Aug 2017 13:22:20 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36949) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhJ4B-0003UE-Rc; Mon, 14 Aug 2017 13:22:15 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4832 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dhJ4B-0001C8-9s; Mon, 14 Aug 2017 13:22:15 -0400 In-reply-to: (message from Philipp Stephani on Mon, 14 Aug 2017 17:09:35 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:135754 Archived-At: > From: Philipp Stephani > 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.