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: Tue, 21 Feb 2012 21:58:16 +0100 Message-ID: <87mx8b3nvb.fsf@gmail.com> References: <87mx9su32g.fsf@web.de> <878vlbljnc.fsf@gmx.de> <8739bj8mu1.fsf@gmail.com> <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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1329857936 22310 80.91.229.3 (21 Feb 2012 20:58:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 21 Feb 2012 20:58:56 +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 Tue Feb 21 21:58:54 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 1RzwnW-0003kf-2p for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Feb 2012 21:58:54 +0100 Original-Received: from localhost ([::1]:40985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzwnV-0000L1-6s for geb-bug-gnu-emacs@m.gmane.org; Tue, 21 Feb 2012 15:58:53 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzwnQ-0000G3-0L for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2012 15:58:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzwnL-0006Ca-Th for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2012 15:58:47 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzwnL-0006CW-Rw for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2012 15:58:43 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1RzwpZ-0003ZG-RB for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2012 16:01:01 -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: Tue, 21 Feb 2012 21:01: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.132985805413701 (code B ref 10489); Tue, 21 Feb 2012 21:01:01 +0000 Original-Received: (at 10489) by debbugs.gnu.org; 21 Feb 2012 21:00:54 +0000 Original-Received: from localhost ([127.0.0.1]:49243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RzwpO-0003Yq-NG for submit@debbugs.gnu.org; Tue, 21 Feb 2012 16:00:54 -0500 Original-Received: from mail-we0-f172.google.com ([74.125.82.172]:44892) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RzwpJ-0003YY-2s for 10489@debbugs.gnu.org; Tue, 21 Feb 2012 16:00:49 -0500 Original-Received: by werg1 with SMTP id g1so3159942wer.3 for <10489@debbugs.gnu.org>; Tue, 21 Feb 2012 12:58:21 -0800 (PST) Received-SPF: pass (google.com: domain of thierry.volpiatto@gmail.com designates 10.216.138.195 as permitted sender) client-ip=10.216.138.195; Authentication-Results: mr.google.com; spf=pass (google.com: domain of thierry.volpiatto@gmail.com designates 10.216.138.195 as permitted sender) smtp.mail=thierry.volpiatto@gmail.com; dkim=pass header.i=thierry.volpiatto@gmail.com Original-Received: from mr.google.com ([10.216.138.195]) by 10.216.138.195 with SMTP id a45mr7480149wej.25.1329857901066 (num_hops = 1); Tue, 21 Feb 2012 12:58:21 -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:content-transfer-encoding; bh=/ybBMn8lk5FKsSk2/5VLoyqdxKbfZjQhDxITeSATvRQ=; b=csATgA6Gzqzh/G3/FGOsZ9HV8CCgF++KCMwkVYsPQG5T1ogZuydhrVb8NzUNg1/+1N HyO/93VzgAUO0TuA2xplIIRhhdjDnpRwiakCu/JETWIXzedGpnIvG4UqnmKenFVSUBCK p6wUZqyBY3ABJvdY+/10KVX/wZvvukOvl1hGk= Original-Received: by 10.216.138.195 with SMTP id a45mr6232555wej.25.1329857900985; Tue, 21 Feb 2012 12:58:20 -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 gf3sm23484260wib.6.2012.02.21.12.58.18 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Feb 2012 12:58:20 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Tue, 21 Feb 2012 12:59:16 -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:57050 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? The following function should work: --8<---------------cut here---------------start------------->8--- (defun file-subdir-of-p (file1 file2) "Check if FILE1 is a subdirectory of FILE2 on current filesystem. If directory FILE1 is the same than directory FILE2, return non--nil." (when (and (not (or (file-remote-p file1) (file-remote-p file2))) (not (string=3D file1 "/")) (file-directory-p file1) (file-directory-p file2)) (or (string=3D file2 "/") (loop with f1 =3D (expand-file-name (file-truename file1)) with f2 =3D (expand-file-name (file-truename file2)) with ls1 =3D (split-string f1 "/" t) with ls2 =3D (split-string f2 "/" t) for p =3D (string-match "^/" f1) for i in ls1 for j in ls2 when (string=3D i j) concat (if p (concat "/" i) (concat i "/")) into root finally return (equal (file-attributes (file-truename root)) (file-attributes f2)))))) --8<---------------cut here---------------end--------------->8--- Can you try? (file-subdir-of-p "erlang-otp/lib/inviso/" "erl/lib") > on my Debian system, and it told me "cp: impossible de cr=C3=A9er un > r=C3=A9pertoire (=C2=AB=C2=A0erl/lib=C2=A0=C2=BB) dans lui-m=C3=AAme (=C2= =AB=C2=A0erlang-otp/lib/inviso/lib=C2=A0=C2=BB)", > but note that it only told me so *after* performing the copy. > I.e. it only detected the problem when trying to make > erlang-otp/lib/inviso/lib/inviso/lib > > 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? > 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"? > 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?" > check whether it happens to have the same identity, in which case > we've hit an inf-loop. --=20 Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997=20