内蔵カードリーダーの種類を確認するには?

内蔵カードリーダーの種類を確認するには?

Busyboxを実行するLinuxボックスがあります。カードリーダーが2つ内蔵されています。カードリーダーの種類を確認するには?

lshw試しましたが、これらのコマンドはBusyboxでは実装されていhwinfoません。lspci


こんにちはステファン・チャジェラス(Stefan Chazeras),

あなたの詳細な答えに心から感謝します。私はこれを試しました。しかし、grepは何も見つかりませんでした。

# l `find /sys/devices -path '*/usb*/configuration'`
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0470300.ehci_v2/usb3/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0470400.ohci_v2/usb7/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0470500.ehci_v2/usb4/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0470600.ohci_v2/usb8/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0471000.xhci_v2/usb1/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0471000.xhci_v2/usb2/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0480300.ehci_v2/usb5/5-1/5-1.1/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0480300.ehci_v2/usb5/5-1/5-1.2/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0480300.ehci_v2/usb5/5-1/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0480300.ehci_v2/usb5/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0480400.ohci_v2/usb9/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0480500.ehci_v2/usb6/configuration
-r--r--r--    1 root     root          4096 Oct  2 19:14 /sys/devices/rdb.3/f0480600.ohci_v2/usb10/configuration
# l `find /sys/devices -path '*/pci*/driver'`
dr-xr-xr-x    2 root     root             0 Oct  2 19:20 .
dr-xr-xr-x    4 root     root             0 Oct  2 19:20 ..
-r--r--r--    1 root     root             0 Oct  2 19:31 devices
# l /proc/bus/pci/devices
-r--r--r--    1 root     root             0 Oct  2 19:31 /proc/bus/pci/devices

ベストアンサー1

カードリーダーは通常USBデバイスです。その場合は、次のようにできます。

find /sys/devices -path '*/usb*/configuration' -exec \
   grep -lx 'CARD READER'  {} + | awk -F/ -vOFS=/ '{
     NF--
     getline idv < ($0 "/idVendor")
     getline idp < ($0 "/idProduct")
     getline v < ($0 "/manufacturer")
     getline p < ($0 "/product")
     print idv":"idp" "v" "p}'

ベンダー/製品IDと名前を取得します(カーネルによって報告されます)。つまり、USBデバイスを探す構成に設定されていますカードリーダー次に、そのファイルを含む親ディレクトリにあるファイルvendorIDproductID内容を抽出しますmanufacturerproductconfiguration

PCI デバイスの場合、次のドライバを使用して少なくともデバイスをキャプチャします。 busybox は GNU の述語をfindサポートしていないので、次のようなものが必要です。find-lname

find /sys/devices -path '*/pci*/driver' -type l -exec readlink {} \; -print |
  awk -F/ -v OFS=/ '
    BEGIN{d["cb710"]d["r592"]d["r852"]d["rts5208"]d["rtsx_pci"]}
    $NF in d {
      getline
      NF--
      getline v < ($0 "/vendor")
      getline p < ($0 "/device")
      print substr(v, 3) ":" substr(p, 3)
    }'

いいえ構成今回は、このファイルを使用してデバイスのクラスを確認できます(実際にはclassPCIデバイスクラスのファイルがありますが、ここでRealtekデバイスは0xff00(その他)であることがわかります。PCIデバイスクラス)「カードリーダー」なので信頼できません)。したがって、私たちは既知のPCIカードリーダードライバへのシンボリックリンクを見つけ、driversそれに関連するパスからベンダー/製品IDを取得します。

より簡単な方法は以下を使用することです/proc/bus/pci/devices

awk '
  BEGIN{d["cb710"]d["r592"]d["r852"]d["rts5208"]d["rtsx_pci"]}
  $NF in d {print substr($2, 1, 4) ":" substr($2, 5)}
' < /proc/bus/pci/devices

おすすめ記事