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