Message ID | 1522877210-27934-1-git-send-email-adhemerval.zanella@linaro.org |
---|---|
State | New |
Headers | show |
Series | Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251) | expand |
Ping. On 04/04/2018 18:26, Adhemerval Zanella wrote: > This patch fixes the OFD ("file private") locks for architectures that > support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). > The problem in this case is both F_OFD_{GETLK,SETLK,SETLKW} and > F_{SET,GET}L{W}K64 expects a flock64 argument. Kernel idea originally was > to avoid using such flags in non-LFS syscall, but since GLIBC uses fcntl64 > as default it still can provide the functionality and avoid the bogus > struct kernel passing by adjusting the struct manually for the required > flags. > > The idea follows other LFS interfaces that provide two symbols: > > 1. A new LFS fcntl64 is added on default ABI with the usual macros to select > it for FILE_OFFSET_BITS=64. > > 2. The Linux non-LFS fcntl use a stack allocated struct flock64 for > F_OFD_{GETLK,SETLK,SETLKW} and F_{SET,GET}L{W}K64 and copy the results on > the user provided struct. > > 3. Keep a compat symbol with old broken semantic for architectures that do > not define __OFF_T_MATCHES_OFF64_T. > > So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will aliased > to fcntl and no adjustment would be required. > > Checked on x86_64-linux-gnu and i686-linux-gnu. > > [BZ #20251] > * include/fcntl.h (__libc_fcntl64, __fcntl64): New prototype. > * io/Makefile (routines): Add fcntl64. > (CFLAGS-fcntl64.c): New rule. > * io/fcntl.h (fcntl64): Add prototype and redirect if > __USE_FILE_OFFSET64 is defined. > * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file. > * io/fcntl64.c: New file. > * nptl/Makefile (pthread-compat-wrappers): Add fcntl64. > (CFLAGS-fcntl64.c): New rule. > * sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols. > * io/Versions [GLIBC_2.28] (fcntl64; __fcntl64): New symbols. > * sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64, > F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for > non-LFS case. > (fcntl_common, __fcntl_nocancel): Remove function. > (flock_to_flock64): New function. > * sysdeps/unix/sysv/linux/fcntl64.c: New file. > * sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (__fcntl64, fcntl, > fcntl64): New symbols. > * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise. > * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Likewise. > * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: > Likewise. > * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: > Likewise. > * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28] (__fcntl64, > fcntl64): New symbols. > * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. > * sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. > * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise. > --- > ChangeLog | 56 +++++++++++ > include/fcntl.h | 4 + > io/Makefile | 3 +- > io/Versions | 3 + > io/fcntl.h | 11 +++ > .../powerpc/powerpc64/fcntl.c => io/fcntl64.c | 28 +++--- > nptl/Makefile | 3 +- > sysdeps/mach/hurd/fcntl.c | 5 + > sysdeps/mach/hurd/i386/libc.abilist | 4 + > sysdeps/unix/sysv/linux/aarch64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/alpha/libc.abilist | 3 + > sysdeps/unix/sysv/linux/arm/libc.abilist | 4 + > sysdeps/unix/sysv/linux/fcntl.c | 102 +++++++++++++-------- > sysdeps/unix/sysv/linux/fcntl64.c | 99 ++++++++++++++++++++ > sysdeps/unix/sysv/linux/hppa/libc.abilist | 4 + > sysdeps/unix/sysv/linux/i386/libc.abilist | 4 + > sysdeps/unix/sysv/linux/ia64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 4 + > sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 4 + > sysdeps/unix/sysv/linux/microblaze/libc.abilist | 4 + > .../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 4 + > .../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 4 + > .../unix/sysv/linux/mips/mips64/n32/libc.abilist | 4 + > .../unix/sysv/linux/mips/mips64/n64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/nios2/libc.abilist | 4 + > sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 8 ++ > .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 4 + > .../linux/powerpc/powerpc32/nofpu/libc.abilist | 4 + > .../sysv/linux/powerpc/powerpc64/libc-le.abilist | 3 + > .../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 4 + > sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/sh/libc.abilist | 4 + > sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 4 + > sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist | 3 + > sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 3 + > sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 3 + > 40 files changed, 376 insertions(+), 49 deletions(-) > rename sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c => io/fcntl64.c (65%) > create mode 100644 sysdeps/unix/sysv/linux/fcntl64.c > > diff --git a/include/fcntl.h b/include/fcntl.h > index 3d68c5e..5fac115 100644 > --- a/include/fcntl.h > +++ b/include/fcntl.h > @@ -10,10 +10,14 @@ extern int __libc_open (const char *file, int oflag, ...); > libc_hidden_proto (__libc_open) > extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden; > libc_hidden_proto (__libc_fcntl) > +extern int __libc_fcntl64 (int fd, int cmd, ...) attribute_hidden; > +libc_hidden_proto (__libc_fcntl64) > extern int __open (const char *__file, int __oflag, ...); > libc_hidden_proto (__open) > extern int __fcntl (int __fd, int __cmd, ...); > libc_hidden_proto (__fcntl) > +extern int __fcntl64 (int __fd, int __cmd, ...); > +libc_hidden_proto (__fcntl64) > extern int __openat (int __fd, const char *__file, int __oflag, ...) > __nonnull ((2)); > libc_hidden_proto (__openat) > diff --git a/io/Makefile b/io/Makefile > index 2117cb6..4a0d8fe 100644 > --- a/io/Makefile > +++ b/io/Makefile > @@ -40,7 +40,7 @@ routines := \ > mkdir mkdirat \ > open open_2 open64 open64_2 openat openat_2 openat64 openat64_2 \ > read write lseek lseek64 access euidaccess faccessat \ > - fcntl flock lockf lockf64 \ > + fcntl fcntl64 flock lockf lockf64 \ > close dup dup2 dup3 pipe pipe2 \ > creat creat64 \ > chdir fchdir \ > @@ -89,6 +89,7 @@ CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-creat.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-creat64.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables > +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-poll.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-ppoll.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-lockf.c += -fexceptions > diff --git a/io/Versions b/io/Versions > index 98898cb..492e72c 100644 > --- a/io/Versions > +++ b/io/Versions > @@ -128,4 +128,7 @@ libc { > GLIBC_2.27 { > copy_file_range; > } > + GLIBC_2.28 { > + fcntl64; __fcntl64; > + } > } > diff --git a/io/fcntl.h b/io/fcntl.h > index 69a4394..3afc620 100644 > --- a/io/fcntl.h > +++ b/io/fcntl.h > @@ -167,7 +167,18 @@ typedef __pid_t pid_t; > > This function is a cancellation point and therefore not marked with > __THROW. */ > +#ifndef __USE_FILE_OFFSET64 > extern int fcntl (int __fd, int __cmd, ...); > +#else > +# ifdef __REDIRECT > +extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); > +# else > +# define fcntl fcntl64 > +# endif > +#endif > +#ifdef __USE_LARGEFILE64 > +extern int fcntl64 (int __fd, int __cmd, ...); > +#endif > > /* Open FILE and return a new file descriptor for it, or -1 on error. > OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/io/fcntl64.c > similarity index 65% > rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c > rename to io/fcntl64.c > index 48198c1..f4e6809 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c > +++ b/io/fcntl64.c > @@ -1,4 +1,5 @@ > -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. > +/* Manipulate file descriptor. Stub LFS version. > + Copyright (C) 2018 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or > @@ -15,18 +16,23 @@ > License along with the GNU C Library; if not, see > <http://www.gnu.org/licenses/>. */ > > -#include <unistd.h> > +#include <errno.h> > #include <fcntl.h> > > -static inline int > -fcntl_adjust_cmd (int cmd) > +/* Perform file control operations on FD. */ > +int > +__fcntl64 (int fd, int cmd, ...) > { > - if (cmd >= F_GETLK64 && cmd <= F_SETLKW64) > - cmd -= F_GETLK64 - F_GETLK; > - return cmd; > -} > + if (fd < 0) > + { > + __set_errno (EBADF); > + return -1; > + } > > -#define FCNTL_ADJUST_CMD(__cmd) \ > - fcntl_adjust_cmd (__cmd) > + __set_errno (ENOSYS); > + return -1; > +} > +libc_hidden_def (__fcntl64) > +stub_warning (fcntl64) > > -#include <sysdeps/unix/sysv/linux/fcntl.c> > +weak_alias (__fcntl64, fcntl64) > diff --git a/nptl/Makefile b/nptl/Makefile > index 94be92c..13d485c 100644 > --- a/nptl/Makefile > +++ b/nptl/Makefile > @@ -36,7 +36,7 @@ static-only-routines = pthread_atfork > # We need to provide certain routines for compatibility with existing > # binaries. > pthread-compat-wrappers = \ > - write read close fcntl accept \ > + write read close fcntl fcntl64 accept \ > connect recv recvfrom send \ > sendto fsync lseek lseek64 \ > msync nanosleep open open64 pause \ > @@ -191,6 +191,7 @@ CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables > > # These are the function wrappers we have to duplicate here. > CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables > +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-lockf.c += -fexceptions > CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables > diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c > index 0b23164..598317d 100644 > --- a/sysdeps/mach/hurd/fcntl.c > +++ b/sysdeps/mach/hurd/fcntl.c > @@ -210,3 +210,8 @@ libc_hidden_def (__libc_fcntl) > weak_alias (__libc_fcntl, __fcntl) > libc_hidden_weak (__fcntl) > weak_alias (__libc_fcntl, fcntl) > + > +strong_alias (__libc_fcntl, __libc_fcntl64) > +libc_hidden_def (__libc_fcntl64) > +weak_alias (__libc_fcntl64, __fcntl64) > +libc_hidden_weak (__fcntl64) > diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist > index 9545e89..36f1a2d 100644 > --- a/sysdeps/mach/hurd/i386/libc.abilist > +++ b/sysdeps/mach/hurd/i386/libc.abilist > @@ -2049,6 +2049,10 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist > index 90c9bc8..6fb0c38 100644 > --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist > @@ -2139,3 +2139,6 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist > index 8674a87..e8dd80c 100644 > --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist > +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist > @@ -2054,6 +2054,9 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist > index 044ec10..69bf5a3 100644 > --- a/sysdeps/unix/sysv/linux/arm/libc.abilist > +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist > @@ -130,6 +130,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.4 GLIBC_2.4 A > GLIBC_2.4 _Exit F > GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 > diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c > index a3cb2ae..5a8fbb5 100644 > --- a/sysdeps/unix/sysv/linux/fcntl.c > +++ b/sysdeps/unix/sysv/linux/fcntl.c > @@ -19,32 +19,23 @@ > #include <stdarg.h> > #include <errno.h> > #include <sysdep-cancel.h> > -#include <not-cancel.h> > > -#ifndef __NR_fcntl64 > -# define __NR_fcntl64 __NR_fcntl > -#endif > +#ifndef __OFF_T_MATCHES_OFF64_T > > -#ifndef FCNTL_ADJUST_CMD > -# define FCNTL_ADJUST_CMD(__cmd) __cmd > -#endif > +# ifndef FCNTL_ADJUST_CMD > +# define FCNTL_ADJUST_CMD(__cmd) __cmd > +# endif > > -static int > -fcntl_common (int fd, int cmd, void *arg) > +static inline struct flock64 > +flock_to_flock64 (const struct flock *flk) > { > - if (cmd == F_GETOWN) > - { > - INTERNAL_SYSCALL_DECL (err); > - struct f_owner_ex fex; > - int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); > - if (!INTERNAL_SYSCALL_ERROR_P (res, err)) > - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; > - > - return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, > - err)); > - } > - > - return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); > + return (struct flock64) { > + .l_type = flk->l_type, > + .l_whence = flk->l_whence, > + .l_start = flk->l_start, > + .l_len = flk->l_len, > + .l_pid = flk->l_pid > + }; > } > > int > @@ -59,16 +50,56 @@ __libc_fcntl (int fd, int cmd, ...) > > cmd = FCNTL_ADJUST_CMD (cmd); > > - if (cmd == F_SETLKW || cmd == F_SETLKW64) > - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); > - > - return fcntl_common (fd, cmd, arg); > + switch (cmd) > + { > + case F_SETLKW: > + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); > + case F_GETLK64: > + case F_OFD_GETLK: > + { > + struct flock *flk = (struct flock *) arg; > + struct flock64 flk64 = flock_to_flock64 (flk); > + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); > + if (ret == -1) > + return -1; > + flk->l_type = flk64.l_type; > + flk->l_whence = flk64.l_whence; > + flk->l_start = flk64.l_start; > + flk->l_len = flk64.l_len; > + flk->l_pid = flk64.l_pid; > + return ret; > + } > + case F_SETLK64: > + case F_SETLKW64: > + case F_OFD_SETLK: > + case F_OFD_SETLKW: > + { > + struct flock64 flk64 = flock_to_flock64 (arg); > + return SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); > + } > + case F_GETOWN: > + { > + INTERNAL_SYSCALL_DECL (err); > + struct f_owner_ex fex; > + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); > + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) > + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; > + > + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, > + err)); > + } > + default: > + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, arg); > + } > } > libc_hidden_def (__libc_fcntl) > +weak_alias (__libc_fcntl, __fcntl) > +libc_hidden_weak (__fcntl) > > -#if !IS_IN (rtld) > +# include <shlib-compat.h> > +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) > int > -__fcntl_nocancel (int fd, int cmd, ...) > +__old_libc_fcntl64 (int fd, int cmd, ...) > { > va_list ap; > void *arg; > @@ -77,13 +108,12 @@ __fcntl_nocancel (int fd, int cmd, ...) > arg = va_arg (ap, void *); > va_end (ap); > > - return fcntl_common (fd, cmd, arg); > + return __libc_fcntl64 (fd, cmd, arg); > } > -#else > -strong_alias (__libc_fcntl, __fcntl_nocancel) > -#endif > -libc_hidden_def (__fcntl_nocancel) > - > -weak_alias (__libc_fcntl, __fcntl) > -libc_hidden_weak (__fcntl) > +compat_symbol (libc, __old_libc_fcntl64, fcntl, GLIBC_2_0); > +versioned_symbol (libc, __libc_fcntl, fcntl, GLIBC_2_28); > +# else > weak_alias (__libc_fcntl, fcntl) > +# endif > + > +#endif /* __OFF_T_MATCHES_OFF64_T */ > diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c > new file mode 100644 > index 0000000..b7f50b0 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/fcntl64.c > @@ -0,0 +1,99 @@ > +/* Manipulate file descriptor. Linux LFS version. > + Copyright (C) 2018 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + <http://www.gnu.org/licenses/>. */ > + > +#define fcntl __no_decl_fcntl > +#define __fcntl __no_decl___fcntl > +#include <fcntl.h> > +#undef fcntl > +#undef __fcntl > +#include <stdarg.h> > +#include <errno.h> > +#include <sysdep-cancel.h> > + > +#ifndef __NR_fcntl64 > +# define __NR_fcntl64 __NR_fcntl > +#endif > + > +#ifndef FCNTL_ADJUST_CMD > +# define FCNTL_ADJUST_CMD(__cmd) __cmd > +#endif > + > +static int > +fcntl64_common (int fd, int cmd, void *arg) > +{ > + if (cmd == F_GETOWN) > + { > + INTERNAL_SYSCALL_DECL (err); > + struct f_owner_ex fex; > + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); > + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) > + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; > + > + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, > + err)); > + } > + > + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); > +} > + > +int > +__libc_fcntl64 (int fd, int cmd, ...) > +{ > + va_list ap; > + void *arg; > + > + va_start (ap, cmd); > + arg = va_arg (ap, void *); > + va_end (ap); > + > + cmd = FCNTL_ADJUST_CMD (cmd); > + > + if (cmd == F_SETLKW || cmd == F_SETLKW64) > + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); > + > + return fcntl64_common (fd, cmd, arg); > +} > +libc_hidden_def (__libc_fcntl64) > +weak_alias (__libc_fcntl64, __fcntl64) > +libc_hidden_weak (__fcntl64) > +weak_alias (__libc_fcntl64, fcntl64) > + > +#ifdef __OFF_T_MATCHES_OFF64_T > +weak_alias (__libc_fcntl64, __libc_fcntl) > +weak_alias (__libc_fcntl64, __fcntl) > +weak_alias (__libc_fcntl64, __GI___fcntl) > +weak_alias (__libc_fcntl64, fcntl) > +#endif > + > +#if !IS_IN (rtld) > +int > +__fcntl_nocancel (int fd, int cmd, ...) > +{ > + va_list ap; > + void *arg; > + > + va_start (ap, cmd); > + arg = va_arg (ap, void *); > + va_end (ap); > + > + return fcntl64_common (fd, cmd, arg); > +} > +#else > +weak_alias (__libc_fcntl64, __fcntl_nocancel) > +#endif > +weak_alias (__fcntl_nocancel, __GI___fcntl_nocancel) > diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist > index 2360130..d87eb4c 100644 > --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist > +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist > @@ -1894,6 +1894,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist > index 39c993f..177b07a 100644 > --- a/sysdeps/unix/sysv/linux/i386/libc.abilist > +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist > @@ -2064,6 +2064,10 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist > index 68496aa..87571f1 100644 > --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist > @@ -1928,6 +1928,9 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist > index b676025..afb9e05 100644 > --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist > +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist > @@ -131,6 +131,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.4 GLIBC_2.4 A > GLIBC_2.4 _Exit F > GLIBC_2.4 _IO_2_1_stderr_ D 0x98 > diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist > index cdd1df5..034ff04 100644 > --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist > +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist > @@ -2008,6 +2008,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist > index e4265fd..8586123 100644 > --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist > +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist > @@ -2129,3 +2129,7 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist > index 3a7e0b4..2187c72 100644 > --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist > +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist > @@ -1983,6 +1983,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist > index 5e80592..4ee5454 100644 > --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist > +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist > @@ -1981,6 +1981,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist > index 1973fac..62468d6 100644 > --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist > @@ -1989,6 +1989,10 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist > index 5e18ab8..48d07e3 100644 > --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist > @@ -1984,6 +1984,9 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist > index cc5885a..ee0b7c0 100644 > --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist > +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist > @@ -2170,3 +2170,7 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h > index 503f562..d755f1d 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h > +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h > @@ -52,3 +52,11 @@ > > #undef __ASSUME_CLONE_DEFAULT > #define __ASSUME_CLONE_BACKWARDS 1 > + > +#define FCNTL_ADJUST_CMD(__cmd) \ > + ({ int __cmdadj = (__cmd); \ > + if (__cmdadj >= F_GETLK64 && __cmdadj <= F_SETLKW64) \ > + __cmdadj -= F_GETLK64 - F_GETLK; \ > + __cmdadj; \ > + }) > + > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist > index 676aa50..6c72516 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist > +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist > @@ -2012,6 +2012,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist > index 2016c7c..0499171 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist > +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist > @@ -2017,6 +2017,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist > index 3d19e38..17a56de 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist > +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist > @@ -2229,3 +2229,6 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist > index c57ab21..1e625c6 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist > @@ -131,6 +131,9 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 _Exit F > GLIBC_2.3 _IO_2_1_stderr_ D 0xe0 > diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist > index 8ab44ec..dce49e0 100644 > --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist > @@ -2094,3 +2094,6 @@ GLIBC_2.27 xdrstdio_create F > GLIBC_2.27 xencrypt F > GLIBC_2.27 xprt_register F > GLIBC_2.27 xprt_unregister F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist > index 2590372..a9db23c 100644 > --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist > @@ -2022,6 +2022,10 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist > index 5d6800c..a0e275f 100644 > --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist > @@ -1923,6 +1923,9 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist > index c04872c..e3db11b 100644 > --- a/sysdeps/unix/sysv/linux/sh/libc.abilist > +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist > @@ -1898,6 +1898,10 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist > index 85cbe30..8b4d22d 100644 > --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist > @@ -2015,6 +2015,10 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist > index f7a1ab8..bc1eba3 100644 > --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist > @@ -1952,6 +1952,9 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist > index ab56ece..d6506ed 100644 > --- a/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist > @@ -2136,3 +2136,6 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist > index f2518c0..ede48fc 100644 > --- a/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist > @@ -2136,3 +2136,6 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist > index 2a3cc40..4a5729f 100644 > --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist > @@ -1905,6 +1905,9 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 GLIBC_2.3 A > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist > index 8bc16b9..0745aee 100644 > --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist > @@ -2148,3 +2148,6 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F >
Ping. On 30/04/2018 08:10, Adhemerval Zanella wrote: > Ping. > > On 04/04/2018 18:26, Adhemerval Zanella wrote: >> This patch fixes the OFD ("file private") locks for architectures that >> support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). >> The problem in this case is both F_OFD_{GETLK,SETLK,SETLKW} and >> F_{SET,GET}L{W}K64 expects a flock64 argument. Kernel idea originally was >> to avoid using such flags in non-LFS syscall, but since GLIBC uses fcntl64 >> as default it still can provide the functionality and avoid the bogus >> struct kernel passing by adjusting the struct manually for the required >> flags. >> >> The idea follows other LFS interfaces that provide two symbols: >> >> 1. A new LFS fcntl64 is added on default ABI with the usual macros to select >> it for FILE_OFFSET_BITS=64. >> >> 2. The Linux non-LFS fcntl use a stack allocated struct flock64 for >> F_OFD_{GETLK,SETLK,SETLKW} and F_{SET,GET}L{W}K64 and copy the results on >> the user provided struct. >> >> 3. Keep a compat symbol with old broken semantic for architectures that do >> not define __OFF_T_MATCHES_OFF64_T. >> >> So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will aliased >> to fcntl and no adjustment would be required. >> >> Checked on x86_64-linux-gnu and i686-linux-gnu. >> >> [BZ #20251] >> * include/fcntl.h (__libc_fcntl64, __fcntl64): New prototype. >> * io/Makefile (routines): Add fcntl64. >> (CFLAGS-fcntl64.c): New rule. >> * io/fcntl.h (fcntl64): Add prototype and redirect if >> __USE_FILE_OFFSET64 is defined. >> * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file. >> * io/fcntl64.c: New file. >> * nptl/Makefile (pthread-compat-wrappers): Add fcntl64. >> (CFLAGS-fcntl64.c): New rule. >> * sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols. >> * io/Versions [GLIBC_2.28] (fcntl64; __fcntl64): New symbols. >> * sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64, >> F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for >> non-LFS case. >> (fcntl_common, __fcntl_nocancel): Remove function. >> (flock_to_flock64): New function. >> * sysdeps/unix/sysv/linux/fcntl64.c: New file. >> * sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (__fcntl64, fcntl, >> fcntl64): New symbols. >> * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise. >> * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Likewise. >> * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: >> Likewise. >> * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: >> Likewise. >> * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28] (__fcntl64, >> fcntl64): New symbols. >> * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. >> * sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. >> * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise. >> --- >> ChangeLog | 56 +++++++++++ >> include/fcntl.h | 4 + >> io/Makefile | 3 +- >> io/Versions | 3 + >> io/fcntl.h | 11 +++ >> .../powerpc/powerpc64/fcntl.c => io/fcntl64.c | 28 +++--- >> nptl/Makefile | 3 +- >> sysdeps/mach/hurd/fcntl.c | 5 + >> sysdeps/mach/hurd/i386/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/aarch64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/alpha/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/arm/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/fcntl.c | 102 +++++++++++++-------- >> sysdeps/unix/sysv/linux/fcntl64.c | 99 ++++++++++++++++++++ >> sysdeps/unix/sysv/linux/hppa/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/i386/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/ia64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/microblaze/libc.abilist | 4 + >> .../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 4 + >> .../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 4 + >> .../unix/sysv/linux/mips/mips64/n32/libc.abilist | 4 + >> .../unix/sysv/linux/mips/mips64/n64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/nios2/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 8 ++ >> .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 4 + >> .../linux/powerpc/powerpc32/nofpu/libc.abilist | 4 + >> .../sysv/linux/powerpc/powerpc64/libc-le.abilist | 3 + >> .../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/sh/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 4 + >> sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 3 + >> sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 3 + >> 40 files changed, 376 insertions(+), 49 deletions(-) >> rename sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c => io/fcntl64.c (65%) >> create mode 100644 sysdeps/unix/sysv/linux/fcntl64.c >> >> diff --git a/include/fcntl.h b/include/fcntl.h >> index 3d68c5e..5fac115 100644 >> --- a/include/fcntl.h >> +++ b/include/fcntl.h >> @@ -10,10 +10,14 @@ extern int __libc_open (const char *file, int oflag, ...); >> libc_hidden_proto (__libc_open) >> extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden; >> libc_hidden_proto (__libc_fcntl) >> +extern int __libc_fcntl64 (int fd, int cmd, ...) attribute_hidden; >> +libc_hidden_proto (__libc_fcntl64) >> extern int __open (const char *__file, int __oflag, ...); >> libc_hidden_proto (__open) >> extern int __fcntl (int __fd, int __cmd, ...); >> libc_hidden_proto (__fcntl) >> +extern int __fcntl64 (int __fd, int __cmd, ...); >> +libc_hidden_proto (__fcntl64) >> extern int __openat (int __fd, const char *__file, int __oflag, ...) >> __nonnull ((2)); >> libc_hidden_proto (__openat) >> diff --git a/io/Makefile b/io/Makefile >> index 2117cb6..4a0d8fe 100644 >> --- a/io/Makefile >> +++ b/io/Makefile >> @@ -40,7 +40,7 @@ routines := \ >> mkdir mkdirat \ >> open open_2 open64 open64_2 openat openat_2 openat64 openat64_2 \ >> read write lseek lseek64 access euidaccess faccessat \ >> - fcntl flock lockf lockf64 \ >> + fcntl fcntl64 flock lockf lockf64 \ >> close dup dup2 dup3 pipe pipe2 \ >> creat creat64 \ >> chdir fchdir \ >> @@ -89,6 +89,7 @@ CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-creat.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-creat64.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables >> +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-poll.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-ppoll.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-lockf.c += -fexceptions >> diff --git a/io/Versions b/io/Versions >> index 98898cb..492e72c 100644 >> --- a/io/Versions >> +++ b/io/Versions >> @@ -128,4 +128,7 @@ libc { >> GLIBC_2.27 { >> copy_file_range; >> } >> + GLIBC_2.28 { >> + fcntl64; __fcntl64; >> + } >> } >> diff --git a/io/fcntl.h b/io/fcntl.h >> index 69a4394..3afc620 100644 >> --- a/io/fcntl.h >> +++ b/io/fcntl.h >> @@ -167,7 +167,18 @@ typedef __pid_t pid_t; >> >> This function is a cancellation point and therefore not marked with >> __THROW. */ >> +#ifndef __USE_FILE_OFFSET64 >> extern int fcntl (int __fd, int __cmd, ...); >> +#else >> +# ifdef __REDIRECT >> +extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); >> +# else >> +# define fcntl fcntl64 >> +# endif >> +#endif >> +#ifdef __USE_LARGEFILE64 >> +extern int fcntl64 (int __fd, int __cmd, ...); >> +#endif >> >> /* Open FILE and return a new file descriptor for it, or -1 on error. >> OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/io/fcntl64.c >> similarity index 65% >> rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c >> rename to io/fcntl64.c >> index 48198c1..f4e6809 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c >> +++ b/io/fcntl64.c >> @@ -1,4 +1,5 @@ >> -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. >> +/* Manipulate file descriptor. Stub LFS version. >> + Copyright (C) 2018 Free Software Foundation, Inc. >> This file is part of the GNU C Library. >> >> The GNU C Library is free software; you can redistribute it and/or >> @@ -15,18 +16,23 @@ >> License along with the GNU C Library; if not, see >> <http://www.gnu.org/licenses/>. */ >> >> -#include <unistd.h> >> +#include <errno.h> >> #include <fcntl.h> >> >> -static inline int >> -fcntl_adjust_cmd (int cmd) >> +/* Perform file control operations on FD. */ >> +int >> +__fcntl64 (int fd, int cmd, ...) >> { >> - if (cmd >= F_GETLK64 && cmd <= F_SETLKW64) >> - cmd -= F_GETLK64 - F_GETLK; >> - return cmd; >> -} >> + if (fd < 0) >> + { >> + __set_errno (EBADF); >> + return -1; >> + } >> >> -#define FCNTL_ADJUST_CMD(__cmd) \ >> - fcntl_adjust_cmd (__cmd) >> + __set_errno (ENOSYS); >> + return -1; >> +} >> +libc_hidden_def (__fcntl64) >> +stub_warning (fcntl64) >> >> -#include <sysdeps/unix/sysv/linux/fcntl.c> >> +weak_alias (__fcntl64, fcntl64) >> diff --git a/nptl/Makefile b/nptl/Makefile >> index 94be92c..13d485c 100644 >> --- a/nptl/Makefile >> +++ b/nptl/Makefile >> @@ -36,7 +36,7 @@ static-only-routines = pthread_atfork >> # We need to provide certain routines for compatibility with existing >> # binaries. >> pthread-compat-wrappers = \ >> - write read close fcntl accept \ >> + write read close fcntl fcntl64 accept \ >> connect recv recvfrom send \ >> sendto fsync lseek lseek64 \ >> msync nanosleep open open64 pause \ >> @@ -191,6 +191,7 @@ CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables >> >> # These are the function wrappers we have to duplicate here. >> CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables >> +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-lockf.c += -fexceptions >> CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables >> diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c >> index 0b23164..598317d 100644 >> --- a/sysdeps/mach/hurd/fcntl.c >> +++ b/sysdeps/mach/hurd/fcntl.c >> @@ -210,3 +210,8 @@ libc_hidden_def (__libc_fcntl) >> weak_alias (__libc_fcntl, __fcntl) >> libc_hidden_weak (__fcntl) >> weak_alias (__libc_fcntl, fcntl) >> + >> +strong_alias (__libc_fcntl, __libc_fcntl64) >> +libc_hidden_def (__libc_fcntl64) >> +weak_alias (__libc_fcntl64, __fcntl64) >> +libc_hidden_weak (__fcntl64) >> diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist >> index 9545e89..36f1a2d 100644 >> --- a/sysdeps/mach/hurd/i386/libc.abilist >> +++ b/sysdeps/mach/hurd/i386/libc.abilist >> @@ -2049,6 +2049,10 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist >> index 90c9bc8..6fb0c38 100644 >> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist >> @@ -2139,3 +2139,6 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist >> index 8674a87..e8dd80c 100644 >> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist >> @@ -2054,6 +2054,9 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist >> index 044ec10..69bf5a3 100644 >> --- a/sysdeps/unix/sysv/linux/arm/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist >> @@ -130,6 +130,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.4 GLIBC_2.4 A >> GLIBC_2.4 _Exit F >> GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 >> diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c >> index a3cb2ae..5a8fbb5 100644 >> --- a/sysdeps/unix/sysv/linux/fcntl.c >> +++ b/sysdeps/unix/sysv/linux/fcntl.c >> @@ -19,32 +19,23 @@ >> #include <stdarg.h> >> #include <errno.h> >> #include <sysdep-cancel.h> >> -#include <not-cancel.h> >> >> -#ifndef __NR_fcntl64 >> -# define __NR_fcntl64 __NR_fcntl >> -#endif >> +#ifndef __OFF_T_MATCHES_OFF64_T >> >> -#ifndef FCNTL_ADJUST_CMD >> -# define FCNTL_ADJUST_CMD(__cmd) __cmd >> -#endif >> +# ifndef FCNTL_ADJUST_CMD >> +# define FCNTL_ADJUST_CMD(__cmd) __cmd >> +# endif >> >> -static int >> -fcntl_common (int fd, int cmd, void *arg) >> +static inline struct flock64 >> +flock_to_flock64 (const struct flock *flk) >> { >> - if (cmd == F_GETOWN) >> - { >> - INTERNAL_SYSCALL_DECL (err); >> - struct f_owner_ex fex; >> - int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); >> - if (!INTERNAL_SYSCALL_ERROR_P (res, err)) >> - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; >> - >> - return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, >> - err)); >> - } >> - >> - return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); >> + return (struct flock64) { >> + .l_type = flk->l_type, >> + .l_whence = flk->l_whence, >> + .l_start = flk->l_start, >> + .l_len = flk->l_len, >> + .l_pid = flk->l_pid >> + }; >> } >> >> int >> @@ -59,16 +50,56 @@ __libc_fcntl (int fd, int cmd, ...) >> >> cmd = FCNTL_ADJUST_CMD (cmd); >> >> - if (cmd == F_SETLKW || cmd == F_SETLKW64) >> - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); >> - >> - return fcntl_common (fd, cmd, arg); >> + switch (cmd) >> + { >> + case F_SETLKW: >> + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); >> + case F_GETLK64: >> + case F_OFD_GETLK: >> + { >> + struct flock *flk = (struct flock *) arg; >> + struct flock64 flk64 = flock_to_flock64 (flk); >> + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); >> + if (ret == -1) >> + return -1; >> + flk->l_type = flk64.l_type; >> + flk->l_whence = flk64.l_whence; >> + flk->l_start = flk64.l_start; >> + flk->l_len = flk64.l_len; >> + flk->l_pid = flk64.l_pid; >> + return ret; >> + } >> + case F_SETLK64: >> + case F_SETLKW64: >> + case F_OFD_SETLK: >> + case F_OFD_SETLKW: >> + { >> + struct flock64 flk64 = flock_to_flock64 (arg); >> + return SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); >> + } >> + case F_GETOWN: >> + { >> + INTERNAL_SYSCALL_DECL (err); >> + struct f_owner_ex fex; >> + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); >> + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) >> + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; >> + >> + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, >> + err)); >> + } >> + default: >> + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, arg); >> + } >> } >> libc_hidden_def (__libc_fcntl) >> +weak_alias (__libc_fcntl, __fcntl) >> +libc_hidden_weak (__fcntl) >> >> -#if !IS_IN (rtld) >> +# include <shlib-compat.h> >> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) >> int >> -__fcntl_nocancel (int fd, int cmd, ...) >> +__old_libc_fcntl64 (int fd, int cmd, ...) >> { >> va_list ap; >> void *arg; >> @@ -77,13 +108,12 @@ __fcntl_nocancel (int fd, int cmd, ...) >> arg = va_arg (ap, void *); >> va_end (ap); >> >> - return fcntl_common (fd, cmd, arg); >> + return __libc_fcntl64 (fd, cmd, arg); >> } >> -#else >> -strong_alias (__libc_fcntl, __fcntl_nocancel) >> -#endif >> -libc_hidden_def (__fcntl_nocancel) >> - >> -weak_alias (__libc_fcntl, __fcntl) >> -libc_hidden_weak (__fcntl) >> +compat_symbol (libc, __old_libc_fcntl64, fcntl, GLIBC_2_0); >> +versioned_symbol (libc, __libc_fcntl, fcntl, GLIBC_2_28); >> +# else >> weak_alias (__libc_fcntl, fcntl) >> +# endif >> + >> +#endif /* __OFF_T_MATCHES_OFF64_T */ >> diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c >> new file mode 100644 >> index 0000000..b7f50b0 >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/fcntl64.c >> @@ -0,0 +1,99 @@ >> +/* Manipulate file descriptor. Linux LFS version. >> + Copyright (C) 2018 Free Software Foundation, Inc. >> + This file is part of the GNU C Library. >> + >> + The GNU C Library is free software; you can redistribute it and/or >> + modify it under the terms of the GNU Lesser General Public >> + License as published by the Free Software Foundation; either >> + version 2.1 of the License, or (at your option) any later version. >> + >> + The GNU C Library is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> + Lesser General Public License for more details. >> + >> + You should have received a copy of the GNU Lesser General Public >> + License along with the GNU C Library; if not, see >> + <http://www.gnu.org/licenses/>. */ >> + >> +#define fcntl __no_decl_fcntl >> +#define __fcntl __no_decl___fcntl >> +#include <fcntl.h> >> +#undef fcntl >> +#undef __fcntl >> +#include <stdarg.h> >> +#include <errno.h> >> +#include <sysdep-cancel.h> >> + >> +#ifndef __NR_fcntl64 >> +# define __NR_fcntl64 __NR_fcntl >> +#endif >> + >> +#ifndef FCNTL_ADJUST_CMD >> +# define FCNTL_ADJUST_CMD(__cmd) __cmd >> +#endif >> + >> +static int >> +fcntl64_common (int fd, int cmd, void *arg) >> +{ >> + if (cmd == F_GETOWN) >> + { >> + INTERNAL_SYSCALL_DECL (err); >> + struct f_owner_ex fex; >> + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); >> + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) >> + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; >> + >> + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, >> + err)); >> + } >> + >> + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); >> +} >> + >> +int >> +__libc_fcntl64 (int fd, int cmd, ...) >> +{ >> + va_list ap; >> + void *arg; >> + >> + va_start (ap, cmd); >> + arg = va_arg (ap, void *); >> + va_end (ap); >> + >> + cmd = FCNTL_ADJUST_CMD (cmd); >> + >> + if (cmd == F_SETLKW || cmd == F_SETLKW64) >> + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); >> + >> + return fcntl64_common (fd, cmd, arg); >> +} >> +libc_hidden_def (__libc_fcntl64) >> +weak_alias (__libc_fcntl64, __fcntl64) >> +libc_hidden_weak (__fcntl64) >> +weak_alias (__libc_fcntl64, fcntl64) >> + >> +#ifdef __OFF_T_MATCHES_OFF64_T >> +weak_alias (__libc_fcntl64, __libc_fcntl) >> +weak_alias (__libc_fcntl64, __fcntl) >> +weak_alias (__libc_fcntl64, __GI___fcntl) >> +weak_alias (__libc_fcntl64, fcntl) >> +#endif >> + >> +#if !IS_IN (rtld) >> +int >> +__fcntl_nocancel (int fd, int cmd, ...) >> +{ >> + va_list ap; >> + void *arg; >> + >> + va_start (ap, cmd); >> + arg = va_arg (ap, void *); >> + va_end (ap); >> + >> + return fcntl64_common (fd, cmd, arg); >> +} >> +#else >> +weak_alias (__libc_fcntl64, __fcntl_nocancel) >> +#endif >> +weak_alias (__fcntl_nocancel, __GI___fcntl_nocancel) >> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist >> index 2360130..d87eb4c 100644 >> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist >> @@ -1894,6 +1894,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist >> index 39c993f..177b07a 100644 >> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist >> @@ -2064,6 +2064,10 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist >> index 68496aa..87571f1 100644 >> --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist >> @@ -1928,6 +1928,9 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist >> index b676025..afb9e05 100644 >> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist >> @@ -131,6 +131,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.4 GLIBC_2.4 A >> GLIBC_2.4 _Exit F >> GLIBC_2.4 _IO_2_1_stderr_ D 0x98 >> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist >> index cdd1df5..034ff04 100644 >> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist >> @@ -2008,6 +2008,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist >> index e4265fd..8586123 100644 >> --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist >> @@ -2129,3 +2129,7 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist >> index 3a7e0b4..2187c72 100644 >> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist >> @@ -1983,6 +1983,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist >> index 5e80592..4ee5454 100644 >> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist >> @@ -1981,6 +1981,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist >> index 1973fac..62468d6 100644 >> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist >> @@ -1989,6 +1989,10 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist >> index 5e18ab8..48d07e3 100644 >> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist >> @@ -1984,6 +1984,9 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist >> index cc5885a..ee0b7c0 100644 >> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist >> @@ -2170,3 +2170,7 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h >> index 503f562..d755f1d 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h >> +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h >> @@ -52,3 +52,11 @@ >> >> #undef __ASSUME_CLONE_DEFAULT >> #define __ASSUME_CLONE_BACKWARDS 1 >> + >> +#define FCNTL_ADJUST_CMD(__cmd) \ >> + ({ int __cmdadj = (__cmd); \ >> + if (__cmdadj >= F_GETLK64 && __cmdadj <= F_SETLKW64) \ >> + __cmdadj -= F_GETLK64 - F_GETLK; \ >> + __cmdadj; \ >> + }) >> + >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist >> index 676aa50..6c72516 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist >> @@ -2012,6 +2012,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist >> index 2016c7c..0499171 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist >> @@ -2017,6 +2017,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist >> index 3d19e38..17a56de 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist >> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist >> @@ -2229,3 +2229,6 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist >> index c57ab21..1e625c6 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist >> @@ -131,6 +131,9 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 _Exit F >> GLIBC_2.3 _IO_2_1_stderr_ D 0xe0 >> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist >> index 8ab44ec..dce49e0 100644 >> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist >> @@ -2094,3 +2094,6 @@ GLIBC_2.27 xdrstdio_create F >> GLIBC_2.27 xencrypt F >> GLIBC_2.27 xprt_register F >> GLIBC_2.27 xprt_unregister F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist >> index 2590372..a9db23c 100644 >> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist >> @@ -2022,6 +2022,10 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist >> index 5d6800c..a0e275f 100644 >> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist >> @@ -1923,6 +1923,9 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist >> index c04872c..e3db11b 100644 >> --- a/sysdeps/unix/sysv/linux/sh/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist >> @@ -1898,6 +1898,10 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist >> index 85cbe30..8b4d22d 100644 >> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist >> @@ -2015,6 +2015,10 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist >> index f7a1ab8..bc1eba3 100644 >> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist >> @@ -1952,6 +1952,9 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist >> index ab56ece..d6506ed 100644 >> --- a/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist >> @@ -2136,3 +2136,6 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist >> index f2518c0..ede48fc 100644 >> --- a/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist >> @@ -2136,3 +2136,6 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist >> index 2a3cc40..4a5729f 100644 >> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist >> @@ -1905,6 +1905,9 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 GLIBC_2.3 A >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist >> index 8bc16b9..0745aee 100644 >> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist >> @@ -2148,3 +2148,6 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >>
Updated version, change from previous one: - Adjsut abilist with recent changes to remove the ABI tags. - Do not export __fcntl64 (there is no need to mimic old behavior). --- This patch fixes the OFD ("file private") locks for architectures that support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). The issue in this case is both F_OFD_{GETLK,SETLK,SETLKW} and F_{SET,GET}L{W}K64 expects a flock64 argument and when using old F_OFD_* flags with a non LFS flock argument the kernel might interpret the underlying data wrongly. Kernel idea originally was to avoid using such flags in non-LFS syscall, but since GLIBC uses fcntl with LFS semantic as default it is possible to provide the functionality and avoid the bogus struct kernel passing by adjusting the struct manually for the required flags. The idea follows other LFS interfaces that provide two symbols: 1. A new LFS fcntl64 is added on default ABI with the usual macros to select it for FILE_OFFSET_BITS=64. 2. The Linux non-LFS fcntl use a stack allocated struct flock64 for F_OFD_{GETLK,SETLK,SETLKW} and F_{SET,GET}L{W}K64 and copy the results on the user provided struct. 3. Keep a compat symbol with old broken semantic for architectures that do not define __OFF_T_MATCHES_OFF64_T. So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will aliased to fcntl and no adjustment would be required. Checked on x86_64-linux-gnu and i686-linux-gnu. [BZ #20251] * include/fcntl.h (__libc_fcntl64, __fcntl64): New prototype. * io/Makefile (routines): Add fcntl64. (CFLAGS-fcntl64.c): New rule. * io/fcntl.h (fcntl64): Add prototype and redirect if __USE_FILE_OFFSET64 is defined. * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file. * io/fcntl64.c: New file. * nptl/Makefile (pthread-compat-wrappers): Add fcntl64. (CFLAGS-fcntl64.c): New rule. * sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols. * io/Versions [GLIBC_2.28] (fcntl64; __fcntl64): New symbols. * sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64, F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for non-LFS case. (fcntl_common, __fcntl_nocancel): Remove function. (flock_to_flock64): New function. * sysdeps/unix/sysv/linux/fcntl64.c: New file. * sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (__fcntl64, fcntl, fcntl64): New symbols. * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28] (__fcntl64, fcntl64): New symbols. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise. --- ChangeLog | 54 ++++++++++ include/fcntl.h | 4 + io/Makefile | 3 +- io/Versions | 3 + io/fcntl.h | 11 ++ .../powerpc/powerpc64/fcntl.c => io/fcntl64.c | 28 ++++-- nptl/Makefile | 3 +- sysdeps/mach/hurd/fcntl.c | 5 + sysdeps/mach/hurd/i386/libc.abilist | 2 + sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 + sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 + sysdeps/unix/sysv/linux/arm/libc.abilist | 2 + sysdeps/unix/sysv/linux/fcntl.c | 111 +++++++++++++-------- sysdeps/unix/sysv/linux/fcntl64.c | 99 ++++++++++++++++++ sysdeps/unix/sysv/linux/hppa/libc.abilist | 2 + sysdeps/unix/sysv/linux/i386/libc.abilist | 2 + sysdeps/unix/sysv/linux/ia64/libc.abilist | 1 + sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 2 + sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 2 + sysdeps/unix/sysv/linux/microblaze/libc.abilist | 2 + .../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 2 + .../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 2 + .../unix/sysv/linux/mips/mips64/n32/libc.abilist | 2 + .../unix/sysv/linux/mips/mips64/n64/libc.abilist | 1 + sysdeps/unix/sysv/linux/nios2/libc.abilist | 2 + sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 9 ++ .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 2 + .../linux/powerpc/powerpc32/nofpu/libc.abilist | 2 + .../sysv/linux/powerpc/powerpc64/libc-le.abilist | 3 + .../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 1 + sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 1 + sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 2 + sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 1 + sysdeps/unix/sysv/linux/sh/libc.abilist | 2 + sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 2 + sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 1 + sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 1 + sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 1 + 38 files changed, 323 insertions(+), 52 deletions(-) rename sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c => io/fcntl64.c (65%) create mode 100644 sysdeps/unix/sysv/linux/fcntl64.c diff --git a/include/fcntl.h b/include/fcntl.h index 3d68c5e..374e784 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -10,10 +10,14 @@ extern int __libc_open (const char *file, int oflag, ...); libc_hidden_proto (__libc_open) extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden; libc_hidden_proto (__libc_fcntl) +extern int __libc_fcntl64 (int fd, int cmd, ...) attribute_hidden; +libc_hidden_proto (__libc_fcntl64) extern int __open (const char *__file, int __oflag, ...); libc_hidden_proto (__open) extern int __fcntl (int __fd, int __cmd, ...); libc_hidden_proto (__fcntl) +extern int __fcntl64 (int __fd, int __cmd, ...) attribute_hidden; +libc_hidden_proto (__fcntl64) extern int __openat (int __fd, const char *__file, int __oflag, ...) __nonnull ((2)); libc_hidden_proto (__openat) diff --git a/io/Makefile b/io/Makefile index 2117cb6..4a0d8fe 100644 --- a/io/Makefile +++ b/io/Makefile @@ -40,7 +40,7 @@ routines := \ mkdir mkdirat \ open open_2 open64 open64_2 openat openat_2 openat64 openat64_2 \ read write lseek lseek64 access euidaccess faccessat \ - fcntl flock lockf lockf64 \ + fcntl fcntl64 flock lockf lockf64 \ close dup dup2 dup3 pipe pipe2 \ creat creat64 \ chdir fchdir \ @@ -89,6 +89,7 @@ CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-creat.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-creat64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-poll.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-ppoll.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c += -fexceptions diff --git a/io/Versions b/io/Versions index 98898cb..7653588 100644 --- a/io/Versions +++ b/io/Versions @@ -128,4 +128,7 @@ libc { GLIBC_2.27 { copy_file_range; } + GLIBC_2.28 { + fcntl64; + } } diff --git a/io/fcntl.h b/io/fcntl.h index 69a4394..3afc620 100644 --- a/io/fcntl.h +++ b/io/fcntl.h @@ -167,7 +167,18 @@ typedef __pid_t pid_t; This function is a cancellation point and therefore not marked with __THROW. */ +#ifndef __USE_FILE_OFFSET64 extern int fcntl (int __fd, int __cmd, ...); +#else +# ifdef __REDIRECT +extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); +# else +# define fcntl fcntl64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int fcntl64 (int __fd, int __cmd, ...); +#endif /* Open FILE and return a new file descriptor for it, or -1 on error. OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/io/fcntl64.c similarity index 65% rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c rename to io/fcntl64.c index 48198c1..f4e6809 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c +++ b/io/fcntl64.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Manipulate file descriptor. Stub LFS version. + Copyright (C) 2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,18 +16,23 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <unistd.h> +#include <errno.h> #include <fcntl.h> -static inline int -fcntl_adjust_cmd (int cmd) +/* Perform file control operations on FD. */ +int +__fcntl64 (int fd, int cmd, ...) { - if (cmd >= F_GETLK64 && cmd <= F_SETLKW64) - cmd -= F_GETLK64 - F_GETLK; - return cmd; -} + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } -#define FCNTL_ADJUST_CMD(__cmd) \ - fcntl_adjust_cmd (__cmd) + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__fcntl64) +stub_warning (fcntl64) -#include <sysdeps/unix/sysv/linux/fcntl.c> +weak_alias (__fcntl64, fcntl64) diff --git a/nptl/Makefile b/nptl/Makefile index 94be92c..13d485c 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -36,7 +36,7 @@ static-only-routines = pthread_atfork # We need to provide certain routines for compatibility with existing # binaries. pthread-compat-wrappers = \ - write read close fcntl accept \ + write read close fcntl fcntl64 accept \ connect recv recvfrom send \ sendto fsync lseek lseek64 \ msync nanosleep open open64 pause \ @@ -191,6 +191,7 @@ CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables # These are the function wrappers we have to duplicate here. CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c += -fexceptions CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c index 0b23164..598317d 100644 --- a/sysdeps/mach/hurd/fcntl.c +++ b/sysdeps/mach/hurd/fcntl.c @@ -210,3 +210,8 @@ libc_hidden_def (__libc_fcntl) weak_alias (__libc_fcntl, __fcntl) libc_hidden_weak (__fcntl) weak_alias (__libc_fcntl, fcntl) + +strong_alias (__libc_fcntl, __libc_fcntl64) +libc_hidden_def (__libc_fcntl64) +weak_alias (__libc_fcntl64, __fcntl64) +libc_hidden_weak (__fcntl64) diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 2cb5070..3d46de7 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2033,6 +2033,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index 80cdb98..884d0df 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2131,3 +2131,4 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index c761f61..28d54b9 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2026,6 +2026,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist index 6aa58c3..dfde3bd 100644 --- a/sysdeps/unix/sysv/linux/arm/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist @@ -115,6 +115,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c index a3cb2ae..ada922b 100644 --- a/sysdeps/unix/sysv/linux/fcntl.c +++ b/sysdeps/unix/sysv/linux/fcntl.c @@ -19,33 +19,12 @@ #include <stdarg.h> #include <errno.h> #include <sysdep-cancel.h> -#include <not-cancel.h> -#ifndef __NR_fcntl64 -# define __NR_fcntl64 __NR_fcntl -#endif +#ifndef __OFF_T_MATCHES_OFF64_T -#ifndef FCNTL_ADJUST_CMD -# define FCNTL_ADJUST_CMD(__cmd) __cmd -#endif - -static int -fcntl_common (int fd, int cmd, void *arg) -{ - if (cmd == F_GETOWN) - { - INTERNAL_SYSCALL_DECL (err); - struct f_owner_ex fex; - int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); - if (!INTERNAL_SYSCALL_ERROR_P (res, err)) - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; - - return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, - err)); - } - - return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); -} +# ifndef FCNTL_ADJUST_CMD +# define FCNTL_ADJUST_CMD(__cmd) __cmd +# endif int __libc_fcntl (int fd, int cmd, ...) @@ -59,16 +38,71 @@ __libc_fcntl (int fd, int cmd, ...) cmd = FCNTL_ADJUST_CMD (cmd); - if (cmd == F_SETLKW || cmd == F_SETLKW64) - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); - - return fcntl_common (fd, cmd, arg); + switch (cmd) + { + case F_SETLKW: + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); + case F_GETLK64: + case F_OFD_GETLK: + { + struct flock *flk = (struct flock *) arg; + struct flock64 flk64 = + { + .l_type = flk->l_type, + .l_whence = flk->l_whence, + .l_start = flk->l_start, + .l_len = flk->l_len, + .l_pid = flk->l_pid + }; + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); + if (ret == -1) + return -1; + flk->l_type = flk64.l_type; + flk->l_whence = flk64.l_whence; + flk->l_start = flk64.l_start; + flk->l_len = flk64.l_len; + flk->l_pid = flk64.l_pid; + return ret; + } + case F_SETLK64: + case F_SETLKW64: + case F_OFD_SETLK: + case F_OFD_SETLKW: + { + struct flock *flk = (struct flock *) arg; + struct flock64 flk64 = + { + .l_type = flk->l_type, + .l_whence = flk->l_whence, + .l_start = flk->l_start, + .l_len = flk->l_len, + .l_pid = flk->l_pid + }; + return SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); + } + case F_GETOWN: + { + INTERNAL_SYSCALL_DECL (err); + struct f_owner_ex fex; + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; + + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, + err)); + } + default: + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, arg); + } } libc_hidden_def (__libc_fcntl) +weak_alias (__libc_fcntl, __fcntl) +libc_hidden_weak (__fcntl) -#if !IS_IN (rtld) +# include <shlib-compat.h> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) int -__fcntl_nocancel (int fd, int cmd, ...) +__old_libc_fcntl64 (int fd, int cmd, ...) { va_list ap; void *arg; @@ -77,13 +111,12 @@ __fcntl_nocancel (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - return fcntl_common (fd, cmd, arg); + return __libc_fcntl64 (fd, cmd, arg); } -#else -strong_alias (__libc_fcntl, __fcntl_nocancel) -#endif -libc_hidden_def (__fcntl_nocancel) - -weak_alias (__libc_fcntl, __fcntl) -libc_hidden_weak (__fcntl) +compat_symbol (libc, __old_libc_fcntl64, fcntl, GLIBC_2_0); +versioned_symbol (libc, __libc_fcntl, fcntl, GLIBC_2_28); +# else weak_alias (__libc_fcntl, fcntl) +# endif + +#endif /* __OFF_T_MATCHES_OFF64_T */ diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c new file mode 100644 index 0000000..b7f50b0 --- /dev/null +++ b/sysdeps/unix/sysv/linux/fcntl64.c @@ -0,0 +1,99 @@ +/* Manipulate file descriptor. Linux LFS version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define fcntl __no_decl_fcntl +#define __fcntl __no_decl___fcntl +#include <fcntl.h> +#undef fcntl +#undef __fcntl +#include <stdarg.h> +#include <errno.h> +#include <sysdep-cancel.h> + +#ifndef __NR_fcntl64 +# define __NR_fcntl64 __NR_fcntl +#endif + +#ifndef FCNTL_ADJUST_CMD +# define FCNTL_ADJUST_CMD(__cmd) __cmd +#endif + +static int +fcntl64_common (int fd, int cmd, void *arg) +{ + if (cmd == F_GETOWN) + { + INTERNAL_SYSCALL_DECL (err); + struct f_owner_ex fex; + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; + + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, + err)); + } + + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); +} + +int +__libc_fcntl64 (int fd, int cmd, ...) +{ + va_list ap; + void *arg; + + va_start (ap, cmd); + arg = va_arg (ap, void *); + va_end (ap); + + cmd = FCNTL_ADJUST_CMD (cmd); + + if (cmd == F_SETLKW || cmd == F_SETLKW64) + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); + + return fcntl64_common (fd, cmd, arg); +} +libc_hidden_def (__libc_fcntl64) +weak_alias (__libc_fcntl64, __fcntl64) +libc_hidden_weak (__fcntl64) +weak_alias (__libc_fcntl64, fcntl64) + +#ifdef __OFF_T_MATCHES_OFF64_T +weak_alias (__libc_fcntl64, __libc_fcntl) +weak_alias (__libc_fcntl64, __fcntl) +weak_alias (__libc_fcntl64, __GI___fcntl) +weak_alias (__libc_fcntl64, fcntl) +#endif + +#if !IS_IN (rtld) +int +__fcntl_nocancel (int fd, int cmd, ...) +{ + va_list ap; + void *arg; + + va_start (ap, cmd); + arg = va_arg (ap, void *); + va_end (ap); + + return fcntl64_common (fd, cmd, arg); +} +#else +weak_alias (__libc_fcntl64, __fcntl_nocancel) +#endif +weak_alias (__fcntl_nocancel, __GI___fcntl_nocancel) diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index d10695b..06b00f7 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -1872,6 +1872,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 23092ab..1c1cc00 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2037,6 +2037,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist index 7bf259e..f6e17a0 100644 --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -1907,6 +1907,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 4673bcd..ee054a6 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -116,6 +116,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0x98 GLIBC_2.4 _IO_2_1_stdin_ D 0x98 diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index 1f8ac40..227a058 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -1981,6 +1981,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist index 09277f5..18781b3 100644 --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist @@ -2122,3 +2122,5 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index f562e20..2d86989 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -1959,6 +1959,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index ceb7388..b8b113e 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -1957,6 +1957,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 5765f48..6a3cd13 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -1965,6 +1965,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index a84bb45..596ec05 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -1961,6 +1961,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist index e432959..8da18ee 100644 --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2163,3 +2163,5 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h index 503f562..dd8a7ea 100644 --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h @@ -52,3 +52,12 @@ #undef __ASSUME_CLONE_DEFAULT #define __ASSUME_CLONE_BACKWARDS 1 + +#ifdef __powerpc64__ +# define FCNTL_ADJUST_CMD(__cmd) \ + ({ int __cmdadj = (__cmd); \ + if (__cmdadj >= F_GETLK64 && __cmdadj <= F_SETLKW64) \ + __cmdadj -= F_GETLK64 - F_GETLK; \ + __cmdadj; \ + }) +#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index a5f2b23..555751e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -1985,6 +1985,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index e4cbe36..80324e4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -1989,6 +1989,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist index 9869feb..079bbb4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist @@ -2221,3 +2221,6 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist index e526dc4..15be314 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist @@ -116,6 +116,7 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 _Exit F GLIBC_2.3 _IO_2_1_stderr_ D 0xe0 GLIBC_2.3 _IO_2_1_stdin_ D 0xe0 diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index e6319ee..436b992 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2093,3 +2093,4 @@ GLIBC_2.27 xdrstdio_create F GLIBC_2.27 xencrypt F GLIBC_2.27 xprt_register F GLIBC_2.27 xprt_unregister F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 41cdda0..f66715f 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -1994,6 +1994,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 8a756cf..bd62428 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -1900,6 +1900,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist index 999bddd..f2f070f 100644 --- a/sysdeps/unix/sysv/linux/sh/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist @@ -1876,6 +1876,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 7c4296f..265087f 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -1988,6 +1988,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index dafe9d7..16a6981 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -1930,6 +1930,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index f72d494..fa8c198 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -1888,6 +1888,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 96c9fa0..2536971 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2139,3 +2139,4 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F -- 2.7.4
Ping. On 21/05/2018 16:00, Adhemerval Zanella wrote: > Updated version, change from previous one: > > - Adjsut abilist with recent changes to remove the ABI tags. > - Do not export __fcntl64 (there is no need to mimic old behavior). > > --- > > This patch fixes the OFD ("file private") locks for architectures that > support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). The > issue in this case is both F_OFD_{GETLK,SETLK,SETLKW} and > F_{SET,GET}L{W}K64 expects a flock64 argument and when using old F_OFD_* > flags with a non LFS flock argument the kernel might interpret the underlying > data wrongly. Kernel idea originally was to avoid using such flags in > non-LFS syscall, but since GLIBC uses fcntl with LFS semantic as default > it is possible to provide the functionality and avoid the bogus struct kernel > passing by adjusting the struct manually for the required flags. > > The idea follows other LFS interfaces that provide two symbols: > > 1. A new LFS fcntl64 is added on default ABI with the usual macros to select > it for FILE_OFFSET_BITS=64. > > 2. The Linux non-LFS fcntl use a stack allocated struct flock64 for > F_OFD_{GETLK,SETLK,SETLKW} and F_{SET,GET}L{W}K64 and copy the results on > the user provided struct. > > 3. Keep a compat symbol with old broken semantic for architectures that do > not define __OFF_T_MATCHES_OFF64_T. > > So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will aliased > to fcntl and no adjustment would be required. > > Checked on x86_64-linux-gnu and i686-linux-gnu. > > [BZ #20251] > * include/fcntl.h (__libc_fcntl64, __fcntl64): New prototype. > * io/Makefile (routines): Add fcntl64. > (CFLAGS-fcntl64.c): New rule. > * io/fcntl.h (fcntl64): Add prototype and redirect if > __USE_FILE_OFFSET64 is defined. > * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file. > * io/fcntl64.c: New file. > * nptl/Makefile (pthread-compat-wrappers): Add fcntl64. > (CFLAGS-fcntl64.c): New rule. > * sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols. > * io/Versions [GLIBC_2.28] (fcntl64; __fcntl64): New symbols. > * sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64, > F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for > non-LFS case. > (fcntl_common, __fcntl_nocancel): Remove function. > (flock_to_flock64): New function. > * sysdeps/unix/sysv/linux/fcntl64.c: New file. > * sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (__fcntl64, fcntl, > fcntl64): New symbols. > * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise. > * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Likewise. > * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: > Likewise. > * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: > Likewise. > * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28] (__fcntl64, > fcntl64): New symbols. > * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. > * sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. > * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. > * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise. > --- > ChangeLog | 54 ++++++++++ > include/fcntl.h | 4 + > io/Makefile | 3 +- > io/Versions | 3 + > io/fcntl.h | 11 ++ > .../powerpc/powerpc64/fcntl.c => io/fcntl64.c | 28 ++++-- > nptl/Makefile | 3 +- > sysdeps/mach/hurd/fcntl.c | 5 + > sysdeps/mach/hurd/i386/libc.abilist | 2 + > sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 + > sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 + > sysdeps/unix/sysv/linux/arm/libc.abilist | 2 + > sysdeps/unix/sysv/linux/fcntl.c | 111 +++++++++++++-------- > sysdeps/unix/sysv/linux/fcntl64.c | 99 ++++++++++++++++++ > sysdeps/unix/sysv/linux/hppa/libc.abilist | 2 + > sysdeps/unix/sysv/linux/i386/libc.abilist | 2 + > sysdeps/unix/sysv/linux/ia64/libc.abilist | 1 + > sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 2 + > sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 2 + > sysdeps/unix/sysv/linux/microblaze/libc.abilist | 2 + > .../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 2 + > .../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 2 + > .../unix/sysv/linux/mips/mips64/n32/libc.abilist | 2 + > .../unix/sysv/linux/mips/mips64/n64/libc.abilist | 1 + > sysdeps/unix/sysv/linux/nios2/libc.abilist | 2 + > sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 9 ++ > .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 2 + > .../linux/powerpc/powerpc32/nofpu/libc.abilist | 2 + > .../sysv/linux/powerpc/powerpc64/libc-le.abilist | 3 + > .../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 1 + > sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 1 + > sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 2 + > sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 1 + > sysdeps/unix/sysv/linux/sh/libc.abilist | 2 + > sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 2 + > sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 1 + > sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 1 + > sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 1 + > 38 files changed, 323 insertions(+), 52 deletions(-) > rename sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c => io/fcntl64.c (65%) > create mode 100644 sysdeps/unix/sysv/linux/fcntl64.c > > > diff --git a/include/fcntl.h b/include/fcntl.h > index 3d68c5e..374e784 100644 > --- a/include/fcntl.h > +++ b/include/fcntl.h > @@ -10,10 +10,14 @@ extern int __libc_open (const char *file, int oflag, ...); > libc_hidden_proto (__libc_open) > extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden; > libc_hidden_proto (__libc_fcntl) > +extern int __libc_fcntl64 (int fd, int cmd, ...) attribute_hidden; > +libc_hidden_proto (__libc_fcntl64) > extern int __open (const char *__file, int __oflag, ...); > libc_hidden_proto (__open) > extern int __fcntl (int __fd, int __cmd, ...); > libc_hidden_proto (__fcntl) > +extern int __fcntl64 (int __fd, int __cmd, ...) attribute_hidden; > +libc_hidden_proto (__fcntl64) > extern int __openat (int __fd, const char *__file, int __oflag, ...) > __nonnull ((2)); > libc_hidden_proto (__openat) > diff --git a/io/Makefile b/io/Makefile > index 2117cb6..4a0d8fe 100644 > --- a/io/Makefile > +++ b/io/Makefile > @@ -40,7 +40,7 @@ routines := \ > mkdir mkdirat \ > open open_2 open64 open64_2 openat openat_2 openat64 openat64_2 \ > read write lseek lseek64 access euidaccess faccessat \ > - fcntl flock lockf lockf64 \ > + fcntl fcntl64 flock lockf lockf64 \ > close dup dup2 dup3 pipe pipe2 \ > creat creat64 \ > chdir fchdir \ > @@ -89,6 +89,7 @@ CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-creat.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-creat64.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables > +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-poll.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-ppoll.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-lockf.c += -fexceptions > diff --git a/io/Versions b/io/Versions > index 98898cb..7653588 100644 > --- a/io/Versions > +++ b/io/Versions > @@ -128,4 +128,7 @@ libc { > GLIBC_2.27 { > copy_file_range; > } > + GLIBC_2.28 { > + fcntl64; > + } > } > diff --git a/io/fcntl.h b/io/fcntl.h > index 69a4394..3afc620 100644 > --- a/io/fcntl.h > +++ b/io/fcntl.h > @@ -167,7 +167,18 @@ typedef __pid_t pid_t; > > This function is a cancellation point and therefore not marked with > __THROW. */ > +#ifndef __USE_FILE_OFFSET64 > extern int fcntl (int __fd, int __cmd, ...); > +#else > +# ifdef __REDIRECT > +extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); > +# else > +# define fcntl fcntl64 > +# endif > +#endif > +#ifdef __USE_LARGEFILE64 > +extern int fcntl64 (int __fd, int __cmd, ...); > +#endif > > /* Open FILE and return a new file descriptor for it, or -1 on error. > OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/io/fcntl64.c > similarity index 65% > rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c > rename to io/fcntl64.c > index 48198c1..f4e6809 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c > +++ b/io/fcntl64.c > @@ -1,4 +1,5 @@ > -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. > +/* Manipulate file descriptor. Stub LFS version. > + Copyright (C) 2018 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or > @@ -15,18 +16,23 @@ > License along with the GNU C Library; if not, see > <http://www.gnu.org/licenses/>. */ > > -#include <unistd.h> > +#include <errno.h> > #include <fcntl.h> > > -static inline int > -fcntl_adjust_cmd (int cmd) > +/* Perform file control operations on FD. */ > +int > +__fcntl64 (int fd, int cmd, ...) > { > - if (cmd >= F_GETLK64 && cmd <= F_SETLKW64) > - cmd -= F_GETLK64 - F_GETLK; > - return cmd; > -} > + if (fd < 0) > + { > + __set_errno (EBADF); > + return -1; > + } > > -#define FCNTL_ADJUST_CMD(__cmd) \ > - fcntl_adjust_cmd (__cmd) > + __set_errno (ENOSYS); > + return -1; > +} > +libc_hidden_def (__fcntl64) > +stub_warning (fcntl64) > > -#include <sysdeps/unix/sysv/linux/fcntl.c> > +weak_alias (__fcntl64, fcntl64) > diff --git a/nptl/Makefile b/nptl/Makefile > index 94be92c..13d485c 100644 > --- a/nptl/Makefile > +++ b/nptl/Makefile > @@ -36,7 +36,7 @@ static-only-routines = pthread_atfork > # We need to provide certain routines for compatibility with existing > # binaries. > pthread-compat-wrappers = \ > - write read close fcntl accept \ > + write read close fcntl fcntl64 accept \ > connect recv recvfrom send \ > sendto fsync lseek lseek64 \ > msync nanosleep open open64 pause \ > @@ -191,6 +191,7 @@ CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables > > # These are the function wrappers we have to duplicate here. > CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables > +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-lockf.c += -fexceptions > CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables > CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables > diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c > index 0b23164..598317d 100644 > --- a/sysdeps/mach/hurd/fcntl.c > +++ b/sysdeps/mach/hurd/fcntl.c > @@ -210,3 +210,8 @@ libc_hidden_def (__libc_fcntl) > weak_alias (__libc_fcntl, __fcntl) > libc_hidden_weak (__fcntl) > weak_alias (__libc_fcntl, fcntl) > + > +strong_alias (__libc_fcntl, __libc_fcntl64) > +libc_hidden_def (__libc_fcntl64) > +weak_alias (__libc_fcntl64, __fcntl64) > +libc_hidden_weak (__fcntl64) > diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist > index 2cb5070..3d46de7 100644 > --- a/sysdeps/mach/hurd/i386/libc.abilist > +++ b/sysdeps/mach/hurd/i386/libc.abilist > @@ -2033,6 +2033,8 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist > index 80cdb98..884d0df 100644 > --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist > @@ -2131,3 +2131,4 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist > index c761f61..28d54b9 100644 > --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist > +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist > @@ -2026,6 +2026,7 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist > index 6aa58c3..dfde3bd 100644 > --- a/sysdeps/unix/sysv/linux/arm/libc.abilist > +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist > @@ -115,6 +115,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.4 _Exit F > GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 > GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 > diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c > index a3cb2ae..ada922b 100644 > --- a/sysdeps/unix/sysv/linux/fcntl.c > +++ b/sysdeps/unix/sysv/linux/fcntl.c > @@ -19,33 +19,12 @@ > #include <stdarg.h> > #include <errno.h> > #include <sysdep-cancel.h> > -#include <not-cancel.h> > > -#ifndef __NR_fcntl64 > -# define __NR_fcntl64 __NR_fcntl > -#endif > +#ifndef __OFF_T_MATCHES_OFF64_T > > -#ifndef FCNTL_ADJUST_CMD > -# define FCNTL_ADJUST_CMD(__cmd) __cmd > -#endif > - > -static int > -fcntl_common (int fd, int cmd, void *arg) > -{ > - if (cmd == F_GETOWN) > - { > - INTERNAL_SYSCALL_DECL (err); > - struct f_owner_ex fex; > - int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); > - if (!INTERNAL_SYSCALL_ERROR_P (res, err)) > - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; > - > - return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, > - err)); > - } > - > - return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); > -} > +# ifndef FCNTL_ADJUST_CMD > +# define FCNTL_ADJUST_CMD(__cmd) __cmd > +# endif > > int > __libc_fcntl (int fd, int cmd, ...) > @@ -59,16 +38,71 @@ __libc_fcntl (int fd, int cmd, ...) > > cmd = FCNTL_ADJUST_CMD (cmd); > > - if (cmd == F_SETLKW || cmd == F_SETLKW64) > - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); > - > - return fcntl_common (fd, cmd, arg); > + switch (cmd) > + { > + case F_SETLKW: > + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); > + case F_GETLK64: > + case F_OFD_GETLK: > + { > + struct flock *flk = (struct flock *) arg; > + struct flock64 flk64 = > + { > + .l_type = flk->l_type, > + .l_whence = flk->l_whence, > + .l_start = flk->l_start, > + .l_len = flk->l_len, > + .l_pid = flk->l_pid > + }; > + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); > + if (ret == -1) > + return -1; > + flk->l_type = flk64.l_type; > + flk->l_whence = flk64.l_whence; > + flk->l_start = flk64.l_start; > + flk->l_len = flk64.l_len; > + flk->l_pid = flk64.l_pid; > + return ret; > + } > + case F_SETLK64: > + case F_SETLKW64: > + case F_OFD_SETLK: > + case F_OFD_SETLKW: > + { > + struct flock *flk = (struct flock *) arg; > + struct flock64 flk64 = > + { > + .l_type = flk->l_type, > + .l_whence = flk->l_whence, > + .l_start = flk->l_start, > + .l_len = flk->l_len, > + .l_pid = flk->l_pid > + }; > + return SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); > + } > + case F_GETOWN: > + { > + INTERNAL_SYSCALL_DECL (err); > + struct f_owner_ex fex; > + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); > + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) > + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; > + > + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, > + err)); > + } > + default: > + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, arg); > + } > } > libc_hidden_def (__libc_fcntl) > +weak_alias (__libc_fcntl, __fcntl) > +libc_hidden_weak (__fcntl) > > -#if !IS_IN (rtld) > +# include <shlib-compat.h> > +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) > int > -__fcntl_nocancel (int fd, int cmd, ...) > +__old_libc_fcntl64 (int fd, int cmd, ...) > { > va_list ap; > void *arg; > @@ -77,13 +111,12 @@ __fcntl_nocancel (int fd, int cmd, ...) > arg = va_arg (ap, void *); > va_end (ap); > > - return fcntl_common (fd, cmd, arg); > + return __libc_fcntl64 (fd, cmd, arg); > } > -#else > -strong_alias (__libc_fcntl, __fcntl_nocancel) > -#endif > -libc_hidden_def (__fcntl_nocancel) > - > -weak_alias (__libc_fcntl, __fcntl) > -libc_hidden_weak (__fcntl) > +compat_symbol (libc, __old_libc_fcntl64, fcntl, GLIBC_2_0); > +versioned_symbol (libc, __libc_fcntl, fcntl, GLIBC_2_28); > +# else > weak_alias (__libc_fcntl, fcntl) > +# endif > + > +#endif /* __OFF_T_MATCHES_OFF64_T */ > diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c > new file mode 100644 > index 0000000..b7f50b0 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/fcntl64.c > @@ -0,0 +1,99 @@ > +/* Manipulate file descriptor. Linux LFS version. > + Copyright (C) 2018 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + <http://www.gnu.org/licenses/>. */ > + > +#define fcntl __no_decl_fcntl > +#define __fcntl __no_decl___fcntl > +#include <fcntl.h> > +#undef fcntl > +#undef __fcntl > +#include <stdarg.h> > +#include <errno.h> > +#include <sysdep-cancel.h> > + > +#ifndef __NR_fcntl64 > +# define __NR_fcntl64 __NR_fcntl > +#endif > + > +#ifndef FCNTL_ADJUST_CMD > +# define FCNTL_ADJUST_CMD(__cmd) __cmd > +#endif > + > +static int > +fcntl64_common (int fd, int cmd, void *arg) > +{ > + if (cmd == F_GETOWN) > + { > + INTERNAL_SYSCALL_DECL (err); > + struct f_owner_ex fex; > + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); > + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) > + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; > + > + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, > + err)); > + } > + > + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); > +} > + > +int > +__libc_fcntl64 (int fd, int cmd, ...) > +{ > + va_list ap; > + void *arg; > + > + va_start (ap, cmd); > + arg = va_arg (ap, void *); > + va_end (ap); > + > + cmd = FCNTL_ADJUST_CMD (cmd); > + > + if (cmd == F_SETLKW || cmd == F_SETLKW64) > + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); > + > + return fcntl64_common (fd, cmd, arg); > +} > +libc_hidden_def (__libc_fcntl64) > +weak_alias (__libc_fcntl64, __fcntl64) > +libc_hidden_weak (__fcntl64) > +weak_alias (__libc_fcntl64, fcntl64) > + > +#ifdef __OFF_T_MATCHES_OFF64_T > +weak_alias (__libc_fcntl64, __libc_fcntl) > +weak_alias (__libc_fcntl64, __fcntl) > +weak_alias (__libc_fcntl64, __GI___fcntl) > +weak_alias (__libc_fcntl64, fcntl) > +#endif > + > +#if !IS_IN (rtld) > +int > +__fcntl_nocancel (int fd, int cmd, ...) > +{ > + va_list ap; > + void *arg; > + > + va_start (ap, cmd); > + arg = va_arg (ap, void *); > + va_end (ap); > + > + return fcntl64_common (fd, cmd, arg); > +} > +#else > +weak_alias (__libc_fcntl64, __fcntl_nocancel) > +#endif > +weak_alias (__fcntl_nocancel, __GI___fcntl_nocancel) > diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist > index d10695b..06b00f7 100644 > --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist > +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist > @@ -1872,6 +1872,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist > index 23092ab..1c1cc00 100644 > --- a/sysdeps/unix/sysv/linux/i386/libc.abilist > +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist > @@ -2037,6 +2037,8 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist > index 7bf259e..f6e17a0 100644 > --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist > @@ -1907,6 +1907,7 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist > index 4673bcd..ee054a6 100644 > --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist > +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist > @@ -116,6 +116,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.4 _Exit F > GLIBC_2.4 _IO_2_1_stderr_ D 0x98 > GLIBC_2.4 _IO_2_1_stdin_ D 0x98 > diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist > index 1f8ac40..227a058 100644 > --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist > +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist > @@ -1981,6 +1981,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist > index 09277f5..18781b3 100644 > --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist > +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist > @@ -2122,3 +2122,5 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist > index f562e20..2d86989 100644 > --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist > +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist > @@ -1959,6 +1959,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist > index ceb7388..b8b113e 100644 > --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist > +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist > @@ -1957,6 +1957,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist > index 5765f48..6a3cd13 100644 > --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist > @@ -1965,6 +1965,8 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist > index a84bb45..596ec05 100644 > --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist > @@ -1961,6 +1961,7 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist > index e432959..8da18ee 100644 > --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist > +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist > @@ -2163,3 +2163,5 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h > index 503f562..dd8a7ea 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h > +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h > @@ -52,3 +52,12 @@ > > #undef __ASSUME_CLONE_DEFAULT > #define __ASSUME_CLONE_BACKWARDS 1 > + > +#ifdef __powerpc64__ > +# define FCNTL_ADJUST_CMD(__cmd) \ > + ({ int __cmdadj = (__cmd); \ > + if (__cmdadj >= F_GETLK64 && __cmdadj <= F_SETLKW64) \ > + __cmdadj -= F_GETLK64 - F_GETLK; \ > + __cmdadj; \ > + }) > +#endif > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist > index a5f2b23..555751e 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist > +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist > @@ -1985,6 +1985,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist > index e4cbe36..80324e4 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist > +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist > @@ -1989,6 +1989,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist > index 9869feb..079bbb4 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist > +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist > @@ -2221,3 +2221,6 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 GLIBC_2.28 A > +GLIBC_2.28 __fcntl64 F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist > index e526dc4..15be314 100644 > --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist > @@ -116,6 +116,7 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 _Exit F > GLIBC_2.3 _IO_2_1_stderr_ D 0xe0 > GLIBC_2.3 _IO_2_1_stdin_ D 0xe0 > diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist > index e6319ee..436b992 100644 > --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist > @@ -2093,3 +2093,4 @@ GLIBC_2.27 xdrstdio_create F > GLIBC_2.27 xencrypt F > GLIBC_2.27 xprt_register F > GLIBC_2.27 xprt_unregister F > +GLIBC_2.28 fcntl64 F > diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist > index 41cdda0..f66715f 100644 > --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist > @@ -1994,6 +1994,8 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist > index 8a756cf..bd62428 100644 > --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist > @@ -1900,6 +1900,7 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist > index 999bddd..f2f070f 100644 > --- a/sysdeps/unix/sysv/linux/sh/libc.abilist > +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist > @@ -1876,6 +1876,8 @@ GLIBC_2.27 wcstof32x F > GLIBC_2.27 wcstof32x_l F > GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist > index 7c4296f..265087f 100644 > --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist > @@ -1988,6 +1988,8 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist > index dafe9d7..16a6981 100644 > --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist > @@ -1930,6 +1930,7 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist > index f72d494..fa8c198 100644 > --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist > @@ -1888,6 +1888,7 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl64 F > GLIBC_2.3 __ctype_b_loc F > GLIBC_2.3 __ctype_tolower_loc F > GLIBC_2.3 __ctype_toupper_loc F > diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist > index 96c9fa0..2536971 100644 > --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist > +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist > @@ -2139,3 +2139,4 @@ GLIBC_2.27 wcstof64 F > GLIBC_2.27 wcstof64_l F > GLIBC_2.27 wcstof64x F > GLIBC_2.27 wcstof64x_l F > +GLIBC_2.28 fcntl64 F >
I will commit this shortly if no one opposes it. On 25/05/2018 17:03, Adhemerval Zanella wrote: > Ping. > > On 21/05/2018 16:00, Adhemerval Zanella wrote: >> Updated version, change from previous one: >> >> - Adjsut abilist with recent changes to remove the ABI tags. >> - Do not export __fcntl64 (there is no need to mimic old behavior). >> >> --- >> >> This patch fixes the OFD ("file private") locks for architectures that >> support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). The >> issue in this case is both F_OFD_{GETLK,SETLK,SETLKW} and >> F_{SET,GET}L{W}K64 expects a flock64 argument and when using old F_OFD_* >> flags with a non LFS flock argument the kernel might interpret the underlying >> data wrongly. Kernel idea originally was to avoid using such flags in >> non-LFS syscall, but since GLIBC uses fcntl with LFS semantic as default >> it is possible to provide the functionality and avoid the bogus struct kernel >> passing by adjusting the struct manually for the required flags. >> >> The idea follows other LFS interfaces that provide two symbols: >> >> 1. A new LFS fcntl64 is added on default ABI with the usual macros to select >> it for FILE_OFFSET_BITS=64. >> >> 2. The Linux non-LFS fcntl use a stack allocated struct flock64 for >> F_OFD_{GETLK,SETLK,SETLKW} and F_{SET,GET}L{W}K64 and copy the results on >> the user provided struct. >> >> 3. Keep a compat symbol with old broken semantic for architectures that do >> not define __OFF_T_MATCHES_OFF64_T. >> >> So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will aliased >> to fcntl and no adjustment would be required. >> >> Checked on x86_64-linux-gnu and i686-linux-gnu. >> >> [BZ #20251] >> * include/fcntl.h (__libc_fcntl64, __fcntl64): New prototype. >> * io/Makefile (routines): Add fcntl64. >> (CFLAGS-fcntl64.c): New rule. >> * io/fcntl.h (fcntl64): Add prototype and redirect if >> __USE_FILE_OFFSET64 is defined. >> * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file. >> * io/fcntl64.c: New file. >> * nptl/Makefile (pthread-compat-wrappers): Add fcntl64. >> (CFLAGS-fcntl64.c): New rule. >> * sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols. >> * io/Versions [GLIBC_2.28] (fcntl64; __fcntl64): New symbols. >> * sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64, >> F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for >> non-LFS case. >> (fcntl_common, __fcntl_nocancel): Remove function. >> (flock_to_flock64): New function. >> * sysdeps/unix/sysv/linux/fcntl64.c: New file. >> * sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (__fcntl64, fcntl, >> fcntl64): New symbols. >> * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise. >> * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/powerpc/kernel-features.h: Likewise. >> * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: >> Likewise. >> * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: >> Likewise. >> * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28] (__fcntl64, >> fcntl64): New symbols. >> * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. >> * sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. >> * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. >> * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise. >> --- >> ChangeLog | 54 ++++++++++ >> include/fcntl.h | 4 + >> io/Makefile | 3 +- >> io/Versions | 3 + >> io/fcntl.h | 11 ++ >> .../powerpc/powerpc64/fcntl.c => io/fcntl64.c | 28 ++++-- >> nptl/Makefile | 3 +- >> sysdeps/mach/hurd/fcntl.c | 5 + >> sysdeps/mach/hurd/i386/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/arm/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/fcntl.c | 111 +++++++++++++-------- >> sysdeps/unix/sysv/linux/fcntl64.c | 99 ++++++++++++++++++ >> sysdeps/unix/sysv/linux/hppa/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/i386/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/ia64/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/microblaze/libc.abilist | 2 + >> .../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 2 + >> .../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 2 + >> .../unix/sysv/linux/mips/mips64/n32/libc.abilist | 2 + >> .../unix/sysv/linux/mips/mips64/n64/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/nios2/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 9 ++ >> .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 2 + >> .../linux/powerpc/powerpc32/nofpu/libc.abilist | 2 + >> .../sysv/linux/powerpc/powerpc64/libc-le.abilist | 3 + >> .../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/sh/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 2 + >> sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 1 + >> sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 1 + >> 38 files changed, 323 insertions(+), 52 deletions(-) >> rename sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c => io/fcntl64.c (65%) >> create mode 100644 sysdeps/unix/sysv/linux/fcntl64.c >> >> >> diff --git a/include/fcntl.h b/include/fcntl.h >> index 3d68c5e..374e784 100644 >> --- a/include/fcntl.h >> +++ b/include/fcntl.h >> @@ -10,10 +10,14 @@ extern int __libc_open (const char *file, int oflag, ...); >> libc_hidden_proto (__libc_open) >> extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden; >> libc_hidden_proto (__libc_fcntl) >> +extern int __libc_fcntl64 (int fd, int cmd, ...) attribute_hidden; >> +libc_hidden_proto (__libc_fcntl64) >> extern int __open (const char *__file, int __oflag, ...); >> libc_hidden_proto (__open) >> extern int __fcntl (int __fd, int __cmd, ...); >> libc_hidden_proto (__fcntl) >> +extern int __fcntl64 (int __fd, int __cmd, ...) attribute_hidden; >> +libc_hidden_proto (__fcntl64) >> extern int __openat (int __fd, const char *__file, int __oflag, ...) >> __nonnull ((2)); >> libc_hidden_proto (__openat) >> diff --git a/io/Makefile b/io/Makefile >> index 2117cb6..4a0d8fe 100644 >> --- a/io/Makefile >> +++ b/io/Makefile >> @@ -40,7 +40,7 @@ routines := \ >> mkdir mkdirat \ >> open open_2 open64 open64_2 openat openat_2 openat64 openat64_2 \ >> read write lseek lseek64 access euidaccess faccessat \ >> - fcntl flock lockf lockf64 \ >> + fcntl fcntl64 flock lockf lockf64 \ >> close dup dup2 dup3 pipe pipe2 \ >> creat creat64 \ >> chdir fchdir \ >> @@ -89,6 +89,7 @@ CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-creat.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-creat64.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables >> +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-poll.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-ppoll.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-lockf.c += -fexceptions >> diff --git a/io/Versions b/io/Versions >> index 98898cb..7653588 100644 >> --- a/io/Versions >> +++ b/io/Versions >> @@ -128,4 +128,7 @@ libc { >> GLIBC_2.27 { >> copy_file_range; >> } >> + GLIBC_2.28 { >> + fcntl64; >> + } >> } >> diff --git a/io/fcntl.h b/io/fcntl.h >> index 69a4394..3afc620 100644 >> --- a/io/fcntl.h >> +++ b/io/fcntl.h >> @@ -167,7 +167,18 @@ typedef __pid_t pid_t; >> >> This function is a cancellation point and therefore not marked with >> __THROW. */ >> +#ifndef __USE_FILE_OFFSET64 >> extern int fcntl (int __fd, int __cmd, ...); >> +#else >> +# ifdef __REDIRECT >> +extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); >> +# else >> +# define fcntl fcntl64 >> +# endif >> +#endif >> +#ifdef __USE_LARGEFILE64 >> +extern int fcntl64 (int __fd, int __cmd, ...); >> +#endif >> >> /* Open FILE and return a new file descriptor for it, or -1 on error. >> OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/io/fcntl64.c >> similarity index 65% >> rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c >> rename to io/fcntl64.c >> index 48198c1..f4e6809 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c >> +++ b/io/fcntl64.c >> @@ -1,4 +1,5 @@ >> -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. >> +/* Manipulate file descriptor. Stub LFS version. >> + Copyright (C) 2018 Free Software Foundation, Inc. >> This file is part of the GNU C Library. >> >> The GNU C Library is free software; you can redistribute it and/or >> @@ -15,18 +16,23 @@ >> License along with the GNU C Library; if not, see >> <http://www.gnu.org/licenses/>. */ >> >> -#include <unistd.h> >> +#include <errno.h> >> #include <fcntl.h> >> >> -static inline int >> -fcntl_adjust_cmd (int cmd) >> +/* Perform file control operations on FD. */ >> +int >> +__fcntl64 (int fd, int cmd, ...) >> { >> - if (cmd >= F_GETLK64 && cmd <= F_SETLKW64) >> - cmd -= F_GETLK64 - F_GETLK; >> - return cmd; >> -} >> + if (fd < 0) >> + { >> + __set_errno (EBADF); >> + return -1; >> + } >> >> -#define FCNTL_ADJUST_CMD(__cmd) \ >> - fcntl_adjust_cmd (__cmd) >> + __set_errno (ENOSYS); >> + return -1; >> +} >> +libc_hidden_def (__fcntl64) >> +stub_warning (fcntl64) >> >> -#include <sysdeps/unix/sysv/linux/fcntl.c> >> +weak_alias (__fcntl64, fcntl64) >> diff --git a/nptl/Makefile b/nptl/Makefile >> index 94be92c..13d485c 100644 >> --- a/nptl/Makefile >> +++ b/nptl/Makefile >> @@ -36,7 +36,7 @@ static-only-routines = pthread_atfork >> # We need to provide certain routines for compatibility with existing >> # binaries. >> pthread-compat-wrappers = \ >> - write read close fcntl accept \ >> + write read close fcntl fcntl64 accept \ >> connect recv recvfrom send \ >> sendto fsync lseek lseek64 \ >> msync nanosleep open open64 pause \ >> @@ -191,6 +191,7 @@ CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables >> >> # These are the function wrappers we have to duplicate here. >> CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables >> +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-lockf.c += -fexceptions >> CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables >> CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables >> diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c >> index 0b23164..598317d 100644 >> --- a/sysdeps/mach/hurd/fcntl.c >> +++ b/sysdeps/mach/hurd/fcntl.c >> @@ -210,3 +210,8 @@ libc_hidden_def (__libc_fcntl) >> weak_alias (__libc_fcntl, __fcntl) >> libc_hidden_weak (__fcntl) >> weak_alias (__libc_fcntl, fcntl) >> + >> +strong_alias (__libc_fcntl, __libc_fcntl64) >> +libc_hidden_def (__libc_fcntl64) >> +weak_alias (__libc_fcntl64, __fcntl64) >> +libc_hidden_weak (__fcntl64) >> diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist >> index 2cb5070..3d46de7 100644 >> --- a/sysdeps/mach/hurd/i386/libc.abilist >> +++ b/sysdeps/mach/hurd/i386/libc.abilist >> @@ -2033,6 +2033,8 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist >> index 80cdb98..884d0df 100644 >> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist >> @@ -2131,3 +2131,4 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist >> index c761f61..28d54b9 100644 >> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist >> @@ -2026,6 +2026,7 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist >> index 6aa58c3..dfde3bd 100644 >> --- a/sysdeps/unix/sysv/linux/arm/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist >> @@ -115,6 +115,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.4 _Exit F >> GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 >> GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 >> diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c >> index a3cb2ae..ada922b 100644 >> --- a/sysdeps/unix/sysv/linux/fcntl.c >> +++ b/sysdeps/unix/sysv/linux/fcntl.c >> @@ -19,33 +19,12 @@ >> #include <stdarg.h> >> #include <errno.h> >> #include <sysdep-cancel.h> >> -#include <not-cancel.h> >> >> -#ifndef __NR_fcntl64 >> -# define __NR_fcntl64 __NR_fcntl >> -#endif >> +#ifndef __OFF_T_MATCHES_OFF64_T >> >> -#ifndef FCNTL_ADJUST_CMD >> -# define FCNTL_ADJUST_CMD(__cmd) __cmd >> -#endif >> - >> -static int >> -fcntl_common (int fd, int cmd, void *arg) >> -{ >> - if (cmd == F_GETOWN) >> - { >> - INTERNAL_SYSCALL_DECL (err); >> - struct f_owner_ex fex; >> - int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); >> - if (!INTERNAL_SYSCALL_ERROR_P (res, err)) >> - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; >> - >> - return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, >> - err)); >> - } >> - >> - return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); >> -} >> +# ifndef FCNTL_ADJUST_CMD >> +# define FCNTL_ADJUST_CMD(__cmd) __cmd >> +# endif >> >> int >> __libc_fcntl (int fd, int cmd, ...) >> @@ -59,16 +38,71 @@ __libc_fcntl (int fd, int cmd, ...) >> >> cmd = FCNTL_ADJUST_CMD (cmd); >> >> - if (cmd == F_SETLKW || cmd == F_SETLKW64) >> - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); >> - >> - return fcntl_common (fd, cmd, arg); >> + switch (cmd) >> + { >> + case F_SETLKW: >> + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); >> + case F_GETLK64: >> + case F_OFD_GETLK: >> + { >> + struct flock *flk = (struct flock *) arg; >> + struct flock64 flk64 = >> + { >> + .l_type = flk->l_type, >> + .l_whence = flk->l_whence, >> + .l_start = flk->l_start, >> + .l_len = flk->l_len, >> + .l_pid = flk->l_pid >> + }; >> + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); >> + if (ret == -1) >> + return -1; >> + flk->l_type = flk64.l_type; >> + flk->l_whence = flk64.l_whence; >> + flk->l_start = flk64.l_start; >> + flk->l_len = flk64.l_len; >> + flk->l_pid = flk64.l_pid; >> + return ret; >> + } >> + case F_SETLK64: >> + case F_SETLKW64: >> + case F_OFD_SETLK: >> + case F_OFD_SETLKW: >> + { >> + struct flock *flk = (struct flock *) arg; >> + struct flock64 flk64 = >> + { >> + .l_type = flk->l_type, >> + .l_whence = flk->l_whence, >> + .l_start = flk->l_start, >> + .l_len = flk->l_len, >> + .l_pid = flk->l_pid >> + }; >> + return SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); >> + } >> + case F_GETOWN: >> + { >> + INTERNAL_SYSCALL_DECL (err); >> + struct f_owner_ex fex; >> + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); >> + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) >> + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; >> + >> + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, >> + err)); >> + } >> + default: >> + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, arg); >> + } >> } >> libc_hidden_def (__libc_fcntl) >> +weak_alias (__libc_fcntl, __fcntl) >> +libc_hidden_weak (__fcntl) >> >> -#if !IS_IN (rtld) >> +# include <shlib-compat.h> >> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) >> int >> -__fcntl_nocancel (int fd, int cmd, ...) >> +__old_libc_fcntl64 (int fd, int cmd, ...) >> { >> va_list ap; >> void *arg; >> @@ -77,13 +111,12 @@ __fcntl_nocancel (int fd, int cmd, ...) >> arg = va_arg (ap, void *); >> va_end (ap); >> >> - return fcntl_common (fd, cmd, arg); >> + return __libc_fcntl64 (fd, cmd, arg); >> } >> -#else >> -strong_alias (__libc_fcntl, __fcntl_nocancel) >> -#endif >> -libc_hidden_def (__fcntl_nocancel) >> - >> -weak_alias (__libc_fcntl, __fcntl) >> -libc_hidden_weak (__fcntl) >> +compat_symbol (libc, __old_libc_fcntl64, fcntl, GLIBC_2_0); >> +versioned_symbol (libc, __libc_fcntl, fcntl, GLIBC_2_28); >> +# else >> weak_alias (__libc_fcntl, fcntl) >> +# endif >> + >> +#endif /* __OFF_T_MATCHES_OFF64_T */ >> diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c >> new file mode 100644 >> index 0000000..b7f50b0 >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/fcntl64.c >> @@ -0,0 +1,99 @@ >> +/* Manipulate file descriptor. Linux LFS version. >> + Copyright (C) 2018 Free Software Foundation, Inc. >> + This file is part of the GNU C Library. >> + >> + The GNU C Library is free software; you can redistribute it and/or >> + modify it under the terms of the GNU Lesser General Public >> + License as published by the Free Software Foundation; either >> + version 2.1 of the License, or (at your option) any later version. >> + >> + The GNU C Library is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> + Lesser General Public License for more details. >> + >> + You should have received a copy of the GNU Lesser General Public >> + License along with the GNU C Library; if not, see >> + <http://www.gnu.org/licenses/>. */ >> + >> +#define fcntl __no_decl_fcntl >> +#define __fcntl __no_decl___fcntl >> +#include <fcntl.h> >> +#undef fcntl >> +#undef __fcntl >> +#include <stdarg.h> >> +#include <errno.h> >> +#include <sysdep-cancel.h> >> + >> +#ifndef __NR_fcntl64 >> +# define __NR_fcntl64 __NR_fcntl >> +#endif >> + >> +#ifndef FCNTL_ADJUST_CMD >> +# define FCNTL_ADJUST_CMD(__cmd) __cmd >> +#endif >> + >> +static int >> +fcntl64_common (int fd, int cmd, void *arg) >> +{ >> + if (cmd == F_GETOWN) >> + { >> + INTERNAL_SYSCALL_DECL (err); >> + struct f_owner_ex fex; >> + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); >> + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) >> + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; >> + >> + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, >> + err)); >> + } >> + >> + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); >> +} >> + >> +int >> +__libc_fcntl64 (int fd, int cmd, ...) >> +{ >> + va_list ap; >> + void *arg; >> + >> + va_start (ap, cmd); >> + arg = va_arg (ap, void *); >> + va_end (ap); >> + >> + cmd = FCNTL_ADJUST_CMD (cmd); >> + >> + if (cmd == F_SETLKW || cmd == F_SETLKW64) >> + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); >> + >> + return fcntl64_common (fd, cmd, arg); >> +} >> +libc_hidden_def (__libc_fcntl64) >> +weak_alias (__libc_fcntl64, __fcntl64) >> +libc_hidden_weak (__fcntl64) >> +weak_alias (__libc_fcntl64, fcntl64) >> + >> +#ifdef __OFF_T_MATCHES_OFF64_T >> +weak_alias (__libc_fcntl64, __libc_fcntl) >> +weak_alias (__libc_fcntl64, __fcntl) >> +weak_alias (__libc_fcntl64, __GI___fcntl) >> +weak_alias (__libc_fcntl64, fcntl) >> +#endif >> + >> +#if !IS_IN (rtld) >> +int >> +__fcntl_nocancel (int fd, int cmd, ...) >> +{ >> + va_list ap; >> + void *arg; >> + >> + va_start (ap, cmd); >> + arg = va_arg (ap, void *); >> + va_end (ap); >> + >> + return fcntl64_common (fd, cmd, arg); >> +} >> +#else >> +weak_alias (__libc_fcntl64, __fcntl_nocancel) >> +#endif >> +weak_alias (__fcntl_nocancel, __GI___fcntl_nocancel) >> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist >> index d10695b..06b00f7 100644 >> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist >> @@ -1872,6 +1872,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist >> index 23092ab..1c1cc00 100644 >> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist >> @@ -2037,6 +2037,8 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist >> index 7bf259e..f6e17a0 100644 >> --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist >> @@ -1907,6 +1907,7 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist >> index 4673bcd..ee054a6 100644 >> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist >> @@ -116,6 +116,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.4 _Exit F >> GLIBC_2.4 _IO_2_1_stderr_ D 0x98 >> GLIBC_2.4 _IO_2_1_stdin_ D 0x98 >> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist >> index 1f8ac40..227a058 100644 >> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist >> @@ -1981,6 +1981,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist >> index 09277f5..18781b3 100644 >> --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist >> @@ -2122,3 +2122,5 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist >> index f562e20..2d86989 100644 >> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist >> @@ -1959,6 +1959,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist >> index ceb7388..b8b113e 100644 >> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist >> @@ -1957,6 +1957,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist >> index 5765f48..6a3cd13 100644 >> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist >> @@ -1965,6 +1965,8 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist >> index a84bb45..596ec05 100644 >> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist >> @@ -1961,6 +1961,7 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist >> index e432959..8da18ee 100644 >> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist >> @@ -2163,3 +2163,5 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h >> index 503f562..dd8a7ea 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h >> +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h >> @@ -52,3 +52,12 @@ >> >> #undef __ASSUME_CLONE_DEFAULT >> #define __ASSUME_CLONE_BACKWARDS 1 >> + >> +#ifdef __powerpc64__ >> +# define FCNTL_ADJUST_CMD(__cmd) \ >> + ({ int __cmdadj = (__cmd); \ >> + if (__cmdadj >= F_GETLK64 && __cmdadj <= F_SETLKW64) \ >> + __cmdadj -= F_GETLK64 - F_GETLK; \ >> + __cmdadj; \ >> + }) >> +#endif >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist >> index a5f2b23..555751e 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist >> @@ -1985,6 +1985,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist >> index e4cbe36..80324e4 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist >> @@ -1989,6 +1989,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist >> index 9869feb..079bbb4 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist >> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist >> @@ -2221,3 +2221,6 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 GLIBC_2.28 A >> +GLIBC_2.28 __fcntl64 F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist >> index e526dc4..15be314 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist >> @@ -116,6 +116,7 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 _Exit F >> GLIBC_2.3 _IO_2_1_stderr_ D 0xe0 >> GLIBC_2.3 _IO_2_1_stdin_ D 0xe0 >> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist >> index e6319ee..436b992 100644 >> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist >> @@ -2093,3 +2093,4 @@ GLIBC_2.27 xdrstdio_create F >> GLIBC_2.27 xencrypt F >> GLIBC_2.27 xprt_register F >> GLIBC_2.27 xprt_unregister F >> +GLIBC_2.28 fcntl64 F >> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist >> index 41cdda0..f66715f 100644 >> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist >> @@ -1994,6 +1994,8 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist >> index 8a756cf..bd62428 100644 >> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist >> @@ -1900,6 +1900,7 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist >> index 999bddd..f2f070f 100644 >> --- a/sysdeps/unix/sysv/linux/sh/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist >> @@ -1876,6 +1876,8 @@ GLIBC_2.27 wcstof32x F >> GLIBC_2.27 wcstof32x_l F >> GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist >> index 7c4296f..265087f 100644 >> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist >> @@ -1988,6 +1988,8 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist >> index dafe9d7..16a6981 100644 >> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist >> @@ -1930,6 +1930,7 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist >> index f72d494..fa8c198 100644 >> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist >> @@ -1888,6 +1888,7 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl64 F >> GLIBC_2.3 __ctype_b_loc F >> GLIBC_2.3 __ctype_tolower_loc F >> GLIBC_2.3 __ctype_toupper_loc F >> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist >> index 96c9fa0..2536971 100644 >> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist >> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist >> @@ -2139,3 +2139,4 @@ GLIBC_2.27 wcstof64 F >> GLIBC_2.27 wcstof64_l F >> GLIBC_2.27 wcstof64x F >> GLIBC_2.27 wcstof64x_l F >> +GLIBC_2.28 fcntl64 F >>
On 04/04/2018 11:26 PM, Adhemerval Zanella wrote: > @@ -59,16 +50,56 @@ __libc_fcntl (int fd, int cmd, ...) > > cmd = FCNTL_ADJUST_CMD (cmd); > > - if (cmd == F_SETLKW || cmd == F_SETLKW64) > - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); > - > - return fcntl_common (fd, cmd, arg); > + switch (cmd) > + { > + case F_SETLKW: > + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); > + case F_GETLK64: > + case F_OFD_GETLK: > + { > + struct flock *flk = (struct flock *) arg; > + struct flock64 flk64 = flock_to_flock64 (flk); > + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); > + if (ret == -1) > + return -1; > + flk->l_type = flk64.l_type; > + flk->l_whence = flk64.l_whence; > + flk->l_start = flk64.l_start; > + flk->l_len = flk64.l_len; > + flk->l_pid = flk64.l_pid; > + return ret; Doesn't this need an overflow check? I think you should mention somewhere that this introduces new cancellation points. Thanks, Florian
On 01/06/2018 12:00, Florian Weimer wrote: > On 04/04/2018 11:26 PM, Adhemerval Zanella wrote: >> @@ -59,16 +50,56 @@ __libc_fcntl (int fd, int cmd, ...) >> cmd = FCNTL_ADJUST_CMD (cmd); >> - if (cmd == F_SETLKW || cmd == F_SETLKW64) >> - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); >> - >> - return fcntl_common (fd, cmd, arg); >> + switch (cmd) >> + { >> + case F_SETLKW: >> + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); >> + case F_GETLK64: >> + case F_OFD_GETLK: >> + { >> + struct flock *flk = (struct flock *) arg; >> + struct flock64 flk64 = flock_to_flock64 (flk); >> + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64) >> + if (ret == -1) >> + return -1; >> + flk->l_type = flk64.l_type; >> + flk->l_whence = flk64.l_whence; >> + flk->l_start = flk64.l_start; >> + flk->l_len = flk64.l_len; >> + flk->l_pid = flk64.l_pid; >> + return ret; > > Doesn't this need an overflow check? Indeed, if process sets a lock region with l_start larger than off_t, a later calls to F_GETLK64/F_OFD_GETLK can't really indicate the lock region back to caller. I have added a testcase for this specific case. > > I think you should mention somewhere that this introduces new cancellation points. It is not really new, since for architectures with default LFS support this is transparent and for architectures with non-default LFS my understanding is functions with *64 suffix are expected to handle cancellation as the non-LFS. Below it is the updated patch with the testcase, I plan to commit it next week. -- [BZ #20251] * include/fcntl.h (__libc_fcntl64, __fcntl64): New prototype. * io/Makefile (routines): Add fcntl64. (CFLAGS-fcntl64.c): New rule. * io/fcntl.h (fcntl64): Add prototype and redirect if __USE_FILE_OFFSET64 is defined. * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Remove file. * io/fcntl64.c: New file. * nptl/Makefile (pthread-compat-wrappers): Add fcntl64. (CFLAGS-fcntl64.c): New rule. * sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols. * io/Versions [GLIBC_2.28] (fcntl64): New symbol. * sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64, F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for non-LFS case. (fcntl_common, __fcntl_nocancel): Remove function. (flock_to_flock64): New function. * sysdeps/unix/sysv/linux/fcntl64.c: New file. * sysdeps/unix/sysv/linux/powerpc/kernel-features.h (FCNTL_ADJUST_CMD): New macro. * sysdeps/unix/sysv/linux/Makefile (tests): Add tst-ofdlocks. * sysdeps/unix/sysv/linux/tst-ofdlocks.c: New file. * sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl, fcntl64): New symbols. * sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise. * sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28] (fcntl64): New symbol. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise. --- diff --git a/include/fcntl.h b/include/fcntl.h index 3d68c5e..374e784 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -10,10 +10,14 @@ extern int __libc_open (const char *file, int oflag, ...); libc_hidden_proto (__libc_open) extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden; libc_hidden_proto (__libc_fcntl) +extern int __libc_fcntl64 (int fd, int cmd, ...) attribute_hidden; +libc_hidden_proto (__libc_fcntl64) extern int __open (const char *__file, int __oflag, ...); libc_hidden_proto (__open) extern int __fcntl (int __fd, int __cmd, ...); libc_hidden_proto (__fcntl) +extern int __fcntl64 (int __fd, int __cmd, ...) attribute_hidden; +libc_hidden_proto (__fcntl64) extern int __openat (int __fd, const char *__file, int __oflag, ...) __nonnull ((2)); libc_hidden_proto (__openat) diff --git a/io/Makefile b/io/Makefile index 2117cb6..4a0d8fe 100644 --- a/io/Makefile +++ b/io/Makefile @@ -40,7 +40,7 @@ routines := \ mkdir mkdirat \ open open_2 open64 open64_2 openat openat_2 openat64 openat64_2 \ read write lseek lseek64 access euidaccess faccessat \ - fcntl flock lockf lockf64 \ + fcntl fcntl64 flock lockf lockf64 \ close dup dup2 dup3 pipe pipe2 \ creat creat64 \ chdir fchdir \ @@ -89,6 +89,7 @@ CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-creat.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-creat64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-poll.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-ppoll.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c += -fexceptions diff --git a/io/Versions b/io/Versions index 98898cb..7653588 100644 --- a/io/Versions +++ b/io/Versions @@ -128,4 +128,7 @@ libc { GLIBC_2.27 { copy_file_range; } + GLIBC_2.28 { + fcntl64; + } } diff --git a/io/fcntl.h b/io/fcntl.h index 69a4394..3afc620 100644 --- a/io/fcntl.h +++ b/io/fcntl.h @@ -167,7 +167,18 @@ typedef __pid_t pid_t; This function is a cancellation point and therefore not marked with __THROW. */ +#ifndef __USE_FILE_OFFSET64 extern int fcntl (int __fd, int __cmd, ...); +#else +# ifdef __REDIRECT +extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); +# else +# define fcntl fcntl64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int fcntl64 (int __fd, int __cmd, ...); +#endif /* Open FILE and return a new file descriptor for it, or -1 on error. OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/io/fcntl64.c similarity index 65% rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c rename to io/fcntl64.c index 48198c1..f4e6809 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c +++ b/io/fcntl64.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Manipulate file descriptor. Stub LFS version. + Copyright (C) 2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,18 +16,23 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <unistd.h> +#include <errno.h> #include <fcntl.h> -static inline int -fcntl_adjust_cmd (int cmd) +/* Perform file control operations on FD. */ +int +__fcntl64 (int fd, int cmd, ...) { - if (cmd >= F_GETLK64 && cmd <= F_SETLKW64) - cmd -= F_GETLK64 - F_GETLK; - return cmd; -} + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } -#define FCNTL_ADJUST_CMD(__cmd) \ - fcntl_adjust_cmd (__cmd) + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__fcntl64) +stub_warning (fcntl64) -#include <sysdeps/unix/sysv/linux/fcntl.c> +weak_alias (__fcntl64, fcntl64) diff --git a/nptl/Makefile b/nptl/Makefile index 94be92c..13d485c 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -36,7 +36,7 @@ static-only-routines = pthread_atfork # We need to provide certain routines for compatibility with existing # binaries. pthread-compat-wrappers = \ - write read close fcntl accept \ + write read close fcntl fcntl64 accept \ connect recv recvfrom send \ sendto fsync lseek lseek64 \ msync nanosleep open open64 pause \ @@ -191,6 +191,7 @@ CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables # These are the function wrappers we have to duplicate here. CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c += -fexceptions CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c index 0b23164..598317d 100644 --- a/sysdeps/mach/hurd/fcntl.c +++ b/sysdeps/mach/hurd/fcntl.c @@ -210,3 +210,8 @@ libc_hidden_def (__libc_fcntl) weak_alias (__libc_fcntl, __fcntl) libc_hidden_weak (__fcntl) weak_alias (__libc_fcntl, fcntl) + +strong_alias (__libc_fcntl, __libc_fcntl64) +libc_hidden_def (__libc_fcntl64) +weak_alias (__libc_fcntl64, __fcntl64) +libc_hidden_weak (__fcntl64) diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 2cb5070..3d46de7 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2033,6 +2033,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index cd6244f..9780e75 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -45,7 +45,7 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \ test-errno-linux tst-memfd_create tst-mlock2 tst-pkey \ - tst-rlimit-infinity + tst-rlimit-infinity tst-ofdlocks # Generate the list of SYS_* macros for the system calls (__NR_* # macros). The file syscall-names.list contains all possible system diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index 80cdb98..884d0df 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2131,3 +2131,4 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index c761f61..28d54b9 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2026,6 +2026,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist index 6aa58c3..dfde3bd 100644 --- a/sysdeps/unix/sysv/linux/arm/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist @@ -115,6 +115,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c index a3cb2ae..b1fdf71 100644 --- a/sysdeps/unix/sysv/linux/fcntl.c +++ b/sysdeps/unix/sysv/linux/fcntl.c @@ -19,33 +19,12 @@ #include <stdarg.h> #include <errno.h> #include <sysdep-cancel.h> -#include <not-cancel.h> -#ifndef __NR_fcntl64 -# define __NR_fcntl64 __NR_fcntl -#endif +#ifndef __OFF_T_MATCHES_OFF64_T -#ifndef FCNTL_ADJUST_CMD -# define FCNTL_ADJUST_CMD(__cmd) __cmd -#endif - -static int -fcntl_common (int fd, int cmd, void *arg) -{ - if (cmd == F_GETOWN) - { - INTERNAL_SYSCALL_DECL (err); - struct f_owner_ex fex; - int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); - if (!INTERNAL_SYSCALL_ERROR_P (res, err)) - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; - - return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, - err)); - } - - return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); -} +# ifndef FCNTL_ADJUST_CMD +# define FCNTL_ADJUST_CMD(__cmd) __cmd +# endif int __libc_fcntl (int fd, int cmd, ...) @@ -59,16 +38,77 @@ __libc_fcntl (int fd, int cmd, ...) cmd = FCNTL_ADJUST_CMD (cmd); - if (cmd == F_SETLKW || cmd == F_SETLKW64) - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); - - return fcntl_common (fd, cmd, arg); + switch (cmd) + { + case F_SETLKW: + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); + case F_GETLK64: + case F_OFD_GETLK: + { + struct flock *flk = (struct flock *) arg; + struct flock64 flk64 = + { + .l_type = flk->l_type, + .l_whence = flk->l_whence, + .l_start = flk->l_start, + .l_len = flk->l_len, + .l_pid = flk->l_pid + }; + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); + if (ret == -1) + return -1; + if ((off_t) flk64.l_start != flk64.l_start + || (off_t) flk64.l_len != flk64.l_len) + { + __set_errno (EOVERFLOW); + return -1; + } + flk->l_type = flk64.l_type; + flk->l_whence = flk64.l_whence; + flk->l_start = flk64.l_start; + flk->l_len = flk64.l_len; + flk->l_pid = flk64.l_pid; + return ret; + } + case F_SETLK64: + case F_SETLKW64: + case F_OFD_SETLK: + case F_OFD_SETLKW: + { + struct flock *flk = (struct flock *) arg; + struct flock64 flk64 = + { + .l_type = flk->l_type, + .l_whence = flk->l_whence, + .l_start = flk->l_start, + .l_len = flk->l_len, + .l_pid = flk->l_pid + }; + return SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); + } + case F_GETOWN: + { + INTERNAL_SYSCALL_DECL (err); + struct f_owner_ex fex; + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; + + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, + err)); + } + default: + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, arg); + } } libc_hidden_def (__libc_fcntl) +weak_alias (__libc_fcntl, __fcntl) +libc_hidden_weak (__fcntl) -#if !IS_IN (rtld) +# include <shlib-compat.h> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) int -__fcntl_nocancel (int fd, int cmd, ...) +__old_libc_fcntl64 (int fd, int cmd, ...) { va_list ap; void *arg; @@ -77,13 +117,12 @@ __fcntl_nocancel (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - return fcntl_common (fd, cmd, arg); + return __libc_fcntl64 (fd, cmd, arg); } -#else -strong_alias (__libc_fcntl, __fcntl_nocancel) -#endif -libc_hidden_def (__fcntl_nocancel) - -weak_alias (__libc_fcntl, __fcntl) -libc_hidden_weak (__fcntl) +compat_symbol (libc, __old_libc_fcntl64, fcntl, GLIBC_2_0); +versioned_symbol (libc, __libc_fcntl, fcntl, GLIBC_2_28); +# else weak_alias (__libc_fcntl, fcntl) +# endif + +#endif /* __OFF_T_MATCHES_OFF64_T */ diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c new file mode 100644 index 0000000..b7f50b0 --- /dev/null +++ b/sysdeps/unix/sysv/linux/fcntl64.c @@ -0,0 +1,99 @@ +/* Manipulate file descriptor. Linux LFS version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define fcntl __no_decl_fcntl +#define __fcntl __no_decl___fcntl +#include <fcntl.h> +#undef fcntl +#undef __fcntl +#include <stdarg.h> +#include <errno.h> +#include <sysdep-cancel.h> + +#ifndef __NR_fcntl64 +# define __NR_fcntl64 __NR_fcntl +#endif + +#ifndef FCNTL_ADJUST_CMD +# define FCNTL_ADJUST_CMD(__cmd) __cmd +#endif + +static int +fcntl64_common (int fd, int cmd, void *arg) +{ + if (cmd == F_GETOWN) + { + INTERNAL_SYSCALL_DECL (err); + struct f_owner_ex fex; + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; + + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, + err)); + } + + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); +} + +int +__libc_fcntl64 (int fd, int cmd, ...) +{ + va_list ap; + void *arg; + + va_start (ap, cmd); + arg = va_arg (ap, void *); + va_end (ap); + + cmd = FCNTL_ADJUST_CMD (cmd); + + if (cmd == F_SETLKW || cmd == F_SETLKW64) + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); + + return fcntl64_common (fd, cmd, arg); +} +libc_hidden_def (__libc_fcntl64) +weak_alias (__libc_fcntl64, __fcntl64) +libc_hidden_weak (__fcntl64) +weak_alias (__libc_fcntl64, fcntl64) + +#ifdef __OFF_T_MATCHES_OFF64_T +weak_alias (__libc_fcntl64, __libc_fcntl) +weak_alias (__libc_fcntl64, __fcntl) +weak_alias (__libc_fcntl64, __GI___fcntl) +weak_alias (__libc_fcntl64, fcntl) +#endif + +#if !IS_IN (rtld) +int +__fcntl_nocancel (int fd, int cmd, ...) +{ + va_list ap; + void *arg; + + va_start (ap, cmd); + arg = va_arg (ap, void *); + va_end (ap); + + return fcntl64_common (fd, cmd, arg); +} +#else +weak_alias (__libc_fcntl64, __fcntl_nocancel) +#endif +weak_alias (__fcntl_nocancel, __GI___fcntl_nocancel) diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index d10695b..06b00f7 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -1872,6 +1872,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 23092ab..1c1cc00 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2037,6 +2037,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist index 7bf259e..f6e17a0 100644 --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -1907,6 +1907,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 4673bcd..ee054a6 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -116,6 +116,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0x98 GLIBC_2.4 _IO_2_1_stdin_ D 0x98 diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index 1f8ac40..227a058 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -1981,6 +1981,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist index 09277f5..18781b3 100644 --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist @@ -2122,3 +2122,5 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index f562e20..2d86989 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -1959,6 +1959,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index ceb7388..b8b113e 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -1957,6 +1957,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 5765f48..6a3cd13 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -1965,6 +1965,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index a84bb45..596ec05 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -1961,6 +1961,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist index e432959..8da18ee 100644 --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2163,3 +2163,5 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h index 503f562..dd8a7ea 100644 --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h @@ -52,3 +52,12 @@ #undef __ASSUME_CLONE_DEFAULT #define __ASSUME_CLONE_BACKWARDS 1 + +#ifdef __powerpc64__ +# define FCNTL_ADJUST_CMD(__cmd) \ + ({ int __cmdadj = (__cmd); \ + if (__cmdadj >= F_GETLK64 && __cmdadj <= F_SETLKW64) \ + __cmdadj -= F_GETLK64 - F_GETLK; \ + __cmdadj; \ + }) +#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index a5f2b23..555751e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -1985,6 +1985,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index e4cbe36..80324e4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -1989,6 +1989,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist index 9869feb..079bbb4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist @@ -2221,3 +2221,6 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist index e526dc4..15be314 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist @@ -116,6 +116,7 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 _Exit F GLIBC_2.3 _IO_2_1_stderr_ D 0xe0 GLIBC_2.3 _IO_2_1_stdin_ D 0xe0 diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index e6319ee..436b992 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2093,3 +2093,4 @@ GLIBC_2.27 xdrstdio_create F GLIBC_2.27 xencrypt F GLIBC_2.27 xprt_register F GLIBC_2.27 xprt_unregister F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 41cdda0..f66715f 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -1994,6 +1994,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 8a756cf..bd62428 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -1900,6 +1900,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist index 999bddd..f2f070f 100644 --- a/sysdeps/unix/sysv/linux/sh/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist @@ -1876,6 +1876,8 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 7c4296f..265087f 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -1988,6 +1988,8 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index dafe9d7..16a6981 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -1930,6 +1930,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/tst-ofdlocks.c b/sysdeps/unix/sysv/linux/tst-ofdlocks.c new file mode 100644 index 0000000..d7bb859 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-ofdlocks.c @@ -0,0 +1,76 @@ +/* Check non representable region in non-LFS mode (BZ #20251) + Copyright (C) 2018 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <unistd.h> +#include <fcntl.h> +#include <stdint.h> +#include <errno.h> + +#include <support/temp_file.h> +#include <support/check.h> + +static char *temp_filename; +static int temp_fd; + +static void +do_prepare (int argc, char **argv) +{ + temp_fd = create_temp_file ("tst-ofdlocks.", &temp_filename); + TEST_VERIFY_EXIT (temp_fd != -1); +} + +#define PREPARE do_prepare + +static int +do_test (void) +{ + /* It first allocates a open file description lock range which can not + be represented in a 32 bit struct flock. */ + struct flock64 lck64 = { + .l_type = F_WRLCK, + .l_whence = SEEK_SET, + .l_start = (off64_t)INT32_MAX + 1024, + .l_len = 1024, + }; + TEST_VERIFY_EXIT (fcntl64 (temp_fd, F_OFD_SETLKW, &lck64) == 0); + + /* Open file description locks placed through the same open file description + (either by same file descriptor or a duplicated one created by fork, + dup, fcntl F_DUPFD, etc.) overwrites the old lock. To force a conflicting + lock combination, it creates a new file descriptor. */ + int fd = open64 (temp_filename, O_RDWR, 0666); + TEST_VERIFY_EXIT (fd != -1); + + /* It tries then to allocate another open file descriptior with a valid + non-LFS bits struct flock but which will result in a conflicted region + which can not be represented in a non-LFS struct flock. */ + struct flock lck = { + .l_type = F_WRLCK, + .l_whence = SEEK_SET, + .l_start = INT32_MAX - 1024, + .l_len = 4 * 1024, + }; + int r = fcntl (fd, F_OFD_GETLK, &lck); + if (sizeof (off_t) != sizeof (off64_t)) + TEST_VERIFY (r == -1 && errno == EOVERFLOW); + else + TEST_VERIFY (r == 0); + + return 0; +} + +#include <support/test-driver.c> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index f72d494..fa8c198 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -1888,6 +1888,7 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F GLIBC_2.3 __ctype_toupper_loc F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 96c9fa0..2536971 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2139,3 +2139,4 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 fcntl64 F -- 2.7.4
On Fri, 1 Jun 2018, Adhemerval Zanella wrote: > It is not really new, since for architectures with default LFS support this is > transparent and for architectures with non-default LFS my understanding is > functions with *64 suffix are expected to handle cancellation as the non-LFS. *64 functions are generally expected to be analogous with the corresponding non-LFS functions, yes. I think the new fcntl64 API still merits a specific NEWS entry, just like other new function APIs. -- Joseph S. Myers joseph@codesourcery.com
On 06/01/2018 10:38 PM, Adhemerval Zanella wrote: >> I think you should mention somewhere that this introduces new cancellation points. > It is not really new, since for architectures with default LFS support this is > transparent and for architectures with non-default LFS my understanding is > functions with *64 suffix are expected to handle cancellation as the non-LFS. The old condition was: - if (cmd == F_SETLKW || cmd == F_SETLKW64) - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); The new code calls SYSCALL_CANCEL for many more cases, some of which probably are bugs. I'm also a bit worried about this: + case F_GETLK64: + case F_OFD_GETLK: + { + struct flock *flk = (struct flock *) arg; + struct flock64 flk64 = + { + .l_type = flk->l_type, + .l_whence = flk->l_whence, + .l_start = flk->l_start, + .l_len = flk->l_len, + .l_pid = flk->l_pid + }; Should we really perform translation for F_GETLK64? That looks like a bug. Thanks, Florian
On 01/06/2018 18:07, Florian Weimer wrote: > On 06/01/2018 10:38 PM, Adhemerval Zanella wrote: >>> I think you should mention somewhere that this introduces new cancellation points. > >> It is not really new, since for architectures with default LFS support this is >> transparent and for architectures with non-default LFS my understanding is >> functions with *64 suffix are expected to handle cancellation as the non-LFS. > > The old condition was: > > - if (cmd == F_SETLKW || cmd == F_SETLKW64) > - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); > > The new code calls SYSCALL_CANCEL for many more cases, some of which probably are bugs. Indeed the F_{OFD}_GETLK* case is not the case for cancellation (since the lock won't be enforced by kernel). My understanding is both POSIX and Linux OFD locks have similar code path which may suspend process execution (the case for cancellation syscall). Do you have any reservation about making F_OFD_GETLK a cancellation entrypoint as well? > > I'm also a bit worried about this: > > + case F_GETLK64: > + case F_OFD_GETLK: > + { > + struct flock *flk = (struct flock *) arg; > + struct flock64 flk64 = > + { > + .l_type = flk->l_type, > + .l_whence = flk->l_whence, > + .l_start = flk->l_start, > + .l_len = flk->l_len, > + .l_pid = flk->l_pid > + }; > > Should we really perform translation for F_GETLK64? That looks like a bug. My understanding is Linux expects a 'struct flock64' for both F_OFD_GETLK and F_GETLK64 (fs/fcntl.c:493) and with the patch fcntl on non-LFS mode will only be called with 'struct fcntl'. So we need to transform to avoid the same issue as for OFD locks.
On 01/06/2018 17:50, Joseph Myers wrote: > On Fri, 1 Jun 2018, Adhemerval Zanella wrote: > >> It is not really new, since for architectures with default LFS support this is >> transparent and for architectures with non-default LFS my understanding is >> functions with *64 suffix are expected to handle cancellation as the non-LFS. > > *64 functions are generally expected to be analogous with the > corresponding non-LFS functions, yes. I think the new fcntl64 API still > merits a specific NEWS entry, just like other new function APIs. > Alright, I will add a NEWS entry.
On 01/06/2018 18:48, Adhemerval Zanella wrote: >> >> The new code calls SYSCALL_CANCEL for many more cases, some of which probably are bugs. > > Indeed the F_{OFD}_GETLK* case is not the case for cancellation (since the > lock won't be enforced by kernel). My understanding is both POSIX and Linux > OFD locks have similar code path which may suspend process execution (the > case for cancellation syscall). Do you have any reservation about making > F_OFD_GETLK a cancellation entrypoint as well? The questioning in fact for F_SETLK64/F_SETLKW64/F_OFD_SETLK/F_OFD_SETLKW (instead of F_OFD_GETLK).
* Adhemerval Zanella: >> I'm also a bit worried about this: >> >> + case F_GETLK64: >> + case F_OFD_GETLK: >> + { >> + struct flock *flk = (struct flock *) arg; >> + struct flock64 flk64 = >> + { >> + .l_type = flk->l_type, >> + .l_whence = flk->l_whence, >> + .l_start = flk->l_start, >> + .l_len = flk->l_len, >> + .l_pid = flk->l_pid >> + }; >> >> Should we really perform translation for F_GETLK64? That looks like a bug. > > My understanding is Linux expects a 'struct flock64' for both > F_OFD_GETLK and F_GETLK64 (fs/fcntl.c:493) and with the patch fcntl > on non-LFS mode will only be called with 'struct fcntl'. So we need > to transform to avoid the same issue as for OFD locks. My concern is that existing code uses F_GETLK64 as a replacement for the missing fcntl64 in non-LFS mode. Here's some example in the criu test suite: | static int lock_reg(int fd, int cmd, int type, int whence, | off_t offset, off_t len) | { | struct flock64 lock; | | lock.l_type = type; /* F_RDLCK, F_WRLCK, F_UNLCK */ | lock.l_whence = whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ | lock.l_start = offset; /* byte offset, relative to l_whence */ | lock.l_len = len; /* #bytes (0 means to EOF) */ | | errno = 0; | return fcntl(fd, cmd, &lock); | } | | #define set_read_lock(fd, whence, offset, len) \ | lock_reg(fd, F_SETLK64, F_RDLCK, whence, offset, len) | #define set_write_lock(fd, whence, offset, len) \ | lock_reg(fd, F_SETLK64, F_WRLCK, whence, offset, len) Doesn't this break (silently) after your changes? I'm still not sure if translation is the right approach here. Maybe we can add warnings or compile-time failures on type mis-matches instead. Or provide non-variadic functions like fcntl_getlk64, fcntl_ofd_getlk, fcntl_getfl etc.
diff --git a/include/fcntl.h b/include/fcntl.h index 3d68c5e..5fac115 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -10,10 +10,14 @@ extern int __libc_open (const char *file, int oflag, ...); libc_hidden_proto (__libc_open) extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden; libc_hidden_proto (__libc_fcntl) +extern int __libc_fcntl64 (int fd, int cmd, ...) attribute_hidden; +libc_hidden_proto (__libc_fcntl64) extern int __open (const char *__file, int __oflag, ...); libc_hidden_proto (__open) extern int __fcntl (int __fd, int __cmd, ...); libc_hidden_proto (__fcntl) +extern int __fcntl64 (int __fd, int __cmd, ...); +libc_hidden_proto (__fcntl64) extern int __openat (int __fd, const char *__file, int __oflag, ...) __nonnull ((2)); libc_hidden_proto (__openat) diff --git a/io/Makefile b/io/Makefile index 2117cb6..4a0d8fe 100644 --- a/io/Makefile +++ b/io/Makefile @@ -40,7 +40,7 @@ routines := \ mkdir mkdirat \ open open_2 open64 open64_2 openat openat_2 openat64 openat64_2 \ read write lseek lseek64 access euidaccess faccessat \ - fcntl flock lockf lockf64 \ + fcntl fcntl64 flock lockf lockf64 \ close dup dup2 dup3 pipe pipe2 \ creat creat64 \ chdir fchdir \ @@ -89,6 +89,7 @@ CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-creat.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-creat64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-poll.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-ppoll.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c += -fexceptions diff --git a/io/Versions b/io/Versions index 98898cb..492e72c 100644 --- a/io/Versions +++ b/io/Versions @@ -128,4 +128,7 @@ libc { GLIBC_2.27 { copy_file_range; } + GLIBC_2.28 { + fcntl64; __fcntl64; + } } diff --git a/io/fcntl.h b/io/fcntl.h index 69a4394..3afc620 100644 --- a/io/fcntl.h +++ b/io/fcntl.h @@ -167,7 +167,18 @@ typedef __pid_t pid_t; This function is a cancellation point and therefore not marked with __THROW. */ +#ifndef __USE_FILE_OFFSET64 extern int fcntl (int __fd, int __cmd, ...); +#else +# ifdef __REDIRECT +extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); +# else +# define fcntl fcntl64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int fcntl64 (int __fd, int __cmd, ...); +#endif /* Open FILE and return a new file descriptor for it, or -1 on error. OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/io/fcntl64.c similarity index 65% rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c rename to io/fcntl64.c index 48198c1..f4e6809 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c +++ b/io/fcntl64.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2018 Free Software Foundation, Inc. +/* Manipulate file descriptor. Stub LFS version. + Copyright (C) 2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,18 +16,23 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <unistd.h> +#include <errno.h> #include <fcntl.h> -static inline int -fcntl_adjust_cmd (int cmd) +/* Perform file control operations on FD. */ +int +__fcntl64 (int fd, int cmd, ...) { - if (cmd >= F_GETLK64 && cmd <= F_SETLKW64) - cmd -= F_GETLK64 - F_GETLK; - return cmd; -} + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } -#define FCNTL_ADJUST_CMD(__cmd) \ - fcntl_adjust_cmd (__cmd) + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__fcntl64) +stub_warning (fcntl64) -#include <sysdeps/unix/sysv/linux/fcntl.c> +weak_alias (__fcntl64, fcntl64) diff --git a/nptl/Makefile b/nptl/Makefile index 94be92c..13d485c 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -36,7 +36,7 @@ static-only-routines = pthread_atfork # We need to provide certain routines for compatibility with existing # binaries. pthread-compat-wrappers = \ - write read close fcntl accept \ + write read close fcntl fcntl64 accept \ connect recv recvfrom send \ sendto fsync lseek lseek64 \ msync nanosleep open open64 pause \ @@ -191,6 +191,7 @@ CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables # These are the function wrappers we have to duplicate here. CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c += -fexceptions CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c index 0b23164..598317d 100644 --- a/sysdeps/mach/hurd/fcntl.c +++ b/sysdeps/mach/hurd/fcntl.c @@ -210,3 +210,8 @@ libc_hidden_def (__libc_fcntl) weak_alias (__libc_fcntl, __fcntl) libc_hidden_weak (__fcntl) weak_alias (__libc_fcntl, fcntl) + +strong_alias (__libc_fcntl, __libc_fcntl64) +libc_hidden_def (__libc_fcntl64) +weak_alias (__libc_fcntl64, __fcntl64) +libc_hidden_weak (__fcntl64) diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 9545e89..36f1a2d 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2049,6 +2049,10 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index 90c9bc8..6fb0c38 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2139,3 +2139,6 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 8674a87..e8dd80c 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2054,6 +2054,9 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist index 044ec10..69bf5a3 100644 --- a/sysdeps/unix/sysv/linux/arm/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/libc.abilist @@ -130,6 +130,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.4 GLIBC_2.4 A GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c index a3cb2ae..5a8fbb5 100644 --- a/sysdeps/unix/sysv/linux/fcntl.c +++ b/sysdeps/unix/sysv/linux/fcntl.c @@ -19,32 +19,23 @@ #include <stdarg.h> #include <errno.h> #include <sysdep-cancel.h> -#include <not-cancel.h> -#ifndef __NR_fcntl64 -# define __NR_fcntl64 __NR_fcntl -#endif +#ifndef __OFF_T_MATCHES_OFF64_T -#ifndef FCNTL_ADJUST_CMD -# define FCNTL_ADJUST_CMD(__cmd) __cmd -#endif +# ifndef FCNTL_ADJUST_CMD +# define FCNTL_ADJUST_CMD(__cmd) __cmd +# endif -static int -fcntl_common (int fd, int cmd, void *arg) +static inline struct flock64 +flock_to_flock64 (const struct flock *flk) { - if (cmd == F_GETOWN) - { - INTERNAL_SYSCALL_DECL (err); - struct f_owner_ex fex; - int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); - if (!INTERNAL_SYSCALL_ERROR_P (res, err)) - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; - - return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, - err)); - } - - return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); + return (struct flock64) { + .l_type = flk->l_type, + .l_whence = flk->l_whence, + .l_start = flk->l_start, + .l_len = flk->l_len, + .l_pid = flk->l_pid + }; } int @@ -59,16 +50,56 @@ __libc_fcntl (int fd, int cmd, ...) cmd = FCNTL_ADJUST_CMD (cmd); - if (cmd == F_SETLKW || cmd == F_SETLKW64) - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); - - return fcntl_common (fd, cmd, arg); + switch (cmd) + { + case F_SETLKW: + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); + case F_GETLK64: + case F_OFD_GETLK: + { + struct flock *flk = (struct flock *) arg; + struct flock64 flk64 = flock_to_flock64 (flk); + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); + if (ret == -1) + return -1; + flk->l_type = flk64.l_type; + flk->l_whence = flk64.l_whence; + flk->l_start = flk64.l_start; + flk->l_len = flk64.l_len; + flk->l_pid = flk64.l_pid; + return ret; + } + case F_SETLK64: + case F_SETLKW64: + case F_OFD_SETLK: + case F_OFD_SETLKW: + { + struct flock64 flk64 = flock_to_flock64 (arg); + return SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); + } + case F_GETOWN: + { + INTERNAL_SYSCALL_DECL (err); + struct f_owner_ex fex; + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; + + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, + err)); + } + default: + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, arg); + } } libc_hidden_def (__libc_fcntl) +weak_alias (__libc_fcntl, __fcntl) +libc_hidden_weak (__fcntl) -#if !IS_IN (rtld) +# include <shlib-compat.h> +# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) int -__fcntl_nocancel (int fd, int cmd, ...) +__old_libc_fcntl64 (int fd, int cmd, ...) { va_list ap; void *arg; @@ -77,13 +108,12 @@ __fcntl_nocancel (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - return fcntl_common (fd, cmd, arg); + return __libc_fcntl64 (fd, cmd, arg); } -#else -strong_alias (__libc_fcntl, __fcntl_nocancel) -#endif -libc_hidden_def (__fcntl_nocancel) - -weak_alias (__libc_fcntl, __fcntl) -libc_hidden_weak (__fcntl) +compat_symbol (libc, __old_libc_fcntl64, fcntl, GLIBC_2_0); +versioned_symbol (libc, __libc_fcntl, fcntl, GLIBC_2_28); +# else weak_alias (__libc_fcntl, fcntl) +# endif + +#endif /* __OFF_T_MATCHES_OFF64_T */ diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c new file mode 100644 index 0000000..b7f50b0 --- /dev/null +++ b/sysdeps/unix/sysv/linux/fcntl64.c @@ -0,0 +1,99 @@ +/* Manipulate file descriptor. Linux LFS version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define fcntl __no_decl_fcntl +#define __fcntl __no_decl___fcntl +#include <fcntl.h> +#undef fcntl +#undef __fcntl +#include <stdarg.h> +#include <errno.h> +#include <sysdep-cancel.h> + +#ifndef __NR_fcntl64 +# define __NR_fcntl64 __NR_fcntl +#endif + +#ifndef FCNTL_ADJUST_CMD +# define FCNTL_ADJUST_CMD(__cmd) __cmd +#endif + +static int +fcntl64_common (int fd, int cmd, void *arg) +{ + if (cmd == F_GETOWN) + { + INTERNAL_SYSCALL_DECL (err); + struct f_owner_ex fex; + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex); + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; + + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res, + err)); + } + + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); +} + +int +__libc_fcntl64 (int fd, int cmd, ...) +{ + va_list ap; + void *arg; + + va_start (ap, cmd); + arg = va_arg (ap, void *); + va_end (ap); + + cmd = FCNTL_ADJUST_CMD (cmd); + + if (cmd == F_SETLKW || cmd == F_SETLKW64) + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); + + return fcntl64_common (fd, cmd, arg); +} +libc_hidden_def (__libc_fcntl64) +weak_alias (__libc_fcntl64, __fcntl64) +libc_hidden_weak (__fcntl64) +weak_alias (__libc_fcntl64, fcntl64) + +#ifdef __OFF_T_MATCHES_OFF64_T +weak_alias (__libc_fcntl64, __libc_fcntl) +weak_alias (__libc_fcntl64, __fcntl) +weak_alias (__libc_fcntl64, __GI___fcntl) +weak_alias (__libc_fcntl64, fcntl) +#endif + +#if !IS_IN (rtld) +int +__fcntl_nocancel (int fd, int cmd, ...) +{ + va_list ap; + void *arg; + + va_start (ap, cmd); + arg = va_arg (ap, void *); + va_end (ap); + + return fcntl64_common (fd, cmd, arg); +} +#else +weak_alias (__libc_fcntl64, __fcntl_nocancel) +#endif +weak_alias (__fcntl_nocancel, __GI___fcntl_nocancel) diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index 2360130..d87eb4c 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -1894,6 +1894,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 39c993f..177b07a 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2064,6 +2064,10 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist index 68496aa..87571f1 100644 --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -1928,6 +1928,9 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index b676025..afb9e05 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -131,6 +131,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.4 GLIBC_2.4 A GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0x98 diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index cdd1df5..034ff04 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2008,6 +2008,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist index e4265fd..8586123 100644 --- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist @@ -2129,3 +2129,7 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index 3a7e0b4..2187c72 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -1983,6 +1983,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 5e80592..4ee5454 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -1981,6 +1981,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 1973fac..62468d6 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -1989,6 +1989,10 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index 5e18ab8..48d07e3 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -1984,6 +1984,9 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist index cc5885a..ee0b7c0 100644 --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2170,3 +2170,7 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h index 503f562..d755f1d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h @@ -52,3 +52,11 @@ #undef __ASSUME_CLONE_DEFAULT #define __ASSUME_CLONE_BACKWARDS 1 + +#define FCNTL_ADJUST_CMD(__cmd) \ + ({ int __cmdadj = (__cmd); \ + if (__cmdadj >= F_GETLK64 && __cmdadj <= F_SETLKW64) \ + __cmdadj -= F_GETLK64 - F_GETLK; \ + __cmdadj; \ + }) + diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index 676aa50..6c72516 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -2012,6 +2012,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index 2016c7c..0499171 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -2017,6 +2017,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist index 3d19e38..17a56de 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist @@ -2229,3 +2229,6 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist index c57ab21..1e625c6 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist @@ -131,6 +131,9 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 _Exit F GLIBC_2.3 _IO_2_1_stderr_ D 0xe0 diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index 8ab44ec..dce49e0 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2094,3 +2094,6 @@ GLIBC_2.27 xdrstdio_create F GLIBC_2.27 xencrypt F GLIBC_2.27 xprt_register F GLIBC_2.27 xprt_unregister F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 2590372..a9db23c 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2022,6 +2022,10 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 5d6800c..a0e275f 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -1923,6 +1923,9 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist index c04872c..e3db11b 100644 --- a/sysdeps/unix/sysv/linux/sh/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/libc.abilist @@ -1898,6 +1898,10 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 85cbe30..8b4d22d 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -2015,6 +2015,10 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index f7a1ab8..bc1eba3 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -1952,6 +1952,9 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist index ab56ece..d6506ed 100644 --- a/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist +++ b/sysdeps/unix/sysv/linux/tile/tilegx32/libc.abilist @@ -2136,3 +2136,6 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist index f2518c0..ede48fc 100644 --- a/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist +++ b/sysdeps/unix/sysv/linux/tile/tilegx64/libc.abilist @@ -2136,3 +2136,6 @@ GLIBC_2.27 wcstof32x F GLIBC_2.27 wcstof32x_l F GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index 2a3cc40..4a5729f 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -1905,6 +1905,9 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F GLIBC_2.3 GLIBC_2.3 A GLIBC_2.3 __ctype_b_loc F GLIBC_2.3 __ctype_tolower_loc F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 8bc16b9..0745aee 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2148,3 +2148,6 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 GLIBC_2.28 A +GLIBC_2.28 __fcntl64 F +GLIBC_2.28 fcntl64 F