function of major/minor device number

Robert P. J. Day rpjday at crashcourse.ca
Sun Feb 12 05:08:31 EST 2012


On Sun, 12 Feb 2012, Alexandru Juncu wrote:

> 2012/2/12 hz hanks <hankshz at gmail.com>:
> > Hi, all
> >
> > I have a question about major/minor device number. I know that one can
> > use int register_chrdev_region(dev_t from, unsigned count, const char
> > *name); to register a driver with a unique pair of major/minor device
> > number. But what's the difference between two drivers: in one case
> > they have same major device number but different minor device number;
> > on another case they have different major device number but same minor
> > device number. When I searched the Internet, it said that major device
> > number is to identify the driver while the minor device number is to
> > identify specific hardware. But I'm still confused because it seems
> > legal to share the major device number with different drivers.

  you're talking about the "misc" character device driver here, which
allows you to register very simple and independent character drivers
that need only a single minor number all at major number 10.

  look in /dev for how many char device files have major number 10.
that's the perfect example of what you're talking about.  see the
source in drivers/char/misc.c.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



More information about the Kernelnewbies mailing list