X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=sknPRmqJEFguhVpho5hl8fhH1bOinP/n9p1t/FmqnV0 VW2jdA+ujto+swSWqRBRqEUtWL2W5I2K33yG0R4VMNkHwY0iSh5sEo50ua7BbWId 27DY+BuhLRTtn+6J1ZtrHgJTj6apd35/Gyn5xDtlLu6He9QWo4EzjzZhW0cpRJrg = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding; s=default; bh=37CIn6oGGD2+HiNFsaJf5Pn9j48=; b=FV+O9Hv3rnOkd+haO LrgLP1zT3kqKSHH8lErjd1/t2BJjwNOu96MQ/xVsrOdbpUxy6kaO/lMyP3baYXcL //EZ9w3trACzSyHK1Gog1vQq+crgtGWYbHPFMZbPLQdJFd4KSzSQshO0ErJhcAXI mSI3fJT1qCQoRcWY64lDfHmbSU= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.1 From: Fedin Pavel

To: cygwin AT cygwin DOT com References: <001401ce66a4$bb9029a0$32b07ce0$%fedin AT samsung DOT com> <20130611134807 DOT GG23332 AT calimero DOT vinschen DOT de> In-reply-to: <20130611134807.GG23332@calimero.vinschen.de> Subject: RE: [PATCH] Check for existence of the path before processing '..' Date: Thu, 13 Jun 2013 10:10:29 +0400 Message-id: <001301ce67fc$b4c19c90$1e44d5b0$%fedin@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id r5D6Alak016647 Hello! Sorry for delayed replies, at home i'm not subscribed to Cygwin ML, and in Russia we had a holiday yesterday. > Thanks for the patch. The idea sounds good, and I think it's the right > thing to do *not* to add this to normalize_win32_path, because the .. > semantics on WINdows are so that a .. is allowed even if the parent > doesn't exist. Yes, i agree. After all, POSIX rules apply to POSIX paths. And having Win32 paths in POSIX environment is kind of supernatural. :) > I didn't test your patch so far, but I'm a bit puzzled about your > performance claim: ~0.2 secs compared to what? What's your test case? I don't remember exactly, but i've done something like 'time ls -l ../bin' after cd'ing to /usr/src. > I mean, this tiny code snippet can't take 0.2 secs per single call, Yes, but: 1. From strace it seems that 'ls -l' fstat()s every file with file name appended to the given path. And each file gets '..' in its path. 2. Path conversion implies reading mount tables, symlinks, etc. I tried to imagine how this could be optimized, but found no simple solution. Because in general case this should also work for things like '/mnt/drive1/../symlink2/../drive3', across all mounts and symlinks. So, this solution is kind of balance between performance and simplicity. Actually, this even can be optimized by implementing a part-by-part path conversion, for example (imagine we get /usr/src/../bin as argument): 1. Start conversion until we meet '..'. Remember this place. 2. Convert '/usr/src' to Windows format, get 'C:\cygwin64\usr\src'. 3. Check for existence. 4. Step one component back in Win32 path, get 'C:\cygwin64\usr'. 5. Proceed with conversion from the point remembered in (1), the part of path is already converted and checked, we don't need to re-convert it. But this approach would really require total overhaul of all the path handling which is difficult. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia -- 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