Skip to content

fix utab after external update#2607

Merged
karelzak merged 5 commits intoutil-linux:masterfrom
karelzak:PR/libmount-utab-external
Dec 5, 2023
Merged

fix utab after external update#2607
karelzak merged 5 commits intoutil-linux:masterfrom
karelzak:PR/libmount-utab-external

Conversation

@karelzak
Copy link
Copy Markdown
Collaborator

Fixes: #2554

Please take a look at the commit message of the second patch.

The function compares two options strings and returns options which
are missing.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount is able to add missing entry to /run/mount/utab after
external /sbin/mouht.<type> helper execution. This is not enough, it's
possible that the helper write proper entry to the utab, but there is
missing some options expected by libmount (usually because the options
are irrelevant fro the helper.

Reproducer:

 Create a stupid mount.foo which writes x-foo=123 to utab:

   # echo -e '#!/bin/bash\n\n/bin/mount -i "$1" "$2" -o x-foo=123' > /sbin/mount.foo
   # chmod +x /sbin/mount.foo

 Run mount which needs to write x-bar=BAR options to utab and executes
 the helper (due to "-t foo", /dev/sdc1 is ext4):

   # mount -t foo /dev/sdc1 /mnt/test -o x-bar=BAR

 old mount:

   # cat /run/mount/utab
   ID=121 SRC=/dev/sdc1 TARGET=/mnt/test ROOT=/ OPTS=x-foo=123

 fixed mount:

   # cat /run/mount/utab
   ID=121 SRC=/dev/sdc1 TARGET=/mnt/test ROOT=/ OPTS=x-foo=123,x-bar=BAR

Fixes: util-linux#2554
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak karelzak force-pushed the PR/libmount-utab-external branch from 8b5e5ea to 477401f Compare November 29, 2023 12:35
t-8ch added a commit to t-8ch/util-linux that referenced this pull request Nov 29, 2023
See util-linux#2607

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
See util-linux#2607

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
@karelzak karelzak force-pushed the PR/libmount-utab-external branch 4 times, most recently from f7a8e9b to 9ed0195 Compare November 30, 2023 10:51
Comment thread tests/ts/mount/special Fixed
* remove optional ID= field (not on systems without statx())
* add missing tests/expected/mount/special-missing-options
* make sure utab is created
* use udevadm settle to wait for systemd

Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak karelzak force-pushed the PR/libmount-utab-external branch from 9ed0195 to 201bc72 Compare November 30, 2023 11:58
@karelzak
Copy link
Copy Markdown
Collaborator Author

I don't understand this (ubuntu 18):

umount: /__w/util-linux/util-linux/tests/output/mount/mnt: must be superuser to unmount.
                : missing-options             ...
diff-{{{
--- /__w/util-linux/util-linux/tests/expected/mount/special-missing-options	2023-11-30 11:58:55.575723318 +0000
+++ /__w/util-linux/util-linux/tests/output/mount/special-missing-options	2023-11-30 12:01:55.800410091 +0000
@@ -1 +0,0 @@
-SRC=/foo TARGET=/mountpoint ROOT=/ OPTS=x-foo=123,x-bar=BAR
}}}-diff

It seems utab does not exist or is empty, although explicitly created in the test; and umount(2) syscall ends with EPERM.

@t-8ch any idea what is wrong with the test?

@t-8ch
Copy link
Copy Markdown
Member

t-8ch commented Nov 30, 2023

No clue right now, maybe LIBMOUNT_DEBUG would help.

Comment thread tests/ts/mount/special Fixed
Comment thread tests/ts/mount/special Outdated
# This util-linux regression test component
# It's safe to remove me...
#
$TS_CMD_MOUNT -t tmpfs -i "\$1" "\$2" -o x-foo=123
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here could be an exec to pass through the status code

@karelzak
Copy link
Copy Markdown
Collaborator Author

karelzak commented Dec 1, 2023

So... it passed on Ubuntu 18 with

   missing-options             ... SKIPPED (tmpfs not mounted)

Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak karelzak force-pushed the PR/libmount-utab-external branch from f2fe531 to 4e1d7bf Compare December 5, 2023 09:22
@karelzak karelzak merged commit a25ccda into util-linux:master Dec 5, 2023
schubi2 pushed a commit to schubi2/util-linux that referenced this pull request Jan 18, 2024
See util-linux#2607

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
gnomesysadmins pushed a commit to GNOME/glib that referenced this pull request Jan 22, 2024
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: util-linux/util-linux#2607
gnomesysadmins pushed a commit to GNOME/glib that referenced this pull request Jan 31, 2024
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: util-linux/util-linux#2607
gnomesysadmins pushed a commit to GNOME/glib that referenced this pull request Jan 31, 2024
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: util-linux/util-linux#2607
gnomesysadmins pushed a commit to GNOME/glib that referenced this pull request Jan 31, 2024
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: util-linux/util-linux#2607
ahmed-masud pushed a commit to safai-labs/util-linux that referenced this pull request Feb 23, 2024
See util-linux#2607

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
havardgraff pushed a commit to pexip/glib that referenced this pull request Nov 17, 2025
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: util-linux/util-linux#2607
gnomesysadmins pushed a commit to GNOME/glib that referenced this pull request Jan 19, 2026
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: util-linux/util-linux#2607
gnomesysadmins pushed a commit to GNOME/glib that referenced this pull request Jan 22, 2026
The `GUnixMountMonitor` object implements monitoring on its own currently.
Only the `/proc/mounts` file changes are monitored. It is not aware of the
`/run/mount/utab` file changes. This file contains the userspace mount
options (e.g. `x-gvfs-notrash`, `x-gvfs-hide`) among others. There is a
problem when `/sbin/mount.<type>` (e.g. `mount.nfs`) helper programs are
used. In that case, the `/run/mount/utab` file is updated later than the
`/proc/mounts` file and thus the `GUnixMountMonitor` clients (e.g.
`gvfs-udisks2-volume-monitor`, `gvfsd-trash`) don't see the userspace
options until the next `mount-changed` signal. Let's use the `libmnt_monitor`
API for monitoring instead and emit the `mount-changed` signal also when the
`/run/mount/utab` file is changed.

Related: https://issues.redhat.com/browse/RHEL-14607
Related: util-linux/util-linux#2607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libmount: update options in /run/mount/utab after mount.type helper execution

3 participants