This is the mail archive of the cygwin@cygwin.com 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]

RE: [PATCH] ls & "magic" cygdrive dir (was: RE: cygdrive stuff)


Hi Chuck,

> None of these are correct.  You should be looking in 
> /cygwin/winsup/cygwin/*.cc, not /newlib/*.  You probably want to take 
> a look at syscalls.cc or fhandler_*.cc or path.cc.
Found stat_worker() in syscalls.cc (which is called by _stat()).
opendir() and readdir() are both in dir.cc

I'll have a good look tomorow. What I'm thinking of doing for stat() is 
this: I let the stat() call run until the end (there's a done flag there 
that it jumps to, and there's only one other return, which is 
succesful). If it's not successful, I take a look whether the stat()-ed 
path is actually a magic dir, and if so, I report it as a dir. Like 
that, I don't do anything if stat() would figure it out by himself, and 
I can only report a magic dir as a directory.
There's some details I have to figure out before I actually do anything 
(like what the MALLOC_CHECK macro does, for example) but I think this 
should work.

As for opendir() and readdir(), I don't know what the problem is yet - 
opendir() calls stat() to see if it's a directory, so after fixing 
stat() it should think it's looking at a directory. As it's not real, it 
will fail when it starts requesting information to win32, and/or tries 
to open it with open(), so I'll probably have to hook in after that's 
failed (so I know it would fail), fill in the dirent structure. It looks 
like the cookie field (__d_cookie) is a nice place to hide that we're 
looking at the magic dir, but I'd have to make sure it's not used by 
anyone else first. As is, readdir() expects it to be __DIRENT_COOKIE and 
nothing else, but I'll be working on readdir() anyway. I don't expect 
anything else to use this field, but I have all the sources anyway, so 
I'll do a grep search to make sure. (If that's the case, I can make a 
__DIRENT_COOKIE and a __DIRENT_MAGICDIR_COOKIE, and have readdir() 
handle it accordingly.

Now it's three AM. I have a call to put in to Canada (where it's 9 PM) 
and a nap to take (tomorow, it'll be 7 AM again..)

If you have any thoughts about the above, feel free to share them :)

Greetz!

Ronald


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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