LIST USB

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

LIST USB

kryptonite
There is a list HDD function which lists HDD in functions.

Is there a way to create a list USB functions in the same way that lists all USB devices EG /dev/sda , /dev/sdb would like to use this with hdparm
Reply | Threaded
Open this post in threaded view
|

Re: LIST USB

Mikhail Yakshin
Administrator
Hi,

> There is a list HDD function which lists HDD in functions.
>
> Is there a way to create a list USB functions in the same way that lists all
> USB devices EG /dev/sda , /dev/sdb would like to use this with hdparm

There's no simple way to address all USB devices - i.e. they don't
have to have a block/char device node, as HDDs usually do.

There are multiple ways to list USB devices, for example, you can
iterate over nodes in /sys/bus/usb/devices:

$ ls -al /sys/bus/usb/devices
total 0
drwxr-xr-x 2 root root 0 Jun 18 13:52 ./
drwxr-xr-x 4 root root 0 Jun 18 13:52 ../
lrwxrwxrwx 1 root root 0 Jun 25 00:32 1-0:1.0 ->
../../../devices/pci0000:00/0000:00:1c.4/0000:0d:00.0/usb1/1-0:1.0/
lrwxrwxrwx 1 root root 0 Jul 10 18:26 1-1 ->
../../../devices/pci0000:00/0000:00:1c.4/0000:0d:00.0/usb1/1-1/
lrwxrwxrwx 1 root root 0 Jul 10 18:26 1-1:1.0 ->
../../../devices/pci0000:00/0000:00:1c.4/0000:0d:00.0/usb1/1-1/1-1:1.0/
lrwxrwxrwx 1 root root 0 Jun 25 00:32 2-0:1.0 ->
../../../devices/pci0000:00/0000:00:1c.4/0000:0d:00.0/usb2/2-0:1.0/
lrwxrwxrwx 1 root root 0 Jun 25 00:32 3-0:1.0 ->
../../../devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0/
lrwxrwxrwx 1 root root 0 Jun 25 00:32 3-1 ->
../../../devices/pci0000:00/0000:00:1a.0/usb3/3-1/
lrwxrwxrwx 1 root root 0 Jun 25 00:32 3-1.4 ->
../../../devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1.4/
lrwxrwxrwx 1 root root 0 Jun 25 00:32 3-1.4:1.0 ->
../../../devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1.4/3-1.4:1.0/
lrwxrwxrwx 1 root root 0 Jun 25 00:32 3-1.4:1.1 ->
../../../devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1.4/3-1.4:1.1/
...

Or you can run something like lsusb:

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
...

May be you want something more specific - i.e. not all USB devices,
but only USB devices with some distinct properties?

--
WBR, Mikhail Yakshin

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
inq-discuss-en mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inq-discuss-en
Reply | Threaded
Open this post in threaded view
|

Re: LIST USB

kryptonite
Was able to get all the storage tests running on USB and SDCARDS ,

Added two functions to USB list and MMC list to the functions call and in the stroage scripts like bonnie , iozone etc changed to get either usb list or mmc list .

Thanks again for all the support , looking forward to submiting patches once tests are stable.

get_mmc_list()

{
for UDI in `hal-find-by-property --key storage.bus --string mmc`; do
        hal-get-property --udi "$UDI" --key storage.drive_type |
                grep -q "sd_mmc" || continue
        block_dev=`hal-get-property --udi "$UDI" --key block.device`
        echo -n "$block_dev"
        echo ""
done

}

get_usb_list()

{
for UDI in `hal-find-by-property --key storage.bus --string usb`; do
        hal-get-property --udi "$UDI" --key storage.drive_type |
                grep -q "^disk$" || continue
        block_dev=`hal-get-property --udi "$UDI" --key block.device`
        echo -n "$block_dev"
        echo ""
done

}