Tamanho de um arquivo de caractere / bloco

0

Por que o tamanho de um arquivo de caractere ou bloco é fornecido como separado por vírgulas?

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

O tamanho de um arquivo é o número de bytes ocupados no dispositivo de armazenamento. Para arquivos de caracteres ou blocos, qual será o tamanho? E você pode, por favor, explicar sobre sua representação usando vírgula?

    
por 0aslam0 09.03.2016 / 14:54

1 resposta

2

Esses valores não representam o tamanho de qualquer maneira, mas fazem referência a algum tipo de identificação de dispositivo.

Dê uma olhada na página do Projeto de Documentação do Linux, onde eles dizem :

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.

    
por 09.03.2016 / 15:18