• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) Linux Test Project, 2001-2009
4  * Copyright (c) International Business Machines Corp., 2001
5  */
6 
7 #include <stdio.h>
8 #include <sys/stat.h>
9 #include <errno.h>
10 #include <sys/types.h>
11 #include <fcntl.h>
12 #include <unistd.h>
13 
14 int		lock_reg(int, int, off_t, int, off_t, int);
15 
16 #define read_lock(fd, offset, whence, len) \
17 			lock_reg(fd, F_RDLCK, offset, whence, len, F_SETLK)
18 #define write_lock(fd, offset, whence, len) \
19 			lock_reg(fd, F_WRLCK, offset, whence, len, F_SETLK)
20 #define un_lock(fd, offset, whence, len) \
21 			lock_reg(fd, F_UNLCK, offset, whence, len, F_SETLK)
22 #define readb_lock(fd, offset, whence, len) \
23 			lock_reg(fd, F_RDLCK, offset, whence, len, F_SETLKW)
24 #define writeb_lock(fd, offset, whence, len) \
25 			lock_reg(fd, F_WRLCK, offset, whence, len, F_SETLKW)
26 #define unb_lock(fd, offset, whence, len) \
27 			lock_reg(fd, F_UNLCK, offset, whence, len, F_SETLKW)
28