Re: Signal when device is disconnected

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

 



Phil Endecott wrote:
Dear Experts,

The proc/bus/usb API has an ioctl that can arrange for the application to receive a signal when the device is disconnected. Is there anything similar for the SCSI generic (or other SCSI) APIs?

Assuming that there isn't, I think I need to either poll the device to see if it's still there, or listen on a netlink socket for a removal uevent, or I need to find the USB device corresponding to the sg device that I'm using and use its signal-on-removal ioctl. In the latter case, is there a way to traverse from an sg device's /sys directory to the corresponding usb device's /sys directory? /sys seems to be full of symlinks but I can't find the one that I need in this case.

Basically I have a fairly simple user-space driver for a USB SCSI device that uses the SCSI-generic API, and I want it to terminate tidily when the device is detached.

Phil,
If you are using the lk 2.6 series (from around 2.6.15) then
you could use the inotify mechanism (look at 'man inotify'
to start with). For example, you could monitor the deletion of
/sys/class/scsi_generic/sg1/dev or the corresponsing device
node: /dev/sg1 .

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux