* udev rule for unmount action
@ 2009-06-06 15:02 Christian Schmitt
2009-06-06 16:27 ` Marco d'Itri
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Christian Schmitt @ 2009-06-06 15:02 UTC (permalink / raw)
To: linux-hotplug
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).
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.
Cheers,
Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: udev rule for unmount action
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
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Marco d'Itri @ 2009-06-06 16:27 UTC (permalink / raw)
To: linux-hotplug
On Jun 06, Christian Schmitt <chris@ilovelinux.de> wrote:
> 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.
The approved method is using inotify(2) on /proc/mounts, which is not
related to udev.
--
ciao,
Marco
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: udev rule for unmount action
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
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Christian Schmitt @ 2009-06-07 13:05 UTC (permalink / raw)
To: linux-hotplug
On Saturday 06 June 2009 18:27:26 Marco d'Itri wrote:
> The approved method is using inotify(2) on /proc/mounts, which is not
> related to udev.
Thanks for this hint. As I am not too familiar with how to best implement it,
can you give me a direction or an example for it? Is something like this
already available somewhere? I did not find it.
Thanks
Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: udev rule for unmount action
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
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Karel Zak @ 2009-06-08 12:38 UTC (permalink / raw)
To: linux-hotplug
On Sat, Jun 06, 2009 at 06:27:26PM +0200, Marco d'Itri wrote:
> On Jun 06, Christian Schmitt <chris@ilovelinux.de> wrote:
>
> > 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.
> The approved method is using inotify(2) on /proc/mounts, which is not
> related to udev.
/proc and inotify are not good friends, but you can use poll() / select()
Karel
--
Karel Zak <kzak@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: udev rule for unmount action
2009-06-06 15:02 udev rule for unmount action Christian Schmitt
` (2 preceding siblings ...)
2009-06-08 12:38 ` Karel Zak
@ 2009-06-08 14:42 ` Christian Schmitt
2009-06-09 0:45 ` David Zeuthen
2009-06-10 19:34 ` Christian Schmitt
5 siblings, 0 replies; 7+ messages in thread
From: Christian Schmitt @ 2009-06-08 14:42 UTC (permalink / raw)
To: linux-hotplug
On Monday 08 June 2009 14:38:26 Karel Zak wrote:
>
> /proc and inotify are not good friends, but you can use poll() / select()
>
> Karel
Sorry, but I do not want to write a C program, but a script. So I'd need a way
to accomplish the detection of an unmount event in the script. As I'm using
HAL there should be a way to do it without using inotify manually on
/proc/mounts.
Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: udev rule for unmount action
2009-06-06 15:02 udev rule for unmount action Christian Schmitt
` (3 preceding siblings ...)
2009-06-08 14:42 ` Christian Schmitt
@ 2009-06-09 0:45 ` David Zeuthen
2009-06-10 19:34 ` Christian Schmitt
5 siblings, 0 replies; 7+ messages in thread
From: David Zeuthen @ 2009-06-09 0:45 UTC (permalink / raw)
To: linux-hotplug
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: udev rule for unmount action
2009-06-06 15:02 udev rule for unmount action Christian Schmitt
` (4 preceding siblings ...)
2009-06-09 0:45 ` David Zeuthen
@ 2009-06-10 19:34 ` Christian Schmitt
5 siblings, 0 replies; 7+ messages in thread
From: Christian Schmitt @ 2009-06-10 19:34 UTC (permalink / raw)
To: linux-hotplug
On Tuesday 09 June 2009 02:45:57 David Zeuthen wrote:
Hi David,
> 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.
... and KDE users obviously, too ;-)
> 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.
Perfectly right. And that is why it would make sense IMHO to let the user
specify special treatment for certain devices (like it is possible with udev
rules (serial number, manufactor, model....)).
Actually, I am asking myself if the eject command is sufficient in this case of
a certain external HD device that seems to need some more commands to go into
suspend mode. That's why I think it would make more sense not to hard-wire
certain detach/supend/spindown commands, but make them selectable for every
device. Well, just some brainstorming. :-)
> Anyway, it's not a problem to do all this from the desktop level and I
> just added support for this.
As you seem to be a GNOME guy, I'll probably have to wait until someone starts
to integrate DeviceKit support into Solid. Are you aware of any work in this
direction?
Thanks for your effort.
Cheers,
Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-06-10 19:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-06-10 19:34 ` Christian Schmitt
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).