Date: Mon, 29 Jan 2001 14:00:43 GMT From: Brian Somers <brian@Awfulhak.org> To: Poul-Henning Kamp <phk@critter.freebsd.dk> Cc: Brian Somers <brian@Awfulhak.org>, freebsd-arch@FreeBSD.org Subject: Re: Cloned open support Message-ID: <200101291400.f0TE0hY61432@storm.FreeBSD.org.uk> In-Reply-To: Your message of "Mon, 29 Jan 2001 13:45:01 %2B0100" <20820.980772301@critter>
next in thread | previous in thread | raw e-mail | index | archive | help
> >The thing is that I believe the driver needs to be able to > >decide what minor number will be opened. This idea is taken > >from the Solaris implementation. For example, I have a > >theoretical driver that does this: > > I'm not arguing that the driver should not do the decisionmaking, > only that it should not be done in the d_open routine. > > By the time you get to the d_open, you have already committed, > and possibly reused or even shared a vnode with somebody else. I was thinking along the lines of just VN_RELE'ing it and making up another at this point. > If you do it at namei time, you can create the right vnode > before you go (further) down the open path. > > That is how our cloning works: > > When devfs doesn't find what you are looking for, it will > poll all drivers and ask if they can create the dev_t for it. > > If one of the drivers returns a dev_t, a devfs vnode is > instantiated and everybody are happy. > > >o Makes minor 0 available in /dev as a control device > > No worries: > > make_dev(..., minor = 0, "/dev/foo"); > > >o Makes minor 1 available as something that'll be cloned. > > Nope, decide on a name which is cloned; and recognize it > in foo_clone(dev_t *dev, ...) Allocate the next free minor and > > if (strcmp(name, "fooclone")) > return; > ... /* find free minor */ > *dev = make_dev(..., minor = n, "dev/foo%03d", n); > return; > > This should work as far as I know. Userland needs to find the > right pathname, preferably without too much magic. fstat(2) + > devname(3) is probably doing that just fine for that. Hmm, I'm not sure I like the idea of a user being able to open things they can't see beforehand (permissions seem to be one problem)... My thoughts were along the lines of doing the make_dev(... minor=1, "dev/fooclone" ...) in foo_attach() as we do now, then tweaking the dev_t in foo_open(). The namei() bit is necessary to get to the point that you know you're talking about a device and can call any foo_clone() etc. So, how about this then (or is this what you're already saying): make_dev() is called during attach as normal. devfs's vfs lookup routine checks if the cdevsw of the thing it finds has D_CLONE, and if so asks the owning driver via a new foo_isclone() cdevsw function if it'd like to change the dev_t it's about to give back to the namei side of things. Would that work ? I haven't looked at the devfs stuff, but I wouldn't imagine there would be any problems doing this... > -- > Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 > phk@FreeBSD.ORG | TCP/IP since RFC 956 > FreeBSD committer | BSD since 4.3-tahoe > Never attribute to malice what can adequately be explained by incompetence. -- Brian <brian@Awfulhak.org> <brian@[uk.]FreeBSD.org> <http://www.Awfulhak.org> <brian@[uk.]OpenBSD.org> Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101291400.f0TE0hY61432>