@@ -92,6 +92,7 @@ AC_CHECK_FUNCS_ONCE([ \
epoll_pwait \
epoll_pwait2 \
execveat \
+ faccessat2 \
fallocate \
fchownat \
fsconfig \
new file mode 100644
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 FUJITSU LIMITED. All rights reserved.
+ * Copyright (c) Linux Test Project, 2003-2023
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+ */
+
+#ifndef FACCESSAT2_H
+#define FACCESSAT2_H
+
+#include "tst_test.h"
+#include "lapi/syscalls.h"
+
+#ifndef HAVE_FACCESSAT2
+int faccessat2(int dirfd, const char *pathname, int mode, int flags)
+{
+ return tst_syscall(__NR_faccessat2, dirfd, pathname, mode, flags);
+}
+#endif
+
+#endif /* FACCESSAT2_H */
@@ -293,6 +293,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -313,6 +313,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -391,6 +391,7 @@ clone3 (__NR_SYSCALL_BASE+435)
close_range (__NR_SYSCALL_BASE+436)
openat2 (__NR_SYSCALL_BASE+437)
pidfd_getfd (__NR_SYSCALL_BASE+438)
+faccessat2 (__NR_SYSCALL_BASE+439)
epoll_pwait2 (__NR_SYSCALL_BASE+441)
quotactl_fd (__NR_SYSCALL_BASE+443)
futex_waitv (__NR_SYSCALL_BASE+449)
@@ -40,6 +40,7 @@ fsmount 432
fspick 433
pidfd_open 434
close_range 436
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -427,6 +427,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -340,6 +340,7 @@ pidfd_open 1458
close_range 1460
openat2 1461
pidfd_getfd 1462
+faccessat2 1463
epoll_pwait2 1465
quotactl_fd 1467
futex_waitv 1473
@@ -420,6 +420,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -420,6 +420,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -407,6 +407,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -355,6 +355,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -401,6 +401,7 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -406,6 +406,7 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -371,6 +371,7 @@ pidfd_open 434
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -348,6 +348,7 @@ clone3 435
close_range 436
openat2 437
pidfd_getfd 438
+faccessat2 439
epoll_pwait2 441
quotactl_fd 443
futex_waitv 449
@@ -216,6 +216,9 @@ exit_group01 exit_group01
#faccessat test cases
faccessat01 faccessat01
+#faccessat2 test cases
+faccessat201 faccessat201
+
#fallocate test cases
fallocate01 fallocate01
fallocate02 fallocate02
new file mode 100644
@@ -0,0 +1 @@
+/faccessat201
new file mode 100644
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2023 FUJITSU LIMITED. All rights reserved.
+# Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
new file mode 100644
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 FUJITSU LIMITED. All rights reserved.
+ * Copyright (c) Linux Test Project, 2003-2023
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Check the basic functionality of faccessat2().
+ *
+ * Minimum Linux version required is v5.8.
+ */
+
+#include <stdlib.h>
+
+#include "tst_test.h"
+#include "lapi/syscalls.h"
+#include "lapi/faccessat.h"
+
+#define TESTDIR "faccessat2dir"
+#define TESTFILE "faccessat2file"
+#define RELPATH "faccessat2dir/faccessat2file"
+#define TESTSYMLINK "faccessat2symlink"
+
+static int dir_fd, bad_fd = -1;
+static int atcwd_fd = AT_FDCWD;
+static char *testfile;
+static char *abs_path;
+static char *rel_path;
+static char *sym_path;
+
+static struct tcase {
+ int *fd;
+ char **filename;
+ int flags;
+} tcases[] = {
+ {&dir_fd, &testfile, 0},
+ {&bad_fd, &abs_path, 0},
+ {&atcwd_fd, &rel_path, 0},
+ {&dir_fd, &testfile, AT_EACCESS},
+ {&bad_fd, &abs_path, AT_EACCESS},
+ {&atcwd_fd, &rel_path, AT_EACCESS},
+ {&atcwd_fd, &sym_path, AT_SYMLINK_NOFOLLOW},
+};
+
+static void verify_faccessat2(unsigned int i)
+{
+ struct tcase *tc = &tcases[i];
+
+ TST_EXP_PASS(faccessat2(*tc->fd, *tc->filename, R_OK, tc->flags),
+ "faccessat2(%d, %s, R_OK, %d)",
+ *tc->fd, *tc->filename, tc->flags);
+}
+
+static void setup(void)
+{
+ char *tmpdir_path = tst_get_tmpdir();
+
+ abs_path = tst_aprintf("%s/%s", tmpdir_path, RELPATH);
+ free(tmpdir_path);
+
+ SAFE_MKDIR(TESTDIR, 0666);
+ dir_fd = SAFE_OPEN(TESTDIR, O_DIRECTORY);
+ SAFE_TOUCH(abs_path, 0444, NULL);
+ SAFE_SYMLINK(abs_path, TESTSYMLINK);
+}
+
+static void cleanup(void)
+{
+ if (dir_fd > -1)
+ SAFE_CLOSE(dir_fd);
+}
+
+static struct tst_test test = {
+ .test = verify_faccessat2,
+ .tcnt = ARRAY_SIZE(tcases),
+ .setup = setup,
+ .cleanup = cleanup,
+ .bufs = (struct tst_buffers []) {
+ {&testfile, .str = TESTFILE},
+ {&abs_path, .size = sizeof(char)},
+ {&rel_path, .str = RELPATH},
+ {&sym_path, .str = TESTSYMLINK},
+ {},
+ },
+ .needs_tmpdir = 1,
+};
Check the basic functionality of faccessat2(). Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> --- configure.ac | 1 + include/lapi/faccessat.h | 21 +++++ include/lapi/syscalls/aarch64.in | 1 + include/lapi/syscalls/arc.in | 1 + include/lapi/syscalls/arm.in | 1 + include/lapi/syscalls/hppa.in | 1 + include/lapi/syscalls/i386.in | 1 + include/lapi/syscalls/ia64.in | 1 + include/lapi/syscalls/powerpc.in | 1 + include/lapi/syscalls/powerpc64.in | 1 + include/lapi/syscalls/s390.in | 1 + include/lapi/syscalls/s390x.in | 1 + include/lapi/syscalls/sh.in | 1 + include/lapi/syscalls/sparc.in | 1 + include/lapi/syscalls/sparc64.in | 1 + include/lapi/syscalls/x86_64.in | 1 + runtest/syscalls | 3 + .../kernel/syscalls/faccessat2/.gitignore | 1 + testcases/kernel/syscalls/faccessat2/Makefile | 9 ++ .../kernel/syscalls/faccessat2/faccessat201.c | 89 +++++++++++++++++++ 20 files changed, 138 insertions(+) create mode 100644 include/lapi/faccessat.h create mode 100644 testcases/kernel/syscalls/faccessat2/.gitignore create mode 100644 testcases/kernel/syscalls/faccessat2/Makefile create mode 100644 testcases/kernel/syscalls/faccessat2/faccessat201.c