]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: implement ro[=vfs,fs]
authorKarel Zak <kzak@redhat.com>
Tue, 29 Oct 2024 14:56:31 +0000 (15:56 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 29 Oct 2024 15:04:20 +0000 (16:04 +0100)
commit4095c5bb6757b506acbe47a8bc60d8ebd04ba8a5
tree582c9fdb97d79c441581fc8576e7b1649e880bac
parent03b2e73ae649a957a4f695df4f44c2cbce8d5f92
libmount: implement ro[=vfs,fs]

The new mount API allows for specifying whether to use a read-only
setting on the VFS or FS. Let's export this feature to the mount(8)
command line and fstab by adding new optional arguments "fs" and "vfs"
for the readonly mount flags. If nothing is specified, then the
default will be to mount as read-only on both layers for a normal
mount.

 # mount -o ro=vfs /dev/sdc /mnt/test
 ...
 fsopen("ext4", FSOPEN_CLOEXEC)          = 3
 fsconfig(3, FSCONFIG_SET_STRING, "source", "/dev/sdc", 0) = 0
 fsconfig(3, FSCONFIG_CMD_CREATE, NULL, NULL, 0) = 0
 mount_setattr(4, "", AT_EMPTY_PATH, {attr_set=MOUNT_ATTR_RDONLY, attr_clr=0, propagation=0 /* MS_??? */, userns_fd=0}, 32) = 0
 move_mount(4, "", AT_FDCWD, "/mnt/test", MOVE_MOUNT_F_EMPTY_PATH) = 0

 # mount -o ro=fs /dev/sdc /mnt/test
 ...
 fsopen("ext4", FSOPEN_CLOEXEC)          = 3
 fsconfig(3, FSCONFIG_SET_STRING, "source", "/dev/sdc", 0) = 0
 fsconfig(3, FSCONFIG_SET_FLAG, "ro", NULL, 0) = 0
 fsconfig(3, FSCONFIG_CMD_CREATE, NULL, NULL, 0) = 0
 move_mount(4, "", AT_FDCWD, "/mnt/test", MOVE_MOUNT_F_EMPTY_PATH) = 0

 # mount -o ro /dev/sdc /mnt/test
 ...
 fsopen("ext4", FSOPEN_CLOEXEC)          = 3
 fsconfig(3, FSCONFIG_SET_STRING, "source", "/dev/sdc", 0) = 0
 fsconfig(3, FSCONFIG_SET_FLAG, "ro", NULL, 0) = 0
 fsconfig(3, FSCONFIG_CMD_CREATE, NULL, NULL, 0) = 0
 mount_setattr(4, "", AT_EMPTY_PATH, {attr_set=MOUNT_ATTR_RDONLY, attr_clr=0, propagation=0 /* MS_??? */, userns_fd=0}, 32) = 0
 move_mount(4, "", AT_FDCWD, "/mnt/test", MOVE_MOUNT_F_EMPTY_PATH) = 0

The patch improves also the mount(8) man page to provide clearer
information about VFS.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/hook_mount.c
libmount/src/mountP.h
libmount/src/optlist.c
sys-utils/mount.8.adoc