LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to get Drive letter and serial number of thumb drive in linux? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-get-drive-letter-and-serial-number-of-thumb-drive-in-linux-787152/)

manucng 02-04-2010 11:55 PM

How to get Drive letter and serial number of thumb drive in linux?
 
Hi All,

I am new to Linux ,i did one project in windows which will block the thumb drive with respect to serial number(Device instance ID) of the device.i am planning to do the same project in Linux using c/c++.I am very new to Linux,there is no drive letter for thumb drives we insert into Linux OS.How to get Drive letter and how to get Device instance id of thumb drives please help me get some clues.please provide me any tutorial or any links .

Please let me know if have any other clues to block devices with respect "block list" and "allow device list".if the serial number in block list it has to block if serial number in allow device list it has to allow thumb drive to access.


regards,
manu

EricTRA 02-05-2010 12:41 AM

Hello and Welcome to LinuxQuestions,

As you stated yourself:
Quote:

there is no drive letter for thumb drives we insert into Linux OS
so don't look for one, you will not find it. Drives are mounted in Linux so you'd have to look for the mountpoints with the mount command. More info on the mount command can be found reading the man page:
Code:

man mount
Device information can be found with several commands, start out with
Code:

lspci
lsusb

and take it from there.

Kind regards,

Eric

catkin 02-05-2010 01:48 AM

Details vary from Linux distro to distro. This is for Slackware 13.0.

Here's an excerpt from /var/log/messages after plugging in a thumb drive
Code:

Feb  5 13:12:12 CW8 kernel: usb 1-8: new high speed USB device using ehci_hcd and address 4
Feb  5 13:12:12 CW8 kernel: usb 1-8: New USB device found, idVendor=0781, idProduct=5151
Feb  5 13:12:12 CW8 kernel: usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Feb  5 13:12:12 CW8 kernel: usb 1-8: Product: Cruzer Micro
Feb  5 13:12:12 CW8 kernel: usb 1-8: Manufacturer: SanDisk Corporation
Feb  5 13:12:12 CW8 kernel: usb 1-8: SerialNumber: 20042203931424B115DC
Feb  5 13:12:12 CW8 kernel: usb 1-8: configuration #1 chosen from 1 choice
Feb  5 13:12:12 CW8 kernel: scsi6 : SCSI emulation for USB Mass Storage devices
Feb  5 13:12:17 CW8 kernel: scsi 6:0:0:0: Direct-Access    SanDisk  Cruzer Micro    0.1  PQ: 0 ANSI: 2
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] 4001760 512-byte hardware sectors: (2.04 GB/1.90 GiB)
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] Write Protect is off
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] 4001760 512-byte hardware sectors: (2.04 GB/1.90 GiB)
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] Write Protect is off
Feb  5 13:12:17 CW8 kernel:  sdc: sdc1
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: [sdc] Attached SCSI removable disk
Feb  5 13:12:17 CW8 kernel: sd 6:0:0:0: Attached scsi generic sg3 type 0

The udev system is responsible for handling pluggable devices. It is configured by files under /etc/udev

jschiwal 02-05-2010 02:25 AM

You can use "/sbin/udevadm info --query=property --name /dev/<device>" to print information about a device.
If you know the node, also look at "ls /dev/disk/by-uuid/* -l" or "ls /dev/disk/by-path/* -l". These will be symbolic links to the actual devices and contain the path or uuid in their name.

Using policy kit, you can disable the users ability to mount external drives all together.
You could also have an /etc/fstab entry for mounting a particular usb drives filesystem with "uid=" and/or "dmask" options that will only give access to a particular user. This will only work on that computer. If the user can use "sudo" or "su", then all bets are off.

For your own program, you would probably be working with policy kit to enforce your own policies.

Here is an overview about how policy kit works.
http://hal.freedesktop.org/docs/Poli...operation.html


All times are GMT -5. The time now is 10:53 PM.