Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 01 Sep 2004 12:40:36 -0600
From:      Scott Long <scottl@samsco.org>
To:        Sam <sah@softcardsystems.com>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: disk_create and cdevsw_add
Message-ID:  <413617A4.1030202@samsco.org>
In-Reply-To: <Pine.LNX.4.60.0409011215400.13505@athena>
References:  <Pine.LNX.4.60.0409011215400.13505@athena>

next in thread | previous in thread | raw e-mail | index | archive | help
Sam wrote:
> 'lo again,
> 
> kern/subr_disk.c:/^disk_create/ takes
> two cdevsw types, and I only vaguely
> understand why.  Can someone explain it to me?

I'm not really clear on this myself, other than the first cdevsw
contains your actual table, and the second one is a dummy that you
allocate but don't actually touch.

> 
> I'm generally confused about resolving
> entry points into the driver.  Does a
> block device only get an open() after
> registering it with disk_create?

Yes.  disk_create() is just a modified form of cdevsw_add(), and
your cdevsw entry points are not accessable until that is called.

> Supposing I want to set some ioctls for
> an aoecontrol utility (show all devices
> known, eg), what would aoecontrol open
> to ioctl?

You can either implement the ioctl handler in the same device as the
AoE device, or you can create a separate control device with it's own
major and minor that represents all of the AoE devices, or you can do
both.  You can also create a control device per AoE device, but that
isn't terribly common these days and has implications when porting to
5.x and beyond.

What kind of things will aoecontrol do?  If it will be creating and
destroying AoE device instances, then you definetly want a separate
control device.  You might want to look at my old 4.x RAIDFrame patches
that do this.  They can be found at http://people.freebsd.org/~scottl/rf

Scott



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?413617A4.1030202>