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 770923 - nautilus does not show external drives in sidebar if plugged in on reboot
nautilus does not show external drives in sidebar if plugged in on reboot
Status: RESOLVED NOTGNOME
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
3.21.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-09-06 04:47 UTC by rockorequin
Modified: 2016-09-10 08:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
output from gvfs-mount -li (9.33 KB, text/plain)
2016-09-08 20:54 UTC, rockorequin
Details

Description rockorequin 2016-09-06 04:47:17 UTC
nautilus 3.20 should show external drives in its sidebar (I believe this is the case since 3.19). It always shows my SD card drive in the sidebar, but it only shows external USB drives in the sidebar if I plug them in once I have logged into the desktop. If they are plugged in during a reboot and I log in, they only appear in 'Other Locations' (although if the SD card is plugged in at reboot, it still appears in the sidebar; I don't know if that's a bug or not).

If I unmount the external drives and remount them, they still only appear in 'Other Locations'. I have to unmount them, remove them and plug them back in for them to appear in the sidebar.

The screenshot at https://launchpadlibrarian.net/281700879/nautilus%20with%20external%20drives.png illustrates this. nautilus has 3 drives plugged in and the SD card appears in the sidebar, but the USB drives (a btrfs and another with a btrfs and a ntfs partition) only are in 'Other Locations'.
Comment 1 Ondrej Holy 2016-09-06 06:11:02 UTC
This should be already fixed for upcoming 3.22, see Bug 765924. I doubt it can be backported in 3.20, because it requires API changes in GLib/GVfs...
Comment 2 Carlos Soriano 2016-09-06 07:55:49 UTC

*** This bug has been marked as a duplicate of bug 765924 ***
Comment 3 rockorequin 2016-09-06 09:32:05 UTC
Looking at the duplicate bug, it looks like the fix is gtk+, in commit https://git.gnome.org/browse/gtk%2B/commit/?id=55751fc. Is it correct that since I still have the issue, either Ubuntu 16.10 needs to apply the patch manually or update the gtk+ it is using? Thanks.
Comment 4 Carlos Soriano 2016-09-06 13:32:16 UTC
(In reply to rockorequin from comment #3)
> Looking at the duplicate bug, it looks like the fix is gtk+, in commit
> https://git.gnome.org/browse/gtk%2B/commit/?id=55751fc. Is it correct that
> since I still have the issue, either Ubuntu 16.10 needs to apply the patch
> manually or update the gtk+ it is using? Thanks.

yeah
Comment 5 rockorequin 2016-09-07 01:59:43 UTC
Hmm. I apt got the Ubuntu source out for gtk+3.0 (version 3.20.9 in this case) and it contains these files:

./debian/patches/0001-Improve-external-drives-detection.patch
./.pc/0001-Improve-external-drives-detection.patch

And it looks like the changes from the commit  https://git.gnome.org/browse/gtk%2B/commit/?id=55751fc are in already present in the files configure.ac, gtk/gtkplacessidebar.c, and gtk/gtkplacesview.c.

So does that indicate the patch has already been applied, and isn't working since I still have the issue? Does the fix rely on any other changes that are in gtk 3.22 and not 3.20?
Comment 6 Ondrej Holy 2016-09-07 06:04:49 UTC
AFAIK all of the following components needs patch in order to fix this in 3.20.x: GVfs, GLib, GTK+ and Nautilus.
Comment 7 rockorequin 2016-09-07 06:20:06 UTC
Thanks. Do you have any hints on how I could track down the relevant changes for this particular issue, eg are there other related bugs?
Comment 8 Ondrej Holy 2016-09-07 06:55:44 UTC
GVfs: Bug 765457
GLib: Bug 765900
GTK+: Bug 765924
Nautilus: Bug 768657 (as a part of attachment 331312 [details] [review])
Comment 9 rockorequin 2016-09-07 07:57:20 UTC
Thanks for that. Have I understood this correctly: does g_drive_is_removable() ultimately reflect the value of /sys/block/<device>/removable? If so, my drive is returning zero for this, so I assume it's a kernel bug?
Comment 10 Ondrej Holy 2016-09-07 08:10:45 UTC
I think so...
Comment 11 rockorequin 2016-09-07 09:14:46 UTC
Actually, /sys/block/<device>/removable is zero for all my block devices, even SD and USB ones, even if I plug them in after a reboot. So there must be more to it than that...

I looked at the related bugs, and AFAICT all the patches are already in Ubuntu except for the gvfs one. (The one you listed as nautilus with patches for placesview is in the gtk+ package, is that right?)

If I patch gvfs manually, gvfs_mount -li reports the new variable is_removable for my SD and USB external drives, but its value is always zero. Is there a patch required in udisks2 as well to support this new variable?
Comment 12 Ondrej Holy 2016-09-07 09:53:26 UTC
(In reply to rockorequin from comment #11)
> Actually, /sys/block/<device>/removable is zero for all my block devices,
> even SD and USB ones, even if I plug them in after a reboot. So there must
> be more to it than that...

AFAIK udisks2 just reflects /sys/block/<device>/removable (although it can be modified by udev rules), so there is a problem with kernel probably in your case, because I can see "1" for my removable media in /sys/block/<device>/removable.

> I looked at the related bugs, and AFAICT all the patches are already in
> Ubuntu except for the gvfs one. (The one you listed as nautilus with patches
> for placesview is in the gtk+ package, is that right?)

I am not Nautilus developer, so please correct me if needed, but I am convinced that you need also patch for Nautilus. The part in GTK+ is used e.g. for file chooser dialog. Nautilus uses same code, but it needs to be "copy-and-pasted" from gtkplacesview.c into nautilusgtkplacesview.c.

> If I patch gvfs manually, gvfs_mount -li reports the new variable
> is_removable for my SD and USB external drives, but its value is always
> zero. Is there a patch required in udisks2 as well to support this new
> variable?

Nothing for udisks2 is needed.
Comment 13 Carlos Soriano 2016-09-07 10:00:19 UTC
> I am not Nautilus developer, so please correct me if needed, but I am
> convinced that you need also patch for Nautilus. The part in GTK+ is used
> e.g. for file chooser dialog. Nautilus uses same code, but it needs to be
> "copy-and-pasted" from gtkplacesview.c into nautilusgtkplacesview.c.
> 
Hey, not for the sidebar no, that is public API. This bug is about the placessidebar.c not gtkplacesview.c (although you guess it makes sense to have both syncronized).
Comment 14 rockorequin 2016-09-07 16:09:24 UTC
> I can see "1" for my removable media in /sys/block/<device>/removable.

Is that for a USB flash key or USB hard drive or an SD card? Because I found this at http://unix.stackexchange.com/questions/125961/how-to-tell-if-a-scsi-device-is-removable:

> Note that removable (the device keeps existing but may have no media) 
> isn't the same thing as hotpluggable (the device can come and go). 
> For example, CD drives are removable but often not hotpluggable. 
> USB flash drives are both, but hard disks in external enclosures are 
> typically hotpluggable but not removable.
 
So I did some testing with my patched gvfs, and it seems to confirm the above is correct:

* my USB flash drive has removable set to one and it shows up in the sidebar

* my SD card has removable set to zero, and it *doesn't* show up in the sidebar. (It used to before I patched gvfs, though.)

* all of my USB hard drives in external enclosures (whether SSD or HDD) have removable set to zero, and they don't show up in the sidebar

All of the above are hotpluggable. They are removable in the sense that I can remove them from the USB port, but they are not all removable as far as the kernel is concerned. Because they are all hotpluggable, I would expect them to all appear in the sidebar. But is the sidebar deliberately not showing all hotpluggable drives?
Comment 15 Ondrej Holy 2016-09-08 08:07:11 UTC
Hmm, maybe the heuristics which drives are shown needs to be modified a bit. It worked correctly for my optical drive, my card reader, my usb flash drives and portable disks... hard drives in external enclosures are discutable, but card readers should be shown. Can you please attach output of "gvfs-mount -li" for those drives? I will have to make more tests....
Comment 16 rockorequin 2016-09-08 20:54:34 UTC
Created attachment 335142 [details]
output from gvfs-mount -li

The attached is for a bunch of drives:

* a portable 2.5" USB drive (Samsung SSD 840 EVO 500G)

* a desktop 3.5" USB drive (WDC WD40EZRX-00SPEB0)

* an SD card (SL08G)

* a USB flash key (Corsair Flash Voyager)

* a portable 2.5" USB drive (WD Elements 10B8)

* there's also a volume called 'OS', which is sitting on the internal SSD drive and isn't shown as being attached to any disk in the output from gvfs-mount (the laptop's internal drive doesn't show up at all unless I run gvfs-mount with sudo). It's the only one that is not hot-pluggable and that I don't particularly want to see in the sidebar.

The only drive that currently shows up in the sidebar is the USB flash drive. It is also the only one that has /sys/block/<device>/removable=1 and the only one that gvfs-mount shows with can_eject=1.

is_removable is shown as zero for all of the drives. Is it possible the patched gvfs package isn't installed completely? Although "which gvfs-mount" shows I'm running the one installed to /usr/local/bin/, "ps xa|grep gvfsd" suggests it's running the daemon from /usr/lib/gvfs, even though the install log suggests it was installed to /usr/local/libexec. Some of the patched gvfs must be installed, though, because my desktop drive used to show in the sidebar if I plugged it after logging in, and now it doesn't.

When gvfs-mount gives a drive a themed icon with "-usb" in it (eg drive-harddisk-usb), is that because it has correctly identified them as USB? (If run with sudo, it only gives them drive-harddisk for some reason, but when run as my user I see drive-harddisk-usb). Might that be a way perhaps to determine whether to show them in the sidebar?
 
I'm interested in the debate about drives in external enclosures versus portable drives, assuming my desktop 3.5" USB drive falls into this category. It's physically just as easy to unplug as the portable drives and if nautilus treats it differently I won't be able to easily tell if needs unmounting (or if it's even attached) by looking at the nautilus sidebar and hence I'll be far more likely to unplug it accidentally and maybe lose data.
Comment 17 Ondrej Holy 2016-09-09 12:01:05 UTC
Thanks for the output.

I've tested all removable devices I found at home (flash drives, optical drive, portable disk, card reader) and all of them has "is_removable=1" :-( although not all of them has 1 in "/sys/block/<device>/removable". So I've looked in udisks2 codes again and recalled it sets "removable=True" for all usb devices among others, see:
https://cgit.freedesktop.org/udisks/tree/src/udiskslinuxdrive.c#n875

Please check "Removable:" in "udisksctl dump" output, rather than "/sys/...". GVfs just reflects what is in udisks2. So yes, it seems that you probably installed the patched gvfs wrongly and the heuristics should work correctly...
Comment 18 Matthias Clasen 2016-09-09 20:18:07 UTC
I don't think there's anything to do in gtk in this bug, so I'm going to close this. It sounds like a downstream Ubuntu issue that should probably tracked in their bug tracker...
Comment 19 rockorequin 2016-09-10 07:32:01 UTC
udisksctl dump does show "Removable: true" for my SSD and desktop drives (not in the section /org/freedesktop/UDisks2/block_devices/sda, but in a section /org/freedesktop/UDisks2/drives/WDC_WD40EZRX_00SPEB0_WD_WCC4E0302897).

So from what I can tell, my patched "gvfs-mount -li" command is showing the return value of the g_drive_is_removable() function in glib. Since this is zero but udisks2 correctly shows "Removable: true", glib can't be querying udisks2 directly, but instead I assume it's querying the value from the gvfsd daemon, presumably read in by the code in monitor/proxy/gvfsproxyvolumemonitordaemon.c (which is also modified by the patch, but which I think hasn't been installed correctly).

Does that sound right? If so, I just now have to figure out why the makefile installs the daemons into /usr/local/lib/libexec or /usr/lib/libexec, but ubuntu runs from everything from /usr/lib/gvfs. 

Thanks for all the help, btw.
Comment 20 rockorequin 2016-09-10 08:51:01 UTC
Ok, I don't fully understand how I did it, but right now my patched daemons are running from /usr/local/lib/libexec and nautilus' sidebar is working properly and gvfs-mount --li is showing is_removable=1. Excellent!