On 6/18/26 6:54 PM, Shuah Khan wrote:
On 6/18/26 09:14, Amin Vakil wrote:proc-pidns.c uses open() and O_* flags, but does not include <fcntl.h>. This breaks the proc selftests build with errors such as:error: implicit declaration of function 'open' error: 'O_WRONLY' undeclared error: 'O_CREAT' undeclared error: 'O_RDONLY' undeclared Include <fcntl.h> to provide the declaration and flag definitions.Did you install headers before compiling the test?
Sorry, no I hadn't.But seems like problem is still relevant after make headers, I've tested now with these commands:
make -C tools/testing/selftests TARGETS=proc clean make headers make -C tools/testing/selftests TARGETS=proc CC proc-pidns proc-pidns.c: In function ‘touch’:proc-pidns.c:34:18: error: implicit declaration of function ‘open’; did you mean ‘popen’? [-Wimplicit-function-declaration]
34 | int fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC, 0644);
| ^~~~
| popen
proc-pidns.c:34:29: error: ‘O_WRONLY’ undeclared (first use in this
function)
34 | int fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC, 0644);
| ^~~~~~~~
proc-pidns.c:34:29: note: each undeclared identifier is reported only
once for each function it appears in
proc-pidns.c:34:38: error: ‘O_CREAT’ undeclared (first use in this function)
34 | int fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC, 0644);
| ^~~~~~~
proc-pidns.c: In function ‘ns_setup’:
proc-pidns.c:49:54: error: ‘O_RDONLY’ undeclared (first use in this
function); did you mean ‘MS_RDONLY’?
49 | self->host_mntns = open("/proc/self/ns/mnt",
O_RDONLY|O_CLOEXEC);
| ^~~~~~~~
| MS_RDONLY
After applying the patch I've sent, error is gone.
My environment if relevant:
$ gcc --version
gcc (GCC) 16.1.1 20260430
$ make --version
GNU Make 4.4.1
Built for x86_64-pc-linux-gnu
$ ldd --version
ldd (GNU libc) 2.43
$ getconf GNU_LIBC_VERSION
glibc 2.43
Fixes: 5554d820f71c ("selftests/proc: add tests for new pidns APIs") Tested with: make -C tools/testing/selftests TARGETS=proc Signed-off-by: Amin Vakil <[email protected]> --- tools/testing/selftests/proc/proc-pidns.c | 1 + 1 file changed, 1 insertion(+)diff --git a/tools/testing/selftests/proc/proc-pidns.c b/tools/ testing/selftests/proc/proc-pidns.cindex 25b9a2933c45..6f7c10fe97b3 100644 --- a/tools/testing/selftests/proc/proc-pidns.c +++ b/tools/testing/selftests/proc/proc-pidns.c @@ -6,6 +6,7 @@ #include <assert.h> #include <errno.h> +#include <fcntl.h> #include <sched.h> #include <stdbool.h> #include <stdlib.h>thanks, -- Shuah
OpenPGP_0x1EFC1864E9D9E56B.asc
Description: OpenPGP public key
OpenPGP_signature.asc
Description: OpenPGP digital signature

