Click to See Complete Forum and Search --> : ls -l /dev column meaning


rgeyer
04-27-2003, 10:45 AM
Hello,

I have a newbie question.

If is use ls -l to list the /dev directory, there is a column (5th col. from left) that reports a numeric value followed by a comma. The value for floppies for example is 2.

Can anyone tell me what this value represents?

Thanks!

Roger

bwkaz
04-27-2003, 12:03 PM
It's the major device number.

Every driver in the kernel gets a major number to use for its devices (this number is how the kernel knows which driver to send requests to, when the requests come in on the device files).

The assignment of numbers is documented in Documentation/devices.txt in the Linux kernel source tree.

The number after that number is the minor number. Each driver can allocate its 255 minor device numbers however it wants (for example, the nVidia kernel module gets major number 195; it allocates minor 0 to the 1st card, minor 1 to the next, and so on, up to minor 254; minor 255 is the "control" device).

There is one exception, the "misc" driver. Stuff like the PS/2 driver get allocated only one minor number under the misc major (which I believe is 10).

The majors for character devices are different from the majors for block devices, too. The difference between the two is that character devices get written to a character at a time, while block devices buffer the output. A disk drive, for example, is a block device, while a serial port is a character device.

rgeyer
04-27-2003, 01:00 PM
Thanks!