2024-01-10 07:33:51

by Huyadi

[permalink] [raw]
Subject: [PATCH v2] selftests/move_mount_set_group:Make tests build with old libc

From: "Hu.Yadi" <[email protected]>

Replace SYS_<syscall> with __NR_<syscall>. Using the __NR_<syscall>
notation, provided by UAPI, is useful to build tests on systems without
the SYS_<syscall> definitions.

Replace SYS_move_mount with __NR_move_mount

Signed-off-by: Hu.Yadi <[email protected]>
Suggested-by:Jiao <[email protected]>
Reviewed-by:Berlin <[email protected]>
---
Changes v1 -> v2:
- Fix mail of Suggested-by and Reviewed-by

.../move_mount_set_group/move_mount_set_group_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
index 50ed5d475dd1..bcf51d785a37 100644
--- a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
+++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
@@ -218,7 +218,7 @@ static bool move_mount_set_group_supported(void)
if (mount(NULL, SET_GROUP_FROM, NULL, MS_SHARED, 0))
return -1;

- ret = syscall(SYS_move_mount, AT_FDCWD, SET_GROUP_FROM,
+ ret = syscall(__NR_move_mount, AT_FDCWD, SET_GROUP_FROM,
AT_FDCWD, SET_GROUP_TO, MOVE_MOUNT_SET_GROUP);
umount2("/tmp", MNT_DETACH);

@@ -363,7 +363,7 @@ TEST_F(move_mount_set_group, complex_sharing_copying)
CLONE_VM | CLONE_FILES); ASSERT_GT(pid, 0);
ASSERT_EQ(wait_for_pid(pid), 0);

- ASSERT_EQ(syscall(SYS_move_mount, ca_from.mntfd, "",
+ ASSERT_EQ(syscall(__NR_move_mount, ca_from.mntfd, "",
ca_to.mntfd, "", MOVE_MOUNT_SET_GROUP
| MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH),
0);
--
2.23.0



2024-01-10 17:52:53

by Mickaël Salaün

[permalink] [raw]
Subject: Re: [PATCH v2] selftests/move_mount_set_group:Make tests build with old libc

On Wed, Jan 10, 2024 at 03:29:01PM +0800, Hu Yadi wrote:
> From: "Hu.Yadi" <[email protected]>
>
> Replace SYS_<syscall> with __NR_<syscall>. Using the __NR_<syscall>
> notation, provided by UAPI, is useful to build tests on systems without
> the SYS_<syscall> definitions.

This looks a lot like that...
https://git.kernel.org/stable/c/87129ef13603ae46c82bcd09eed948acf0506dbb

>
> Replace SYS_move_mount with __NR_move_mount
>
> Signed-off-by: Hu.Yadi <[email protected]>
> Suggested-by:Jiao <[email protected]>
> Reviewed-by:Berlin <[email protected]>
> ---
> Changes v1 -> v2:
> - Fix mail of Suggested-by and Reviewed-by
>
> .../move_mount_set_group/move_mount_set_group_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> index 50ed5d475dd1..bcf51d785a37 100644
> --- a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> +++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> @@ -218,7 +218,7 @@ static bool move_mount_set_group_supported(void)
> if (mount(NULL, SET_GROUP_FROM, NULL, MS_SHARED, 0))
> return -1;
>
> - ret = syscall(SYS_move_mount, AT_FDCWD, SET_GROUP_FROM,
> + ret = syscall(__NR_move_mount, AT_FDCWD, SET_GROUP_FROM,
> AT_FDCWD, SET_GROUP_TO, MOVE_MOUNT_SET_GROUP);
> umount2("/tmp", MNT_DETACH);
>
> @@ -363,7 +363,7 @@ TEST_F(move_mount_set_group, complex_sharing_copying)
> CLONE_VM | CLONE_FILES); ASSERT_GT(pid, 0);
> ASSERT_EQ(wait_for_pid(pid), 0);
>
> - ASSERT_EQ(syscall(SYS_move_mount, ca_from.mntfd, "",
> + ASSERT_EQ(syscall(__NR_move_mount, ca_from.mntfd, "",
> ca_to.mntfd, "", MOVE_MOUNT_SET_GROUP
> | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH),
> 0);
> --
> 2.23.0
>

2024-01-11 02:27:01

by Huyadi

[permalink] [raw]
Subject: 回复: [PATCH v2] selftests/move_mount_set_g roup:Make tests build with old libc


>On Wed, Jan 10, 2024 at 03:29:01PM +0800, Hu Yadi wrote:
>> From: "Hu.Yadi" <[email protected]>
>>
>> Replace SYS_<syscall> with __NR_<syscall>. Using the __NR_<syscall>
>> notation, provided by UAPI, is useful to build tests on systems
>> without the SYS_<syscall> definitions.
>
>This looks a lot like that...
>https://git.kernel.org/stable/c/87129ef13603ae46c82bcd09eed948acf0506dbb

Yes, I picked up comments from above commit in order for consistent,
I would send v3 patch if it is inappropriate.

>>
>> Replace SYS_move_mount with __NR_move_mount
>>
>> Signed-off-by: Hu.Yadi <[email protected]> Suggested-by:Jiao
>> <[email protected]> Reviewed-by:Berlin <[email protected]>
>> ---
>> Changes v1 -> v2:
>> - Fix mail of Suggested-by and Reviewed-by
>>
>> .../move_mount_set_group/move_mount_set_group_test.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git
>> a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_te
>> st.c
>> b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_te
>> st.c index 50ed5d475dd1..bcf51d785a37 100644
>> ---
>> a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_te
>> st.c
>> +++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_grou
>> +++ p_test.c
>> @@ -218,7 +218,7 @@ static bool move_mount_set_group_supported(void)
>> if (mount(NULL, SET_GROUP_FROM, NULL, MS_SHARED, 0))
>> return -1;
>>
>> - ret = syscall(SYS_move_mount, AT_FDCWD, SET_GROUP_FROM,
>> + ret = syscall(__NR_move_mount, AT_FDCWD, SET_GROUP_FROM,
>> AT_FDCWD, SET_GROUP_TO, MOVE_MOUNT_SET_GROUP);
>> umount2("/tmp", MNT_DETACH);
>>
>> @@ -363,7 +363,7 @@ TEST_F(move_mount_set_group, complex_sharing_copying)
>> CLONE_VM | CLONE_FILES); ASSERT_GT(pid, 0);
>> ASSERT_EQ(wait_for_pid(pid), 0);
>>
>> - ASSERT_EQ(syscall(SYS_move_mount, ca_from.mntfd, "",
>> + ASSERT_EQ(syscall(__NR_move_mount, ca_from.mntfd, "",
>> ca_to.mntfd, "", MOVE_MOUNT_SET_GROUP
>> | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH),
>> 0);
>> --
>> 2.23.0
>>

2024-01-11 11:14:20

by Mickaël Salaün

[permalink] [raw]
Subject: Re: 回复: [PATCH v2] selftests/move_mo unt_set_group:Make tests build with old libc

On Thu, Jan 11, 2024 at 02:25:03AM +0000, Huyadi wrote:
>
> >On Wed, Jan 10, 2024 at 03:29:01PM +0800, Hu Yadi wrote:
> >> From: "Hu.Yadi" <[email protected]>
> >>
> >> Replace SYS_<syscall> with __NR_<syscall>. Using the __NR_<syscall>
> >> notation, provided by UAPI, is useful to build tests on systems
> >> without the SYS_<syscall> definitions.
> >
> >This looks a lot like that...
> >https://git.kernel.org/stable/c/87129ef13603ae46c82bcd09eed948acf0506dbb
>
> Yes, I picked up comments from above commit in order for consistent,
> I would send v3 patch if it is inappropriate.

This is not an issue at all to use the same wording if it makes sense.
Actually, the description of v3 is less explanatory. It might just be
appropriate to reference past similar work. That would justify your
work, add a precedent, and if there is any issue we could fix both
changes.

You can append this to the commit message (with the v2 description):

Similar changes: commit 87129ef13603 ("selftests/landlock: Make tests
build with old libc")

Acked-by: Mickaël Salaün <[email protected]>

>
> >>
> >> Replace SYS_move_mount with __NR_move_mount
> >>
> >> Signed-off-by: Hu.Yadi <[email protected]> Suggested-by:Jiao
> >> <[email protected]> Reviewed-by:Berlin <[email protected]>
> >> ---
> >> Changes v1 -> v2:
> >> - Fix mail of Suggested-by and Reviewed-by
> >>
> >> .../move_mount_set_group/move_mount_set_group_test.c | 4 ++--
> >> 1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git
> >> a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_te
> >> st.c
> >> b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_te
> >> st.c index 50ed5d475dd1..bcf51d785a37 100644
> >> ---
> >> a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_te
> >> st.c
> >> +++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_grou
> >> +++ p_test.c
> >> @@ -218,7 +218,7 @@ static bool move_mount_set_group_supported(void)
> >> if (mount(NULL, SET_GROUP_FROM, NULL, MS_SHARED, 0))
> >> return -1;
> >>
> >> - ret = syscall(SYS_move_mount, AT_FDCWD, SET_GROUP_FROM,
> >> + ret = syscall(__NR_move_mount, AT_FDCWD, SET_GROUP_FROM,
> >> AT_FDCWD, SET_GROUP_TO, MOVE_MOUNT_SET_GROUP);
> >> umount2("/tmp", MNT_DETACH);
> >>
> >> @@ -363,7 +363,7 @@ TEST_F(move_mount_set_group, complex_sharing_copying)
> >> CLONE_VM | CLONE_FILES); ASSERT_GT(pid, 0);
> >> ASSERT_EQ(wait_for_pid(pid), 0);
> >>
> >> - ASSERT_EQ(syscall(SYS_move_mount, ca_from.mntfd, "",
> >> + ASSERT_EQ(syscall(__NR_move_mount, ca_from.mntfd, "",
> >> ca_to.mntfd, "", MOVE_MOUNT_SET_GROUP
> >> | MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_T_EMPTY_PATH),
> >> 0);
> >> --
> >> 2.23.0
> >>