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.

        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.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to