how to get the device ID of a USB mass storage device
Hi,
I need to mount a USB mass storage device (a memory stick) on to my linux.
from the output of "dmesg" I can see the device name/node is "sdb1".
At different times, when I inserted different USB drives, on different linux PCs I have seen this name in different ways. Sometimes its "sda" sometimes "sda1" etc.
My requirement is I should be able to mount the USB device from "C" program using the mount system call ie.
int mount(const char *source, const char *target, const char *filesystemtype,
unsigned long mountflags, const void *data);
So I need the device name/node everytime.
1) My question is say I hardcoded the device name as "sdb1" after reading the output of "dmesg" manually. Is the name going to be same everytime.
I may be using a different USB device etc.
2) Or is there a way to get the device name dynamically by invoking some linux system call, so that at startup I check this and mount accordingly.
Thanks in advance.
Ebin.
|