From: David Zeuthen <david@fubar.dk>
To: linux-hotplug@vger.kernel.org
Subject: Re: udev rule for unmount action
Date: Tue, 09 Jun 2009 00:45:57 +0000 [thread overview]
Message-ID: <1244508357.18491.31.camel@localhost.localdomain> (raw)
In-Reply-To: <200906061702.10974.chris@ilovelinux.de>
Hi,
On Sat, 2009-06-06 at 17:02 +0200, Christian Schmitt wrote:
> Hi,
>
> I am trying to write a udev rule for my external HD that needs some special
> "care" when being unmounted (see here:
> http://elliotli.blogspot.com/2009/01/safely-remove-usb-hard-drive-in-
> linux.html).
That's a very interesting blog entry, thanks for sharing. My experience
dealing with the storage stack in GNOME is that people keep asking for
this feature.
> The problem is that I can not find a way to make udev react on the unmount
> command and execute a script. The "ACTION=remove" rule only works when I
> unplug the device. Is there a way to execute a script when unmounting? I guess
> doing this on the DE level is not the best way to go.
Actually I think doing this on the desktop level is the way forward.
There are two problems here.
First, consider a USB optical drive attached to the system. A typical
thing you want to do here is to eject the disc so you can insert another
one. Now, to eject media you first have to unmount it before you can
send the eject ioctl to the device. But if you hook into the unmount
process then you unbind the device before it is mounted and you never
get to send the eject ioctl.
The other example is when the user manually wants to unmount a partition
instead of ejecting it. Now, in the Nautilus file manager we do default
to ejecting stuff (the eject icon in the sidebar) but the user can also
right-click and click on Unmount in the context menu. If you hook into
the unmount process then the device(s) actually disappears, much against
what the user wanted.
Anyway, it's not a problem to do all this from the desktop level and I
just added support for this.
First, I wrote a patch to DeviceKit-disks (the successor to HAL for
handling storage devices) that offers a DriveDetach() method and also
a :drive-can-detach property. Right now we only set :drive-can-detach
for USB devices but we can add support for other connection fabrics as
needed. The patch is here
http://cgit.freedesktop.org/DeviceKit/DeviceKit-disks/commit/?id[7350df8b63cf4178a2fe69ee740b5222130421
Then I added support for this in GVfs which is what Nautilus uses.
http://git.gnome.org/cgit/gvfs/commit/?id'b14622b7fcc228ddd617ebd723751ccd8dadaa
http://git.gnome.org/cgit/gnome-disk-utility/commit/?id÷6001f6f6beca8b21ff81e70f2633c60783479f
(actually GVfs uses gnome-disk-utility which is a "binding" of some sort
of DeviceKit-disks. But that's unimportant for this discussion.)
So, in a nutshell, GNOME 2.28 will support powering down USB enclosures
out of the box.
Btw, another change I made is to only unbind the usb-storage driver to
better handle multifunction devices. E.g. you don't want to unbind
drivers from all the USB interfaces.
Cheers,
David
next prev parent reply other threads:[~2009-06-09 0:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-06 15:02 udev rule for unmount action Christian Schmitt
2009-06-06 16:27 ` Marco d'Itri
2009-06-07 13:05 ` Christian Schmitt
2009-06-08 12:38 ` Karel Zak
2009-06-08 14:42 ` Christian Schmitt
2009-06-09 0:45 ` David Zeuthen [this message]
2009-06-10 19:34 ` Christian Schmitt
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=1244508357.18491.31.camel@localhost.localdomain \
--to=david@fubar.dk \
--cc=linux-hotplug@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).