diff mbox series

[v2] open64: Force O_LARGEFILE on all architectures

Message ID 20211229051036.2245590-1-shorne@gmail.com
State New
Headers show
Series [v2] open64: Force O_LARGEFILE on all architectures | expand

Commit Message

Stafford Horne Dec. 29, 2021, 5:10 a.m. UTC
When running tests on OpenRISC which has 32-bit wordsize but 64-bit
timesize it was found that O_LARGEFILE is not being set when calling
open64.  For 64-bit architectures the O_LARGEFILE flag is generally
implied by the kernel according to force_o_largefile.  However, for
32-bit architectures this is not done.

For this patch we unconditionally now set the O_LARGEFILE flag for
open64 class syscalls as there is no harm in doing so.

Tested on the OpenRISC the build works and timezone/tst-tzset passes
which was failing before.  I would expect this also would fix arc.
---

Changes since v1:
 - Replace ifdef with just using O_LARGEFILE in all cases as
   discussed with Adhemerval.

 sysdeps/unix/sysv/linux/open64.c            | 9 +--------
 sysdeps/unix/sysv/linux/open64_nocancel.c   | 8 +-------
 sysdeps/unix/sysv/linux/openat64.c          | 8 +-------
 sysdeps/unix/sysv/linux/openat64_nocancel.c | 8 +-------
 4 files changed, 4 insertions(+), 29 deletions(-)

Comments

Adhemerval Zanella Dec. 30, 2021, 2:59 p.m. UTC | #1
On 29/12/2021 02:10, Stafford Horne via Libc-alpha wrote:
> When running tests on OpenRISC which has 32-bit wordsize but 64-bit
> timesize it was found that O_LARGEFILE is not being set when calling
> open64.  For 64-bit architectures the O_LARGEFILE flag is generally
> implied by the kernel according to force_o_largefile.  However, for
> 32-bit architectures this is not done.
> 
> For this patch we unconditionally now set the O_LARGEFILE flag for
> open64 class syscalls as there is no harm in doing so.
> 
> Tested on the OpenRISC the build works and timezone/tst-tzset passes
> which was failing before.  I would expect this also would fix arc.
> ---
> 
> Changes since v1:
>  - Replace ifdef with just using O_LARGEFILE in all cases as
>    discussed with Adhemerval.


LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 
>  sysdeps/unix/sysv/linux/open64.c            | 9 +--------
>  sysdeps/unix/sysv/linux/open64_nocancel.c   | 8 +-------
>  sysdeps/unix/sysv/linux/openat64.c          | 8 +-------
>  sysdeps/unix/sysv/linux/openat64_nocancel.c | 8 +-------
>  4 files changed, 4 insertions(+), 29 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c
> index 0904696973..8e2eb0bad8 100644
> --- a/sysdeps/unix/sysv/linux/open64.c
> +++ b/sysdeps/unix/sysv/linux/open64.c
> @@ -23,13 +23,6 @@
>  #include <sysdep-cancel.h>
>  #include <shlib-compat.h>
>  
> -
> -#ifdef __OFF_T_MATCHES_OFF64_T
> -# define EXTRA_OPEN_FLAGS 0
> -#else
> -# define EXTRA_OPEN_FLAGS O_LARGEFILE
> -#endif
> -
>  /* Open FILE with access OFLAG.  If O_CREAT or O_TMPFILE is in OFLAG,
>     a third argument is the file protection.  */
>  int
> @@ -45,7 +38,7 @@ __libc_open64 (const char *file, int oflag, ...)
>        va_end (arg);
>      }
>  
> -  return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS,
> +  return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | O_LARGEFILE,
>  			 mode);
>  }
>  
> diff --git a/sysdeps/unix/sysv/linux/open64_nocancel.c b/sysdeps/unix/sysv/linux/open64_nocancel.c
> index d7f35656a1..a270891dc8 100644
> --- a/sysdeps/unix/sysv/linux/open64_nocancel.c
> +++ b/sysdeps/unix/sysv/linux/open64_nocancel.c
> @@ -23,12 +23,6 @@
>  
>  #include <not-cancel.h>
>  
> -#ifdef __OFF_T_MATCHES_OFF64_T
> -# define EXTRA_OPEN_FLAGS 0
> -#else
> -# define EXTRA_OPEN_FLAGS O_LARGEFILE
> -#endif
> -
>  int
>  __open64_nocancel (const char *file, int oflag, ...)
>  {
> @@ -42,7 +36,7 @@ __open64_nocancel (const char *file, int oflag, ...)
>        va_end (arg);
>      }
>  
> -  return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS,
> +  return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE,
>  			      mode);
>  }
>  
> diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c
> index dc226567c1..9019d2b48f 100644
> --- a/sysdeps/unix/sysv/linux/openat64.c
> +++ b/sysdeps/unix/sysv/linux/openat64.c
> @@ -21,12 +21,6 @@
>  
>  #include <sysdep-cancel.h>
>  
> -#ifdef __OFF_T_MATCHES_OFF64_T
> -# define EXTRA_OPEN_FLAGS 0
> -#else
> -# define EXTRA_OPEN_FLAGS O_LARGEFILE
> -#endif
> -
>  /* Open FILE with access OFLAG.  Interpret relative paths relative to
>     the directory associated with FD.  If OFLAG includes O_CREAT or
>     O_TMPFILE, a fourth argument is the file protection.  */
> @@ -42,7 +36,7 @@ __libc_openat64 (int fd, const char *file, int oflag, ...)
>        va_end (arg);
>      }
>  
> -  return SYSCALL_CANCEL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS, mode);
> +  return SYSCALL_CANCEL (openat, fd, file, oflag | O_LARGEFILE, mode);
>  }
>  
>  strong_alias (__libc_openat64, __openat64)
> diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c
> index 51377aea45..b9c0d98770 100644
> --- a/sysdeps/unix/sysv/linux/openat64_nocancel.c
> +++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c
> @@ -22,12 +22,6 @@
>  #include <sysdep-cancel.h>
>  #include <not-cancel.h>
>  
> -#ifdef __OFF_T_MATCHES_OFF64_T
> -# define EXTRA_OPEN_FLAGS 0
> -#else
> -# define EXTRA_OPEN_FLAGS O_LARGEFILE
> -#endif
> -
>  int
>  __openat64_nocancel (int fd, const char *file, int oflag, ...)
>  {
> @@ -40,7 +34,7 @@ __openat64_nocancel (int fd, const char *file, int oflag, ...)
>        va_end (arg);
>      }
>  
> -  return INLINE_SYSCALL_CALL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS,
> +  return INLINE_SYSCALL_CALL (openat, fd, file, oflag | O_LARGEFILE,
>  			      mode);
>  }
>  hidden_def (__openat64_nocancel)
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c
index 0904696973..8e2eb0bad8 100644
--- a/sysdeps/unix/sysv/linux/open64.c
+++ b/sysdeps/unix/sysv/linux/open64.c
@@ -23,13 +23,6 @@ 
 #include <sysdep-cancel.h>
 #include <shlib-compat.h>
 
-
-#ifdef __OFF_T_MATCHES_OFF64_T
-# define EXTRA_OPEN_FLAGS 0
-#else
-# define EXTRA_OPEN_FLAGS O_LARGEFILE
-#endif
-
 /* Open FILE with access OFLAG.  If O_CREAT or O_TMPFILE is in OFLAG,
    a third argument is the file protection.  */
 int
@@ -45,7 +38,7 @@  __libc_open64 (const char *file, int oflag, ...)
       va_end (arg);
     }
 
-  return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS,
+  return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | O_LARGEFILE,
 			 mode);
 }
 
diff --git a/sysdeps/unix/sysv/linux/open64_nocancel.c b/sysdeps/unix/sysv/linux/open64_nocancel.c
index d7f35656a1..a270891dc8 100644
--- a/sysdeps/unix/sysv/linux/open64_nocancel.c
+++ b/sysdeps/unix/sysv/linux/open64_nocancel.c
@@ -23,12 +23,6 @@ 
 
 #include <not-cancel.h>
 
-#ifdef __OFF_T_MATCHES_OFF64_T
-# define EXTRA_OPEN_FLAGS 0
-#else
-# define EXTRA_OPEN_FLAGS O_LARGEFILE
-#endif
-
 int
 __open64_nocancel (const char *file, int oflag, ...)
 {
@@ -42,7 +36,7 @@  __open64_nocancel (const char *file, int oflag, ...)
       va_end (arg);
     }
 
-  return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS,
+  return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE,
 			      mode);
 }
 
diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c
index dc226567c1..9019d2b48f 100644
--- a/sysdeps/unix/sysv/linux/openat64.c
+++ b/sysdeps/unix/sysv/linux/openat64.c
@@ -21,12 +21,6 @@ 
 
 #include <sysdep-cancel.h>
 
-#ifdef __OFF_T_MATCHES_OFF64_T
-# define EXTRA_OPEN_FLAGS 0
-#else
-# define EXTRA_OPEN_FLAGS O_LARGEFILE
-#endif
-
 /* Open FILE with access OFLAG.  Interpret relative paths relative to
    the directory associated with FD.  If OFLAG includes O_CREAT or
    O_TMPFILE, a fourth argument is the file protection.  */
@@ -42,7 +36,7 @@  __libc_openat64 (int fd, const char *file, int oflag, ...)
       va_end (arg);
     }
 
-  return SYSCALL_CANCEL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS, mode);
+  return SYSCALL_CANCEL (openat, fd, file, oflag | O_LARGEFILE, mode);
 }
 
 strong_alias (__libc_openat64, __openat64)
diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c
index 51377aea45..b9c0d98770 100644
--- a/sysdeps/unix/sysv/linux/openat64_nocancel.c
+++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c
@@ -22,12 +22,6 @@ 
 #include <sysdep-cancel.h>
 #include <not-cancel.h>
 
-#ifdef __OFF_T_MATCHES_OFF64_T
-# define EXTRA_OPEN_FLAGS 0
-#else
-# define EXTRA_OPEN_FLAGS O_LARGEFILE
-#endif
-
 int
 __openat64_nocancel (int fd, const char *file, int oflag, ...)
 {
@@ -40,7 +34,7 @@  __openat64_nocancel (int fd, const char *file, int oflag, ...)
       va_end (arg);
     }
 
-  return INLINE_SYSCALL_CALL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS,
+  return INLINE_SYSCALL_CALL (openat, fd, file, oflag | O_LARGEFILE,
 			      mode);
 }
 hidden_def (__openat64_nocancel)