summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2022-08-08 15:33:24 +0200
committerStefan Metzmacher <metze@samba.org>2022-08-16 18:27:13 +0000
commit4b1f56aa04a3e0a1ffbfda7f596d7a5762813a56 (patch)
tree0a92d0206abe84d230c955ee64fb04a9d9b1001c
parentdd18624395dc8a7cd2cfc9527961ae2f1375b744 (diff)
downloadsamba-4b1f56aa04a3e0a1ffbfda7f596d7a5762813a56.tar.gz
lib/replace: add fallback defines for __NR_openat2
sys/syscall.h might be older than the runtime kernel. If the kernel has support for openat2() we should try to use if anyway. The callers have to deal with ENOSYS anyway, so there's no difference if we get that from syscall(__NR_openat2) or directly from rep_openat2(). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=15146 (cherry picked from commit f7618dd31a9f8f6c0dbfdedd1a664eed25e2e449)
-rw-r--r--lib/replace/replace.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index 5ec2f7ccc56..54d3a60e179 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -1084,6 +1084,26 @@ ssize_t rep_copy_file_range(int fd_in,
#endif /* HAVE_COPY_FILE_RANGE */
#ifndef HAVE_OPENAT2
+
+/* fallback known wellknown __NR_openat2 values */
+#ifndef __NR_openat2
+# if defined(LINUX) && defined(HAVE_SYS_SYSCALL_H)
+# if defined(__i386__)
+# define __NR_openat2 437
+# elif defined(__x86_64__) && defined(__LP64__)
+# define __NR_openat2 437 /* 437 0x1B5 */
+# elif defined(__x86_64__) && defined(__ILP32__)
+# define __NR_openat2 1073742261 /* 1073742261 0x400001B5 */
+# elif defined(__aarch64__)
+# define __NR_openat2 437
+# elif defined(__arm__)
+# define __NR_openat2 437
+# elif defined(__sparc__)
+# define __NR_openat2 437
+# endif
+# endif /* defined(LINUX) && defined(HAVE_SYS_SYSCALL_H) */
+#endif /* !__NR_openat2 */
+
long rep_openat2(int dirfd, const char *pathname,
struct open_how *how, size_t size)
{