Getting udev name from usb_device structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all!

I'm writting a LSM hook in order to allow to mount just only some
particular USB Mass Storage devices according to their idVendor,
idProduct, and Serial. The hook is executed when a device is going to
be mounted, and it has the following prototype:

static int sb_mount(const char *dev_name, struct path *path, const char *type,
                    unsigned long flags, void *data)

The relevant parameter here is dev_name, which provides the name of
the device to be mounted in a "udev" style (e.g. "/dev/sdb1"). So, the
main idea to perform the mount restriction inside the hook is,
firstly, to determine if there is a USB Mass Storage device connected
to the system which is identified as dev_name. After that, I will
inspect if it's corresponding idVendor, idProduct and serial are
considered valid according to a given list of authorized devices, and
then
allow the mount.

Currently, I'm using the usb_for_each_dev function, which gives me
access to the idVendor, idProduct and serial of all the USB devices by
means of the usb_device structure.  However, I don't know how I can
determine which is the "udev device name" associated to each
usb_device structure. I have observed that the name of the "udev
device" is present in the sysfs, so I guess that by accesing to the
kobject of the usb_device I could obtain such mapping (usb_device <->
udev name). I also know that the Mass Storage Devices are considered
as SCSI devices, so I guess that the name can also be obtained from a
structure related with the SCSI subsystem. The problem is that I don't
know which is the best way to find the mapping between the usb_device
and the dev_name parameter. I have tried to inspect all the related
structures without any success :-(

Can anyone advise me about how can I obtain the udev device name of a
USB by means of the usb_device structure. Any other better idea will
be appreciated :-)

Sergio
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux