Skip to contentSkip to conversation

selftests: openat2: fix build error on newer glibc

PATCH In review Aleksa Sarai 2 participants 2 messages Feb 13, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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:

Quoted 9 lines

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 ();
      |    ^~~~~~~~~~~~~~~~~~~~~~~~
---
 tools/testing/selftests/openat2/helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/openat2/helpers.c +1 -1
index e9a6557ab16f..5074681ffdc9 100644
@@ -46,7 +46,7 @@ int sys_renameat2(int olddirfd, const char *oldpath,
 
 int touchat(int dfd, const char *path)
 {
-	int fd = openat(dfd, path, O_CREAT);
+	int fd = openat(dfd, path, O_CREAT, 0700);
 	if (fd >= 0)
 		close(fd);
 	return fd;
Signature · 1 line
2.25.0
maintainer
#1 lore raw
Quoted 26 lines · Aleksa Sarai

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:

Quoted 9 lines

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 ();
       |    ^~~~~~~~~~~~~~~~~~~~~~~~
---
  tools/testing/selftests/openat2/helpers.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/openat2/helpers.c +0 -0
index e9a6557ab16f..5074681ffdc9 100644

tools/testing/selftests/openat2/helpers.c int sys_renameat2(int olddirfd, const char *oldpath, · line 52

Quoted 8 lines
tools/testing/selftests/openat2/helpers.c +1 -1
@@ -46,7 +46,7 @@ int sys_renameat2(int olddirfd, const char *oldpath,
 
  int touchat(int dfd, const char *path)
  {
-	int fd = openat(dfd, path, O_CREAT);
+	int fd = openat(dfd, path, O_CREAT, 0700);
  	if (fd >= 0)
  		close(fd);
  	return fd;

Thanks for a quick patch. It compiles now.

I will take this through kselftest tree.

thanks,
-- Shuah