descobrir os atributos e "fabricante" e "produto" usando o udev para pendrive

1

Eu vi Escrever imagens em bruto com segurança para pen drives USB

No Debian, porém, não receba nada desse comando: -

[$] udevadm info -a -p $(udevadm info -q path -n /dev/sdb)|grep -iE "manufacturer|product"  
[$]

Pediram-me para colocar isso como uma nova pergunta, portanto, fazendo exatamente isso: -

Eu obtenho alguma saída do udevadm se eu usar o comando monitor: -

[$] udevadm monitor                                                                                                                
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[3684.776590] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
KERNEL[3684.777597] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[3684.777635] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
KERNEL[3684.777658] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
KERNEL[3684.777838] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
KERNEL[3684.782360] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
KERNEL[3684.782727] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
KERNEL[3684.782760] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0 (scsi)
KERNEL[3684.782988] remove   /devices/virtual/bdi/8:16 (bdi)
KERNEL[3684.783019] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0 (scsi)
UDEV  [3684.783049] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg)
UDEV  [3684.784068] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk)
UDEV  [3684.785019] remove   /devices/virtual/bdi/8:16 (bdi)
UDEV  [3684.787027] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/scsi_generic/sg2 (scsi_generic)
UDEV  [3684.791681] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 (block)
UDEV  [3684.791719] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device)
UDEV  [3684.792728] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb2 (block)
UDEV  [3684.795562] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0/block/sdb (block)
UDEV  [3684.798166] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0/4:0:0:0 (scsi)
UDEV  [3684.800061] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/target4:0:0 (scsi)
KERNEL[3684.808192] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/scsi_host/host4 (scsi_host)
KERNEL[3684.808231] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4 (scsi)
KERNEL[3684.808519] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0 (usb)
KERNEL[3684.808707] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8 (usb)
UDEV  [3684.809582] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4/scsi_host/host4 (scsi_host)
UDEV  [3684.810490] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host4 (scsi)
UDEV  [3684.811610] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0 (usb)
UDEV  [3684.813368] remove   /devices/pci0000:00/0000:00:1d.7/usb5/5-8 (usb)
KERNEL[3690.682615] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8 (usb)
KERNEL[3690.683475] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0 (usb)
KERNEL[3690.683743] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5 (scsi)
KERNEL[3690.683944] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/scsi_host/host5 (scsi_host)
UDEV  [3690.692470] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8 (usb)
UDEV  [3690.699536] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0 (usb)
UDEV  [3690.701644] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5 (scsi)
UDEV  [3690.708123] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/scsi_host/host5 (scsi_host)
KERNEL[3691.694749] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0 (scsi)
KERNEL[3691.694829] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0 (scsi)
KERNEL[3691.694902] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/scsi_disk/5:0:0:0 (scsi_disk)
KERNEL[3691.694961] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/scsi_device/5:0:0:0 (scsi_device)
KERNEL[3691.695201] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[3691.695321] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/bsg/5:0:0:0 (bsg)
UDEV  [3691.697351] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0 (scsi)
KERNEL[3691.697770] add      /devices/virtual/bdi/8:16 (bdi)
UDEV  [3691.702172] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0 (scsi)
UDEV  [3691.705059] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/scsi_disk/5:0:0:0 (scsi_disk)
KERNEL[3691.705443] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/block/sdb (block)
KERNEL[3691.705469] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/block/sdb/sdb1 (block)
KERNEL[3691.705485] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/block/sdb/sdb2 (block)
UDEV  [3691.710056] add      /devices/virtual/bdi/8:16 (bdi)
UDEV  [3691.712737] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/bsg/5:0:0:0 (bsg)
UDEV  [3691.713573] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/scsi_device/5:0:0:0 (scsi_device)
UDEV  [3691.714949] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/scsi_generic/sg2 (scsi_generic)
UDEV  [3692.356460] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/block/sdb (block)
UDEV  [3692.392059] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/block/sdb/sdb2 (block)
UDEV  [3692.440775] add      /devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/block/sdb/sdb1 (block)

Também o lsblk confirma que existe algo no sdb, veja: -

[$] lsblk                                                                                                                          
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0  48.8G  0 part 
├─sda2   8:2    0     1K  0 part 
├─sda5   8:5    0  48.8G  0 part 
├─sda6   8:6    0 186.3G  0 part /
├─sda7   8:7    0  93.1G  0 part /home
├─sda8   8:8    0 549.5G  0 part /data
└─sda9   8:9    0     5G  0 part [SWAP]
sdb      8:16   1   3.8G  0 disk 
├─sdb1   8:17   1   247M  0 part 
└─sdb2   8:18   1   416K  0 part 
sr0     11:0    1  1024M  0 rom

Eu também recebo a saída aqui: -

[$] ls -l /dev/sdb*                                                                                                                
brw-rw---- 1 root disk 8, 16 Jun 30 15:49 /dev/sdb
brw-rw---- 1 root disk 8, 17 Jun 30 15:49 /dev/sdb1
brw-rw---- 1 root disk 8, 18 Jun 30 15:49 /dev/sdb2

Ansiosos para aprender como obter informações sobre o fabricante e o produto. ou talvez tenha sido escrito ou algo assim.

Parte do comando faz alguma coisa: -

[$] udevadm info -a -p $(udevadm info -q path -n /dev/sdb)                                                                         

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0/block/sdb':
    KERNEL=="sdb"
    SUBSYSTEM=="block"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0/5:0:0:0':
    KERNELS=="5:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5/target5:0:0':
    KERNELS=="target5:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0/host5':
    KERNELS=="host5"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb5/5-8/5-8:1.0':
    KERNELS=="5-8:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb-storage"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb5/5-8':
    KERNELS=="5-8"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb5':
    KERNELS=="usb5"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7':
    KERNELS=="0000:00:1d.7"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

mas a última parte não dá nada, a parte grep -iE "manufacturer|product" : (

Sou capaz de obtê-lo em lsusb: -

[$] lsusb                                                                                                                           
Bus 005 Device 007: ID 058f:6387 Alcor Micro Corp. Flash Drive
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 046d:c31c Logitech, Inc. Keyboard K120 for Business
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Foi capaz de obter a saída necessária via lsscsi, ou seja, fabricante / produto, ou seja, Jetflash e o número do modelo. Alguém conhece mais a Alcor Micro Corporation?

Mais interessante ainda, por que esse comando não funcionou?

    
por shirish 30.06.2015 / 12:28

0 respostas

Tags