1 #include "lapi/syscalls.h"
2
3 /*
4 * glibc commit:
5 * 06ab719d30b0 ("Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)")
6 * changed behavior of arg parameter for OFD commands. It is no
7 * longer passing arg directly to syscall, but expects it to be
8 * 'struct flock'.
9 *
10 * On 64-bit or _FILE_OFFSET_BITS == 64 we can use fcntl() and
11 * struct flock64 with any glibc version. struct flock and flock64
12 * should be identical.
13 *
14 * On 32-bit, older glibc would pass arg directly, recent one treats
15 * it as 'struct flock' and converts it to 'struct flock64'.
16 * So, to support both version, on 32-bit we use fcntl64 syscall
17 * directly with struct flock64.
18 */
19 #if __WORDSIZE == 64 || _FILE_OFFSET_BITS == 64
my_fcntl(int fd,int cmd,void * lck)20 static int my_fcntl(int fd, int cmd, void *lck)
21 {
22 return SAFE_FCNTL(fd, cmd, lck);
23 }
24 #else
my_fcntl(int fd,int cmd,void * lck)25 static int my_fcntl(int fd, int cmd, void *lck)
26 {
27 int ret = tst_syscall(__NR_fcntl64, fd, cmd, lck);
28 if (ret == -1)
29 tst_brk(TBROK|TERRNO, "fcntl64");
30 return ret;
31 }
32 #endif
33