* how to see the minor numbers allocated to a driver?
@ 2011-05-04 13:40 Robert P. J. Day
2011-05-04 15:32 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Robert P. J. Day @ 2011-05-04 13:40 UTC (permalink / raw)
To: kernelnewbies
something i was curious about way back when -- given that
register_chrdev_region() and alloc_chrdev_region() allow one to
specify a range of minor numbers desired that doesn't necessarily have
to start at zero, is there a way from user space to see what those
numbers are after the device registration is complete?
obviously, looking at /proc/devices will always give you the major
number, that part's easy. and if you look at fs/char_dev.c, it's the
chrdev_show() routine that prints each major number and its registered
name:
===
void chrdev_show(struct seq_file *f, off_t offset)
{
struct char_device_struct *cd;
if (offset < CHRDEV_MAJOR_HASH_SIZE) {
mutex_lock(&chrdevs_lock);
for (cd = chrdevs[offset]; cd; cd = cd->next)
seq_printf(f, "%3d %s\n", cd->major, cd->name);
mutex_unlock(&chrdevs_lock);
}
}
===
if it's a "misc" driver, then you already know that it's major
number is 10, and the contents of /proc/misc will give you the single
minor number allocated for it. but if, for some (bizarre) reason, you
don't know what minor numbers the driver will try to allocate, is
there a way to tell what they are after the fact? or is this just a
silly question?
rday
p.s. for fun, a while back, i extended the chrdev_show() routine to
append to each line the range of minor numbers that had been
allocated, so that each line would read:
#### name [a-b]
i didn't have a compelling reason for that, i was just curious. and
it occurred to me that if userspace programs parse that file for the
first two fields, then having extra info at the end of each line might
not be that disruptive, especially if adding it was a kernel config
option. or maybe i'm making too much of this.
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread
* how to see the minor numbers allocated to a driver?
2011-05-04 13:40 how to see the minor numbers allocated to a driver? Robert P. J. Day
@ 2011-05-04 15:32 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2011-05-04 15:32 UTC (permalink / raw)
To: kernelnewbies
On Wed, May 04, 2011 at 09:40:52AM -0400, Robert P. J. Day wrote:
>
> something i was curious about way back when -- given that
> register_chrdev_region() and alloc_chrdev_region() allow one to
> specify a range of minor numbers desired that doesn't necessarily have
> to start at zero, is there a way from user space to see what those
> numbers are after the device registration is complete?
/sys/dev/char/ after the driver has registered those minor numbers with
the driver core is your best bet.
hope this helps,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-04 15:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 13:40 how to see the minor numbers allocated to a driver? Robert P. J. Day
2011-05-04 15:32 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).