From: Douglas Gilbert <dgilbert@interlog.com>
To: Phil Endecott <phil_joqdm_endecott@chezphil.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: Signal when device is disconnected
Date: Wed, 13 May 2009 22:08:24 +0200 [thread overview]
Message-ID: <4A0B28B8.6040705@interlog.com> (raw)
In-Reply-To: <1242236945846@dmwebmail.dmwebmail.chezphil.org>
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
prev parent reply other threads:[~2009-05-13 20:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-13 17:49 Signal when device is disconnected Phil Endecott
2009-05-13 20:08 ` Douglas Gilbert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A0B28B8.6040705@interlog.com \
--to=dgilbert@interlog.com \
--cc=linux-scsi@vger.kernel.org \
--cc=phil_joqdm_endecott@chezphil.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.