1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2014 Cyril Hrubis <chrubis@suse.cz> 4 */ 5 6 #ifndef LAPI_FCNTL_H__ 7 #define LAPI_FCNTL_H__ 8 9 #include "config.h" 10 #include <fcntl.h> 11 #include <sys/socket.h> 12 13 #ifndef O_DIRECT 14 # define O_DIRECT 040000 15 #endif 16 17 #ifndef O_CLOEXEC 18 # define O_CLOEXEC 02000000 19 #endif 20 21 #ifndef SOCK_CLOEXEC 22 # define SOCK_CLOEXEC O_CLOEXEC 23 #endif 24 25 #ifndef SOCK_NONBLOCK 26 # define SOCK_NONBLOCK O_NONBLOCK 27 #endif 28 29 #ifndef O_TMPFILE 30 # define O_TMPFILE (020000000 | O_DIRECTORY) 31 #endif 32 33 #ifndef F_DUPFD_CLOEXEC 34 # define F_DUPFD_CLOEXEC 1030 35 #endif 36 37 #ifndef F_SETPIPE_SZ 38 # define F_SETPIPE_SZ 1031 39 #endif 40 41 #ifndef F_GETPIPE_SZ 42 # define F_GETPIPE_SZ 1032 43 #endif 44 45 /* 46 * Set/Get seals 47 */ 48 #ifndef F_ADD_SEALS 49 # define F_ADD_SEALS (1033) 50 #endif 51 52 #ifndef F_GET_SEALS 53 # define F_GET_SEALS (1034) 54 #endif 55 56 #ifndef F_SEAL_SEAL 57 # define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ 58 #endif 59 60 #ifndef F_SEAL_SHRINK 61 # define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ 62 #endif 63 #ifndef F_SEAL_GROW 64 # define F_SEAL_GROW 0x0004 /* prevent file from growing */ 65 #endif 66 #ifndef F_SEAL_WRITE 67 # define F_SEAL_WRITE 0x0008 /* prevent writes */ 68 #endif 69 70 #ifndef F_OWNER_PGRP 71 # define F_OWNER_PGRP 2 72 #endif 73 74 #ifndef F_OFD_GETLK 75 # define F_OFD_GETLK 36 76 #endif 77 78 #ifndef F_OFD_SETLK 79 # define F_OFD_SETLK 37 80 #endif 81 82 #ifndef F_OFD_SETLKW 83 # define F_OFD_SETLKW 38 84 #endif 85 86 #ifndef AT_FDCWD 87 # define AT_FDCWD -100 88 #endif 89 90 #ifndef AT_SYMLINK_FOLLOW 91 # define AT_SYMLINK_FOLLOW 0x400 92 #endif 93 94 #ifndef AT_SYMLINK_NOFOLLOW 95 # define AT_SYMLINK_NOFOLLOW 0x100 96 #endif 97 98 #ifndef AT_EMPTY_PATH 99 # define AT_EMPTY_PATH 0x1000 100 #endif 101 102 #ifndef AT_REMOVEDIR 103 # define AT_REMOVEDIR 0x200 104 #endif 105 106 #ifndef O_NOATIME 107 # define O_NOATIME 01000000 108 #endif 109 110 #ifndef O_PATH 111 # ifdef __sparc__ 112 # define O_PATH 0x1000000 113 # else 114 # define O_PATH 010000000 115 # endif 116 #endif 117 118 #ifndef FALLOC_FL_KEEP_SIZE 119 # define FALLOC_FL_KEEP_SIZE 1 120 #endif 121 122 #ifndef RENAME_NOREPLACE 123 # define RENAME_NOREPLACE (1 << 0) 124 #endif 125 126 #ifndef RENAME_EXCHANGE 127 # define RENAME_EXCHANGE (1 << 1) 128 #endif 129 130 #ifndef RENAME_WHITEOUT 131 # define RENAME_WHITEOUT (1 << 2) 132 #endif 133 134 /* splice, vmsplice, tee */ 135 136 #ifndef SPLICE_F_NONBLOCK 137 # define SPLICE_F_NONBLOCK 2 138 #endif 139 140 #ifndef MAX_HANDLE_SZ 141 # define MAX_HANDLE_SZ 128 142 #endif 143 144 #define TST_OPEN_NEEDS_MODE(oflag) \ 145 (((oflag) & O_CREAT) != 0 || ((oflag) & O_TMPFILE) == O_TMPFILE) 146 147 #ifndef HAVE_STRUCT_FILE_HANDLE 148 struct file_handle { 149 unsigned int handle_bytes; 150 int handle_type; 151 /* File identifier. */ 152 unsigned char f_handle[0]; 153 }; 154 #endif /* HAVE_STRUCT_FILE_HANDLE */ 155 156 #endif /* LAPI_FCNTL_H__ */ 157