From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#28792: 26.0.60; Deleting to a custom trash directory in Dired gives error Date: Thu, 12 Oct 2017 13:25:47 -0700 Organization: UCLA Computer Science Department Message-ID: <04f4ac98-93b4-7356-8251-304c3601fe86@cs.ucla.edu> References: <83zi8wld5l.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------538F153F9E30057A84FB7B42" X-Trace: blaine.gmane.org 1507839973 11567 195.159.176.226 (12 Oct 2017 20:26:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 12 Oct 2017 20:26:13 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 Cc: self@gkayaalp.com, 28792@debbugs.gnu.org To: Andreas Schwab , Kaushal Modi Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 12 22:26:09 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 1e2k3S-0002DK-85 for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Oct 2017 22:26:06 +0200 Original-Received: from localhost ([::1]:47100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2k3Z-0002Tw-Iq for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Oct 2017 16:26:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2k3R-0002Tq-N5 for bug-gnu-emacs@gnu.org; Thu, 12 Oct 2017 16:26:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2k3O-0006ds-Gs for bug-gnu-emacs@gnu.org; Thu, 12 Oct 2017 16:26:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55947) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2k3O-0006dB-C3 for bug-gnu-emacs@gnu.org; Thu, 12 Oct 2017 16:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e2k3N-0003bp-W7 for bug-gnu-emacs@gnu.org; Thu, 12 Oct 2017 16:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Oct 2017 20:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28792 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28792-submit@debbugs.gnu.org id=B28792.150783995913864 (code B ref 28792); Thu, 12 Oct 2017 20:26:01 +0000 Original-Received: (at 28792) by debbugs.gnu.org; 12 Oct 2017 20:25:59 +0000 Original-Received: from localhost ([127.0.0.1]:36395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2k3J-0003bX-VG for submit@debbugs.gnu.org; Thu, 12 Oct 2017 16:25:58 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:43604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2k3G-0003bG-Pu for 28792@debbugs.gnu.org; Thu, 12 Oct 2017 16:25:56 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C4429160E2F; Thu, 12 Oct 2017 13:25:48 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id yMTyAtNakyfA; Thu, 12 Oct 2017 13:25:48 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EB560160E4D; Thu, 12 Oct 2017 13:25:47 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cLWCZHQF1BXM; Thu, 12 Oct 2017 13:25:47 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id CEFBC160E2F; Thu, 12 Oct 2017 13:25:47 -0700 (PDT) In-Reply-To: Content-Language: en-US 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:138301 Archived-At: This is a multi-part message in MIME format. --------------538F153F9E30057A84FB7B42 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 10/12/2017 08:27 AM, Andreas Schwab wrote: > rename-file now refuses to copy directory across > file systems unless the target name ends in a slash. Thanks for the diagnosis. This is an unintended consequence of the race-condition patch for rename-file that I installed last month. I installed the attached patch into the emacs-26 branch to fix the bug. --------------538F153F9E30057A84FB7B42 Content-Type: text/x-patch; name="0001-Let-rename-file-rename-dirs-across-filesystems.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Let-rename-file-rename-dirs-across-filesystems.patch" >From 21df0eec6d056c88c7ffbd5a1c0f76661702d5cf Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 12 Oct 2017 13:08:53 -0700 Subject: [PATCH] Let rename-file rename dirs across filesystems Problem diagnosed by Andreas Schwab (Bug#28792#65). This fixes a bug that I introduced in 2017-09-10T22:39:24@eggert@cs.ucla.edu "Fix race with rename-file etc. with dir NEWNAME". * src/fileio.c (Frename_file): Copy a source directory across file system boundaries even if its name does not end in slash. --- src/fileio.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 4bbcec6f17..e57bf46015 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2260,7 +2260,7 @@ This is what happens in interactive use with M-x. */) (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists) { Lisp_Object handler; - Lisp_Object encoded_file, encoded_newname, symlink_target; + Lisp_Object encoded_file, encoded_newname; file = Fexpand_file_name (file, Qnil); @@ -2334,12 +2334,22 @@ This is what happens in interactive use with M-x. */) if (rename_errno != EXDEV) report_file_errno ("Renaming", list2 (file, newname), rename_errno); + struct stat file_st; bool dirp = !NILP (Fdirectory_name_p (file)); + if (!dirp) + { + if (lstat (SSDATA (encoded_file), &file_st) != 0) + report_file_error ("Renaming", list2 (file, newname)); + dirp = S_ISDIR (file_st.st_mode) != 0; + } if (dirp) call4 (Qcopy_directory, file, newname, Qt, Qnil); else { - symlink_target = Ffile_symlink_p (file); + Lisp_Object symlink_target + = (S_ISLNK (file_st.st_mode) + ? emacs_readlinkat (AT_FDCWD, SSDATA (encoded_file)) + : Qnil); if (!NILP (symlink_target)) Fmake_symbolic_link (symlink_target, newname, ok_if_already_exists); else -- 2.13.6 --------------538F153F9E30057A84FB7B42--