Operating System - HP-UX
1833192 Members
2702 Online
110051 Solutions
New Discussion

Misc type module doesn't reuse major numbers

 
Bernardo Pastorelli
Occasional Advisor

Misc type module doesn't reuse major numbers

I wrote a Misc type kernel module. It uses automatic major number assignment, but each time I unload and reload it a new major number is assigned.
The already used major numbers are never reused: so if the first time 240 is assigned, the second time 241 is used and so on up to the time it reaches the maximum value of 254 (or 255??). From that moment I'm not able to load it again; I have to reboot the machine. It seems that the systems thinks that the old majors are something like already in use.
Is it a normal behaviour? If not what could be wrong with my module? Is there a way to have the system dynamically assign to a Misc module always the same major (at least as long as it is available)?

Regards,
Bernardo
4 REPLIES 4
Michael Steele_2
Honored Contributor

Re: Misc type module doesn't reuse major numbers

I think you've got minor and major numbers confused. Major numbers are kernel drivers and all devices of the same class have the same major number. For example:

ls -d /dev/vg*/group

You should see 64 used as the major number for every vg group file.

Its minor number that have to be unique. Referring to the same example, 0x010000 should be first, then it increments, usually by one, afterwards.

Its minor numbers that are unique.
Support Fatherhood - Stop Family Law
Bill Hassell
Honored Contributor

Re: Misc type module doesn't reuse major numbers

Bernardo is indeed referring to major numbers. When writing a driver, a major number is used to identify the driver uniquely to the kernel. The LVM driver is permanently assigned 64 as a major number but many drivers are assigned unused major numbers when the driver is added to the kernel. Since the driver is being added and removed dynamically (not a normal circumstance), the in-core automatic major number pointer is incrementing for each new driver that is added. The kernel isn't expecting drivers to be added and deleted as a daily task as this is a driver development function that would be done on a non-production system (ie, reboots are normal).


Bill Hassell, sysadmin
Bernardo Pastorelli
Occasional Advisor

Re: Misc type module doesn't reuse major numbers

Bill, is there a way to maintain the same major for a misc driver as it is done for a WSIO driver?
When I unload a WSIO driver, lsdev reports that the major is still in use by the driver. So when I reload it the old major is reused.
It is possible to have a Misc driver maintain the same major as done by a WSIO?

Thanks for the support.
Regards,
Bernardo
Bill Hassell
Honored Contributor

Re: Misc type module doesn't reuse major numbers

I haven't written a driver for HP-UX so I don't know a lot of details about the load/unload functions in HP-UX.


Bill Hassell, sysadmin