Skip to contentSkip to conversation

generic/772: split and fix

PATCH New Andrey Albershteyn 3 participants 5 messages Oct 30, 2025 – Nov 1, 2025

lore
Share & tools
lore
#0 lore raw

v2 cover generic/772: split and fix

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]

Changes from v1:
- Remove patch which added file attribute as it's now convered
- Use TEST_DIR instead of depending on SCRATCH_MNT

To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

[1]: https://lore.kernel.org/fstests/176107188615.4163693.708102333699699249.stgit@frogsfrogsfrogs/

Andrey Albershteyn <[email protected]>:
generic/772: require filesystem to support file_[g|s]etattr generic/772: split this test into 772 and 779 for regular and special files

common/rc             | 32 ++++++++++++++++++++++++++++++++
tests/generic/772     | 41 ++---------------------------------------
tests/generic/772.out | 14 --------------
tests/generic/779     | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/779.out | 20 ++++++++++++++++++++
tests/xfs/648         |  6 ++----
6 files changed, 142 insertions(+), 57 deletions(-)
Signature · 1 line
- Andrey
#1 lore raw

PATCH v2 1/2 generic/772: require filesystem to support file_[g|s]etattr

Add _require_* function to check that filesystem support these syscalls on regular and special files.

---
 common/rc         | 32 ++++++++++++++++++++++++++++++++
 tests/generic/772 |  4 +---
 tests/xfs/648     |  6 ++----
 3 files changed, 35 insertions(+), 7 deletions(-)
common/rc +32 -0
index 462f433197..be3cdd8d64 100644
@@ -6032,6 +6032,38 @@
 	esac
 }
 
+# Require filesystem to support file_getattr()/file_setattr() syscalls on
+# regular files
+_require_file_attr()
+{
+	local test_file="$TEST_DIR/foo"
+	touch $test_file
+
+	$here/src/file_attr --set --set-nodump $TEST_DIR ./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="$TEST_DIR/fifo"
+	mkfifo $test_file
+
+	$here/src/file_attr --set --set-nodump $TEST_DIR ./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
tests/generic/772 +1 -3
index cdadf09ff2..dba1ee7f50 100755
@@ -17,6 +17,7 @@
 _require_test_program "file_attr"
 _require_symlinks
 _require_mknod
+_require_file_attr
 
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
@@ -43,9 +44,6 @@
 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
tests/xfs/648 +2 -4
index e3c2fbe00b..58e5aa8c5b 100755
@@ -20,7 +20,8 @@
 _require_test_program "file_attr"
 _require_symlinks
 _require_mknod
-
+_require_file_attr
+_require_file_attr_special
 _scratch_mkfs >>$seqres.full 2>&1
 _qmount_option "pquota"
 _scratch_mount
@@ -47,9 +48,6 @@
 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 \
Signature · 1 line
- Andrey
#4 lore raw

PATCH v2 2/2 generic/772: split this test into 772 and 779 for regular and special files

In reply to 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.

---
 tests/generic/772     | 37 +---------------------
 tests/generic/772.out | 14 --------
 tests/generic/779     | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/779.out | 20 ++++++++++++
 4 files changed, 107 insertions(+), 50 deletions(-)
tests/generic/772 +1 -36
index dba1ee7f50..8346de8961 100755
@@ -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 @@
 
 # Modify as appropriate.
 _require_scratch
-_require_test_program "af_unix"
 _require_test_program "file_attr"
 _require_symlinks
 _require_mknod
@@ -26,23 +25,11 @@
 	$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
@@ -58,37 +45,15 @@
 
 echo "Initial attributes state"
 file_attr --get $projectdir | _filter_scratch | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./fifo | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./chardev | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./blockdev | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./socket | _filter_vfs_file_attributes ~d
 file_attr --get $projectdir ./foo | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./symlink | _filter_vfs_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_vfs_file_attributes ~d
-file_attr --get $projectdir ./fifo | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./chardev | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./blockdev | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./socket | _filter_vfs_file_attributes ~d
 file_attr --get $projectdir ./foo | _filter_vfs_file_attributes ~d
-file_attr --get $projectdir ./symlink | _filter_vfs_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_vfs_file_attributes ~d
 
 cd $SCRATCH_MNT
 touch ./foo2
tests/generic/772.out +0 -14
index f7c23d94da..c89dbcf5d6 100644
@@ -9,25 +9,11 @@
 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
tests/generic/779 new file +86 -0

86 lines not on this page · raw message

tests/generic/779.out new file +20 -0
new file mode 100644
index 0000000000..d40376fa42
@@ -0,0 +1,20 @@
+QA output created by 779
+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
Signature · 1 line
- Andrey
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] generic/772: require filesystem to support file_[g|s]etattr

In reply to Andrey Albershteyn
Quoted 4 lines · Andrey Albershteyn

Add _require_* function to check that filesystem support these syscalls on regular and special files.

Looks good to me,

--D

Quoted 100 lines
---
 common/rc         | 32 ++++++++++++++++++++++++++++++++
 tests/generic/772 |  4 +---
 tests/xfs/648     |  6 ++----
 3 files changed, 35 insertions(+), 7 deletions(-)
common/rc +32 -0
index 462f433197..be3cdd8d64 100644
@@ -6032,6 +6032,38 @@
 	esac
 }
 
+# Require filesystem to support file_getattr()/file_setattr() syscalls on
+# regular files
+_require_file_attr()
+{
+	local test_file="$TEST_DIR/foo"
+	touch $test_file
+
+	$here/src/file_attr --set --set-nodump $TEST_DIR ./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="$TEST_DIR/fifo"
+	mkfifo $test_file
+
+	$here/src/file_attr --set --set-nodump $TEST_DIR ./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
tests/generic/772 +1 -3
index cdadf09ff2..dba1ee7f50 100755
@@ -17,6 +17,7 @@
 _require_test_program "file_attr"
 _require_symlinks
 _require_mknod
+_require_file_attr
 
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
@@ -43,9 +44,6 @@
 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
tests/xfs/648 +2 -4
index e3c2fbe00b..58e5aa8c5b 100755
@@ -20,7 +20,8 @@
 _require_test_program "file_attr"
 _require_symlinks
 _require_mknod
-
+_require_file_attr
+_require_file_attr_special
 _scratch_mkfs >>$seqres.full 2>&1
 _qmount_option "pquota"
 _scratch_mount
@@ -47,9 +48,6 @@
 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 \
Signature · 2 lines
-- 
- Andrey
Reviewed-by on v2 1/2
#3 lore raw

Re: [PATCH v2 1/2] generic/772: require filesystem to support file_[g|s]etattr

In reply to Andrey Albershteyn
Quoted 5 lines · Andrey Albershteyn

Add _require_* function to check that filesystem support these syscalls on regular and special files.

---

Thanks for doing this, that's more clear for me now:) I think this patch bases on another patch from Darrick. I'll merge his patch at first, then merge this one.

Quoted 99 lines
 common/rc         | 32 ++++++++++++++++++++++++++++++++
 tests/generic/772 |  4 +---
 tests/xfs/648     |  6 ++----
 3 files changed, 35 insertions(+), 7 deletions(-)
common/rc +32 -0
index 462f433197..be3cdd8d64 100644
@@ -6032,6 +6032,38 @@
 	esac
 }
 
+# Require filesystem to support file_getattr()/file_setattr() syscalls on
+# regular files
+_require_file_attr()
+{
+	local test_file="$TEST_DIR/foo"
+	touch $test_file
+
+	$here/src/file_attr --set --set-nodump $TEST_DIR ./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="$TEST_DIR/fifo"
+	mkfifo $test_file
+
+	$here/src/file_attr --set --set-nodump $TEST_DIR ./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
tests/generic/772 +1 -3
index cdadf09ff2..dba1ee7f50 100755
@@ -17,6 +17,7 @@
 _require_test_program "file_attr"
 _require_symlinks
 _require_mknod
+_require_file_attr
 
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
@@ -43,9 +44,6 @@
 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
tests/xfs/648 +2 -4
index e3c2fbe00b..58e5aa8c5b 100755
@@ -20,7 +20,8 @@
 _require_test_program "file_attr"
 _require_symlinks
 _require_mknod
-
+_require_file_attr
+_require_file_attr_special
 _scratch_mkfs >>$seqres.full 2>&1
 _qmount_option "pquota"
 _scratch_mount
@@ -47,9 +48,6 @@
 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 \
Signature · 2 lines
-- 
- Andrey