Commit bc52235e authored by Ondrej Holy's avatar Ondrej Holy

gunixmounts: Return the last matching mount for same mount path

More mounts can have same mount path, but only the last one is
accessible. Thus we should always return the last matching mount from
g_unix_mount_at() and g_unix_mount_for(). This should also solve
problems with g_file_trash() on automounted filesystems, which are
caused by the recently added mount checks.

Closes: #1727
parent 1a03ebc4
Pipeline #69954 passed with stages
in 15 minutes and 39 seconds
......@@ -1552,6 +1552,9 @@ g_unix_mounts_get (guint64 *time_read)
* is set, it will be filled with a unix timestamp for checking
* if the mounts have changed since with g_unix_mounts_changed_since().
*
* If more mounts have the same mount path, the last matching mount
* is returned.
*
* Returns: (transfer full): a #GUnixMountEntry.
**/
GUnixMountEntry *
......@@ -1568,8 +1571,13 @@ g_unix_mount_at (const char *mount_path,
{
mount_entry = l->data;
if (!found && strcmp (mount_path, mount_entry->mount_path) == 0)
found = mount_entry;
if (strcmp (mount_path, mount_entry->mount_path) == 0)
{
if (found != NULL)
g_unix_mount_free (found);
found = mount_entry;
}
else
g_unix_mount_free (mount_entry);
}
......@@ -1587,6 +1595,9 @@ g_unix_mount_at (const char *mount_path,
* is set, it will be filled with a unix timestamp for checking
* if the mounts have changed since with g_unix_mounts_changed_since().
*
* If more mounts have the same mount path, the last matching mount
* is returned.
*
* Returns: (transfer full): a #GUnixMountEntry.
*
* Since: 2.52
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment