mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests: proc: include fcntl.h in proc-pidns
@ 2026-06-18 15:14 Amin Vakil
  2026-06-18 15:24 ` Shuah Khan
  2026-06-23 10:13 ` Christian Brauner
  0 siblings, 2 replies; 5+ messages in thread
From: Amin Vakil @ 2026-06-18 15:14 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Aleksa Sarai, Christian Brauner, linux-kselftest, linux-fsdevel,
	linux-kernel, Amin Vakil

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.

Fixes: 5554d820f71c ("selftests/proc: add tests for new pidns APIs")
Tested with:
  make -C tools/testing/selftests TARGETS=proc

Signed-off-by: Amin Vakil <info@aminvakil.com>
---
 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.c
index 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>
-- 
2.54.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: proc: include fcntl.h in proc-pidns
  2026-06-18 15:14 [PATCH] selftests: proc: include fcntl.h in proc-pidns Amin Vakil
@ 2026-06-18 15:24 ` Shuah Khan
  2026-06-18 16:12   ` Amin Vakil
  2026-06-23 10:13 ` Christian Brauner
  1 sibling, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2026-06-18 15:24 UTC (permalink / raw)
  To: Amin Vakil, Shuah Khan
  Cc: Aleksa Sarai, Christian Brauner, linux-kselftest, linux-fsdevel,
	linux-kernel, Shuah Khan

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?

> 
> Fixes: 5554d820f71c ("selftests/proc: add tests for new pidns APIs")
> Tested with:
>    make -C tools/testing/selftests TARGETS=proc
> 
> Signed-off-by: Amin Vakil <info@aminvakil.com>
> ---
>   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.c
> index 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: proc: include fcntl.h in proc-pidns
  2026-06-18 15:24 ` Shuah Khan
@ 2026-06-18 16:12   ` Amin Vakil
  0 siblings, 0 replies; 5+ messages in thread
From: Amin Vakil @ 2026-06-18 16:12 UTC (permalink / raw)
  To: Shuah Khan, Shuah Khan
  Cc: Aleksa Sarai, Christian Brauner, linux-kselftest, linux-fsdevel,
	linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 3062 bytes --]

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 <info@aminvakil.com>
>> ---
>>   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.c
>> index 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


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 2493 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 665 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: proc: include fcntl.h in proc-pidns
  2026-06-18 15:14 [PATCH] selftests: proc: include fcntl.h in proc-pidns Amin Vakil
  2026-06-18 15:24 ` Shuah Khan
@ 2026-06-23 10:13 ` Christian Brauner
  2026-06-29 14:47   ` Amin Vakil
  1 sibling, 1 reply; 5+ messages in thread
From: Christian Brauner @ 2026-06-23 10:13 UTC (permalink / raw)
  To: Shuah Khan, Amin Vakil
  Cc: Aleksa Sarai, linux-kselftest, linux-fsdevel, linux-kernel

On Thu, 18 Jun 2026 18:44:44 +0330, Amin Vakil wrote:
> selftests: proc: include fcntl.h in proc-pidns

Applied to the vfs-7.3.misc branch of the vfs/vfs.git tree.
Patches in the vfs-7.3.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.3.misc

[1/1] selftests: proc: include fcntl.h in proc-pidns
      https://git.kernel.org/vfs/vfs/c/03ebedea000e


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: proc: include fcntl.h in proc-pidns
  2026-06-23 10:13 ` Christian Brauner
@ 2026-06-29 14:47   ` Amin Vakil
  0 siblings, 0 replies; 5+ messages in thread
From: Amin Vakil @ 2026-06-29 14:47 UTC (permalink / raw)
  To: Christian Brauner, Shuah Khan
  Cc: Aleksa Sarai, linux-kselftest, linux-fsdevel, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 1830 bytes --]

On 6/23/26 1:43 PM, Christian Brauner wrote:
> On Thu, 18 Jun 2026 18:44:44 +0330, Amin Vakil wrote:
>> selftests: proc: include fcntl.h in proc-pidns
> 
> Applied to the vfs-7.3.misc branch of the vfs/vfs.git tree.
> Patches in the vfs-7.3.misc branch should appear in linux-next soon.
> 
> Please report any outstanding bugs that were missed during review in a
> new review to the original patch series allowing us to drop it.
> 
> It's encouraged to provide Acked-bys and Reviewed-bys even though the
> patch has now been applied. If possible patch trailers will be updated.
> 
> Note that commit hashes shown below are subject to change due to rebase,
> trailer updates or similar. If in doubt, please check the listed branch.
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
> branch: vfs-7.3.misc
> 
> [1/1] selftests: proc: include fcntl.h in proc-pidns
>        https://git.kernel.org/vfs/vfs/c/03ebedea000e
> 

Sorry for the follow-up email, I do not know if there is something that 
should be done from me.

Patch is not present wherever I looked at.

https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/tools/testing/selftests/proc/proc-pidns.c?h=vfs-7.3.misc

does not show the patch.

https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/commit/?id=03ebedea000e

says Bad object id (which I think is not a concern as you've said commit 
hashes may change)

https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/plain/tools/testing/selftests/proc/proc-pidns.c?h=vfs-7.3.misc

does not show
#include <fcntl.h>
as well.

Again please accept my apologies if I should've waited more or I 
should've done something else, this is my first patch to kernel mailing 
lists. Thank you for your patience.

Best Regards,
Amin Vakil

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 2493 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 665 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-29 14:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-18 15:14 [PATCH] selftests: proc: include fcntl.h in proc-pidns Amin Vakil
2026-06-18 15:24 ` Shuah Khan
2026-06-18 16:12   ` Amin Vakil
2026-06-23 10:13 ` Christian Brauner
2026-06-29 14:47   ` Amin Vakil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®