* Signal when device is disconnected
@ 2009-05-13 17:49 Phil Endecott
2009-05-13 20:08 ` Douglas Gilbert
0 siblings, 1 reply; 2+ messages in thread
From: Phil Endecott @ 2009-05-13 17:49 UTC (permalink / raw)
To: linux-scsi
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.
Many thanks for any advice.
Phil.
(Please Cc: me in any replies.)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Signal when device is disconnected
2009-05-13 17:49 Signal when device is disconnected Phil Endecott
@ 2009-05-13 20:08 ` Douglas Gilbert
0 siblings, 0 replies; 2+ messages in thread
From: Douglas Gilbert @ 2009-05-13 20:08 UTC (permalink / raw)
To: Phil Endecott; +Cc: linux-scsi
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-13 20:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-13 17:49 Signal when device is disconnected Phil Endecott
2009-05-13 20:08 ` Douglas Gilbert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.