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 668132 - Use libmount and expose mount options on GUnixMountEntry type
Use libmount and expose mount options on GUnixMountEntry type
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 795578
 
 
Reported: 2012-01-17 19:54 UTC by David Zeuthen (not reading bugmail)
Modified: 2018-05-16 10:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio: Add g_unix_mount_get_options (6.66 KB, patch)
2018-04-26 12:25 UTC, Ondrej Holy
none Details | Review
gio: Add g_unix_mount_get_options (6.79 KB, patch)
2018-05-02 08:39 UTC, Ondrej Holy
committed Details | Review

Description David Zeuthen (not reading bugmail) 2012-01-17 19:54:30 UTC
Similar to how bug 660536 exposes mount options on the GUnixMountPoint type (corresponding to fstab entries), it would be very useful if we can get mount options for actual mounts (if the underlying platform allows it). E.g. this new API

 const gchar *g_unix_mount_get_options()

For example: It would be nice if the user could override whether a specific mount is displayed or not, so e.g.

 # mount /dev/sdc1 /mnt -ocomment=gvfs-show=1

forces the mount to be visible (would usually be invisible) and

 # mount /dev/sdc1 /home/user/Somewhere -ocomment=gvfs-show=0

forces the mount to be invisible (would usually be visible).

On Linux, however, this requires a libmount-based mount(8) command since right now the information is thrown away (this is because /etc/mtab is now a symlink to /proc/mounts).

Additionally, we would want to switch gio/gunixmounts.c to use libmount because otherwise we wouldn't be able to recover the information.

I think Fedora 17 will have the new libmount-based mount(8) command so suggest to start looking at this for GNOME 3.5/3.6.
Comment 1 Ondrej Holy 2018-04-26 12:25:28 UTC
Created attachment 371428 [details] [review]
gio: Add g_unix_mount_get_options

GVfsUDisks2VolumeMonitor handles x-gvfs-hide/x-gvfs-show mount options
used to overwrite our heuristics whether the mount should be shown, or
hidden. Unfortunately, it works currently only for mounts with
corresponding fstab entries, because the options are read over
g_unix_mount_point_get_options. Let's introduce g_unix_mount_get_options
to allow reading of the options for all sort of mounts (e.g. created
over pam_mount, or manually mounted).

GLIB_AVAILABLE_IN_ has to be updated accordingly before push.
Comment 2 Philip Withnall 2018-04-27 10:26:26 UTC
Review of attachment 371428 [details] [review]:

::: gio/gunixmounts.c
@@ +2170,3 @@
+ * @mount_entry: a #GUnixMount.
+ * 
+ * Gets the options for the unix mount.

This documentation could include some details of the format used by options, and an example of some typical options, or what you might want to use the function for. For example, are the options space-separated? Are they always `key=value`?

@@ +2172,3 @@
+ * Gets the options for the unix mount.
+ * 
+ * Returns: a string containing the options, or NULL.

‘, or %NULL if no options are set’

This also needs a (nullable) annotation.

::: gio/gunixmounts.h
@@ +82,3 @@
 GLIB_AVAILABLE_IN_ALL
 const char *   g_unix_mount_get_fs_type             (GUnixMountEntry    *mount_entry);
+//GLIB_AVAILABLE_IN_2_58

GLIB_AVAILABLE_IN_2_58 has been declared in master since commit affe33b7e7b4eb5550488866cbd1a63d942b51d2.
Comment 3 Ondrej Holy 2018-05-02 08:39:45 UTC
Created attachment 371600 [details] [review]
gio: Add g_unix_mount_get_options

GVfsUDisks2VolumeMonitor handles x-gvfs-hide/x-gvfs-show mount options
used to overwrite our heuristics whether the mount should be shown, or
hidden. Unfortunately, it works currently only for mounts with
corresponding fstab entries, because the options are read over
g_unix_mount_point_get_options. Let's introduce g_unix_mount_get_options
to allow reading of the options for all sort of mounts (e.g. created
over pam_mount, or manually mounted).
Comment 4 Ondrej Holy 2018-05-02 08:42:14 UTC
Thanks for the review, I've made some changes which should reflect your comments...
Comment 5 Philip Withnall 2018-05-16 10:27:11 UTC
Review of attachment 371600 [details] [review]:

Thanks. I’ll fix these minor comments before I push it.

::: gio/gunixmounts.c
@@ +2170,3 @@
+ * @mount_entry: a #GUnixMountEntry.
+ * 
+ * Gets comma-separated list of mount options for the unix mount, e.g.

‘Gets a’

@@ +2173,3 @@
+ * "rw,relatime,seclabel,data=ordered".
+ * 
+ * This is similar to g_unix_mount_point_get_options but it takes

‘g_unix_mount_point_get_options()’ (note the trailing ‘()’) so that it gets automatically linked by gtk-doc.

@@ +2174,3 @@
+ * 
+ * This is similar to g_unix_mount_point_get_options but it takes
+ * #GUnixMountEntry as an argument.

‘a #GUnixMountEntry’
Comment 6 Philip Withnall 2018-05-16 10:32:50 UTC
Attachment 371600 [details] pushed as d0821da - gio: Add g_unix_mount_get_options