[LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase

xuyang2018.jy@fujitsu.com xuyang2018.jy@fujitsu.com
Wed Nov 30 03:02:29 CET 2022


Hi Richard

> Hello,
> 
> Yang Xu <xuyang2018.jy@fujitsu.com> writes:
> 
>> This case should check MS_NOATIME and MS_RELATIME are
>> not inside stat f_flags[1] .
>>
>> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0adde57
>> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>> ---
>>   testcases/kernel/syscalls/mount/mount03.c | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
>> index 31a858c35..60f9963da 100644
>> --- a/testcases/kernel/syscalls/mount/mount03.c
>> +++ b/testcases/kernel/syscalls/mount/mount03.c
>> @@ -19,6 +19,7 @@
>>    * - MS_NOSUID - ignore suid and sgid bits
>>    * - MS_NOATIME - do not update access times
>>    * - MS_NODIRATIME - only update access_time for directory instead of all types
>> + * - MS_STRICTATIME - always update access times
>>    */
>>   
>>   #include <stdio.h>
>> @@ -164,6 +165,11 @@ static void test_nodiratime(void)
>>   	test_file_dir_noatime(1, 0);
>>   }
>>   
>> +static void test_strictatime(void)
>> +{
>> +	test_file_dir_noatime(1, 1);
>> +}
>> +
>>   #define FLAG_DESC(x) .flag = x, .flag2 = x, .desc = #x
>>   #define FLAG_DESC2(x) .flag2 = x, .desc = #x
>>   static struct tcase {
>> @@ -179,6 +185,7 @@ static struct tcase {
>>   	{FLAG_DESC(MS_NOSUID), test_nosuid},
>>   	{FLAG_DESC(MS_NOATIME), test_noatime},
>>   	{FLAG_DESC(MS_NODIRATIME), test_nodiratime},
>> +	{FLAG_DESC(MS_STRICTATIME), test_strictatime}
>>   };
>>   
>>   static void setup(void)
>> @@ -215,6 +222,15 @@ static void run(unsigned int n)
>>   		tc->test();
>>   
>>   	SAFE_STATFS(MNTPOINT, &stfs);
>> +	if (tc->flag == MS_STRICTATIME) {
>> +		if (stfs.f_flags & (MS_NOATIME | MS_RELATIME))
>> +			tst_res(TFAIL, "statfs() gets the incorrect mount flag");
>> +		else
>> +			tst_res(TPASS, "statfs() gets the correct mount flag");
>> +		cleanup();
>> +		return;
>> +	}
> 
> We don't need this branch.
> 
>> +
>>   	if (stfs.f_flags & tc->flag2)
> 
> Could change this to something like
> 
> if (stfs.f_flags & tc->flag2
>     && !(stfs.f_flags & MS_STRICTATIME && stfs.f_flags & (MS_NOATIME | MS_RELATIME))

I try it, but case reports fail because stfs.f_flags doesn't contain 
MS_STRICTATIME flag.  Sorry, I guess my commit message only mentioned 
that MS_NOATIME and MS_RELATIME are not inside stat f_flags but missed 
that the MS_STRICTATIME flag is ignored by kernel.

Best Regards
Yang Xu
> 
> Or however you would like to format that.
> 
> 


More information about the ltp mailing list