]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/replace: let rep_openat2() inject O_LARGEFILE as needed
authorStefan Metzmacher <metze@samba.org>
Wed, 23 Nov 2022 10:38:20 +0000 (11:38 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 24 Nov 2022 11:01:37 +0000 (11:01 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15251

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/replace/replace.c

index cbf372e494f17e655b7d364722dd5d7ced387e84..68829f2a3c9701914357c6ea4f7bde268b3d5c01 100644 (file)
@@ -1116,6 +1116,22 @@ long rep_openat2(int dirfd, const char *pathname,
                 struct open_how *how, size_t size)
 {
 #ifdef __NR_openat2
+#if _FILE_OFFSET_BITS == 64 && SIZE_MAX == 0xffffffffUL && defined(O_LARGEFILE)
+       struct open_how __how;
+
+#if defined(O_PATH) && ! defined(DISABLE_OPATH)
+       if ((how->flags & O_PATH) == 0)
+#endif
+       {
+               if (sizeof(__how) == size) {
+                       __how = *how;
+
+                       __how.flags |= O_LARGEFILE;
+                       how = &__how;
+               }
+       }
+#endif
+
        return syscall(__NR_openat2,
                       dirfd,
                       pathname,