Qual è la differenza tra / sys / class / block e / sys / block


1

Quando faccio una lsdelle due directory, il loro contenuto è molto simile

/ Sys / class / block

$ ls /sys/class/block
dm-0  dm-3   loop1  loop4  loop7  ram10  ram13  ram2  ram5  ram8  sda1  sda4
dm-1  dm-4   loop2  loop5  ram0   ram11  ram14  ram3  ram6  ram9  sda2  sda5
dm-2  loop0  loop3  loop6  ram1   ram12  ram15  ram4  ram7  sda   sda3  sda6

ls -lah /sys/class/block/
total 0
drwxr-xr-x  2 root root 0 Apr 23 16:08 .
drwxr-xr-x 52 root root 0 Apr 23 16:08 ..
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-0 -> ../../devices/virtual/block/dm-0
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-1 -> ../../devices/virtual/block/dm-1
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-2 -> ../../devices/virtual/block/dm-2
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-3 -> ../../devices/virtual/block/dm-3
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-4 -> ../../devices/virtual/block/dm-4
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop0 -> ../../devices/virtual/block/loop0
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop1 -> ../../devices/virtual/block/loop1
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop2 -> ../../devices/virtual/block/loop2
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop3 -> ../../devices/virtual/block/loop3
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop4 -> ../../devices/virtual/block/loop4
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop5 -> ../../devices/virtual/block/loop5
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop6 -> ../../devices/virtual/block/loop6
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop7 -> ../../devices/virtual/block/loop7
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram0 -> ../../devices/virtual/block/ram0
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram1 -> ../../devices/virtual/block/ram1
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram10 -> ../../devices/virtual/block/ram10
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram11 -> ../../devices/virtual/block/ram11
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram12 -> ../../devices/virtual/block/ram12
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram13 -> ../../devices/virtual/block/ram13
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram14 -> ../../devices/virtual/block/ram14
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram15 -> ../../devices/virtual/block/ram15
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram2 -> ../../devices/virtual/block/ram2
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram3 -> ../../devices/virtual/block/ram3
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram4 -> ../../devices/virtual/block/ram4
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram5 -> ../../devices/virtual/block/ram5
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram6 -> ../../devices/virtual/block/ram6
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram7 -> ../../devices/virtual/block/ram7
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram8 -> ../../devices/virtual/block/ram8
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram9 -> ../../devices/virtual/block/ram9
lrwxrwxrwx  1 root root 0 Apr 23 16:08 sda -> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
lrwxrwxrwx  1 root root 0 Apr 23 16:08 sda1 -> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda1
lrwxrwxrwx  1 root root 0 Apr 23 16:08 sda2 -> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda2
lrwxrwxrwx  1 root root 0 Apr 23 16:08 sda3 -> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda3
lrwxrwxrwx  1 root root 0 Apr 23 16:08 sda4 -> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda4
lrwxrwxrwx  1 root root 0 Apr 23 16:08 sda5 -> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda5
lrwxrwxrwx  1 r

/ Sys / block /

$ ls /sys/block/
dm-0  dm-3   loop1  loop4  loop7  ram10  ram13  ram2  ram5  ram8
dm-1  dm-4   loop2  loop5  ram0   ram11  ram14  ram3  ram6  ram9
dm-2  loop0  loop3  loop6  ram1   ram12  ram15  ram4  ram7  sda

$ ls -lah /sys/block/
drwxr-xr-x  2 root root 0 Apr 23 16:08 .
dr-xr-xr-x 13 root root 0 Apr 23 16:08 ..
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-0 -> ../devices/virtual/block/dm-0
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-1 -> ../devices/virtual/block/dm-1
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-2 -> ../devices/virtual/block/dm-2
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-3 -> ../devices/virtual/block/dm-3
lrwxrwxrwx  1 root root 0 Apr 23 16:08 dm-4 -> ../devices/virtual/block/dm-4
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop0 -> ../devices/virtual/block/loop0
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop1 -> ../devices/virtual/block/loop1
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop2 -> ../devices/virtual/block/loop2
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop3 -> ../devices/virtual/block/loop3
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop4 -> ../devices/virtual/block/loop4
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop5 -> ../devices/virtual/block/loop5
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop6 -> ../devices/virtual/block/loop6
lrwxrwxrwx  1 root root 0 Apr 23 16:08 loop7 -> ../devices/virtual/block/loop7
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram0 -> ../devices/virtual/block/ram0
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram1 -> ../devices/virtual/block/ram1
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram10 -> ../devices/virtual/block/ram10
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram11 -> ../devices/virtual/block/ram11
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram12 -> ../devices/virtual/block/ram12
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram13 -> ../devices/virtual/block/ram13
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram14 -> ../devices/virtual/block/ram14
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram15 -> ../devices/virtual/block/ram15
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram2 -> ../devices/virtual/block/ram2
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram3 -> ../devices/virtual/block/ram3
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram4 -> ../devices/virtual/block/ram4
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram5 -> ../devices/virtual/block/ram5
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram6 -> ../devices/virtual/block/ram6
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram7 -> ../devices/virtual/block/ram7
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram8 -> ../devices/virtual/block/ram8
lrwxrwxrwx  1 root root 0 Apr 23 16:08 ram9 -> ../devices/virtual/block/ram9
lrwxrwxrwx  1 root root 0 Apr 23 16:08 sda -> ../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda

Entrambi hanno numerosi collegamenti simbolici nello stesso posto. L'unica differenza che vedo è /sys/class/block/ha sdae sda1fino a sda6quando /sys/block/ha solo sda.

Qual è la differenza principale tra /sys/block/e /sys/class/block?

Risposte:


3

Quest'ultimo esiste per motivi di compatibilità, poiché inizialmente sysfs aveva un codice dedicato per i dispositivi a blocchi, ma in seguito quelli diventarono solo un'altra "classe". Vedi commit v2.6.24-158-gedfaa7c36574:

Driver core: converte il blocco da kobject grezzi in dispositivi core

Questo sposta i dispositivi a blocchi in / sys / class / block. Creerà un elenco semplice di tutti i dispositivi a blocchi, con i dischi e le partizioni in una directory. Per compatibilità / sys / block viene creato e contiene collegamenti simbolici ai dischi.

(Trovato utilizzando tig blame drivers/base/class.c)

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.