From: Karel Zak Date: Tue, 10 Jan 2023 11:40:47 +0000 (+0100) Subject: libmount: use MNT_ERR_APPLYFLAGS for failed mount_setattr() X-Git-Tag: v2.39-rc1~171 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=987d844cdbc0f91ca81de3c1e5d0628a60eb458f;p=thirdparty%2Futil-linux.git libmount: use MNT_ERR_APPLYFLAGS for failed mount_setattr() The classic mount(2) based version uses MNT_ERR_APPLYFLAGS when not able to set flags and errno is EINVAL. This is expected by mnt_context_get_mount_excode() where libmount generates error messages for mount(8). Expected is: # mount --make-private /mnt/test mount: /mnt/test: not mount point or bad option. rather than generic error: mount: /mnt/test: wrong fs type, bad option, bad superblock on none ... Signed-off-by: Karel Zak --- diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c index 6f3dfca0bc..1c5fcc8e79 100644 --- a/libmount/src/hook_mount.c +++ b/libmount/src/hook_mount.c @@ -348,6 +348,9 @@ static int hook_set_vfsflags(struct libmnt_context *cxt, rc = mount_setattr(api->fd_tree, "", callflags, &attr, sizeof(attr)); set_syscall_status(cxt, "move_setattr", rc == 0); + + if (rc && errno == EINVAL) + return -MNT_ERR_APPLYFLAGS; done: return rc == 0 ? 0 : -errno; } @@ -405,6 +408,9 @@ static int hook_set_propagation(struct libmnt_context *cxt, rc = mount_setattr(api->fd_tree, "", flgs, &attr, sizeof(attr)); set_syscall_status(cxt, "move_setattr", rc == 0); + + if (rc && errno == EINVAL) + return -MNT_ERR_APPLYFLAGS; if (rc != 0) break; }