This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Check for existence of the path before processing '..'


Hi Ferdin,

On Jun 11 17:08, Fedin Pavel wrote:
>  Hello!
> 
>  Some time ago i reported ability to access things like
> "/usr/nonexistent/..bin". I still had this problem and i tried my hands on
> fixing it.
>  The patch works by checking the actual existence of the path before
> removing the last component from it. For performance reasons, only one check
> is done for things like "../..". Because, obviously, if "/foo/bar/baz"
> exists, then "/foo/bar" exists too. Also, the check is done only after some
> components have been added to the path. So, for example, current directory
> (obtained when processing relative paths), will not be checked.
>  I tried to add a similar test also to normalize_win32_path() function,
> however this broke things like "cd /usr/src/..". For some reason, a POSIX
> version of the path (but with reversed slashes) is passed to this routine
> when expanding mount points, so, consequently, test for "\usr\src" using
> GetFileType() fails.
>  I think it's ok, at least POSIX paths now behave in POSIX way. I have
> tested against performance, there is some loss (~0.2 seconds), but only for
> referencing '..'.

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.

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 mean, this tiny code snippet can't take 0.2 secs per single call,
right?


Corinna


> --
> 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


-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]