01-11-2012 06:54 AM - edited 01-11-2012 07:18 AM
For ODDI and pre-DDI 8 drivers, the major number identifies the device class or group, such as a controller for several terminals. It is used, for example, to tell the kernel which device driver's open routine to call. The major number is assigned, sequentially, to each device driver by the Installable Driver Tools (idtools) during driver installation.
Character major numbers and block major numbers are assigned separately for devices that are exclusively block or character. This means that two separate special files for two different device drivers may appear to have the same number assigned to them. A device that supports both block and character access (for example, the floppy driver), may have different major numbers for the character and block device files.
For ODDI and pre-DDI 8 drivers, the minor number identifies a specific device, such as a single terminal. Minor numbers are assigned to special files by the driver writer in another system configuration file called the Node file
Minor numbers are typically used to distinguish subdevices, but they can also be used to convey other information. For example, consider a floppy disk controller that can read and write data from floppies in several formats, and can also manage two floppy drives. When a special file associated with the floppy driver is opened, the minor number associated with the file, and available to the open( ) routine as one of its arguments, is used to identify to the floppy driver both which drive to access, and what format to assume for the I/O operation. In this particular case, the least significant bit of the minor number could be used to identify the drive, and the remaining bits used to indicate the format.
A device special file is uniquely identified by its major and minor number:
brw-r----- 1 bin sys 31 0x09f000 Jul 7 15:55 c9t15d0
block device major # minor # file name
the major number of a certain driver can be determined using thelsdev(1M) command, e.g.:
# lsdev -b 31
Character Block Driver Class
188 31 sdisk disk
# lsdev | grep lvm
64 64 lv l
Make Node (mknod)
The mknod command should only be used to create non-standard device files like e.g. for the SCSI pass through driver (spt) or the volume group control file:
# mknod name b|c major minor
where above terms are
name name of the special file
b|c block or character special
major the major number
minor the minor number
select a unique minor number for the VG:
# ll /dev/*/group
crw-r--r-- 1 root sys 64 0x000000 Apr 4 2001 /dev/vg00/group
crw-r--r-- 1 root sys 64 0x010000 Oct 26 15:52 /dev/vg01/group
crw-r--r-- 1 root sys 64 0x020000 Aug 2 15:49 /dev/vgsap/group
create the VG control file (group file):
# mkdir /dev/vgnew
# mknod /dev/vgnew/group c 64 0x030000
when we create device file for volume group, major number (64) remain unchanged ,
we take next available minor number after 0x020000.
01-11-2012 06:55 AM
If you run the command 'lsdev' the first column lists major numbers and their associated drivers.
As far as minor numbers go -- It depends on what you are doing. If it is LVM work (with the group file for example) then just use the next available minor number.
If you are working with other device files, like tape drives, then the minor number can control tape drive options. You can look at other device files for examples.
01-11-2012 07:06 AM
The "lsdev" command will tell you the major numbers that are currently in use, and the device driver each one is assigned to.
The usage of the minor device numbers is independently determined by each driver: the rule of thumb would be "read the documentation of the driver", typically in the section 7 of the man pages. (see "ls /usr/share/man/man7.Z")
Sometimes the driver names listed by lsdev don't match exactly to man page names, so some knowledge (or trial&error) is required. Example (HP-UX 11.23):
# lsdev Character Block Driver Class 0 -1 cn pseudo 1 -1 asio0 tty [... a lot of device entries...] 203 -1 sctl ctl [... still more...]
Character device 203 is associated with driver "sctl", the SCSI pass-through driver.
"man 7 sctl" produces no results, because the man page name is "scsi_ctl".
"man 7 scsi_ctl" produces a man page that includes instructions for constructing appropriate minor numbers for SCSI pass-through device nodes.
But if you need major numbers for LVM VG creation/import operations, the rules are simple:
- for LVM 1.0 (the only version of LVM on HP-UX 11.23 and older) the major number is always 64.
- for LVM 2.x (available on HP-UX 11.31+ only) the major number is 128.
- for /dev/vg*/group devices, the minor number must be 0xNN0000, where NN is a two-digit hexadecimal number that must be a) unique for this VG on the system, and b) between 0 and the value of kernel parameter "maxvgs". For example, if maxvgs is 10 (decimal), then the NN component for the VG group device can be between 00..0A (inclusive). Note that value 00 is normally reserved for vg00.
If you're developing a new driver for HP-UX, the Driver Development Kit probably has advice for choosing the major number for your driver. Once you have a major number, you can decide how to allocate minor numbers as you see fit.
01-12-2012 06:27 AM
Just click on the "kudos" star at the left column, next to the post you feel deserves recognition.
With the former ITRC points system, you could assign points to your own threads only; but this forum allows assigning kudos to any posts except your own.
You can also mark your thread as "solved", and mark the message(s?) that contained the best/accepted solution(s?).