* [PATCH 0/3] generic/772: split and fix
@ 2025-10-20 13:55 Andrey Albershteyn
2025-10-20 13:55 ` [PATCH 1/3] common/filter: add missing file attribute Andrey Albershteyn
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Andrey Albershteyn @ 2025-10-20 13:55 UTC (permalink / raw)
To: linux-xfs, fstests; +Cc: djwong, zlang, Andrey Albershteyn
Hi all,
This one add one missed file attribute flag (n). Then, the check for
file_getattr/file_setattr on regular and special files is lifted to the
common/ for futher test splitting. The generic/772 is split into two
tests one for regular files and one for special files.
This one based on top of Darrick's "random fixes" patchset [1]
To: fstests@vger.kernel.org
Cc: linux-xfs@vger.kernel.org
Cc: zlang@redhat.com
Cc: djwong@kernel.org
[1]: https://lore.kernel.org/fstests/176054617853.2391029.10911105763476647916.stgit@frogsfrogsfrogs/T/#t
Andrey Albershteyn (3):
common/filter: add missing file attribute
generic/772: require filesystem to support file_[g|s]etattr
generic/772: split this test into 772 and 773 for regular and special
files
common/filter | 2 +-
common/rc | 32 +++++++++++++++++
tests/generic/772 | 41 ++-------------------
tests/generic/772.out | 14 --------
tests/generic/773 | 84 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/773.out | 20 +++++++++++
tests/xfs/648 | 7 ++--
7 files changed, 142 insertions(+), 58 deletions(-)
create mode 100755 tests/generic/773
create mode 100644 tests/generic/773.out
--
2.50.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] common/filter: add missing file attribute
2025-10-20 13:55 [PATCH 0/3] generic/772: split and fix Andrey Albershteyn
@ 2025-10-20 13:55 ` Andrey Albershteyn
2025-10-20 16:46 ` Darrick J. Wong
2025-10-20 13:55 ` [PATCH 2/3] generic/772: require filesystem to support file_[g|s]etattr Andrey Albershteyn
2025-10-20 13:55 ` [PATCH 3/3] generic/772: split this test into 772 and 773 for regular and special files Andrey Albershteyn
2 siblings, 1 reply; 9+ messages in thread
From: Andrey Albershteyn @ 2025-10-20 13:55 UTC (permalink / raw)
To: linux-xfs, fstests; +Cc: djwong, zlang, Andrey Albershteyn
Add n (nosymlinks) char according to xfsprogs io/attr.c
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
common/filter | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/filter b/common/filter
index c3a751dd0c39..28048b4b601b 100644
--- a/common/filter
+++ b/common/filter
@@ -692,7 +692,7 @@ _filter_sysfs_error()
_filter_file_attributes()
{
if [[ $1 == ~* ]]; then
- regex=$(echo "[aAcCdDeEfFijmNpPsrStTuxVX]" | tr -d "$1")
+ regex=$(echo "[aAcCdDeEfFijmnNpPrsStTuVxX]" | tr -d "$1")
else
regex="$1"
fi
--
2.50.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] generic/772: require filesystem to support file_[g|s]etattr
2025-10-20 13:55 [PATCH 0/3] generic/772: split and fix Andrey Albershteyn
2025-10-20 13:55 ` [PATCH 1/3] common/filter: add missing file attribute Andrey Albershteyn
@ 2025-10-20 13:55 ` Andrey Albershteyn
2025-10-20 16:45 ` Darrick J. Wong
2025-10-20 13:55 ` [PATCH 3/3] generic/772: split this test into 772 and 773 for regular and special files Andrey Albershteyn
2 siblings, 1 reply; 9+ messages in thread
From: Andrey Albershteyn @ 2025-10-20 13:55 UTC (permalink / raw)
To: linux-xfs, fstests; +Cc: djwong, zlang, Andrey Albershteyn
Add _require_* function to check that filesystem support these syscalls
on regular and special files.
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
common/rc | 32 ++++++++++++++++++++++++++++++++
tests/generic/772 | 5 ++---
tests/xfs/648 | 7 +++----
3 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/common/rc b/common/rc
index dcae5bc33b19..78928c27da97 100644
--- a/common/rc
+++ b/common/rc
@@ -5994,6 +5994,38 @@ _require_inplace_writes()
fi
}
+# Require filesystem to support file_getattr()/file_setattr() syscalls on
+# regular files
+_require_file_attr()
+{
+ local test_file="$SCRATCH_MNT/foo"
+ touch $test_file
+
+ $here/src/file_attr --set --set-nodump $SCRATCH_MNT ./foo &>/dev/null
+ rc=$?
+ rm -f "$test_file"
+
+ if [ $rc -ne 0 ]; then
+ _notrun "file_getattr not supported for regular files on $FSTYP"
+ fi
+}
+
+# Require filesystem to support file_getattr()/file_setattr() syscalls on
+# special files (chardev, fifo...)
+_require_file_attr_special()
+{
+ local test_file="$SCRATCH_MNT/fifo"
+ mkfifo $test_file
+
+ $here/src/file_attr --set --set-nodump $SCRATCH_MNT ./fifo &>/dev/null
+ rc=$?
+ rm -f "$test_file"
+
+ if [ $rc -ne 0 ]; then
+ _notrun "file_getattr not supported for special files on $FSTYP"
+ fi
+}
+
################################################################################
# make sure this script returns success
/bin/true
diff --git a/tests/generic/772 b/tests/generic/772
index e68a67246544..bdd55b10f310 100755
--- a/tests/generic/772
+++ b/tests/generic/772
@@ -20,6 +20,8 @@ _require_mknod
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
+_require_file_attr
+_require_file_attr_special
file_attr () {
$here/src/file_attr $*
@@ -43,9 +45,6 @@ touch $projectdir/bar
ln -s $projectdir/bar $projectdir/broken-symlink
rm -f $projectdir/bar
-file_attr --get $projectdir ./fifo &>/dev/null || \
- _notrun "file_getattr not supported on $FSTYP"
-
echo "Error codes"
# wrong AT_ flags
file_attr --get --invalid-at $projectdir ./foo
diff --git a/tests/xfs/648 b/tests/xfs/648
index e3c2fbe00b66..a268bfdb0e2d 100755
--- a/tests/xfs/648
+++ b/tests/xfs/648
@@ -20,10 +20,12 @@ _require_test_program "af_unix"
_require_test_program "file_attr"
_require_symlinks
_require_mknod
-
_scratch_mkfs >>$seqres.full 2>&1
_qmount_option "pquota"
_scratch_mount
+_require_file_attr
+_require_file_attr_special
+
create_af_unix () {
$here/src/af_unix $* || echo af_unix failed
@@ -47,9 +49,6 @@ touch $projectdir/bar
ln -s $projectdir/bar $projectdir/broken-symlink
rm -f $projectdir/bar
-$here/src/file_attr --get $projectdir ./fifo &>/dev/null || \
- _notrun "file_getattr not supported on $FSTYP"
-
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "project -sp $projectdir $id" $SCRATCH_DEV | filter_quota
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
--
2.50.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] generic/772: split this test into 772 and 773 for regular and special files
2025-10-20 13:55 [PATCH 0/3] generic/772: split and fix Andrey Albershteyn
2025-10-20 13:55 ` [PATCH 1/3] common/filter: add missing file attribute Andrey Albershteyn
2025-10-20 13:55 ` [PATCH 2/3] generic/772: require filesystem to support file_[g|s]etattr Andrey Albershteyn
@ 2025-10-20 13:55 ` Andrey Albershteyn
2025-10-20 16:45 ` Darrick J. Wong
2 siblings, 1 reply; 9+ messages in thread
From: Andrey Albershteyn @ 2025-10-20 13:55 UTC (permalink / raw)
To: linux-xfs, fstests; +Cc: djwong, zlang, Andrey Albershteyn
Not all filesystem support setting file attributes on special files. The
syscalls would still work for regular files. Let's split this test into
two to make it obvious if only special files support is missing.
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
tests/generic/772 | 38 +-------------------
tests/generic/772.out | 14 --------
tests/generic/773 | 84 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/773.out | 20 +++++++++++
4 files changed, 105 insertions(+), 51 deletions(-)
create mode 100755 tests/generic/773
create mode 100644 tests/generic/773.out
diff --git a/tests/generic/772 b/tests/generic/772
index bdd55b10f310..0d5c4749b010 100755
--- a/tests/generic/772
+++ b/tests/generic/772
@@ -4,7 +4,7 @@
#
# FS QA Test No. 772
#
-# Test file_getattr/file_setattr syscalls
+# Test file_getattr() and file_setattr() syscalls on regular files
#
. ./common/preamble
_begin_fstest auto
@@ -13,7 +13,6 @@ _begin_fstest auto
# Modify as appropriate.
_require_scratch
-_require_test_program "af_unix"
_require_test_program "file_attr"
_require_symlinks
_require_mknod
@@ -21,29 +20,16 @@ _require_mknod
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
_require_file_attr
-_require_file_attr_special
file_attr () {
$here/src/file_attr $*
}
-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 "Error codes"
# wrong AT_ flags
@@ -59,37 +45,15 @@ file_attr --set --new-fsx-flag $projectdir ./foo
echo "Initial attributes state"
file_attr --get $projectdir | _filter_scratch | _filter_file_attributes ~d
-file_attr --get $projectdir ./fifo | _filter_file_attributes ~d
-file_attr --get $projectdir ./chardev | _filter_file_attributes ~d
-file_attr --get $projectdir ./blockdev | _filter_file_attributes ~d
-file_attr --get $projectdir ./socket | _filter_file_attributes ~d
file_attr --get $projectdir ./foo | _filter_file_attributes ~d
-file_attr --get $projectdir ./symlink | _filter_file_attributes ~d
echo "Set FS_XFLAG_NODUMP (d)"
file_attr --set --set-nodump $projectdir
-file_attr --set --set-nodump $projectdir ./fifo
-file_attr --set --set-nodump $projectdir ./chardev
-file_attr --set --set-nodump $projectdir ./blockdev
-file_attr --set --set-nodump $projectdir ./socket
file_attr --set --set-nodump $projectdir ./foo
-file_attr --set --set-nodump $projectdir ./symlink
echo "Read attributes"
file_attr --get $projectdir | _filter_scratch | _filter_file_attributes ~d
-file_attr --get $projectdir ./fifo | _filter_file_attributes ~d
-file_attr --get $projectdir ./chardev | _filter_file_attributes ~d
-file_attr --get $projectdir ./blockdev | _filter_file_attributes ~d
-file_attr --get $projectdir ./socket | _filter_file_attributes ~d
file_attr --get $projectdir ./foo | _filter_file_attributes ~d
-file_attr --get $projectdir ./symlink | _filter_file_attributes ~d
-
-echo "Set attribute on broken link with AT_SYMLINK_NOFOLLOW"
-file_attr --set --set-nodump $projectdir ./broken-symlink
-file_attr --get $projectdir ./broken-symlink
-
-file_attr --set --no-follow --set-nodump $projectdir ./broken-symlink
-file_attr --get --no-follow $projectdir ./broken-symlink | _filter_file_attributes ~d
cd $SCRATCH_MNT
touch ./foo2
diff --git a/tests/generic/772.out b/tests/generic/772.out
index f7c23d94da4a..c89dbcf5d630 100644
--- a/tests/generic/772.out
+++ b/tests/generic/772.out
@@ -9,25 +9,11 @@ Can not get fsxattr on ./foo: Invalid argument
Can not set fsxattr on ./foo: Invalid argument
Initial attributes state
----------------- SCRATCH_MNT/prj
------------------ ./fifo
------------------ ./chardev
------------------ ./blockdev
------------------ ./socket
----------------- ./foo
------------------ ./symlink
Set FS_XFLAG_NODUMP (d)
Read attributes
------d---------- SCRATCH_MNT/prj
-------d---------- ./fifo
-------d---------- ./chardev
-------d---------- ./blockdev
-------d---------- ./socket
------d---------- ./foo
-------d---------- ./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
----------------- ./foo2
Set attribute relative to AT_FDCWD
diff --git a/tests/generic/773 b/tests/generic/773
new file mode 100755
index 000000000000..f633706a1455
--- /dev/null
+++ b/tests/generic/773
@@ -0,0 +1,84 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat. All Rights Reserved.
+#
+# FS QA Test 773
+#
+# Test file_getattr() and file_setattr() syscalls on special files (fifo,
+# socket, chardev...)
+#
+. ./common/preamble
+_begin_fstest quick
+
+# Import common functions.
+. ./common/filter
+
+# Modify as appropriate.
+_require_scratch
+_require_test_program "af_unix"
+_require_test_program "file_attr"
+_require_symlinks
+_require_mknod
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+_require_file_attr_special
+
+file_attr () {
+ $here/src/file_attr $*
+}
+
+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"
+file_attr --get $projectdir | _filter_scratch | _filter_file_attributes ~d
+file_attr --get $projectdir ./fifo | _filter_file_attributes ~d
+file_attr --get $projectdir ./chardev | _filter_file_attributes ~d
+file_attr --get $projectdir ./blockdev | _filter_file_attributes ~d
+file_attr --get $projectdir ./socket | _filter_file_attributes ~d
+file_attr --get $projectdir ./symlink | _filter_file_attributes ~d
+
+echo "Set FS_XFLAG_NODUMP (d)"
+file_attr --set --set-nodump $projectdir
+file_attr --set --set-nodump $projectdir ./fifo
+file_attr --set --set-nodump $projectdir ./chardev
+file_attr --set --set-nodump $projectdir ./blockdev
+file_attr --set --set-nodump $projectdir ./socket
+file_attr --set --set-nodump $projectdir ./symlink
+
+echo "Read attributes"
+file_attr --get $projectdir | _filter_scratch | _filter_file_attributes ~d
+file_attr --get $projectdir ./fifo | _filter_file_attributes ~d
+file_attr --get $projectdir ./chardev | _filter_file_attributes ~d
+file_attr --get $projectdir ./blockdev | _filter_file_attributes ~d
+file_attr --get $projectdir ./socket | _filter_file_attributes ~d
+file_attr --get $projectdir ./symlink | _filter_file_attributes ~d
+
+echo "Set attribute on broken link with AT_SYMLINK_NOFOLLOW"
+file_attr --set --set-nodump $projectdir ./broken-symlink
+file_attr --get $projectdir ./broken-symlink
+
+file_attr --set --no-follow --set-nodump $projectdir ./broken-symlink
+file_attr --get --no-follow $projectdir ./broken-symlink | _filter_file_attributes ~d
+
+# optional stuff if your test has verbose output to help resolve problems
+#echo
+#echo "If failure, check $seqres.full (this) and $seqres.full.ok (reference)"
+
+# success, all done
+_exit 0
diff --git a/tests/generic/773.out b/tests/generic/773.out
new file mode 100644
index 000000000000..46ea3baa66fd
--- /dev/null
+++ b/tests/generic/773.out
@@ -0,0 +1,20 @@
+QA output created by 773
+Initial attributes state
+----------------- SCRATCH_MNT/prj
+----------------- ./fifo
+----------------- ./chardev
+----------------- ./blockdev
+----------------- ./socket
+----------------- ./symlink
+Set FS_XFLAG_NODUMP (d)
+Read attributes
+------d---------- SCRATCH_MNT/prj
+------d---------- ./fifo
+------d---------- ./chardev
+------d---------- ./blockdev
+------d---------- ./socket
+------d---------- ./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
--
2.50.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] generic/772: require filesystem to support file_[g|s]etattr
2025-10-20 13:55 ` [PATCH 2/3] generic/772: require filesystem to support file_[g|s]etattr Andrey Albershteyn
@ 2025-10-20 16:45 ` Darrick J. Wong
2025-10-21 9:42 ` Andrey Albershteyn
0 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2025-10-20 16:45 UTC (permalink / raw)
To: Andrey Albershteyn; +Cc: linux-xfs, fstests, zlang, Andrey Albershteyn
On Mon, Oct 20, 2025 at 03:55:29PM +0200, Andrey Albershteyn wrote:
> Add _require_* function to check that filesystem support these syscalls
> on regular and special files.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
> ---
> common/rc | 32 ++++++++++++++++++++++++++++++++
> tests/generic/772 | 5 ++---
> tests/xfs/648 | 7 +++----
> 3 files changed, 37 insertions(+), 7 deletions(-)
>
> diff --git a/common/rc b/common/rc
> index dcae5bc33b19..78928c27da97 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -5994,6 +5994,38 @@ _require_inplace_writes()
> fi
> }
>
> +# Require filesystem to support file_getattr()/file_setattr() syscalls on
> +# regular files
> +_require_file_attr()
> +{
> + local test_file="$SCRATCH_MNT/foo"
Should the test file be on $TEST_DIR so that you don't have an implicit
dependency on _require_scratch?
Otherwise looks fine to me.
--D
> + touch $test_file
> +
> + $here/src/file_attr --set --set-nodump $SCRATCH_MNT ./foo &>/dev/null
> + rc=$?
> + rm -f "$test_file"
> +
> + if [ $rc -ne 0 ]; then
> + _notrun "file_getattr not supported for regular files on $FSTYP"
> + fi
> +}
> +
> +# Require filesystem to support file_getattr()/file_setattr() syscalls on
> +# special files (chardev, fifo...)
> +_require_file_attr_special()
> +{
> + local test_file="$SCRATCH_MNT/fifo"
> + mkfifo $test_file
> +
> + $here/src/file_attr --set --set-nodump $SCRATCH_MNT ./fifo &>/dev/null
> + rc=$?
> + rm -f "$test_file"
> +
> + if [ $rc -ne 0 ]; then
> + _notrun "file_getattr not supported for special files on $FSTYP"
> + fi
> +}
> +
> ################################################################################
> # make sure this script returns success
> /bin/true
> diff --git a/tests/generic/772 b/tests/generic/772
> index e68a67246544..bdd55b10f310 100755
> --- a/tests/generic/772
> +++ b/tests/generic/772
> @@ -20,6 +20,8 @@ _require_mknod
>
> _scratch_mkfs >>$seqres.full 2>&1
> _scratch_mount
> +_require_file_attr
> +_require_file_attr_special
>
> file_attr () {
> $here/src/file_attr $*
> @@ -43,9 +45,6 @@ touch $projectdir/bar
> ln -s $projectdir/bar $projectdir/broken-symlink
> rm -f $projectdir/bar
>
> -file_attr --get $projectdir ./fifo &>/dev/null || \
> - _notrun "file_getattr not supported on $FSTYP"
> -
> echo "Error codes"
> # wrong AT_ flags
> file_attr --get --invalid-at $projectdir ./foo
> diff --git a/tests/xfs/648 b/tests/xfs/648
> index e3c2fbe00b66..a268bfdb0e2d 100755
> --- a/tests/xfs/648
> +++ b/tests/xfs/648
> @@ -20,10 +20,12 @@ _require_test_program "af_unix"
> _require_test_program "file_attr"
> _require_symlinks
> _require_mknod
> -
> _scratch_mkfs >>$seqres.full 2>&1
> _qmount_option "pquota"
> _scratch_mount
> +_require_file_attr
> +_require_file_attr_special
> +
>
> create_af_unix () {
> $here/src/af_unix $* || echo af_unix failed
> @@ -47,9 +49,6 @@ touch $projectdir/bar
> ln -s $projectdir/bar $projectdir/broken-symlink
> rm -f $projectdir/bar
>
> -$here/src/file_attr --get $projectdir ./fifo &>/dev/null || \
> - _notrun "file_getattr not supported on $FSTYP"
> -
> $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
> -c "project -sp $projectdir $id" $SCRATCH_DEV | filter_quota
> $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
> --
> 2.50.1
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] generic/772: split this test into 772 and 773 for regular and special files
2025-10-20 13:55 ` [PATCH 3/3] generic/772: split this test into 772 and 773 for regular and special files Andrey Albershteyn
@ 2025-10-20 16:45 ` Darrick J. Wong
0 siblings, 0 replies; 9+ messages in thread
From: Darrick J. Wong @ 2025-10-20 16:45 UTC (permalink / raw)
To: Andrey Albershteyn; +Cc: linux-xfs, fstests, zlang, Andrey Albershteyn
On Mon, Oct 20, 2025 at 03:55:30PM +0200, Andrey Albershteyn wrote:
> Not all filesystem support setting file attributes on special files. The
> syscalls would still work for regular files. Let's split this test into
> two to make it obvious if only special files support is missing.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
Looks fine to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> tests/generic/772 | 38 +-------------------
> tests/generic/772.out | 14 --------
> tests/generic/773 | 84 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/773.out | 20 +++++++++++
> 4 files changed, 105 insertions(+), 51 deletions(-)
> create mode 100755 tests/generic/773
> create mode 100644 tests/generic/773.out
>
> diff --git a/tests/generic/772 b/tests/generic/772
> index bdd55b10f310..0d5c4749b010 100755
> --- a/tests/generic/772
> +++ b/tests/generic/772
> @@ -4,7 +4,7 @@
> #
> # FS QA Test No. 772
> #
> -# Test file_getattr/file_setattr syscalls
> +# Test file_getattr() and file_setattr() syscalls on regular files
> #
> . ./common/preamble
> _begin_fstest auto
> @@ -13,7 +13,6 @@ _begin_fstest auto
>
> # Modify as appropriate.
> _require_scratch
> -_require_test_program "af_unix"
> _require_test_program "file_attr"
> _require_symlinks
> _require_mknod
> @@ -21,29 +20,16 @@ _require_mknod
> _scratch_mkfs >>$seqres.full 2>&1
> _scratch_mount
> _require_file_attr
> -_require_file_attr_special
>
> file_attr () {
> $here/src/file_attr $*
> }
>
> -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 "Error codes"
> # wrong AT_ flags
> @@ -59,37 +45,15 @@ file_attr --set --new-fsx-flag $projectdir ./foo
>
> echo "Initial attributes state"
> file_attr --get $projectdir | _filter_scratch | _filter_file_attributes ~d
> -file_attr --get $projectdir ./fifo | _filter_file_attributes ~d
> -file_attr --get $projectdir ./chardev | _filter_file_attributes ~d
> -file_attr --get $projectdir ./blockdev | _filter_file_attributes ~d
> -file_attr --get $projectdir ./socket | _filter_file_attributes ~d
> file_attr --get $projectdir ./foo | _filter_file_attributes ~d
> -file_attr --get $projectdir ./symlink | _filter_file_attributes ~d
>
> echo "Set FS_XFLAG_NODUMP (d)"
> file_attr --set --set-nodump $projectdir
> -file_attr --set --set-nodump $projectdir ./fifo
> -file_attr --set --set-nodump $projectdir ./chardev
> -file_attr --set --set-nodump $projectdir ./blockdev
> -file_attr --set --set-nodump $projectdir ./socket
> file_attr --set --set-nodump $projectdir ./foo
> -file_attr --set --set-nodump $projectdir ./symlink
>
> echo "Read attributes"
> file_attr --get $projectdir | _filter_scratch | _filter_file_attributes ~d
> -file_attr --get $projectdir ./fifo | _filter_file_attributes ~d
> -file_attr --get $projectdir ./chardev | _filter_file_attributes ~d
> -file_attr --get $projectdir ./blockdev | _filter_file_attributes ~d
> -file_attr --get $projectdir ./socket | _filter_file_attributes ~d
> file_attr --get $projectdir ./foo | _filter_file_attributes ~d
> -file_attr --get $projectdir ./symlink | _filter_file_attributes ~d
> -
> -echo "Set attribute on broken link with AT_SYMLINK_NOFOLLOW"
> -file_attr --set --set-nodump $projectdir ./broken-symlink
> -file_attr --get $projectdir ./broken-symlink
> -
> -file_attr --set --no-follow --set-nodump $projectdir ./broken-symlink
> -file_attr --get --no-follow $projectdir ./broken-symlink | _filter_file_attributes ~d
>
> cd $SCRATCH_MNT
> touch ./foo2
> diff --git a/tests/generic/772.out b/tests/generic/772.out
> index f7c23d94da4a..c89dbcf5d630 100644
> --- a/tests/generic/772.out
> +++ b/tests/generic/772.out
> @@ -9,25 +9,11 @@ Can not get fsxattr on ./foo: Invalid argument
> Can not set fsxattr on ./foo: Invalid argument
> Initial attributes state
> ----------------- SCRATCH_MNT/prj
> ------------------ ./fifo
> ------------------ ./chardev
> ------------------ ./blockdev
> ------------------ ./socket
> ----------------- ./foo
> ------------------ ./symlink
> Set FS_XFLAG_NODUMP (d)
> Read attributes
> ------d---------- SCRATCH_MNT/prj
> -------d---------- ./fifo
> -------d---------- ./chardev
> -------d---------- ./blockdev
> -------d---------- ./socket
> ------d---------- ./foo
> -------d---------- ./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
> ----------------- ./foo2
> Set attribute relative to AT_FDCWD
> diff --git a/tests/generic/773 b/tests/generic/773
> new file mode 100755
> index 000000000000..f633706a1455
> --- /dev/null
> +++ b/tests/generic/773
> @@ -0,0 +1,84 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2025 Red Hat. All Rights Reserved.
> +#
> +# FS QA Test 773
> +#
> +# Test file_getattr() and file_setattr() syscalls on special files (fifo,
> +# socket, chardev...)
> +#
> +. ./common/preamble
> +_begin_fstest quick
> +
> +# Import common functions.
> +. ./common/filter
> +
> +# Modify as appropriate.
> +_require_scratch
> +_require_test_program "af_unix"
> +_require_test_program "file_attr"
> +_require_symlinks
> +_require_mknod
> +_scratch_mkfs >>$seqres.full 2>&1
> +_scratch_mount
> +_require_file_attr_special
> +
> +file_attr () {
> + $here/src/file_attr $*
> +}
> +
> +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"
> +file_attr --get $projectdir | _filter_scratch | _filter_file_attributes ~d
> +file_attr --get $projectdir ./fifo | _filter_file_attributes ~d
> +file_attr --get $projectdir ./chardev | _filter_file_attributes ~d
> +file_attr --get $projectdir ./blockdev | _filter_file_attributes ~d
> +file_attr --get $projectdir ./socket | _filter_file_attributes ~d
> +file_attr --get $projectdir ./symlink | _filter_file_attributes ~d
> +
> +echo "Set FS_XFLAG_NODUMP (d)"
> +file_attr --set --set-nodump $projectdir
> +file_attr --set --set-nodump $projectdir ./fifo
> +file_attr --set --set-nodump $projectdir ./chardev
> +file_attr --set --set-nodump $projectdir ./blockdev
> +file_attr --set --set-nodump $projectdir ./socket
> +file_attr --set --set-nodump $projectdir ./symlink
> +
> +echo "Read attributes"
> +file_attr --get $projectdir | _filter_scratch | _filter_file_attributes ~d
> +file_attr --get $projectdir ./fifo | _filter_file_attributes ~d
> +file_attr --get $projectdir ./chardev | _filter_file_attributes ~d
> +file_attr --get $projectdir ./blockdev | _filter_file_attributes ~d
> +file_attr --get $projectdir ./socket | _filter_file_attributes ~d
> +file_attr --get $projectdir ./symlink | _filter_file_attributes ~d
> +
> +echo "Set attribute on broken link with AT_SYMLINK_NOFOLLOW"
> +file_attr --set --set-nodump $projectdir ./broken-symlink
> +file_attr --get $projectdir ./broken-symlink
> +
> +file_attr --set --no-follow --set-nodump $projectdir ./broken-symlink
> +file_attr --get --no-follow $projectdir ./broken-symlink | _filter_file_attributes ~d
> +
> +# optional stuff if your test has verbose output to help resolve problems
> +#echo
> +#echo "If failure, check $seqres.full (this) and $seqres.full.ok (reference)"
> +
> +# success, all done
> +_exit 0
> diff --git a/tests/generic/773.out b/tests/generic/773.out
> new file mode 100644
> index 000000000000..46ea3baa66fd
> --- /dev/null
> +++ b/tests/generic/773.out
> @@ -0,0 +1,20 @@
> +QA output created by 773
> +Initial attributes state
> +----------------- SCRATCH_MNT/prj
> +----------------- ./fifo
> +----------------- ./chardev
> +----------------- ./blockdev
> +----------------- ./socket
> +----------------- ./symlink
> +Set FS_XFLAG_NODUMP (d)
> +Read attributes
> +------d---------- SCRATCH_MNT/prj
> +------d---------- ./fifo
> +------d---------- ./chardev
> +------d---------- ./blockdev
> +------d---------- ./socket
> +------d---------- ./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
> --
> 2.50.1
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] common/filter: add missing file attribute
2025-10-20 13:55 ` [PATCH 1/3] common/filter: add missing file attribute Andrey Albershteyn
@ 2025-10-20 16:46 ` Darrick J. Wong
2025-10-21 9:42 ` Andrey Albershteyn
0 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2025-10-20 16:46 UTC (permalink / raw)
To: Andrey Albershteyn; +Cc: linux-xfs, fstests, zlang, Andrey Albershteyn
On Mon, Oct 20, 2025 at 03:55:28PM +0200, Andrey Albershteyn wrote:
> Add n (nosymlinks) char according to xfsprogs io/attr.c
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
The updated version of "common/filter: fix _filter_file_attributes to
handle xfs file flags" that I'm about to send will fix this up by
documenting that _filter_file_attributes only handles xfs attrs and then
making it handle all the known flags.
--D
> ---
> common/filter | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/filter b/common/filter
> index c3a751dd0c39..28048b4b601b 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -692,7 +692,7 @@ _filter_sysfs_error()
> _filter_file_attributes()
> {
> if [[ $1 == ~* ]]; then
> - regex=$(echo "[aAcCdDeEfFijmNpPsrStTuxVX]" | tr -d "$1")
> + regex=$(echo "[aAcCdDeEfFijmnNpPrsStTuVxX]" | tr -d "$1")
> else
> regex="$1"
> fi
> --
> 2.50.1
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] common/filter: add missing file attribute
2025-10-20 16:46 ` Darrick J. Wong
@ 2025-10-21 9:42 ` Andrey Albershteyn
0 siblings, 0 replies; 9+ messages in thread
From: Andrey Albershteyn @ 2025-10-21 9:42 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs, fstests, zlang, Andrey Albershteyn
On 2025-10-20 09:46:24, Darrick J. Wong wrote:
> On Mon, Oct 20, 2025 at 03:55:28PM +0200, Andrey Albershteyn wrote:
> > Add n (nosymlinks) char according to xfsprogs io/attr.c
> >
> > Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
>
> The updated version of "common/filter: fix _filter_file_attributes to
> handle xfs file flags" that I'm about to send will fix this up by
> documenting that _filter_file_attributes only handles xfs attrs and then
> making it handle all the known flags.
I see, thanks, I will drop this one then
>
> --D
>
> > ---
> > common/filter | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/common/filter b/common/filter
> > index c3a751dd0c39..28048b4b601b 100644
> > --- a/common/filter
> > +++ b/common/filter
> > @@ -692,7 +692,7 @@ _filter_sysfs_error()
> > _filter_file_attributes()
> > {
> > if [[ $1 == ~* ]]; then
> > - regex=$(echo "[aAcCdDeEfFijmNpPsrStTuxVX]" | tr -d "$1")
> > + regex=$(echo "[aAcCdDeEfFijmnNpPrsStTuVxX]" | tr -d "$1")
> > else
> > regex="$1"
> > fi
> > --
> > 2.50.1
> >
> >
>
--
- Andrey
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] generic/772: require filesystem to support file_[g|s]etattr
2025-10-20 16:45 ` Darrick J. Wong
@ 2025-10-21 9:42 ` Andrey Albershteyn
0 siblings, 0 replies; 9+ messages in thread
From: Andrey Albershteyn @ 2025-10-21 9:42 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs, fstests, zlang, Andrey Albershteyn
On 2025-10-20 09:45:03, Darrick J. Wong wrote:
> On Mon, Oct 20, 2025 at 03:55:29PM +0200, Andrey Albershteyn wrote:
> > Add _require_* function to check that filesystem support these syscalls
> > on regular and special files.
> >
> > Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
> > ---
> > common/rc | 32 ++++++++++++++++++++++++++++++++
> > tests/generic/772 | 5 ++---
> > tests/xfs/648 | 7 +++----
> > 3 files changed, 37 insertions(+), 7 deletions(-)
> >
> > diff --git a/common/rc b/common/rc
> > index dcae5bc33b19..78928c27da97 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -5994,6 +5994,38 @@ _require_inplace_writes()
> > fi
> > }
> >
> > +# Require filesystem to support file_getattr()/file_setattr() syscalls on
> > +# regular files
> > +_require_file_attr()
> > +{
> > + local test_file="$SCRATCH_MNT/foo"
>
> Should the test file be on $TEST_DIR so that you don't have an implicit
> dependency on _require_scratch?
>
> Otherwise looks fine to me.
Oh right, will send v2
>
> --D
>
> > + touch $test_file
> > +
> > + $here/src/file_attr --set --set-nodump $SCRATCH_MNT ./foo &>/dev/null
> > + rc=$?
> > + rm -f "$test_file"
> > +
> > + if [ $rc -ne 0 ]; then
> > + _notrun "file_getattr not supported for regular files on $FSTYP"
> > + fi
> > +}
> > +
> > +# Require filesystem to support file_getattr()/file_setattr() syscalls on
> > +# special files (chardev, fifo...)
> > +_require_file_attr_special()
> > +{
> > + local test_file="$SCRATCH_MNT/fifo"
> > + mkfifo $test_file
> > +
> > + $here/src/file_attr --set --set-nodump $SCRATCH_MNT ./fifo &>/dev/null
> > + rc=$?
> > + rm -f "$test_file"
> > +
> > + if [ $rc -ne 0 ]; then
> > + _notrun "file_getattr not supported for special files on $FSTYP"
> > + fi
> > +}
> > +
> > ################################################################################
> > # make sure this script returns success
> > /bin/true
> > diff --git a/tests/generic/772 b/tests/generic/772
> > index e68a67246544..bdd55b10f310 100755
> > --- a/tests/generic/772
> > +++ b/tests/generic/772
> > @@ -20,6 +20,8 @@ _require_mknod
> >
> > _scratch_mkfs >>$seqres.full 2>&1
> > _scratch_mount
> > +_require_file_attr
> > +_require_file_attr_special
> >
> > file_attr () {
> > $here/src/file_attr $*
> > @@ -43,9 +45,6 @@ touch $projectdir/bar
> > ln -s $projectdir/bar $projectdir/broken-symlink
> > rm -f $projectdir/bar
> >
> > -file_attr --get $projectdir ./fifo &>/dev/null || \
> > - _notrun "file_getattr not supported on $FSTYP"
> > -
> > echo "Error codes"
> > # wrong AT_ flags
> > file_attr --get --invalid-at $projectdir ./foo
> > diff --git a/tests/xfs/648 b/tests/xfs/648
> > index e3c2fbe00b66..a268bfdb0e2d 100755
> > --- a/tests/xfs/648
> > +++ b/tests/xfs/648
> > @@ -20,10 +20,12 @@ _require_test_program "af_unix"
> > _require_test_program "file_attr"
> > _require_symlinks
> > _require_mknod
> > -
> > _scratch_mkfs >>$seqres.full 2>&1
> > _qmount_option "pquota"
> > _scratch_mount
> > +_require_file_attr
> > +_require_file_attr_special
> > +
> >
> > create_af_unix () {
> > $here/src/af_unix $* || echo af_unix failed
> > @@ -47,9 +49,6 @@ touch $projectdir/bar
> > ln -s $projectdir/bar $projectdir/broken-symlink
> > rm -f $projectdir/bar
> >
> > -$here/src/file_attr --get $projectdir ./fifo &>/dev/null || \
> > - _notrun "file_getattr not supported on $FSTYP"
> > -
> > $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
> > -c "project -sp $projectdir $id" $SCRATCH_DEV | filter_quota
> > $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
> > --
> > 2.50.1
> >
> >
>
--
- Andrey
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-10-21 9:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 13:55 [PATCH 0/3] generic/772: split and fix Andrey Albershteyn
2025-10-20 13:55 ` [PATCH 1/3] common/filter: add missing file attribute Andrey Albershteyn
2025-10-20 16:46 ` Darrick J. Wong
2025-10-21 9:42 ` Andrey Albershteyn
2025-10-20 13:55 ` [PATCH 2/3] generic/772: require filesystem to support file_[g|s]etattr Andrey Albershteyn
2025-10-20 16:45 ` Darrick J. Wong
2025-10-21 9:42 ` Andrey Albershteyn
2025-10-20 13:55 ` [PATCH 3/3] generic/772: split this test into 772 and 773 for regular and special files Andrey Albershteyn
2025-10-20 16:45 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).