Reputation: 1009
I am quite new to kernel programming and I am following the tutorial given at : USB boot authentication
I want to get a 'device struct' of a USB drive. I have 'dev_t' instance of the USB device. Further, I want to check whether the device struct is a USB device or not. I am not able to figure out how to start...
Thanks
Upvotes: 4
Views: 5566
Reputation: 46
As hiteshradia said dev_t
is a device number (a major number and minor number). You can however use this along with the knowledge that it is for a block device to get access to the struct device
associated with it. To do so, use struct block_device *bdget(dev_t)
from linux/fs.h
. From this you can use block_device->bd_part
to get a struct hd_struct *
for the device and finally use struct device *part_to_dev(struct hd_struct *)
defined as a macro in linux/genhd.h
.
Upvotes: 3
Reputation: 357
dev_t
is only a device number which represents a /dev/sdb1
partition as seen from your link. It is not possible to get the underlying usb drive details using it.
In the link you provided there is section
if(udev->serial != NULL)
{
if((strcmp(udev->serial, "3513001D97827E69")) == 0) /* Hard coded usb device serial here*/
{
key_dev_found = 1;
}
}
where you can get usb device details and struct usb_device *udev
Upvotes: 1