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#3353: rename-file being called on directories for cross-device rename, mostly during trashing... Date: Sat, 23 May 2009 00:10:48 +0100 Message-ID: <4A1730F8.7060708@harpegolden.net> Reply-To: David De La Harpe Golden , 3353@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1243034976 28081 80.91.229.12 (22 May 2009 23:29:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 May 2009 23:29:36 +0000 (UTC) To: submit@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 23 01:29:28 2009 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.50) id 1M7eB5-0008Qm-GW for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 May 2009 01:29:27 +0200 Original-Received: from localhost ([127.0.0.1]:55612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7eB4-0000D7-T6 for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 May 2009 19:29:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M7eB0-0000D2-A3 for bug-gnu-emacs@gnu.org; Fri, 22 May 2009 19:29:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M7eAu-0000Cq-Jd for bug-gnu-emacs@gnu.org; Fri, 22 May 2009 19:29:20 -0400 Original-Received: from [199.232.76.173] (port=53253 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7eAu-0000Cn-Cn for bug-gnu-emacs@gnu.org; Fri, 22 May 2009 19:29:16 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:33009) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M7eAt-0005sj-KT for bug-gnu-emacs@gnu.org; Fri, 22 May 2009 19:29:16 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n4MNTAqc006412; Fri, 22 May 2009 16:29:11 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n4MNK5Eb004392; Fri, 22 May 2009 16:20:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: David De La Harpe Golden Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 22 May 2009 23:20:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 3353 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12430338652972 (code B ref -1); Fri, 22 May 2009 23:20:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 22 May 2009 23:11:05 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from harpegolden.net (harpegolden.net [65.99.215.13]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n4MNAxgO002944 for ; Fri, 22 May 2009 16:11:00 -0700 Original-Received: from [87.198.54.59] (87-198-54-59.ptr.magnet.ie [87.198.54.59]) (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 D4AE88274 for ; Sat, 23 May 2009 00:10:58 +0100 (IST) User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Fri, 22 May 2009 19:29:20 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list 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:28093 Archived-At: Sorry about timing, first time I had to investigate - not sure this is release-critical - haven't proved it can really cause data loss, but it's at least surprising. I don't really use trashing myself, but noticed something was acting funny a while back: On a gnu+linux or other unix-like system: To replicate, you'll need two distinct mounted filesystems - I'll assume /home and /tmp as they're often separate filesystems Set delete-by-moving-to-trash non-nil Now both delete-file and delete-directory will call move-file-to-trash to do their deletion. Point your trash-directory to a subdir on one filesystem - the default ~/.Trash/ may well be fine. Make a directory on another filesystem, say mkdir /tmp/uhoh/ Now try to M-x delete-directory /tmp/uhoh/ Get an error: Non-regular file: is a directory, /tmp/uhoh ... But of course you know it's a directory, and you are now puzzled as to why it didn't delete. Do the same with delete-by-moving-to-trash turned off, and the directory will be deleted as one would expect. This is happening because move-file-to-trash is calling rename-file with the directory name, and then rename-file is blindly trying to copy-file the directory if the C-level rename() fails with EXDEV (around line 2269 in fileio.c) as it tries to emulate a rename for the regular file case. Some possible paths to addressing this issue (non-exhaustive...): 1. have move-file-to-trash check if the file is a directory before trying to rename-file it. The issue here is rename-file actually works fine on directories as-is so long as you don't try to rename them across filesystems. 2. make rename-file not blindly copy-file directories but throw an error about renaming directories cross-device not being supported on the platform. That might be "good enough" as a placeholder for the 23.1 release, would at least be less confusing than the "Non-regular file: is a directory" error. 3. make rename-file not blindly copy-file directories but work more like shell "mv". Right now it acts a bit like mv for regular files (emulates move with the problematic copy and delete), but like C-level rename() for directories (bombs out...) (3a. Or make a separate rename-directory that move-file-to-trash can call for directories...) 4. make copy-file do something for directories other than simply noticing it's a directory and giving up, like shell "cp -r". (4a. Or make a separate copy-directory that rename-file (or 3a's rename-directory) could call underneath)