From owner-freebsd-current Sun May 21 7:49:36 2000 Delivered-To: freebsd-current@freebsd.org Received: from overcee.netplex.com.au (peter1.yahoo.com [208.48.107.4]) by hub.freebsd.org (Postfix) with ESMTP id 5907F37B910 for ; Sun, 21 May 2000 07:49:29 -0700 (PDT) (envelope-from peter@netplex.com.au) Received: from netplex.com.au (localhost [127.0.0.1]) by overcee.netplex.com.au (Postfix) with ESMTP id B30681CE1; Sun, 21 May 2000 07:49:28 -0700 (PDT) (envelope-from peter@netplex.com.au) X-Mailer: exmh version 2.1.1 10/15/1999 To: Mark Murray Cc: Doug Rabson , current@FreeBSD.ORG Subject: Re: Major device numbers and mem device redesign In-Reply-To: Message from Mark Murray of "Sun, 21 May 2000 16:41:48 +0200." <200005211441.QAA16615@grimreaper.grondar.za> Date: Sun, 21 May 2000 07:49:28 -0700 From: Peter Wemm Message-Id: <20000521144928.B30681CE1@overcee.netplex.com.au> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Mark Murray wrote: > > > > I want to commit a new /dev/random RSN, so I'll be needing a major > > > > device; what is the procedure for getting one? I know how to steal one, > > > > but ISTR that this is not how it is done. > > > > > > Just edit sys/conf/majors and claim the next available number. > > > > You don't need one. You can use the same major/minor numbers. You can > > register multiple cdevsw's per major number with make_dev(); (do NOT > > use cdevsw_add() for this). > > How does this work for all the routines? When you register the > "new" minor number, can you be specifying new read/write/poll/ioctl/etc > routines? Yes. Each instance of make_dev() takes a cdevsw argument for the minor number in question. So, you could have /dev/mem read/write/ioctl etc routines for major 2, minor 0 and 1, while have minors 3 and 4 being installed with their own open/close/read/write/etc routines. Devices are looked up as a hash of major+minor, and the devsw entries from that point on. Presently: make_dev(&mem_cdevsw, 0, UID_ROOT, GID_KMEM, 0640, "mem"); make_dev(&mem_cdevsw, 1, UID_ROOT, GID_KMEM, 0640, "kmem"); make_dev(&mem_cdevsw, 2, UID_ROOT, GID_WHEEL, 0666, "null"); make_dev(&mem_cdevsw, 3, UID_ROOT, GID_WHEEL, 0644, "random"); make_dev(&mem_cdevsw, 4, UID_ROOT, GID_WHEEL, 0644, "urandom"); make_dev(&mem_cdevsw, 12, UID_ROOT, GID_WHEEL, 0666, "zero"); make_dev(&mem_cdevsw, 14, UID_ROOT, GID_WHEEL, 0600, "io"); There is no reason at all to stop each of those minor devices having their own cdevsw and handler functions. > I ask, as my RNG is a kld, and I want it to be as separate as possible > without getting ridiculous. Yes. You could just cut/paste the existing mem.c driver, and remove everything but the random hooks. In your init code register minors 3 and 4, and that's all you have to worry about. Cheers, -Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message