When compiling selftests files under tools/testing/selftests/pidfd/ , some compiling errors and warnings will pop out as the following.
CC pidfd_fdinfo_test pidfd_fdinfo_test.c: In function ‘child_fdinfo_nspid_test’: pidfd_fdinfo_test.c:231:13: warning: implicit declaration of function \ ‘mount’ [-Wimplicit-function-declaration] 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~ pidfd_fdinfo_test.c:231:36: error: ‘MS_REC’ undeclared \ (first use in this function) 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~~ pidfd_fdinfo_test.c:231:36: note: each undeclared identifier is \ reported only once for each function it appears in pidfd_fdinfo_test.c:231:45: error: ‘MS_PRIVATE’ undeclared \ (first use in this function); did you mean ‘MAP_PRIVATE’? 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~~~~~~ | MAP_PRIVATE pidfd_fdinfo_test.c:237:15: warning: implicit declaration of function \ ‘umount2’; did you mean ‘SYS_umount2’? \ [-Wimplicit-function-declaration] 237 | (void)umount2("/proc", MNT_DETACH); | ^~~~~~~ | SYS_umount2 pidfd_fdinfo_test.c:237:32: error: ‘MNT_DETACH’ undeclared \ (first use in this function) 237 | (void)umount2("/proc", MNT_DETACH); | ^~~~~~~~~~ make: *** [../lib.mk:222: \ ~/linux/tools/testing/selftests/pidfd/pidfd_fdinfo_test] Error 1
Solve these errors and warnings by including header file <sys/mount.h>.
Signed-off-by: I Hsin Cheng richard120310@gmail.com --- tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c index f062a986e..f718aac75 100644 --- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c +++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c @@ -13,6 +13,7 @@ #include <syscall.h> #include <sys/wait.h> #include <sys/mman.h> +#include <sys/mount.h>
#include "pidfd.h" #include "../kselftest.h"
Hello *,
On Wed, 5 Feb 2025 13:39:26 +0800, I Hsin Cheng richard120310@gmail.com wrote:
When compiling selftests files under tools/testing/selftests/pidfd/ , some compiling errors and warnings will pop out as the following.
CC pidfd_fdinfo_test pidfd_fdinfo_test.c: In function ‘child_fdinfo_nspid_test’: pidfd_fdinfo_test.c:231:13: warning: implicit declaration of function \ ‘mount’ [-Wimplicit-function-declaration] 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~ pidfd_fdinfo_test.c:231:36: error: ‘MS_REC’ undeclared \ (first use in this function) 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~~ pidfd_fdinfo_test.c:231:36: note: each undeclared identifier is \ reported only once for each function it appears in pidfd_fdinfo_test.c:231:45: error: ‘MS_PRIVATE’ undeclared \ (first use in this function); did you mean ‘MAP_PRIVATE’? 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~~~~~~ | MAP_PRIVATE pidfd_fdinfo_test.c:237:15: warning: implicit declaration of function \ ‘umount2’; did you mean ‘SYS_umount2’? \ [-Wimplicit-function-declaration] 237 | (void)umount2("/proc", MNT_DETACH); | ^~~~~~~ | SYS_umount2 pidfd_fdinfo_test.c:237:32: error: ‘MNT_DETACH’ undeclared \ (first use in this function) 237 | (void)umount2("/proc", MNT_DETACH); | ^~~~~~~~~~ make: *** [../lib.mk:222: \ ~/linux/tools/testing/selftests/pidfd/pidfd_fdinfo_test] Error 1
Solve these errors and warnings by including header file <sys/mount.h>.
Signed-off-by: I Hsin Cheng richard120310@gmail.com
tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c index f062a986e..f718aac75 100644 --- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c +++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c @@ -13,6 +13,7 @@ #include <syscall.h> #include <sys/wait.h> #include <sys/mman.h> +#include <sys/mount.h> #include "pidfd.h" #include "../kselftest.h"
Predated patch already available, see
https://lore.kernel.org/linux-kselftest/20250115105211.390370-1-ps.report@gm...
Regards, Peter
On Wed, Feb 05, 2025 at 01:07:56PM +0100, Peter Seiderer wrote:
Hello *,
On Wed, 5 Feb 2025 13:39:26 +0800, I Hsin Cheng richard120310@gmail.com wrote:
When compiling selftests files under tools/testing/selftests/pidfd/ , some compiling errors and warnings will pop out as the following.
CC pidfd_fdinfo_test pidfd_fdinfo_test.c: In function ‘child_fdinfo_nspid_test’: pidfd_fdinfo_test.c:231:13: warning: implicit declaration of function \ ‘mount’ [-Wimplicit-function-declaration] 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~ pidfd_fdinfo_test.c:231:36: error: ‘MS_REC’ undeclared \ (first use in this function) 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~~ pidfd_fdinfo_test.c:231:36: note: each undeclared identifier is \ reported only once for each function it appears in pidfd_fdinfo_test.c:231:45: error: ‘MS_PRIVATE’ undeclared \ (first use in this function); did you mean ‘MAP_PRIVATE’? 231 | r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0); | ^~~~~~~~~~ | MAP_PRIVATE pidfd_fdinfo_test.c:237:15: warning: implicit declaration of function \ ‘umount2’; did you mean ‘SYS_umount2’? \ [-Wimplicit-function-declaration] 237 | (void)umount2("/proc", MNT_DETACH); | ^~~~~~~ | SYS_umount2 pidfd_fdinfo_test.c:237:32: error: ‘MNT_DETACH’ undeclared \ (first use in this function) 237 | (void)umount2("/proc", MNT_DETACH); | ^~~~~~~~~~ make: *** [../lib.mk:222: \ ~/linux/tools/testing/selftests/pidfd/pidfd_fdinfo_test] Error 1
Solve these errors and warnings by including header file <sys/mount.h>.
Signed-off-by: I Hsin Cheng richard120310@gmail.com
tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c index f062a986e..f718aac75 100644 --- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c +++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c @@ -13,6 +13,7 @@ #include <syscall.h> #include <sys/wait.h> #include <sys/mman.h> +#include <sys/mount.h> #include "pidfd.h" #include "../kselftest.h"
Predated patch already available, see
https://lore.kernel.org/linux-kselftest/20250115105211.390370-1-ps.report@gm...
Hello Peter,
Thanks for the kindly reminder!
Good to know it's already solved, thanks!
Regards, I Hsin Cheng.
Regards, Peter
linux-kselftest-mirror@lists.linaro.org