GNOME Bugzilla – Bug 585591
Starting/stopping drives
Last modified: 2009-06-18 15:19:20 UTC
Today it's not really possible to sanely make Nautilus expose operations for 1. Powering down external hard disk enclosures 2. Starting/stopping multi-disk devices (such as RAID/btrfs/ZFS) 3. Connecting/disconnecting iSCSI devices 4. Reacting to the user pressing e.g. the "remove drive" button on a IBM/Lenovo Ultrabay: http://www.thinkwiki.org/wiki/Ultrabay Btw, see bug 576587 comment 18 for how we currently abuse the eject() method for use case 1. Notably this won't work for use case 4. However if we added an API like can_stop() stop() can_start() start() with _few_ guarantees on the semantics of what starting/stopping means we could easily support all this. Let us consider the use cases, one by one 1. For an external hard disk enclosure, we'd set can_stop==TRUE and can_start==FALSE. If you call stop(), the drive powers down and disappears (since Detach() on DeviceKit-disks powers down the port) 2. For multi-disk devices, we'd set can_stop==TRUE if the array is running and can_start==TRUE if the array is not running. start() and stop() would, uh, start and stop the array. 3. For iSCSI, we'd do like in 2. with start() attempting to connect to the device (might involve asking for a password) and stop() would tear down the connection. 4. For Ultrabay-ish devices, we get an uevent from the kernel. DKD will intercept that and the gdu volume monitor will then emit ::stop-button. Then Nautilus can react on this (the same way it reacts on the ::eject-button signal today) and call stop() and then tell the user that it's safe to remove that drive. We would need to teach Nautilus about these concepts too. I will attach a patch for adding this to GIO. Then I'll follow up with GVfs and Nautilus patches later.
Created attachment 136459 [details] [review] Proposed API Haven't gotten around to writing the GVfs or Nautilus bits just yet so minor changes might be needed. Do you think it's OK to reuse GMountOperation here? The alternative is duplicating it and call it GStartOperation and then having to do duplicate bloat in GTK+ as well.
Created attachment 136596 [details] [review] Updated GIO patch $ diffstat ~/Desktop/gio-drive-start-stop-3.patch docs/reference/gio/gio-sections.txt | 16 ++ gio/gdrive.c | 259 +++++++++++++++++++++++++++++++- gio/gdrive.h | 57 +++++++ gio/gfile.c | 179 ++++++++++++++++++++++++ gio/gfile.h | 41 +++++ gio/gfileinfo.h | 31 ++++ gio/gio.symbols | 13 + gio/gioenums.h | 39 +++++ gio/gunionvolumemonitor.c | 12 + gio/gvolumemonitor.c | 18 ++ gio/gvolumemonitor.h | 5 11 files changed, 666 insertions(+), 4 deletions(-) Since computer:/// is implemented via Mountables we also need g_file_[start|stop]_mountable methods together with appropriate file attributes.
Created attachment 136597 [details] [review] GVfs patch $ diffstat ~/Desktop/gvfs-drive-start-stop.patch b/client/gdaemonfile.c | 93 +++ b/common/gmountoperationdbus.c | 12 b/common/gmountsource.c | 6 b/common/gvfsdaemonprotocol.h | 2 b/daemon/Makefile.am | 2 b/daemon/gvfsbackend.c | 10 b/daemon/gvfsbackend.h | 19 b/daemon/gvfsbackendcomputer.c | 158 +++++ b/monitor/gdu/ggdudrive.c | 676 +++++++++++++++++----- b/monitor/gdu/ggduvolumemonitor.c | 57 +- b/monitor/proxy/gproxydrive.c | 626 +++++++++++++++++++++ b/monitor/proxy/gproxydrive.h | 9 b/monitor/proxy/gproxyvolume.c | 2 b/monitor/proxy/gproxyvolumemonitor.c | 33 + b/monitor/proxy/gproxyvolumemonitor.h | 8 b/monitor/proxy/gvfsproxyvolumemonitordaemon.c | 556 ++++++++++++++++++++ b/programs/gvfs-mount.c | 16 b/daemon/gvfsjobstartmountable.c | 168 ++++++ b/daemon/gvfsjobstartmountable.h | 64 ++ b/daemon/gvfsjobstopmountable.c | 164 ++++++ b/daemon/gvfsjobstopmountable.h | 64 ++ 21 files changed, 2577 insertions(+), 168 deletions(-) Add support for the proposed GIO API in GVfs. This also fixes a couple of bugs in GMountSource and GMountOperation.
Created attachment 136598 [details] [review] Nautilus patch $ diffstat ~/Desktop/nautilus-drive-start-stop.patch libnautilus-private/nautilus-file-private.h | 3 libnautilus-private/nautilus-file.c | 147 +++++++ libnautilus-private/nautilus-file.h | 17 libnautilus-private/nautilus-mime-actions.c | 95 +++++ libnautilus-private/nautilus-vfs-file.c | 116 ++++++ src/file-manager/fm-actions.h | 6 src/file-manager/fm-directory-view.c | 446 +++++++++++++++++++-- src/file-manager/nautilus-directory-view-ui.xml | 8 src/nautilus-places-sidebar.c | 161 ++++++++ 9 files changed, 969 insertions(+), 30 deletions(-) And finally the Nautilus patch to use this API.
Let me know if you want separate bugs for the GVfs and Nautilus patches. I thought it was easier to just discuss everything here since it's so related to each other.
Also, one note about the Nautilus patch. It drops the Volume word from each of the "Mount Volume", "Unmount Volume" and "Eject Volume" menu items since it is superfluous.
Some screenshots of this feature that I did earlier today: http://people.freedesktop.org/~david/nautilus-raid-1.png http://people.freedesktop.org/~david/nautilus-raid-2.png http://people.freedesktop.org/~david/nautilus-raid-3.png http://people.freedesktop.org/~david/nautilus-poweroff-2.png http://people.freedesktop.org/~david/nautilus-drive-poweroff.png
+ * + * A key in the "mountable" namespace for getting the #GDriveStartStopType. + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN. + * wrong type i guess
Generally this looks ok to me, but I didn't review the patches in detail. There were some TODO comments left i noticed.
Comment on attachment 136596 [details] [review] Updated GIO patch Committed this (with a bugfix for the issue pointed out in comment 8) after talking to alexl on #nautilus
Created attachment 136691 [details] [review] Updated GVfs patch Here's an updated GVfs patch - changes from the previous patch 1. don't leak GMountOperation (also fixed existing leak in computer) 2. fix a bug in async_call_send() in gdaemonfile.c - the problem is that the DBusMessage serial isn't set until after the message is sent - so we always ended up getting 0 back meaning cancellation of any dbus job never actually worked (expect for the sync case). (I'm surprised we haven't seen problems with this before....) So, anyway, I fixed 2. because I wanted to make the ops in the GDU volume monitor support GCancellable. But since the libgdu currently doesn't support GCancellable I decided against this since it would make the code very convoluted. Once libgdu supports GCancellable, I'll fix up GVfs since it will amount to simply passing in the GCancellable to libgdu. It's not a big deal, UI-wise, that we don't support GCancellable for g_drive_start() right now (we do support it for g_volume_mount() (since it's so common) and that code is really disgusting because libgdu doesn't support GCancellable). So I think this bit is ready to go. I'll look through and update the Nautilus patch tomorrow.
Created attachment 136837 [details] [review] Updated GVfs patch No changes from previous GVfs patch except a rebase to master.
Created attachment 136838 [details] [review] Updated Nautilus Patch Only change from previous Nautilus patch is - Start the drive if the user clicks the icon in the places sidebar
alexl: OK to commit?
Committed the GVfs and Nautilus patches after talking to alexl on IRC.