ls -l output no diretório / dev do sistema Unix / Linux [duplicado]

5

Eu li que o diretório / dev contém arquivos de dispositivos que apontam para drivers de dispositivos.

Agora a minha pergunta é, quando eu faço ls -l, eu recebo algo assim

o que esse valor da quinta e sexta colunas representa e sua significância?

    
por Chandan Kumar 27.05.2017 / 08:28

2 respostas

6

são números maiores e menores, mais informações sobre o que você pode encontrar aqui: link

Traditionally, the major number identifies the driver associated with the device. For example, /dev/null and /dev/zero are both managed by driver 1, whereas virtual consoles and serial terminals are managed by driver 4; similarly, both vcs1 and vcsa1 devices are managed by driver 7. Modern Linux kernels allow multiple drivers to share major numbers, but most devices that you will see are still organized on the one-major-one-driver principle.

The minor number is used by the kernel to determine exactly which device is being referred to. Depending on how your driver is written (as we will see below), you can either get a direct pointer to your device from the kernel, or you can use the minor number yourself as an index into a local array of devices. Either way, the kernel itself knows almost nothing about minor numbers beyond the fact that they refer to devices implemented by your driver.

    
por 27.05.2017 / 08:34
3

Como @Daemon mencionou, estes são números maiores e menores. Os números principais são comuns a um tipo específico de dispositivo.

Por exemplo, executando:

ls -l /dev | grep -P "tty\d$"

Produz:

crw--w----  1 root tty     4,   0 May 26 23:41 tty0
crw--w----  1 root tty     4,   1 May 26 23:41 tty1
crw--w----  1 root tty     4,   2 May 26 23:41 tty2
crw--w----  1 root tty     4,   3 May 26 23:41 tty3
crw--w----  1 root tty     4,   4 May 26 23:41 tty4
crw--w----  1 root tty     4,   5 May 26 23:41 tty5
crw--w----  1 root tty     4,   6 May 26 23:41 tty6
crw--w----  1 root tty     4,   7 May 26 23:41 tty7
crw--w----  1 root tty     4,   8 May 26 23:41 tty8
crw--w----  1 root tty     4,   9 May 26 23:41 tty9

Todos compartilham o maior número 4 , mas têm diferentes números menores.

    
por 27.05.2017 / 10:00

Tags