From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7958 invoked by alias); 14 Jan 2013 21:37:19 -0000 Received: (qmail 7730 invoked by uid 22791); 14 Jan 2013 21:37:17 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_NO,RP_MATCHES_RCVD,SPF_NEUTRAL X-Spam-Check-By: sourceware.org Received: from bureau85.ns.utoronto.ca (HELO bureau85.ns.utoronto.ca) (128.100.132.185) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jan 2013 21:37:11 +0000 Received: from [142.1.102.176] (dhcphost-ic176.utsc.utoronto.ca [142.1.102.176]) (authenticated bits=0) by bureau85.ns.utoronto.ca (8.13.8/8.13.8) with ESMTP id r0ELb9lE028645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 14 Jan 2013 16:37:10 -0500 Message-ID: <50F47A8B.5050001@cs.utoronto.ca> Date: Mon, 14 Jan 2013 21:37:00 -0000 From: Ryan Johnson User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: stat() and tilde prefix (was bad bash tab completion) References: <5024B4D4.6080409@shaddybaddah.name> <50F395D5.4050201@shaddybaddah.name> <20130114061747.GB16739@ednor.casa.cgf.cx> <20130114100002.GA22039@calimero.vinschen.de> <50F417F9.8040108@shaddybaddah.name> <20130114161307.GB8617@calimero.vinschen.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2013-01/txt/msg00194.txt.bz2 On 14/01/2013 3:24 PM, Stephan Mueller wrote: > Perhaps (as you may well have already considered): > > - replace the path prefix by the mount point first? (this may be naïve > on my part, but it's not clear to me that .. early in a path should be able > to influence which mount point is substituted) If I mount something at /foo/bar/baz, then /foo/bar/baz/../../blah definitely shouldn't end up inside baz. > - test directory existence of the component preceding .. before collapsing > (in the example above) b/.. to nothing. > - trust that for a/b3/b2/b/../../../c, the existence test of a/b3/b2/b > before collapsing b/.. to nothing implies existence of b2 and b3 so no > further tests are needed for 'runs' of .. components with enough > components before them > > Understood that this is still going to cause a slowdown because paths with > .. are not uncommon, but it would reduce the number of additional > existence checks from one-per-path-component to one-per-run-of-.., > which means none in the case of paths without .. in them. The rest seems totally reasonable to me, FWIW. I wouldn't put it past a Makefile (esp. one generated by autotools) or a gcc header search path to generate paths like: /a/b/c/d/../e/../f/../../../g/h (which resolves to a/g/h, if I counted dots correctly). Even then, though, it's "only" three checks to achieve posix-compliant behavior. Ryan -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple