How can I get the vendor name of SCSI device on linux & c?
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- how to get running process information in java?
Referring to the SCSI SPC-3 document & sg3_utils commands I can suggest you following:
1) Issue command: sg_inq -p 0x00 /dev/your_device_name
This will give you supported pages by your device.
2) If above command displays 0x83 as one of the supported page then issue command:
sudo sg_inq -p 0x83 /dev/your_device_name
This will display vendor information.
P.S -> your_device_name e.g. sr1, sda1
Please use this link to get script for getting these type of information:
http://a-saurabh.blogspot.in/2014/06/sometimes-we-want-to-query-about-our.html
(1)open SCSI device. (2)Send SCSI command "inquiry" by ioctl. then you can get vendor name from the data returned.
you can use scsi inquiry by tools like sg3_utils or just find it under sys/bus/scsi/devices/xxxxx
You can use libudev to find SCSI devices and read the vendor attribute (untested):
You could look into reading /sys files if you know the device/bus id, also check lsscsi.
The sg3_utils package contains utilities that send SCSI commands to devices.
Once we have sg3_utils installed, run sg_inq command on the device you are interested in.
For example: #sg_inq /dev/sda
The above command will run standard SCSI inquiry on the device and provide the Vendor name and other details.