Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: openat2: fix build error on newer glibc

It appears that newer glibcs check that openat(O_CREAT) was provided a
fourth argument (rather than passing garbage), resulting in the
following build error:

> In file included from /usr/include/fcntl.h:301,
> from helpers.c:9:
> In function 'openat',
> inlined from 'touchat' at helpers.c:49:11:
> /usr/include/x86_64-linux-gnu/bits/fcntl2.h:126:4: error: call to
> '__openat_missing_mode' declared with attribute error: openat with O_CREAT
> or O_TMPFILE in third argument needs 4 arguments
> 126 | __openat_missing_mode ();
> | ^~~~~~~~~~~~~~~~~~~~~~~~

Reported-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
Tested-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Aleksa Sarai and committed by
Shuah Khan
9a0584f0 3e839363

+1 -1
+1 -1
tools/testing/selftests/openat2/helpers.c
··· 46 46 47 47 int touchat(int dfd, const char *path) 48 48 { 49 - int fd = openat(dfd, path, O_CREAT); 49 + int fd = openat(dfd, path, O_CREAT, 0700); 50 50 if (fd >= 0) 51 51 close(fd); 52 52 return fd;