After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 585591 - Starting/stopping drives
Starting/stopping drives
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-06-12 17:33 UTC by David Zeuthen (not reading bugmail)
Modified: 2009-06-18 15:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed API (12.05 KB, patch)
2009-06-12 17:35 UTC, David Zeuthen (not reading bugmail)
none Details | Review
Updated GIO patch (30.86 KB, patch)
2009-06-15 03:53 UTC, David Zeuthen (not reading bugmail)
committed Details | Review
GVfs patch (115.64 KB, patch)
2009-06-15 03:55 UTC, David Zeuthen (not reading bugmail)
none Details | Review
Nautilus patch (52.77 KB, patch)
2009-06-15 03:56 UTC, David Zeuthen (not reading bugmail)
none Details | Review
Updated GVfs patch (117.35 KB, patch)
2009-06-16 06:42 UTC, David Zeuthen (not reading bugmail)
none Details | Review
Updated GVfs patch (119.55 KB, patch)
2009-06-17 14:23 UTC, David Zeuthen (not reading bugmail)
committed Details | Review
Updated Nautilus Patch (55.76 KB, patch)
2009-06-17 14:24 UTC, David Zeuthen (not reading bugmail)
committed Details | Review

Description David Zeuthen (not reading bugmail) 2009-06-12 17:33:25 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.
Comment 1 David Zeuthen (not reading bugmail) 2009-06-12 17:35:38 UTC
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.
Comment 2 David Zeuthen (not reading bugmail) 2009-06-15 03:53:08 UTC
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.
Comment 3 David Zeuthen (not reading bugmail) 2009-06-15 03:55:30 UTC
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.
Comment 4 David Zeuthen (not reading bugmail) 2009-06-15 03:56:45 UTC
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.
Comment 5 David Zeuthen (not reading bugmail) 2009-06-15 03:57:18 UTC
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.
Comment 6 David Zeuthen (not reading bugmail) 2009-06-15 03:58:33 UTC
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.
Comment 8 Alexander Larsson 2009-06-15 14:02:31 UTC
+ *
+ * A key in the "mountable" namespace for getting the #GDriveStartStopType.
+ * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_BOOLEAN.
+ *

wrong type i guess
Comment 9 Alexander Larsson 2009-06-15 14:10:13 UTC
Generally this looks ok to me, but I didn't review the patches in detail.

There were some TODO comments left i noticed.
Comment 10 David Zeuthen (not reading bugmail) 2009-06-15 15:28:57 UTC
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
Comment 11 David Zeuthen (not reading bugmail) 2009-06-16 06:42:44 UTC
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.
Comment 12 David Zeuthen (not reading bugmail) 2009-06-17 14:23:27 UTC
Created attachment 136837 [details] [review]
Updated GVfs patch

No changes from previous GVfs patch except a rebase to master.
Comment 13 David Zeuthen (not reading bugmail) 2009-06-17 14:24:44 UTC
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
Comment 14 David Zeuthen (not reading bugmail) 2009-06-18 14:29:12 UTC
alexl: OK to commit?
Comment 15 David Zeuthen (not reading bugmail) 2009-06-18 15:19:20 UTC
Committed the GVfs and Nautilus patches after talking to alexl on IRC.