History log of /linux-master/tools/testing/selftests/mount_setattr/mount_setattr_test.c
Revision Date Author Comments
# f1594bc6 23-Mar-2023 Anh Tuan Phan <tuananhlfc@gmail.com>

selftests mount: Fix mount_setattr_test builds failed

When compiling selftests with target mount_setattr I encountered some errors with the below messages:
mount_setattr_test.c: In function ‘mount_setattr_thread’:
mount_setattr_test.c:343:16: error: variable ‘attr’ has initializer but incomplete type
343 | struct mount_attr attr = {
| ^~~~~~~~~~

These errors might be because of linux/mount.h is not included. This patch resolves that issue.

Signed-off-by: Anh Tuan Phan <tuananhlfc@gmail.com>
Acked-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>


# d8e45bf1 13-Feb-2023 Shuah Khan <skhan@linuxfoundation.org>

selftests/mount_setattr: fix redefine struct mount_attr build error

Fix the following build error due to redefining struct mount_attr by
removing duplicate define from mount_setattr_test.c

gcc -g -isystem .../tools/testing/selftests/../../../usr/include -Wall -O2 -pthread mount_setattr_test.c -o .../tools/testing/selftests/mount_setattr/mount_setattr_test
mount_setattr_test.c:107:8: error: redefinition of ‘struct mount_attr’
107 | struct mount_attr {
| ^~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/mount.h:32,
from mount_setattr_test.c:10:
.../usr/include/linux/mount.h:129:8: note: originally defined here
129 | struct mount_attr {
| ^~~~~~~~~~
make: *** [../lib.mk:145: .../tools/testing/selftests/mount_setattr/mount_setattr_test] Error 1

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>


# d1c56bfd 03-Feb-2022 Christian Brauner <brauner@kernel.org>

tests: fix idmapped mount_setattr test

The test treated zero as a successful run when it really should treat
non-zero as a successful run. A mount's idmapping can't change once it
has been attached to the filesystem.

Link: https://lore.kernel.org/r/20220203131411.3093040-2-brauner@kernel.org
Fixes: 01eadc8dd96d ("tests: add mount_setattr() selftests")
Cc: Seth Forshee <seth.forshee@digitalocean.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-fsdevel@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>


# 5990b5d7 01-Jun-2021 Christian Brauner <christian.brauner@ubuntu.com>

tests: test MOUNT_ATTR_NOSYMFOLLOW with mount_setattr()

Add tests to verify that MOUNT_ATTR_NOSYMFOLLOW is honored.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Mattias Nissler <mnissler@chromium.org>
Cc: Aleksa Sarai <cyphar@cyphar.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Ross Zwisler <zwisler@google.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>


# 01eadc8d 21-Jan-2021 Christian Brauner <christian.brauner@ubuntu.com>

tests: add mount_setattr() selftests

Add a range of selftests for the new mount_setattr() syscall to verify
that it works as expected. This tests that:
- no invalid flags can be specified
- changing properties of a single mount works and leaves other mounts in
the mount tree unchanged
- changing a mount tre to read-only when one of the mounts has writers
fails and leaves the whole mount tree unchanged
- changing mount properties from multiple threads works
- changing atime settings works
- changing mount propagation works
- changing the mount options of a mount tree where the individual mounts
in the tree have different mount options only changes the flags that
were requested to change
- changing mount options from another mount namespace fails
- changing mount options from another user namespace fails
- idmapped mounts

Note, the main test-suite for idmapped mounts is part of xfstests and is
pretty huge. These tests here just make sure that the syscalls bits work
correctly.

TAP version 13
1..20
# Starting 20 tests from 3 test cases.
# RUN mount_setattr.invalid_attributes ...
# OK mount_setattr.invalid_attributes
ok 1 mount_setattr.invalid_attributes
# RUN mount_setattr.extensibility ...
# OK mount_setattr.extensibility
ok 2 mount_setattr.extensibility
# RUN mount_setattr.basic ...
# OK mount_setattr.basic
ok 3 mount_setattr.basic
# RUN mount_setattr.basic_recursive ...
# OK mount_setattr.basic_recursive
ok 4 mount_setattr.basic_recursive
# RUN mount_setattr.mount_has_writers ...
# OK mount_setattr.mount_has_writers
ok 5 mount_setattr.mount_has_writers
# RUN mount_setattr.mixed_mount_options ...
# OK mount_setattr.mixed_mount_options
ok 6 mount_setattr.mixed_mount_options
# RUN mount_setattr.time_changes ...
# OK mount_setattr.time_changes
ok 7 mount_setattr.time_changes
# RUN mount_setattr.multi_threaded ...
# OK mount_setattr.multi_threaded
ok 8 mount_setattr.multi_threaded
# RUN mount_setattr.wrong_user_namespace ...
# OK mount_setattr.wrong_user_namespace
ok 9 mount_setattr.wrong_user_namespace
# RUN mount_setattr.wrong_mount_namespace ...
# OK mount_setattr.wrong_mount_namespace
ok 10 mount_setattr.wrong_mount_namespace
# RUN mount_setattr_idmapped.invalid_fd_negative ...
# OK mount_setattr_idmapped.invalid_fd_negative
ok 11 mount_setattr_idmapped.invalid_fd_negative
# RUN mount_setattr_idmapped.invalid_fd_large ...
# OK mount_setattr_idmapped.invalid_fd_large
ok 12 mount_setattr_idmapped.invalid_fd_large
# RUN mount_setattr_idmapped.invalid_fd_closed ...
# OK mount_setattr_idmapped.invalid_fd_closed
ok 13 mount_setattr_idmapped.invalid_fd_closed
# RUN mount_setattr_idmapped.invalid_fd_initial_userns ...
# OK mount_setattr_idmapped.invalid_fd_initial_userns
ok 14 mount_setattr_idmapped.invalid_fd_initial_userns
# RUN mount_setattr_idmapped.attached_mount_inside_current_mount_namespace ...
# OK mount_setattr_idmapped.attached_mount_inside_current_mount_namespace
ok 15 mount_setattr_idmapped.attached_mount_inside_current_mount_namespace
# RUN mount_setattr_idmapped.attached_mount_outside_current_mount_namespace ...
# OK mount_setattr_idmapped.attached_mount_outside_current_mount_namespace
ok 16 mount_setattr_idmapped.attached_mount_outside_current_mount_namespace
# RUN mount_setattr_idmapped.detached_mount_inside_current_mount_namespace ...
# OK mount_setattr_idmapped.detached_mount_inside_current_mount_namespace
ok 17 mount_setattr_idmapped.detached_mount_inside_current_mount_namespace
# RUN mount_setattr_idmapped.detached_mount_outside_current_mount_namespace ...
# OK mount_setattr_idmapped.detached_mount_outside_current_mount_namespace
ok 18 mount_setattr_idmapped.detached_mount_outside_current_mount_namespace
# RUN mount_setattr_idmapped.change_idmapping ...
# OK mount_setattr_idmapped.change_idmapping
ok 19 mount_setattr_idmapped.change_idmapping
# RUN mount_setattr_idmapped.idmap_mount_tree_invalid ...
# OK mount_setattr_idmapped.idmap_mount_tree_invalid
ok 20 mount_setattr_idmapped.idmap_mount_tree_invalid
# PASSED: 20 / 20 tests passed.
# Totals: pass:20 fail:0 xfail:0 xpass:0 skip:0 error:0

Link: https://lore.kernel.org/r/20210121131959.646623-37-christian.brauner@ubuntu.com
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>