GNOME Bugzilla – Bug 668132
Use libmount and expose mount options on GUnixMountEntry type
Last modified: 2018-05-16 10:32:58 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.
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.
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.
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).
Thanks for the review, I've made some changes which should reflect your comments...
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’
Attachment 371600 [details] pushed as d0821da - gio: Add g_unix_mount_get_options