使用 udev for pendrive 找出 e“制造商”和“产品”属性

使用 udev for pendrive 找出 e“制造商”和“产品”属性

我看见将原始图像安全写入 U 盘

但在 Debian 上,从该命令中获取 nada :-

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

我被要求将其作为一个新问题提出,因此就这样做了:-

如果我使用监视器命令,我确实会从 udevadm 获得一些输出:-

[$] 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)

另外 lsblk 确认 sdb 上有东西,请参阅:-

[$] 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

我也在这里得到输出:-

[$] 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

期待了解如何获取制造商和产品信息。或者也许它被重写了或者什么的。

该命令的一部分确实做了一些事情:-

[$] 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==""

但后一部分什么也没给出,这grep -iE "manufacturer|product"部分:(

我能够在 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

能够通过 lsscsi 即制造商/产品即 Jetflash 和型号获得所需的输出。有人了解更多 Alcor Micro Corporation 吗?

更有趣的是,为什么该命令不起作用?

相关内容