@@ -98,6 +98,11 @@ Deprecated and removed features, and other changes affecting compatibility:
restriction (rejecting '_' in host names, among other things) has been
removed, for increased compatibility with non-IDN name resolution.
+* The fcntl function now have a Long File Support variant named fcntl64. It
+ is added to fix some Linux Open File Description locks usage on non LFS
+ mode. As for others *64 functions, fcntl64 semantics are analogous with
+ fcntl and LFS support is handled transparently.
+
Changes to build and runtime requirements:
[Add changes to build and runtime requirements here]
@@ -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)
@@ -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
@@ -128,4 +128,7 @@ libc {
GLIBC_2.27 {
copy_file_range;
}
+ GLIBC_2.28 {
+ fcntl64;
+ }
}
@@ -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
similarity index 65%
rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
rename to 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)
@@ -3281,12 +3281,13 @@ Set process or process group ID to receive @code{SIGIO} signals.
@xref{Interrupt Input}.
@end vtable
-This function is a cancellation point in multi-threaded programs. This
-is a problem if the thread allocates some resources (like memory, file
-descriptors, semaphores or whatever) at the time @code{fcntl} is
-called. If the thread gets canceled these resources stay allocated
-until the program ends. To avoid this calls to @code{fcntl} should be
-protected using cancellation handlers.
+This function is a cancellation point in multi-threaded programs for the
+commands @code{F_SETLKW} (and the LFS analogous @code{F_SETLKW64}) and
+@code {F_OFD_SETLKW}. This is a problem if the thread allocates some
+resources (like memory, file descriptors, semaphores or whatever) at the time
+@code{fcntl} is called. If the thread gets canceled these resources stay
+allocated until the program ends. To avoid this calls to @code{fcntl} should
+be protected using cancellation handlers.
@c ref pthread_cleanup_push / pthread_cleanup_pop
@end deftypefun
@@ -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
@@ -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)
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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,76 @@ __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:
+ case F_SETLKW64:
+ return SYSCALL_CANCEL (fcntl64, fd, cmd, arg);
+ 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_OFD_GETLK:
+ case F_OFD_SETLK:
+ {
+ 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 = INLINE_SYSCALL_CALL (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_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));
+ }
+ /* case F_OFD_GETLK: case F_OFD_GETLK64: case F_SETLK64: */
+ 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 +116,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 */
new file mode 100644
@@ -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 || cmd == F_OFD_SETLKW)
+ return SYSCALL_CANCEL (fcntl64, fd, cmd, 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)
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
new file mode 100644
@@ -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 then old lock. To force a
+ conflicting lock combinatioin, 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>
@@ -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
@@ -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