From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David De La Harpe Golden Newsgroups: gmane.emacs.bugs Subject: bug#5496: xdev rename-file of symlinks-to-directories broken Date: Sat, 30 Jan 2010 02:15:05 +0000 Message-ID: <4B639629.90600@harpegolden.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090608020508050500050309" X-Trace: ger.gmane.org 1264818989 31359 80.91.229.12 (30 Jan 2010 02:36:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 Jan 2010 02:36:29 +0000 (UTC) To: 5496@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 30 03:36:26 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Nb3BT-0003VC-Sr for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Jan 2010 03:36:24 +0100 Original-Received: from localhost ([127.0.0.1]:44719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nb3BL-0005jq-Lw for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Jan 2010 21:35:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nb3BG-0005jl-R2 for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2010 21:35:26 -0500 Original-Received: from [199.232.76.173] (port=39277 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nb3BG-0005jd-FL for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2010 21:35:26 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nb3BF-0006WJ-1r for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2010 21:35:25 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53697) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Nb3B9-0006VF-E6 for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2010 21:35:24 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Nb2sT-00077b-Uc; Fri, 29 Jan 2010 21:16:01 -0500 X-Loop: bug-gnu-emacs@gnu.org Resent-From: David De La Harpe Golden Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Jan 2010 02:16:01 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-Emacs-PR-Message: report 5496 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.126481772527180 (code B ref -1); Sat, 30 Jan 2010 02:16:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Jan 2010 02:15:25 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nb2rs-00074K-AN for submit@debbugs.gnu.org; Fri, 29 Jan 2010 21:15:24 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nb2rq-00073n-6V for submit@debbugs.gnu.org; Fri, 29 Jan 2010 21:15:22 -0500 Original-Received: from mail.gnu.org ([199.232.76.166]:34546 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nb2rl-0006sB-VC for submit@debbugs.gnu.org; Fri, 29 Jan 2010 21:15:18 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nb2rk-00051W-Mq for submit@debbugs.gnu.org; Fri, 29 Jan 2010 21:15:17 -0500 Original-Received: from lists.gnu.org ([199.232.76.165]:54716) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Nb2rk-00051K-Er for submit@debbugs.gnu.org; Fri, 29 Jan 2010 21:15:16 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nb2rj-0004mX-Vk for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2010 21:15:16 -0500 Original-Received: from [199.232.76.173] (port=52471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nb2ri-0004mN-K9 for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2010 21:15:14 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nb2rg-00050y-St for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2010 21:15:14 -0500 Original-Received: from harpegolden.net ([65.99.215.13]:52018) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nb2rg-00050k-Gn for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2010 21:15:12 -0500 Original-Received: from [87.198.47.232] (87-198-47-232.ptr.magnet.ie [87.198.47.232]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "David De La Harpe Golden", Issuer "David De La Harpe Golden Personal CA rev 3" (verified OK)) by harpegolden.net (Postfix) with ESMTP id CC54A8A63 for ; Sat, 30 Jan 2010 02:15:07 +0000 (GMT) User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 29 Jan 2010 21:16:01 -0500 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:34810 Archived-At: This is a multi-part message in MIME format. --------------090608020508050500050309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit So, file-directory-p returns non-nil for symlinks to directories, so delete-directory now (i.e. following #5436/#3353) gets incorrectly called in rename-file if you try to rename a symlink-to-a-directory to a location on another device. The copy-directory bit is already guarded appropriately, but not the delete-directory bit. delete-directory at least then fails rather than following the symlink and then recursively deleting. However, the result a user would no doubt expect is for just the symlink to be renamed. e.g. /tmp and /home different filesystems mkdir /home/david/foo cd /tmp mkdir bar ln -s bar baz ; in emacs (rename-file "/tmp/baz" "/home/david/foo") result: baz symlink to a "bar" in /home/david/foo - consistent with shell mv behaviour. Unfortunately, /tmp/baz won't be removed properly without attached tiny patch. --------------090608020508050500050309 Content-Type: text/x-patch; name="symlink_dir_rename_r1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="symlink_dir_rename_r1.diff" === modified file 'src/fileio.c' --- src/fileio.c 2010-01-28 17:47:05 +0000 +++ src/fileio.c 2010-01-30 01:50:33 +0000 @@ -2295,17 +2295,21 @@ /* We have already prompted if it was an integer, so don't have copy-file prompt again. */ Fcopy_file (file, newname, NILP (ok_if_already_exists) ? Qnil : Qt, Qt, Qt); count = SPECPDL_INDEX (); specbind (Qdelete_by_moving_to_trash, Qnil); - if (!NILP (Ffile_directory_p (file))) + if ( +#ifdef S_IFLNK + (NILP (symlink_target)) && +#endif + (!NILP (Ffile_directory_p (file)))) call2 (Qdelete_directory, file, Qt); else Fdelete_file (file); unbind_to (count, Qnil); } else report_file_error ("Renaming", list2 (file, newname)); } --------------090608020508050500050309--