Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Jan 2001 13:45:01 +0100
From:      Poul-Henning Kamp <phk@critter.freebsd.dk>
To:        Brian Somers <brian@Awfulhak.org>
Cc:        freebsd-arch@FreeBSD.org
Subject:   Re: Cloned open support 
Message-ID:  <20820.980772301@critter>
In-Reply-To: Your message of "Mon, 29 Jan 2001 12:28:42 GMT." <200101291228.f0TCSgP60147@storm.FreeBSD.org.uk> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200101291228.f0TCSgP60147@storm.FreeBSD.org.uk>, Brian Somers writes:

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

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.

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


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