linux - 如何判断连接的USB设备是否为U盘?

标签 linux linux-kernel linux-device-driver usb-flash-drive

您如何确定哪种媒体已附加到系统?

我有 Ubuntu,当我插入 SD 卡时,它注意到它实际上是一张 SD 卡。 USB 内存棒的计数相同。

但是当插入新设备时,我如何在低级别确定它是什么类型?

似乎根本找不到这方面的信息。

编辑:更完整一点:我说是Linux环境,其实是嵌入式环境下的Android。我将其标记为 Linux,因为我确实在尝试从命令行进行检查。

udevadm 命令不可用,lsusb -vv 显示:

Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 0424:2640
Bus 001 Device 003: ID 0424:4040
Bus 002 Device 001: ID 1d6b:0001

这是非常少的信息。

最佳答案

lsusb 命令列出了系统中注册的 USB 设备。 尝试使用 lsusb -vv 获取更多详细信息。您可以使用 -s 标志来定位特定设备。

更新: 这取决于您的帐户权限,一些细节需要更高的权限。例如,这是我鼠标的输出:

Bus 003 Device 003: ID 04f3:0230 Elan Microelectronics Corp. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x04f3 Elan Microelectronics Corp.
  idProduct          0x0230 
  bcdDevice           24.58
  iManufacturer           0 
  iProduct                2 USB+PS/2 Optical Mouse
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              10
Device Status:     0x0000

关于linux - 如何判断连接的USB设备是否为U盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9993050/

相关文章:

linux - 我如何使这个 awk 命令的真实结果发出像 sendmail 等命令

c - 为什么有些函数不涉及内核?

c - 无缓冲的 misc_device 读取 - linux 内核驱动程序

c - Linux 内核 : schedule() function

我们可以使用 epoll() 来轮询使用 ioctl 进行数据传输的描述符吗

linux - linux-kernel 中进程的当前目录

linux - 如何在远程 Linux 服务器上启动 jhs 并从远程客户端(如 chromebook)访问它

linux - read -p 与2>/dev/null 组合时不提示字符串,这是为什么呢?

sql - 在多个表上进行选择,这些表是另一个选择的结果

linux - 如何在 Linux 上为华硕触控板编写驱动程序?