Linux API to find out the number of USB disks connected to the machine and the files
Hi,
I have to write a Linux Program to write a file to USB disks connected to a machine.
Steps:
->Find out the number of USB disks connected to the machine and the filesystem/partition corresponding to the USB disks
->Mount all the USB disks
->Write the file
I have followed the following approach:
-> dmesg | grep 'removable disk'
The output will be as follows:
“Attached scsi removable disk sdb at scsi8, channel 0, id 0, lun 0”
From this take out fifth field to get the Device name(sda) of Usb disk
-> From /proc/partitions file get the corresponding filesystem name say "/dev/sdb1"
But, I got to know that “dmesg” output may sometimes have different formats(?) and its better to use any available standard Linux API.
The APIs with Libusb library are used to find out the details of USB disk such as bus-name/device-name , device-id/product-id, manufacturer etc.,
I didnt find any API to find out the Usb disk filesystem.
Is there any API or any other standard way for doing this?
Thanks,
Poomathi
|