From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy Date: Wed, 22 Feb 2012 22:37:24 +0100 Message-ID: <87pqd6wnvv.fsf@gmail.com> References: <87mx9su32g.fsf@web.de> <87fwfjo24c.fsf@gmx.de> <87pqen76p4.fsf@gmail.com> <83fwfik92e.fsf@gnu.org> <87mx9q1sz7.fsf@gmail.com> <87vcodm8ns.fsf@gmx.de> <87pqekopb5.fsf@gmail.com> <87hazwoost.fsf@gmail.com> <87ty3w9639.fsf@gmx.de> <8762gckckt.fsf@gmail.com> <87pqek9269.fsf@gmx.de> <87r4z0yqfx.fsf@gmail.com> <871uqzn3bc.fsf@gmx.de> <871uqz651u.fsf@gmx.de> <87pqd89lh4.fsf@gmail.com> <87mx8b3nvb.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1329946727 24567 80.91.229.3 (22 Feb 2012 21:38:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 22 Feb 2012 21:38:47 +0000 (UTC) Cc: 10489@debbugs.gnu.org, Michael Albinus To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 22 22:38:45 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S0Jtb-00009U-Sj for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 Feb 2012 22:38:44 +0100 Original-Received: from localhost ([::1]:52668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0Jtb-0001ic-FE for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 Feb 2012 16:38:43 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:47019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0JtY-0001eb-7U for bug-gnu-emacs@gnu.org; Wed, 22 Feb 2012 16:38:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0JtW-0003kO-OR for bug-gnu-emacs@gnu.org; Wed, 22 Feb 2012 16:38:40 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47870) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0JtW-0003kF-Mn for bug-gnu-emacs@gnu.org; Wed, 22 Feb 2012 16:38:38 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1S0Jvq-0003Rd-5I for bug-gnu-emacs@gnu.org; Wed, 22 Feb 2012 16:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 22 Feb 2012 21:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10489 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 10489-submit@debbugs.gnu.org id=B10489.132994680613166 (code B ref 10489); Wed, 22 Feb 2012 21:41:01 +0000 Original-Received: (at 10489) by debbugs.gnu.org; 22 Feb 2012 21:40:06 +0000 Original-Received: from localhost ([127.0.0.1]:51493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S0Jut-0003QE-WC for submit@debbugs.gnu.org; Wed, 22 Feb 2012 16:40:05 -0500 Original-Received: from mail-ww0-f46.google.com ([74.125.82.46]:60600) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S0Jup-0003Pd-IW for 10489@debbugs.gnu.org; Wed, 22 Feb 2012 16:40:01 -0500 Original-Received: by wgbdt14 with SMTP id dt14so454263wgb.15 for <10489@debbugs.gnu.org>; Wed, 22 Feb 2012 13:37:29 -0800 (PST) Received-SPF: pass (google.com: domain of thierry.volpiatto@gmail.com designates 10.180.82.39 as permitted sender) client-ip=10.180.82.39; Authentication-Results: mr.google.com; spf=pass (google.com: domain of thierry.volpiatto@gmail.com designates 10.180.82.39 as permitted sender) smtp.mail=thierry.volpiatto@gmail.com; dkim=pass header.i=thierry.volpiatto@gmail.com Original-Received: from mr.google.com ([10.180.82.39]) by 10.180.82.39 with SMTP id f7mr76394wiy.19.1329946649596 (num_hops = 1); Wed, 22 Feb 2012 13:37:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=AqbrPYcxkPpFD9733qbVibO4KVZA6B0BDOlXEPKEYy0=; b=KEZM3Xejy1bVZZXUp44eyJk7agK04xWIkVFCPsHilox1TCn+n31FOPeNSabbxxpeRP E4aSSoOrbdcYE/ZAC4/rFiCUzjUn2QRvQKMwvPGI1R1eh8d3cbdJSaAuw5TGeQih5PEQ +vK+siU3ZBFLCChL23EpvbsbTYl3u2B9iRVIw= Original-Received: by 10.180.82.39 with SMTP id f7mr61365wiy.19.1329946649494; Wed, 22 Feb 2012 13:37:29 -0800 (PST) Original-Received: from thierry-MM061 (lbe83-2-78-243-104-167.fbx.proxad.net. [78.243.104.167]) by mx.google.com with ESMTPS id q2sm341941wiy.7.2012.02.22.13.37.26 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Feb 2012 13:37:28 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Tue, 21 Feb 2012 17:51:21 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:57112 Archived-At: Stefan Monnier writes: >>>> so what is the state of this bug and what do you plan for this? >>> >>>> As a reminder, we needed: >>> >>>> 1) A function to compare filenames locally. >>>> 2) A tramp handler for this function. >>>> 3) A function to check if file1 is subdir of file2, locally also. >>>> 4) A tramp handler for this one also? >>> >>>> We have more or less 1 and 3, need tramp handlers for them. >>> >>>> What else is needed? >>> >>> Just before we try and solve this problem the hard way: >>> I just tried: >>> >>> % ln -s erlang-otp erl >>> % cp -r erl/lib erlang-otp/lib/inviso/ > >> We have to check if "erlang-otp/lib/inviso/" is a subdir of "erl/lib" >> to resolve this, right? > > No, we just have to check if during the recursive copy we're trying to > read one of the directories we've just made. Ok, that is true for the solutions you propose below, but what's wrong with the solution I have proposed: Just checking if the destination directory is a subdirectory of the directory we want to copy. >>> So it seems that the coreutils guys have found it sufficient to detect >>> the inf-loop after the fact and interrupt the operation at that point >>> rather than to try and predict that the cp will loop and don't perform >>> it at all. >> Do we have to strictly follow this? > > No, it's just an alternative approach. The potential advantage is that > it does not require figuring out whether a file is within some > directory, it only requires checking actual equality between two > directories. If we do not have to follow this, I would prefer not starting copying stuff the user will have to remove afterward when he realize it was an error (i.e copying a directory on itself). > Another approach is to first get the complete list of files and only > copy them afterwards. This doesn't require any comparison at all and > completely avoids the risk of inf-loop. This may be slow isn't it? >>> It might be easier to get a solution that catches all cases that way: >>> remember the name and identity (inode/file-attributes/younameit) of >>> the top directory we create, >> "erl/lib"? > > No, we don't create erl/lib (it's the source instead), the top-level dir > we create is "erlang-otp/lib/inviso/lib". > >>> and whenever we're about to copy a directory of the same name, >> Not sure to fully understand this, do you mean "and whenever we're >> about to copy the CONTENTS of a directory of the same name?" > > In the recursive loop, the distinction between copying a directory and > copying its contents is not really relevant to this problem (the > recursive call says "copy foo and its contents"). -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997