Busyboxを実行するLinuxボックスがあります。カードリーダーは2つ組み込まれています。カードリーダーの種類を確認するにはどうすればよいですか?
lshw
を試しました 、hwinfo
およびlspci
ただし、これらのコマンドはBusyboxには実装されていません。
こんにちはステファン・チャゼラス、
詳しい回答ありがとうございます。私はそれを試してみました。ただし、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
承認された回答:
カードリーダーは多くの場合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デバイスを探すことです。 カードリーダーに設定されています vendorID
のコンテンツを抽出します 、productID
、manufacturer
およびproduct
configuration
を含むディレクトリの親ディレクトリにあるファイル ファイル。
PCIデバイスの場合、これは少なくとも以下のドライバーを使用しているデバイスをキャッチします。 busybox find
GNU 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)
}'
構成はありません 今回使用してデバイスのクラスを判別できるファイル(実際には、class
があります PCIデバイスクラスのファイルですが、Realtekデバイスの場合は0xff00(Misc)であることがわかります。「カードリーダー」専用のPCIデバイスクラスがないため、信頼できません)。その代わりに、drivers
を探します PCIカードリーダーのドライバーとして知られているドライバーのいずれかを指すシンボリックリンクであり、それに関連するパスでベンダー/製品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