mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Remove __ASSUME_FCNTL64.
This commit is contained in:
17
ChangeLog
17
ChangeLog
@ -1,5 +1,22 @@
|
|||||||
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_FCNTL64):
|
||||||
|
Remove all definitions.
|
||||||
|
* sysdeps/unix/sysv/linux/i386/fcntl.c: Do not include
|
||||||
|
<kernel-features.h>.
|
||||||
|
[!__ASSUME_FCNTL64] (__have_no_fcntl64): Remove.
|
||||||
|
(miss_F_GETOWN_EX): Remove all definitions.
|
||||||
|
[NO_CANCELLATION && !__ASSUME_FCNTL64] (__fcntl_nocancel): Remove
|
||||||
|
macro definition.
|
||||||
|
[!__ASSUME_FCNTL64]: Remove conditional code.
|
||||||
|
[__ASSUME_FCNTL64]: Make code unconditional.
|
||||||
|
* sysdeps/unix/sysv/linux/i386/lockf64.c: Do not include
|
||||||
|
<kernel-features.h>.
|
||||||
|
[__NR_fcntl64 && !__ASSUME_FCNTL64] (__have_no_fcntl64): Remove.
|
||||||
|
(lockf64) [!__ASSUME_FCNTL64]: Remove conditional code.
|
||||||
|
(lockf64) [__NR_fcntl64]: Make code unconditional.
|
||||||
|
(lockf64) [__ASSUME_FCNTL64]: Likewise.
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/kernel-features.h
|
* sysdeps/unix/sysv/linux/kernel-features.h
|
||||||
(__ASSUME_VFORK_SYSCALL): Remove all definitions.
|
(__ASSUME_VFORK_SYSCALL): Remove all definitions.
|
||||||
* sysdeps/unix/sysv/linux/i386/vfork.S (__vfork) [__NR_vfork]:
|
* sysdeps/unix/sysv/linux/i386/vfork.S (__vfork) [__NR_vfork]:
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/arm/kernel-features.h
|
||||||
|
(__ASSUME_FCNTL64): Remove.
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/arm/kernel-features.h
|
* sysdeps/unix/sysv/linux/arm/kernel-features.h
|
||||||
(__ASSUME_VFORK_SYSCALL): Remove.
|
(__ASSUME_VFORK_SYSCALL): Remove.
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/hppa/kernel-features.h
|
||||||
|
(__ASSUME_FCNTL64): Remove.
|
||||||
|
|
||||||
2012-07-26 Andreas Jaeger <aj@suse.de>
|
2012-07-26 Andreas Jaeger <aj@suse.de>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/hppa/sys/epoll.h (EPOLLWAKEUP): Add new
|
* sysdeps/unix/sysv/linux/hppa/sys/epoll.h (EPOLLWAKEUP): Add new
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
|
||||||
|
(__ASSUME_FCNTL64): Remove.
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
|
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
|
||||||
(__ASSUME_VFORK_SYSCALL): Remove.
|
(__ASSUME_VFORK_SYSCALL): Remove.
|
||||||
* sysdeps/unix/sysv/linux/m68k/vfork.S (__vfork) [__NR_vfork]:
|
* sysdeps/unix/sysv/linux/m68k/vfork.S (__vfork) [__NR_vfork]:
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/mips/kernel-features.h
|
||||||
|
(__ASSUME_FCNTL64): Remove.
|
||||||
|
|
||||||
2012-08-01 Steve Ellcey <sellcey@mips.com>
|
2012-08-01 Steve Ellcey <sellcey@mips.com>
|
||||||
|
|
||||||
* sysdeps/mips/sys/asm.h [_MIPS_ISA != _MIPS_ISA_MIPS4 &&
|
* sysdeps/mips/sys/asm.h [_MIPS_ISA != _MIPS_ISA_MIPS4 &&
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2012-08-01 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/tile/kernel-features.h
|
||||||
|
(__ASSUME_FCNTL64): Remove.
|
||||||
|
|
||||||
2012-07-26 Andreas Jaeger <aj@suse.de>
|
2012-07-26 Andreas Jaeger <aj@suse.de>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/tile/sys/ptrace.h (__ptrace_eventcodes):
|
* sysdeps/unix/sysv/linux/tile/sys/ptrace.h (__ptrace_eventcodes):
|
||||||
|
@ -27,9 +27,6 @@
|
|||||||
#define __ASSUME_MMAP2_SYSCALL 1
|
#define __ASSUME_MMAP2_SYSCALL 1
|
||||||
#define __ASSUME_STAT64_SYSCALL 1
|
#define __ASSUME_STAT64_SYSCALL 1
|
||||||
|
|
||||||
/* Arm got fcntl64 in 2.4.4. */
|
|
||||||
#define __ASSUME_FCNTL64 1
|
|
||||||
|
|
||||||
/* The signal frame layout changed in 2.6.18. */
|
/* The signal frame layout changed in 2.6.18. */
|
||||||
#if __LINUX_KERNEL_VERSION >= 132626
|
#if __LINUX_KERNEL_VERSION >= 132626
|
||||||
# define __ASSUME_SIGFRAME_V2 1
|
# define __ASSUME_SIGFRAME_V2 1
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#define __ASSUME_STAT64_SYSCALL 1
|
#define __ASSUME_STAT64_SYSCALL 1
|
||||||
#define __ASSUME_IPC64 1
|
#define __ASSUME_IPC64 1
|
||||||
#define __ASSUME_ST_INO_64_BIT 1
|
#define __ASSUME_ST_INO_64_BIT 1
|
||||||
#define __ASSUME_FCNTL64 1
|
|
||||||
#define __ASSUME_GETDENTS64_SYSCALL 1
|
#define __ASSUME_GETDENTS64_SYSCALL 1
|
||||||
|
|
||||||
/* PA-RISC 2.6.9 kernels had the first LWS CAS support */
|
/* PA-RISC 2.6.9 kernels had the first LWS CAS support */
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
/* These features were surely available with 2.4.12. */
|
/* These features were surely available with 2.4.12. */
|
||||||
#define __ASSUME_MMAP2_SYSCALL 1
|
#define __ASSUME_MMAP2_SYSCALL 1
|
||||||
#define __ASSUME_STAT64_SYSCALL 1
|
#define __ASSUME_STAT64_SYSCALL 1
|
||||||
#define __ASSUME_FCNTL64 1
|
|
||||||
|
|
||||||
/* Many syscalls were added in 2.6.10 for m68k. */
|
/* Many syscalls were added in 2.6.10 for m68k. */
|
||||||
#if __LINUX_KERNEL_VERSION >= 132618
|
#if __LINUX_KERNEL_VERSION >= 132618
|
||||||
|
@ -22,10 +22,6 @@
|
|||||||
/* MIPS platforms had IPC64 all along. */
|
/* MIPS platforms had IPC64 all along. */
|
||||||
#define __ASSUME_IPC64 1
|
#define __ASSUME_IPC64 1
|
||||||
|
|
||||||
#if _MIPS_SIM == _ABIN32
|
|
||||||
# define __ASSUME_FCNTL64 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Support for the eventfd2 and signalfd4 syscalls was added in 2.6.27. */
|
/* Support for the eventfd2 and signalfd4 syscalls was added in 2.6.27. */
|
||||||
#if __LINUX_KERNEL_VERSION >= 0x02061c
|
#if __LINUX_KERNEL_VERSION >= 0x02061c
|
||||||
# define __ASSUME_EVENTFD2 1
|
# define __ASSUME_EVENTFD2 1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2011 Free Software Foundation, Inc.
|
/* Copyright (C) 2011-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
|
Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
|
||||||
|
|
||||||
@ -20,7 +20,6 @@
|
|||||||
/* TILE glibc support starts with 2.6.36, guaranteeing many kernel features. */
|
/* TILE glibc support starts with 2.6.36, guaranteeing many kernel features. */
|
||||||
#define __ASSUME_MMAP2_SYSCALL 1
|
#define __ASSUME_MMAP2_SYSCALL 1
|
||||||
#define __ASSUME_STAT64_SYSCALL 1
|
#define __ASSUME_STAT64_SYSCALL 1
|
||||||
#define __ASSUME_FCNTL64 1
|
|
||||||
#define __ASSUME_CLONE_THREAD_FLAGS 1
|
#define __ASSUME_CLONE_THREAD_FLAGS 1
|
||||||
#define __ASSUME_TGKILL 1
|
#define __ASSUME_TGKILL 1
|
||||||
#define __ASSUME_UTIMES 1
|
#define __ASSUME_UTIMES 1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000,2002-2004,2006,2009,2010 Free Software Foundation, Inc.
|
/* Copyright (C) 2000-2012 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -22,25 +22,8 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <kernel-features.h>
|
|
||||||
|
|
||||||
#ifndef __ASSUME_FCNTL64
|
#ifndef NO_CANCELLATION
|
||||||
/* This variable is shared with all files that check for fcntl64. */
|
|
||||||
int __have_no_fcntl64;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __ASSUME_F_GETOWN_EX
|
|
||||||
# define miss_F_GETOWN_EX 0
|
|
||||||
#elif !defined __ASSUME_FCNTL64
|
|
||||||
static int miss_F_GETOWN_EX;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined NO_CANCELLATION && !defined __ASSUME_FCNTL64
|
|
||||||
# define __fcntl_nocancel __libc_fcntl
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined NO_CANCELLATION || !defined __ASSUME_FCNTL64
|
|
||||||
int
|
int
|
||||||
__fcntl_nocancel (int fd, int cmd, ...)
|
__fcntl_nocancel (int fd, int cmd, ...)
|
||||||
{
|
{
|
||||||
@ -51,112 +34,11 @@ __fcntl_nocancel (int fd, int cmd, ...)
|
|||||||
arg = va_arg (ap, void *);
|
arg = va_arg (ap, void *);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
#ifndef __ASSUME_FCNTL64
|
|
||||||
# ifdef __NR_fcntl64
|
|
||||||
if (! __have_no_fcntl64)
|
|
||||||
{
|
|
||||||
int result = INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
|
|
||||||
if (result >= 0 || errno != ENOSYS)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
__have_no_fcntl64 = 1;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case F_GETLK64:
|
|
||||||
/* Convert arg from flock64 to flock and back. */
|
|
||||||
{
|
|
||||||
struct flock fl;
|
|
||||||
struct flock64 *fl64 = arg;
|
|
||||||
int res;
|
|
||||||
|
|
||||||
fl.l_start = (off_t)fl64->l_start;
|
|
||||||
/* Check if we can represent the values with the smaller type. */
|
|
||||||
if ((off64_t) fl.l_start != fl64->l_start)
|
|
||||||
{
|
|
||||||
eoverflow:
|
|
||||||
__set_errno (EOVERFLOW);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
fl.l_len = (off_t) fl64->l_len;
|
|
||||||
/* Check if we can represent the values with the smaller type. */
|
|
||||||
if ((off64_t) fl.l_len != fl64->l_len)
|
|
||||||
goto eoverflow;
|
|
||||||
|
|
||||||
fl.l_type = fl64->l_type;
|
|
||||||
fl.l_whence = fl64->l_whence;
|
|
||||||
fl.l_pid = fl64->l_pid;
|
|
||||||
|
|
||||||
res = INLINE_SYSCALL (fcntl, 3, fd, F_GETLK, &fl);
|
|
||||||
if (res != 0)
|
|
||||||
return res;
|
|
||||||
/* Everything ok, convert back. */
|
|
||||||
fl64->l_type = fl.l_type;
|
|
||||||
fl64->l_whence = fl.l_whence;
|
|
||||||
fl64->l_start = fl.l_start;
|
|
||||||
fl64->l_len = fl.l_len;
|
|
||||||
fl64->l_pid = fl.l_pid;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
case F_SETLK64:
|
|
||||||
case F_SETLKW64:
|
|
||||||
/* Try to convert arg from flock64 to flock. */
|
|
||||||
{
|
|
||||||
struct flock fl;
|
|
||||||
struct flock64 *fl64 = arg;
|
|
||||||
|
|
||||||
fl.l_start = (off_t) fl64->l_start;
|
|
||||||
/* Check if we can represent the values with the smaller type. */
|
|
||||||
if ((off64_t) fl.l_start != fl64->l_start)
|
|
||||||
goto eoverflow;
|
|
||||||
|
|
||||||
fl.l_len = (off_t)fl64->l_len;
|
|
||||||
/* Check if we can represent the values with the smaller type. */
|
|
||||||
if ((off64_t) fl.l_len != fl64->l_len)
|
|
||||||
{
|
|
||||||
__set_errno (EOVERFLOW);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
fl.l_type = fl64->l_type;
|
|
||||||
fl.l_whence = fl64->l_whence;
|
|
||||||
fl.l_pid = fl64->l_pid;
|
|
||||||
assert (F_SETLK - F_SETLKW == F_SETLK64 - F_SETLKW64);
|
|
||||||
return INLINE_SYSCALL (fcntl, 3, fd, cmd + F_SETLK - F_SETLK64, &fl);
|
|
||||||
}
|
|
||||||
case F_GETOWN:
|
|
||||||
if (! miss_F_GETOWN_EX)
|
|
||||||
{
|
|
||||||
INTERNAL_SYSCALL_DECL (err);
|
|
||||||
struct f_owner_ex fex;
|
|
||||||
int res = INTERNAL_SYSCALL (fcntl, err, 3, fd, F_GETOWN_EX, &fex);
|
|
||||||
if (!INTERNAL_SYSCALL_ERROR_P (res, err))
|
|
||||||
return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
|
|
||||||
|
|
||||||
# ifndef __ASSUME_F_GETOWN_EX
|
|
||||||
if (INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL)
|
|
||||||
miss_F_GETOWN_EX = 1;
|
|
||||||
else
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
__set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* FALLTHROUGH */
|
|
||||||
default:
|
|
||||||
return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
#else
|
|
||||||
return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
|
return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
|
||||||
#endif /* !__ASSUME_FCNTL64 */
|
|
||||||
}
|
}
|
||||||
#endif /* NO_CANCELLATION || !__ASSUME_FCNTL64 */
|
#endif /* NO_CANCELLATION */
|
||||||
|
|
||||||
|
|
||||||
#ifndef __fcntl_nocancel
|
|
||||||
int
|
int
|
||||||
__libc_fcntl (int fd, int cmd, ...)
|
__libc_fcntl (int fd, int cmd, ...)
|
||||||
{
|
{
|
||||||
@ -167,27 +49,17 @@ __libc_fcntl (int fd, int cmd, ...)
|
|||||||
arg = va_arg (ap, void *);
|
arg = va_arg (ap, void *);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
# ifdef __ASSUME_FCNTL64
|
|
||||||
if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
|
if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
|
||||||
return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
|
return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
|
||||||
|
|
||||||
int oldtype = LIBC_CANCEL_ASYNC ();
|
int oldtype = LIBC_CANCEL_ASYNC ();
|
||||||
|
|
||||||
int result = INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
|
int result = INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
|
||||||
# else
|
|
||||||
if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
|
|
||||||
return __fcntl_nocancel (fd, cmd, arg);
|
|
||||||
|
|
||||||
int oldtype = LIBC_CANCEL_ASYNC ();
|
|
||||||
|
|
||||||
int result = __fcntl_nocancel (fd, cmd, arg);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
LIBC_CANCEL_RESET (oldtype);
|
LIBC_CANCEL_RESET (oldtype);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
libc_hidden_def (__libc_fcntl)
|
libc_hidden_def (__libc_fcntl)
|
||||||
|
|
||||||
weak_alias (__libc_fcntl, __fcntl)
|
weak_alias (__libc_fcntl, __fcntl)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/* Copyright (C) 1994,1996,1997,1998,1999,2000,2003,2006
|
/* Copyright (C) 1994-2012 Free Software Foundation, Inc.
|
||||||
Free Software Foundation, Inc.
|
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -23,66 +22,24 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sysdep.h>
|
#include <sysdep.h>
|
||||||
|
|
||||||
#include <kernel-features.h>
|
|
||||||
|
|
||||||
/* lockf is a simplified interface to fcntl's locking facilities. */
|
/* lockf is a simplified interface to fcntl's locking facilities. */
|
||||||
|
|
||||||
#ifdef __NR_fcntl64
|
|
||||||
# if __ASSUME_FCNTL64 == 0
|
|
||||||
/* This variable is shared with all files that check for fcntl64. The
|
|
||||||
declaration is in fcntl.c. */
|
|
||||||
extern int __have_no_fcntl64;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
lockf64 (int fd, int cmd, off64_t len64)
|
lockf64 (int fd, int cmd, off64_t len64)
|
||||||
{
|
{
|
||||||
#if __ASSUME_FCNTL64 == 0
|
|
||||||
struct flock fl;
|
|
||||||
off_t len = (off_t) len64;
|
|
||||||
#endif
|
|
||||||
#ifdef __NR_fcntl64
|
|
||||||
struct flock64 fl64;
|
struct flock64 fl64;
|
||||||
int cmd64;
|
int cmd64;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __ASSUME_FCNTL64 == 0
|
memset ((char *) &fl64, '\0', sizeof (fl64));
|
||||||
memset ((char *) &fl, '\0', sizeof (fl));
|
fl64.l_whence = SEEK_CUR;
|
||||||
|
fl64.l_start = 0;
|
||||||
|
fl64.l_len = len64;
|
||||||
|
|
||||||
/* lockf is always relative to the current file position. */
|
|
||||||
fl.l_whence = SEEK_CUR;
|
|
||||||
fl.l_start = 0;
|
|
||||||
fl.l_len = len;
|
|
||||||
#endif
|
|
||||||
#ifdef __NR_fcntl64
|
|
||||||
# if __ASSUME_FCNTL64 == 0
|
|
||||||
if (!__have_no_fcntl64)
|
|
||||||
{
|
|
||||||
# endif
|
|
||||||
memset ((char *) &fl64, '\0', sizeof (fl64));
|
|
||||||
fl64.l_whence = SEEK_CUR;
|
|
||||||
fl64.l_start = 0;
|
|
||||||
fl64.l_len = len64;
|
|
||||||
# if __ASSUME_FCNTL64 == 0
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __ASSUME_FCNTL64 == 0 && !defined __NR_fcntl64
|
|
||||||
if (len64 != (off64_t) len)
|
|
||||||
{
|
|
||||||
/* We can't represent the length. */
|
|
||||||
__set_errno (EOVERFLOW);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case F_TEST:
|
case F_TEST:
|
||||||
/* Test the lock: return 0 if FD is unlocked or locked by this process;
|
/* Test the lock: return 0 if FD is unlocked or locked by this process;
|
||||||
return -1, set errno to EACCES, if another process holds the lock. */
|
return -1, set errno to EACCES, if another process holds the lock. */
|
||||||
#if __ASSUME_FCNTL64 > 0
|
|
||||||
fl64.l_type = F_RDLCK;
|
fl64.l_type = F_RDLCK;
|
||||||
if (INLINE_SYSCALL (fcntl64, 3, fd, F_GETLK64, &fl64) < 0)
|
if (INLINE_SYSCALL (fcntl64, 3, fd, F_GETLK64, &fl64) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -90,104 +47,22 @@ lockf64 (int fd, int cmd, off64_t len64)
|
|||||||
return 0;
|
return 0;
|
||||||
__set_errno (EACCES);
|
__set_errno (EACCES);
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
|
||||||
# ifdef __NR_fcntl64
|
|
||||||
if (!__have_no_fcntl64)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
|
|
||||||
fl64.l_type = F_RDLCK;
|
|
||||||
res = INLINE_SYSCALL (fcntl64, 3, fd, F_GETLK64, &fl64);
|
|
||||||
/* If errno == ENOSYS try the 32bit interface if len64 can
|
|
||||||
be represented with 32 bits. */
|
|
||||||
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (fl64.l_type == F_UNLCK || fl64.l_pid == __getpid ())
|
|
||||||
return 0;
|
|
||||||
__set_errno (EACCES);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (errno == ENOSYS)
|
|
||||||
__have_no_fcntl64 = 1;
|
|
||||||
else
|
|
||||||
/* res < 0 && errno != ENOSYS. */
|
|
||||||
return -1;
|
|
||||||
if (len64 != (off64_t) len)
|
|
||||||
{
|
|
||||||
/* We can't represent the length. */
|
|
||||||
__set_errno (EOVERFLOW);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
fl.l_type = F_RDLCK;
|
|
||||||
if (__fcntl (fd, F_GETLK, &fl) < 0)
|
|
||||||
return -1;
|
|
||||||
if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ())
|
|
||||||
return 0;
|
|
||||||
__set_errno (EACCES);
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
case F_ULOCK:
|
case F_ULOCK:
|
||||||
#if __ASSUME_FCNTL64 == 0
|
|
||||||
fl.l_type = F_UNLCK;
|
|
||||||
cmd = F_SETLK;
|
|
||||||
#endif
|
|
||||||
#ifdef __NR_fcntl64
|
|
||||||
fl64.l_type = F_UNLCK;
|
fl64.l_type = F_UNLCK;
|
||||||
cmd64 = F_SETLK64;
|
cmd64 = F_SETLK64;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case F_LOCK:
|
case F_LOCK:
|
||||||
#if __ASSUME_FCNTL64 == 0
|
|
||||||
fl.l_type = F_WRLCK;
|
|
||||||
cmd = F_SETLKW;
|
|
||||||
#endif
|
|
||||||
#ifdef __NR_fcntl64
|
|
||||||
fl64.l_type = F_WRLCK;
|
fl64.l_type = F_WRLCK;
|
||||||
cmd64 = F_SETLKW64;
|
cmd64 = F_SETLKW64;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case F_TLOCK:
|
case F_TLOCK:
|
||||||
#if __ASSUME_FCNTL64 == 0
|
|
||||||
fl.l_type = F_WRLCK;
|
|
||||||
cmd = F_SETLK;
|
|
||||||
#endif
|
|
||||||
#ifdef __NR_fcntl64
|
|
||||||
fl64.l_type = F_WRLCK;
|
fl64.l_type = F_WRLCK;
|
||||||
cmd64 = F_SETLK64;
|
cmd64 = F_SETLK64;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
__set_errno (EINVAL);
|
__set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#if __ASSUME_FCNTL64 > 0
|
|
||||||
return INLINE_SYSCALL (fcntl64, 3, fd, cmd64, &fl64);
|
return INLINE_SYSCALL (fcntl64, 3, fd, cmd64, &fl64);
|
||||||
#else
|
|
||||||
# ifdef __NR_fcntl64
|
|
||||||
|
|
||||||
if (!__have_no_fcntl64)
|
|
||||||
{
|
|
||||||
int res = INLINE_SYSCALL (fcntl64, 3, fd, cmd64, &fl64);
|
|
||||||
|
|
||||||
/* If errno == ENOSYS try the 32bit interface if len64 can
|
|
||||||
be represented with 32 bits. */
|
|
||||||
if (res == 0 || errno != ENOSYS)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
__have_no_fcntl64 = 1;
|
|
||||||
|
|
||||||
if (len64 != (off64_t) len)
|
|
||||||
{
|
|
||||||
/* We can't represent the length. */
|
|
||||||
__set_errno (EOVERFLOW);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return __fcntl (fd, cmd, &fl);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -82,20 +82,6 @@
|
|||||||
# define __ASSUME_ST_INO_64_BIT 1
|
# define __ASSUME_ST_INO_64_BIT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* To support locking of large files a new fcntl() syscall was introduced
|
|
||||||
in 2.4.0-test7. */
|
|
||||||
#if defined __i386__ || defined __sparc__
|
|
||||||
# define __ASSUME_FCNTL64 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Arm got fcntl64 in 2.4.4, PowerPC and SH have it also in 2.4.4 (I
|
|
||||||
don't know when it got introduced). But PowerPC64 does not support
|
|
||||||
separate FCNTL64 call, FCNTL is already 64-bit */
|
|
||||||
#if (defined __powerpc__ || defined __sh__) \
|
|
||||||
&& !defined __powerpc64__
|
|
||||||
# define __ASSUME_FCNTL64 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The getdents64 syscall was introduced in 2.4.0-test7 (but later for
|
/* The getdents64 syscall was introduced in 2.4.0-test7 (but later for
|
||||||
MIPS n32). */
|
MIPS n32). */
|
||||||
#define __ASSUME_GETDENTS64_SYSCALL 1
|
#define __ASSUME_GETDENTS64_SYSCALL 1
|
||||||
|
Reference in New Issue
Block a user