Add a test to test basic functionality of getfsxattrat() and setfsxattrat() syscalls. Most of the work is done in fsxattrat utility. Signed-off-by: Andrey Albershteyn <aalbersh@xxxxxxxxxx> --- tests/generic/764 | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/764.out | 26 ++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/tests/generic/764 b/tests/generic/764 new file mode 100755 index 0000000000000000000000000000000000000000..c8e54173dddd425dd62c8752990bb939e5f12d64 --- /dev/null +++ b/tests/generic/764 @@ -0,0 +1,97 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Red Hat Inc. All Rights Reserved. +# +# FS QA Test 764 +# +# Test getfsxattrat/setfsxattrat syscalls +# +. ./common/preamble +_begin_fstest auto + +# Import common functions. +# . ./common/filter + +_wants_kernel_commit xxxxxxxxxxx \ + "fs: introduce getfsxattrat and setfsxattrat syscalls" + +# Modify as appropriate. +_require_scratch +_require_test_program "af_unix" +_require_test_program "fsxattrat" +_require_symlinks +_require_mknod + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +fsxattrat () { + $here/src/fsxattrat $* +} + +create_af_unix () { + $here/src/af_unix $* || echo af_unix failed +} + +projectdir=$SCRATCH_MNT/prj + +# Create normal files and special files +mkdir $projectdir +mkfifo $projectdir/fifo +mknod $projectdir/chardev c 1 1 +mknod $projectdir/blockdev b 1 1 +create_af_unix $projectdir/socket +touch $projectdir/foo +ln -s $projectdir/foo $projectdir/symlink +touch $projectdir/bar +ln -s $projectdir/bar $projectdir/broken-symlink +rm -f $projectdir/bar + +echo "Initial attributes state" +fsxattrat --get $projectdir +fsxattrat --get $projectdir ./fifo +fsxattrat --get $projectdir ./chardev +fsxattrat --get $projectdir ./blockdev +fsxattrat --get $projectdir ./socket +fsxattrat --get $projectdir ./foo +fsxattrat --get $projectdir ./symlink + +echo "Set FS_XFLAG_NODUMP (d)" +fsxattrat --set --set-nodump $projectdir +fsxattrat --set --set-nodump $projectdir ./fifo +fsxattrat --set --set-nodump $projectdir ./chardev +fsxattrat --set --set-nodump $projectdir ./blockdev +fsxattrat --set --set-nodump $projectdir ./socket +fsxattrat --set --set-nodump $projectdir ./foo +fsxattrat --set --set-nodump $projectdir ./symlink + +echo "Read attributes" +fsxattrat --get $projectdir +fsxattrat --get $projectdir ./fifo +fsxattrat --get $projectdir ./chardev +fsxattrat --get $projectdir ./blockdev +fsxattrat --get $projectdir ./socket +fsxattrat --get $projectdir ./foo +fsxattrat --get $projectdir ./symlink + +echo "Set attribute on broken link with AT_SYMLINK_NOFOLLOW" +fsxattrat --set --set-nodump $projectdir ./broken-symlink +fsxattrat --get $projectdir ./broken-symlink + +fsxattrat --set --no-follow --set-nodump $projectdir ./broken-symlink +fsxattrat --get --no-follow $projectdir ./broken-symlink + +cd $SCRATCH_MNT +touch ./foo2 +echo "Initial state of foo2" +fsxattrat --get --at-cwd ./foo2 +echo "Set attribute with AT_FDCWD" +fsxattrat --set --at-cwd --set-nodump ./foo2 +fsxattrat --get --at-cwd ./foo2 + +# if error +exit + +# success, all done +status=0 +exit diff --git a/tests/generic/764.out b/tests/generic/764.out new file mode 100644 index 0000000000000000000000000000000000000000..0dc8e973909c0e486c3662b9beba7deb1e495ba6 --- /dev/null +++ b/tests/generic/764.out @@ -0,0 +1,26 @@ +QA output created by 764 +Initial attributes state +----------------X /mnt/scratch/prj +----------------X ./fifo +----------------X ./chardev +----------------X ./blockdev +----------------X ./socket +----------------X ./foo +----------------X ./symlink +Set FS_XFLAG_NODUMP (d) +Read attributes +------d---------X /mnt/scratch/prj +------d---------X ./fifo +------d---------X ./chardev +------d---------X ./blockdev +------d---------X ./socket +------d---------X ./foo +------d---------X ./symlink +Set attribute on broken link with AT_SYMLINK_NOFOLLOW +Can not get fsxattr on ./broken-symlink: No such file or directory +Can not get fsxattr on ./broken-symlink: No such file or directory +------d---------- ./broken-symlink +Initial state of foo2 +----------------X ./foo2 +Set attribute with AT_FDCWD +------d---------X ./foo2 -- 2.47.2 -- - Andrey