From owner-freebsd-arch Mon Jan 29 4:45:17 2001 Delivered-To: freebsd-arch@freebsd.org Received: from critter.freebsd.dk (flutter.freebsd.dk [212.242.40.147]) by hub.freebsd.org (Postfix) with ESMTP id 58AB137B402 for ; Mon, 29 Jan 2001 04:44:58 -0800 (PST) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.1/8.11.1) with ESMTP id f0TCj1K20822; Mon, 29 Jan 2001 13:45:01 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: Brian Somers Cc: freebsd-arch@FreeBSD.org Subject: Re: Cloned open support In-Reply-To: Your message of "Mon, 29 Jan 2001 12:28:42 GMT." <200101291228.f0TCSgP60147@storm.FreeBSD.org.uk> Date: Mon, 29 Jan 2001 13:45:01 +0100 Message-ID: <20820.980772301@critter> From: Poul-Henning Kamp Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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