Add support for x-gvfs style options in fstab
AbandonedPublic

Authored by broulik on Mar 13 2017, 2:28 PM.

Details

Reviewers
dhaumann
dfaure
Group Reviewers
Plasma
Summary

These fstab options allow an administrator to specify names and icons intended for the user, shown in a GUI.

For details, see https://git.gnome.org/browse/gvfs/tree/monitor/udisks2/what-is-shown.txt

Based on a patch originally done by Stefan Brüns

Test Plan

This is a frameworks port and cleanup of https://git.reviewboard.kde.org/r/113587

Placed the following in /etc/fstab

hostname:/ /mnt/ nfs4 defaults,_netdev,user,rw,exec,comment=x-gvfs-show,x-gvfs-name=Test%20Folder,x-gvfs-icon=folder-home,timeo=14,noatime 0 0

Got the following entry:


Also verified that comment=x-gvfs-hide hides the entry. I did not implement x-gvfs-show as we always show all devices no matter where they are, so the override to forcefully show it is of no use to us.

Diff Detail

Repository
R245 Solid
Lint
Lint Skipped
Unit
Unit Tests Skipped
broulik created this revision.Mar 13 2017, 2:28 PM
Restricted Application added projects: Plasma, Frameworks. · View Herald TranscriptMar 13 2017, 2:28 PM
Restricted Application added subscribers: Frameworks, plasma-devel. · View Herald Transcript

Just some minor comments, besides that, looks sane.

src/solid/devices/backends/fstab/fstabdevice.cpp
40–41

Did you intentionally switch vendor and product?

51

QStringRef through midRef()

54

likewise, use QStringRef

src/solid/devices/backends/fstab/fstabhandling.cpp
146

If you save the decodedName, you could also call splitRef() to avoid more allocations.

broulik added inline comments.Mar 13 2017, 9:06 PM
src/solid/devices/backends/fstab/fstabdevice.cpp
40–41

I wondered that too, that's in the original patch, though, didn't really look into where this will end up, though :D

broulik added inline comments.Mar 14 2017, 9:29 AM
src/solid/devices/backends/fstab/fstabdevice.cpp
40–41

Just checked, this way round it makes more sense.

The vendor will be the host name and product the path. However, I'll split that into a separate patch then.

broulik updated this revision to Diff 12456.Mar 14 2017, 9:46 AM
broulik edited the summary of this revision. (Show Details)
  • Use QStringRef
  • Drop swap of vendor/product, this will be done in a separate patch
broulik updated this revision to Diff 12457.Mar 14 2017, 9:53 AM
  • Cache mountOptions or else it falls out of scope and QStringRef crashes (now I know why I should cache it :D)
dhaumann accepted this revision.Mar 14 2017, 6:47 PM

The patch looks good to me (without testing this locally here). I think the one QStringRef can be turned by to QStringList, since you finally need the QString anyways it seems...

src/solid/devices/backends/fstab/fstabhandling.cpp
152

Well ok, given you need to convert the string to QString finally anyways, you can keep the QStringList above (line 148).

This revision is now accepted and ready to land.Mar 14 2017, 6:47 PM

If no-one objects I'll push this after the next frameworks release

bruns added a subscriber: bruns.Apr 7 2017, 12:30 AM
bruns added inline comments.
src/solid/devices/backends/fstab/fstabdevice.cpp
47

Why QStringList& instead of QStringList?

51

Useless &
use indexOf('=', 11) (i.e. QChar)

54

use indexOf('=', 11)

@broulik Ping. Is there anything that keeps you from submitting this?

bruns added inline comments.Jul 11 2017, 9:09 PM
src/solid/devices/backends/fstab/fstabstorageaccess.cpp
48

Another useless use of const QList<T>&, FstabHandling returns a detached list.
Even if it were not detached, contains() would not detach.

52

According to the linked udisk2 documentation, this should be a plain "x-gvfs-hide", scrap the "comment=".

broulik abandoned this revision.Sep 14 2017, 8:46 AM

Superseded by D7774