como o número principal e os números menores são usados para localizar a operação do arquivo para os drivers?

0

Eu sou iniciante no driver do dispositivo ...

Gostaria de saber como as operações de arquivo estão localizadas a partir de arquivos de dispositivos e drivers usando números maiores e menores?

    
por Rex 13.09.2013 / 09:12

1 resposta

1

Se você está aprendendo a programar drivers de dispositivos Linux, devo dizer que há um e-book gratuito sobre o assunto.

Drivers de dispositivo do Linux, terceira edição

Capítulo 3 do LDD3: Drivers de carro

Nossas respostas devem fornecer mais do que apenas links. Então aqui está um extrato relevante.

crw-rw-rw- 1 root root 1, 3 Apr 11 2002 null
crw------- 1 root root 10, 1 Apr 11 2002 psaux
crw------- 1 root root 4, 1 Oct 28 03:04 tty1
crw-rw-rw- 1 root tty 4, 64 Apr 11 2002 ttys0
crw-rw---- 1 root uucp 4, 65 Apr 11 2002 ttyS1
crw--w---- 1 vcsa tty 7, 1 Apr 11 2002 vcs1
crw--w---- 1 vcsa tty 7, 129 Apr 11 2002 vcsa1
crw-rw-rw- 1 root root 1, 5 Apr 11 2002 zero

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 con- soles 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 13.09.2013 / 09:28