cygdrive stuff
Ronald Landheer
info@rlsystems.net
Fri Sep 21 14:48:00 GMT 2001
Hello Chris, Salvador /et al/.
> On Wed, Sep 19, 2001 at 04:11:52PM -0300, salvador wrote:
>> 1) "ls -la /" doesn't show any cygdrive directory. Note it could
>> be solved in the same way UNIX solves the /proc stuff, just mounting
>> over an existent directory a fake one.
>> 2) "ls -la /cygdrive" doesn't work.
> Correct.
> If you'd like to correct this, patches will be, as always,
> gratefully accepted.
I saw this, it itched me, so I'm attaching a patch :)
The patch I'm attaching is against the source 'ls.c' as found in
fileutils-4.1-1. It introduces three methods, of which one is called:
ls-cygwin-loop(). It is called whenever needed.
I've *only* tested this on a Win98 platform, but I don't think NT
changes anything in this case (I don't have any NT platforms here, so I
can't test them).
Here's how it works:
$ ls -la /
(..)
?--------- 0 0 Sigma 0 Jan 1 1970 cygdrive
(..)
Note it only shows you that cygdrive exists. As there is no "magic dir"
filetype, and it's not a real directory, I'm not showing it as one. My
patch only does anything when there *is* no real directory - if it comes
through a stat() call, it is not handled.
$ ls -la /cygdrive/
?--------- 0 0 Sigma 0 Jan 1 1970 c
?--------- 0 0 Sigma 0 Jan 1 1970 d
?--------- 0 0 Sigma 0 Jan 1 1970 p
?--------- 0 0 Sigma 0 Jan 1 1970 u
Note that 'ls -la /cygdrive' *only* shows:
?--------- 0 0 Sigma 0 Jan 1 1970 cygdrive
The patch works regardless of the cygdrive setting, but does
(regrettably) not show the mounted drives if the cygdrive setting is
'/' and -an 'ls -la /' is done. I guess I should fix this, but the
problem is that the mounted drives come through a stat() call as a
directory, so I don't know whether or not they're really there -
ideas would help.
Everything where displaying etc. is concerned is handled by the old code
- my code only adds stuff to the list and does so conservatively (so it
does not, for example, show the /usr/bin mount when an ls -la /usr is
done, unless the directory is really there, in which case ls would show
it anyway. (This is to avoid duplicates in the file list).
I lifted some code from mount - code used to see what mounts exist, and
what the cygdrive prefix is.. I've surrounded those by copyright notices
attributing it to mount & Cygnus. The rest is my own (but I'm quite
willing to sign it over, if it's significant enough for any signatures:
I'm no lawyer, so I'm being conservative - this, ofcourse, only if it
proves useful enough to apply to ls..).
All code is surrounded by the magic __CYGWIN__ ifdefs - so no other
platforms should be affected at all. (However, I don't know how MinGW32
handles this, or how this goes along with the -mno-cygwin flag)
I hope it's helpful (and bug-free).
Greetz!
Ronald
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ls.c.diff
Type: text/x-diff
Size: 11156 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20010921/876d4d4d/attachment.bin>
More information about the Cygwin
mailing list