1

Why is the size of a character or block file given as comma separated?

crw-rw-rw-. 1 root root 1, 3 Mar  8 10:15 /dev/null

brw-rw----. 1 root disk 8, 1 Mar  8 10:15 /dev/sda1

Size of a file is the number of bytes occupied in the storage device. For character or block files what will be size? And can you please explain about its representation using comma?

1 Answer 1

2

These values do not represent the size in anyway, but make reference to some sort of device identification.

Have a look at the Linux Documentation Project page, where they say:

Devices are defined by type, such as 'block' or 'character', and 'major' and 'minor' number. The major number is used to categorize a device and the minor number is used to identify a specific device type. For example, all IDE device connected to the primary controller have a major number of 3. Master and slave devices, as well as individual partitions are further defined by the use of minor numbers. These are the two numbers precede the date in the following display:

brw-rw----    1 root     disk       3,   0 Mar 15  2002 /dev/hda 
brw-rw----    1 root     disk       3,   1 Mar 15  2002 /dev/hda1 
brw-rw----    1 root     disk       3,  10 Mar 15  2002 /dev/hda10 
brw-rw----    1 root     disk       3,  11 Mar 15  2002 /dev/hda11 
brw-rw----    1 root     disk       3,  12 Mar 15  2002 /dev/hda12 
brw-rw----    1 root     disk       3,  64 Mar 15  2002 /dev/hdb 
brw-rw----    1 root     disk       3,  65 Mar 15  2002 /dev/hdb1 
brw-rw----    1 root     disk      22,   0 Mar 15  2002 /dev/hdc 
brw-rw----    1 root     disk      22,  64 Mar 15  2002 /dev/hdd

The major number for both hda and hdb devices is 3. Of course, the minor number changes for each specific partition. The definition of each major number category can be examined by looking at the contents of the /usr/src/linux/include/linux/major.h file. The devices.txt also documents major and minor numbers. It is located in the /usr/src/linux/Documentation directory. This file defines the major numbers. Almost all files devices are created by default at the install time. However, you can always create a device using the mknod command or the MAKEDEV script which is located in the /dev directory itself. Devices can be created with this utility by supplying the device to be created, the device type (block or character) and the major and minor numbers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .