Re: [PATCH] cifs/002: check nlink returned by fstat()

ChenXiaoSong <[email protected]> Sat, 18 Jul 2026 23:08:05 +0800
Newsgroups org.kernel.vger.fstests,org.kernel.vger.linux-cifs
Message-ID <[email protected]>
Thanks for your suggestions. I will send the next version soon.

在 2026/7/18 1:07, Zorro Lang 写道:
>> +# FS QA Test No. cifs/002
> 
> Although we are considering removing this specific line in the future, it is
> currently still required to follow the standard format. Therefore, it should
> be formatted as: FS QA Test 002
> 
>> +#  from
>> +#  tests/generic/002
> 
> The original test case is a generic test case, this one looks similar, doesn't
> has any cifs specific test steps. So I think this can be a generic test case too
> 
>> +#  Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
>> +#
>> +. ./common/preamble
>> +_begin_fstest metadata auto quick
> 
> I think it also belong to "hardlink" group.
> 
>> +
>> +# Override the default cleanup function.
>> +_cleanup()
>> +{
>> +	rm -f $tmp.*
>> +	rm -rf $TEST_DIR/$$
> 
>          cd /
>          rm -r -f $tmp.*
>          [ -d "$testdir" ] && rm -rf $testdir
> 
>> +}
>> +
>> +status=0	# success is the default!
>> +
>> +_require_test
>> +_require_hardlinks
>> +_require_test_program fstat
> 
> _fixed_by_fs_commit cifs 9dd1964ac59d \
> 	"smb/client: fix incorrect nlink returned by fstat()"
> 
>> +
>> +echo "Silence is goodness ..."
> 
> If no specical reason, please keep the "Silence is golden".
> 
>> +
>> +testdir=$TEST_DIR/$$
>> +mkdir -p $testdir
>> +
>> +touch $testdir/tmp.1
>> +for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
>> +do
> 
> for l in $(seq 2 20);do
> 
> or
> 
> for ((l=2; l<=20; l++))
> 
>> +	ln $testdir/tmp.1 $testdir/tmp.$l
>> +	x=`$here/src/fstat $testdir/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
> 
> I'm wondering if a specific src/fstat.c is needed. Can we replace the whole
> src/fstat.c with `xfs_io -c stat ` ? Can you give it a try?
> 
>> +	if [ "$l" -ne $x ]
>> +	then
> 
> if [ "$l" -ne $x ];then
> 
>> +		echo "Arrgh, created link #$l and fstat looks like ..."
>> +		$here/src/fstat $testdir/tmp.1
>> +		status=1
>> +	fi
>> +done
>> +
>> +for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
>> +do
> 
> for l in $(seq 20 -1 1);do
> 
> or
> 
> for ((l=20; l>=1; l--))
> 
>> +	x=`$here/src/fstat $testdir/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
>> +	if [ "$l" -ne $x ]
>> +	then
>> +		echo "Arrgh, about to remove link #$l and fstat looks like ..."
>> +		$here/src/fstat $testdir/tmp.1
>> +		status=1
>> +	fi
>> +	rm -f $testdir/tmp.$l
>> +done
>> +
>> +exit
> 
> _exit 0
> 
> Thanks,
> Zorro
> 
>> diff --git a/tests/cifs/002.out b/tests/cifs/002.out
>> new file mode 100644
>> index 00000000..11426b54
>> --- /dev/null
>> +++ b/tests/cifs/002.out
>> @@ -0,0 +1,2 @@
>> +QA output created by 002
>> +Silence is goodness ...
>> -- 
>> 2.43.0
>>
>>

-- 
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en