public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: [PATCH] ls & "magic" cygdrive dir (was: RE: cygdrive stuff)
@ 2001-09-24 13:47 Li-Kai Liu
  0 siblings, 0 replies; 33+ messages in thread
From: Li-Kai Liu @ 2001-09-24 13:47 UTC (permalink / raw)
  To: cygwin

 >
 >
 >>I don't want to define special requirements here.  I'm just thinking
 >>that a file system fhandler like /dev should list the real files
 >>(if they exist) _and_ the virtual devices.  I don't think that's
 >>a requirement for a /cygdrive fhandler or a /registry fhandler.
 >>They could but they don't have to.
 >>
 >In the case of both /cygdrive and /registry, I simply wouldn't allow the
 >existance of real files - though Win32 will mess that up, ofcourse.
 >
fhandlers only handle files, but they don't handle directories.
directory enumeration is hard coded in the opendir/readdir calls in
path.cc ...

perhaps we should abstract the implementation of those two calls the
same way as we abstracted fhandlers. say, we'll call it either dhandlers
(directory handlers) or mhandlers (mount handlers). in this setup, the
mount table (in registry) would specify the type of mount (eg, the
handler). i would advocate having dhandlers/mhandlers borrowing the same
design as fhandlers.

first of all, do you people like calling it dhandlers better or
mhandlers better?

liulk




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

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: [PATCH] ls & "magic" cygdrive dir (was: RE: cygdrive stuff)
@ 2001-09-23 20:04 Robert Collins
  2001-09-24  2:18 ` Corinna Vinschen
  2001-09-24  4:01 ` Ronald Landheer
  0 siblings, 2 replies; 33+ messages in thread
From: Robert Collins @ 2001-09-23 20:04 UTC (permalink / raw)
  To: Ronald Landheer; +Cc: cygwin

> -----Original Message-----
> From: Ronald Landheer [ mailto:info@rlsystems.net ]
> Sent: Monday, September 24, 2001 11:05 AM
> To: Charles Wilson
> Cc: Robert Collins; cygwin@cygwin.com
> Subject: 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.

I have some code in my sandbox to allow mounting of aribtrary
filesystems, that I put together for UMSDOS support. Unfortuneately I
hit a serious time constraint, as this was working.

I mention this because supporting stat() and readdir() is obviously
_part_ of that. The way I tackled it was to have the handler of the
mount point listed as well as the mount point in the registry. This then
was automatically transferred to the correct code in cygwin when a
non-win32 backed filesystem was encountered. By pulling in that code
base, the magic dir stuff will become a normal case, rather than a
special case. (I.E. we mount a cygdrive fhandler at /cygdrive, a devlist
fhandler at /dev (equivalent to the linux devfs), and we're done.

There will still be _one_ _optional_ special case, and that is adding a
mounted directory to the directory listing returned from the level
above. (ie to get cygdrive included in the listing for /).

I'm not adamant that this is the right approach, but I thought that you
might like to review it as an alternative (that also adds neat
capabilities, like mounting a registry filesystem without special case
code).

I can extract the mount aspects of my current code tonight, and will
send to cygwin-patches (simply FYI). You can then choose whether to
build on that, or start from scratch.

The TODO on my list to have a minimum production patch would be
something like:
* copy the linux semantics for the mount userspace calls (I rolled my
own variation to which cgf said "if you must change this, copy linux" :]
).
* create the cygdrive fhandler class.
* create the devfs fhandler class.
* Alter setup.exe to add the new default mount point registry entries
(for /cygdrive and /dev).

In a nutshell the code I'll send in handles the detection and
redirection of the io call to the correct arbitrary fhandler type, and
then they have to implement the logic for opendir/readdir/stat as
appropriate.

This is very low on my list of things to do, which is why I haven't
progressed it.

If you choose to take this approach, I offer to do the setup.exe change
once the rest is ready, to save you learning the setup.exe codebase -
which I already know quite well :].

Rob

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

^ permalink raw reply	[flat|nested] 33+ messages in thread
[parent not found: <0c2601c14475$5d9d3210$0200a8c0@lifelesswks>]
* [PATCH] ls & "magic" cygdrive dir (was: RE: cygdrive stuff)
@ 2001-09-23 14:05 Ronald Landheer
  0 siblings, 0 replies; 33+ messages in thread
From: Ronald Landheer @ 2001-09-23 14:05 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 3768 bytes --]

Hello all,

After the overwhelming display of interest for my last mail on this subject (which had gone completely unnoticed as far as I can tell), I have patched up the patch I sent earlier to take care of a lacking feature.
Much of my original mail is still valid, so I'm re-posting:

-- BEGIN RE-POST --
> 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)
--- END RE-POST ---
In addition to this, my former patch didn't handle relative directories 
(at all). I.e. running "ls ../../../.." from the "/usr/src/fileutils-
4.1-1/src" directory didn't show the /cygdrive magic dir, while "ls /" 
did. This has been fixed by expanding the path as handled by the patch 
to the full POSIX path.

Once again: this patch has *only* been tested on my development machine, 
because I do not have any other configurations available here. Please, 
if you have other configurations, feel free to test it - it's only 
prudent.

I hope this will be helpful (and won't go unnoticed this time) :)

Greetz!

Ronald

[-- Attachment #2: ls.c.diff.gz --]
[-- Type: application/x-gzip, Size: 3349 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2001-09-25  3:47 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3BAF94B4.4030207@likai.net>
2001-09-24 14:05 ` [PATCH] ls & "magic" cygdrive dir (was: RE: cygdrive stuff) Ronald Landheer
2001-09-24 16:17   ` Li-Kai Liu
2001-09-24 16:21     ` Robert Collins
2001-09-24 16:41       ` Li-Kai Liu
2001-09-24 16:51       ` Christopher Faylor
2001-09-24 13:47 Li-Kai Liu
  -- strict thread matches above, loose matches on Subject: below --
2001-09-23 20:04 Robert Collins
2001-09-24  2:18 ` Corinna Vinschen
2001-09-24  2:35   ` Robert Collins
2001-09-24  5:01     ` Corinna Vinschen
2001-09-24  5:11       ` Robert Collins
2001-09-24  5:21         ` Robert Collins
2001-09-24  5:40         ` Corinna Vinschen
2001-09-24  5:43           ` Robert Collins
2001-09-24  6:01             ` Corinna Vinschen
2001-09-24 12:25               ` Ronald Landheer
2001-09-24 13:41                 ` Corinna Vinschen
2001-09-24 14:18                   ` Ronald Landheer
2001-09-24 14:26                     ` Corinna Vinschen
2001-09-24 15:35                   ` Robert Collins
2001-09-24 15:33                 ` Robert Collins
2001-09-24 15:18               ` Robert Collins
2001-09-24 15:22                 ` Corinna Vinschen
2001-09-25  3:47                   ` Robert Collins
2001-09-24  4:01 ` Ronald Landheer
2001-09-24  5:10   ` Corinna Vinschen
2001-09-24 12:24     ` Ronald Landheer
     [not found] <0c2601c14475$5d9d3210$0200a8c0@lifelesswks>
2001-09-23 14:20 ` Robert Collins
2001-09-23 14:26   ` Robert Collins
2001-09-23 16:47   ` Ronald Landheer
2001-09-23 16:59     ` Charles Wilson
2001-09-23 18:05       ` Ronald Landheer
2001-09-23 14:05 Ronald Landheer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).