Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _LINUX_FCNTL_H |
| 3 | #define _LINUX_FCNTL_H |
| 4 | |
Aleksa Sarai | fddb5d4 | 2020-01-18 23:07:59 +1100 | [diff] [blame] | 5 | #include <linux/stat.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 6 | #include <uapi/linux/fcntl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
Aleksa Sarai | fddb5d4 | 2020-01-18 23:07:59 +1100 | [diff] [blame] | 8 | /* List of all valid flags for the open/openat flags argument: */ |
Christoph Hellwig | 80f1837 | 2017-04-27 09:42:24 +0200 | [diff] [blame] | 9 | #define VALID_OPEN_FLAGS \ |
| 10 | (O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC | \ |
Krzysztof WilczyĆski | aabf594 | 2020-09-06 22:39:49 +0000 | [diff] [blame] | 11 | O_APPEND | O_NDELAY | O_NONBLOCK | __O_SYNC | O_DSYNC | \ |
Christoph Hellwig | 80f1837 | 2017-04-27 09:42:24 +0200 | [diff] [blame] | 12 | FASYNC | O_DIRECT | O_LARGEFILE | O_DIRECTORY | O_NOFOLLOW | \ |
| 13 | O_NOATIME | O_CLOEXEC | O_PATH | __O_TMPFILE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Aleksa Sarai | fddb5d4 | 2020-01-18 23:07:59 +1100 | [diff] [blame] | 15 | /* List of all valid flags for the how->upgrade_mask argument: */ |
| 16 | #define VALID_UPGRADE_FLAGS \ |
| 17 | (UPGRADE_NOWRITE | UPGRADE_NOREAD) |
| 18 | |
| 19 | /* List of all valid flags for the how->resolve argument: */ |
| 20 | #define VALID_RESOLVE_FLAGS \ |
| 21 | (RESOLVE_NO_XDEV | RESOLVE_NO_MAGICLINKS | RESOLVE_NO_SYMLINKS | \ |
| 22 | RESOLVE_BENEATH | RESOLVE_IN_ROOT) |
| 23 | |
| 24 | /* List of all open_how "versions". */ |
| 25 | #define OPEN_HOW_SIZE_VER0 24 /* sizeof first published struct */ |
| 26 | #define OPEN_HOW_SIZE_LATEST OPEN_HOW_SIZE_VER0 |
| 27 | |
Yoav Zach | ef3daed | 2005-06-23 00:09:58 -0700 | [diff] [blame] | 28 | #ifndef force_o_largefile |
Yury Norov | 942fa98 | 2018-05-16 11:18:49 +0300 | [diff] [blame] | 29 | #define force_o_largefile() (!IS_ENABLED(CONFIG_ARCH_32BIT_OFF_T)) |
Yoav Zach | ef3daed | 2005-06-23 00:09:58 -0700 | [diff] [blame] | 30 | #endif |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #if BITS_PER_LONG == 32 |
| 33 | #define IS_GETLK32(cmd) ((cmd) == F_GETLK) |
| 34 | #define IS_SETLK32(cmd) ((cmd) == F_SETLK) |
| 35 | #define IS_SETLKW32(cmd) ((cmd) == F_SETLKW) |
| 36 | #define IS_GETLK64(cmd) ((cmd) == F_GETLK64) |
| 37 | #define IS_SETLK64(cmd) ((cmd) == F_SETLK64) |
| 38 | #define IS_SETLKW64(cmd) ((cmd) == F_SETLKW64) |
| 39 | #else |
| 40 | #define IS_GETLK32(cmd) (0) |
| 41 | #define IS_SETLK32(cmd) (0) |
| 42 | #define IS_SETLKW32(cmd) (0) |
| 43 | #define IS_GETLK64(cmd) ((cmd) == F_GETLK) |
| 44 | #define IS_SETLK64(cmd) ((cmd) == F_SETLK) |
| 45 | #define IS_SETLKW64(cmd) ((cmd) == F_SETLKW) |
| 46 | #endif /* BITS_PER_LONG == 32 */ |
| 47 | |
| 48 | #define IS_GETLK(cmd) (IS_GETLK32(cmd) || IS_GETLK64(cmd)) |
| 49 | #define IS_SETLK(cmd) (IS_SETLK32(cmd) || IS_SETLK64(cmd)) |
| 50 | #define IS_SETLKW(cmd) (IS_SETLKW32(cmd) || IS_SETLKW64(cmd)) |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #endif |