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