diff options
author | Ondrej Holy <oholy@redhat.com> | 2018-12-03 11:01:16 +0100 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2018-12-03 14:36:50 +0100 |
commit | 1fd0205fdec21717fa63f68710dc62d758f15721 (patch) | |
tree | d6c58963f480a12ac0f56b4ebd6f58244bbf2355 /monitor/udisks2 | |
parent | 396216f71abf6907efd1383ca0d1a597918cd83d (diff) | |
download | gvfs-1fd0205fdec21717fa63f68710dc62d758f15721.tar.gz |
udisks2: Restore support of comment=x-gvfs-* option
Beginning the commit 959db3e0, mtab-based mount options are prioritized
prior to the fstab options. However, "comment" option is not propagated
to mtab and thus mounts with "comment=x-gvfs-show" can be ignored, but
volumes can be still shown for them and vice versa. Consequently, mount
operation fails with the following:
"Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command."
Just a note, that "comment=x-gvfs-*" is wrong as per the docs and it
should be "comment=gvfs-*" instead. However, it seems that the people
started using this after commit 37d4bf32 as workaround on distributions
with old util-linux versions, where plain "x-gvfs-*" option caused the
following error:
"Unrecognized mount option "x-gvfs-show" or missing value"
The workaround using "comment=x-gvfs-*" option worked so far just only
thanks to the "bug" in gvfs_udisks2_utils_lookup_fstab_options_value()
function, which doesn't care about the prefix of the mount option.
Let's prioritize fstab options before mtab-based mount options to fix
this regression. It is maybe less reliable because the assignment of
the corresponding fstab entry is arguable, but the rest of the volume
monitor code relies on it anyway.
Closes: https://gitlab.gnome.org/GNOME/gvfs/issues/348
Diffstat (limited to 'monitor/udisks2')
-rw-r--r-- | monitor/udisks2/gvfsudisks2utils.c | 6 | ||||
-rw-r--r-- | monitor/udisks2/gvfsudisks2volumemonitor.c | 21 |
2 files changed, 18 insertions, 9 deletions
diff --git a/monitor/udisks2/gvfsudisks2utils.c b/monitor/udisks2/gvfsudisks2utils.c index bb2cdaf6..df56962b 100644 --- a/monitor/udisks2/gvfsudisks2utils.c +++ b/monitor/udisks2/gvfsudisks2utils.c @@ -110,6 +110,12 @@ gvfs_udisks2_utils_lookup_fstab_options_value (const gchar *fstab_options, const gchar *start; guint n; + /* The code doesn't care about prefix, which may cause problems for + * options like "auto" and "noauto". However, this function is only used + * with our "x-gvfs-*" options, where mentioned problems are unlikely. + * Be careful, that some people rely on this bug and use "comment=x-gvfs-*" + * as workaround, see: https://gitlab.gnome.org/GNOME/gvfs/issues/348 + */ start = strstr (fstab_options, key); if (start != NULL) { diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c index b3f3ce65..57917b50 100644 --- a/monitor/udisks2/gvfsudisks2volumemonitor.c +++ b/monitor/udisks2/gvfsudisks2volumemonitor.c @@ -701,6 +701,18 @@ should_include_mount (GVfsUDisks2VolumeMonitor *monitor, const gchar *options; gboolean ret; + /* If mounted at the designated mount point, use g_unix_mount_point_get_options + * in prior to g_unix_mount_get_options to keep support of "comment=" options, + * see https://gitlab.gnome.org/GNOME/gvfs/issues/348. + */ + mount_point = get_mount_point_for_mount (mount_entry); + if (mount_point != NULL) + { + ret = should_include_mount_point (monitor, mount_point); + g_unix_mount_point_free (mount_point); + goto out; + } + /* g_unix_mount_get_options works only with libmount, * see https://bugzilla.gnome.org/show_bug.cgi?id=668132 */ @@ -712,15 +724,6 @@ should_include_mount (GVfsUDisks2VolumeMonitor *monitor, goto out; } - /* if mounted at the designated mount point, use that info to decide */ - mount_point = get_mount_point_for_mount (mount_entry); - if (mount_point != NULL) - { - ret = should_include_mount_point (monitor, mount_point); - g_unix_mount_point_free (mount_point); - goto out; - } - ret = should_include (g_unix_mount_get_mount_path (mount_entry), NULL); out: |