Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to send SCSI commands to a USB device from within a kernel module?

Question

How, given the information udev passes to my kernel module (the block device path maybe), can I send SCSI commands to the block device? (yet have it function normally otherwise, meaning partitions are mounted, no data loss, etc)

What I'm Trying To Do

I have a USB mass storage device that has LEDs which are controlled via SCSI commands. I would like to write an LED driver to provide /sys/class/leds/* entries for it.

The goal here is to have the device function normally (partitions mounted and functioning, etc) but also allow /sys/class/leds/* interactions that would send SCSI commands to control the LEDs.

It's easy to to send the SCSI commands I need in user space with sg_raw. But I need a kmod to provide /sys/class/leds/...

Essentially what I need is ioctl(). However, I understand it is generally a bad idea to call open(),ioct(),etc from within a kmod.

like image 363
Daniel Wyatt Avatar asked Nov 03 '22 05:11

Daniel Wyatt


1 Answers

It can be achieved by some pseudo driver that emulates between USB & SCSI. I think what ever be your problem may achieved while you are accessing the USB device through SCSI.


These low level & mid level scsi drivers are defined.

like image 166
suneet saini Avatar answered Nov 09 '22 11:11

suneet saini