]> git.proxmox.com Git - wasi-libc.git/blame - libc-top-half/musl/include/fcntl.h
Update to musl 1.1.22.
[wasi-libc.git] / libc-top-half / musl / include / fcntl.h
CommitLineData
320054e8
DG
1#ifndef _FCNTL_H
2#define _FCNTL_H
3
e5f14be3 4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
320054e8
DG
5#else
6#include <__header_fcntl.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#define __NEED_off_t
15#define __NEED_pid_t
16#define __NEED_mode_t
17
18#ifdef _GNU_SOURCE
19#define __NEED_size_t
20#define __NEED_ssize_t
21#define __NEED_struct_iovec
22#endif
23
24#include <bits/alltypes.h>
25
26#include <bits/fcntl.h>
27
28struct flock {
29 short l_type;
30 short l_whence;
31 off_t l_start;
32 off_t l_len;
33 pid_t l_pid;
34};
35
36int creat(const char *, mode_t);
37int fcntl(int, int, ...);
38int open(const char *, int, ...);
39int openat(int, const char *, int, ...);
40int posix_fadvise(int, off_t, off_t, int);
41int posix_fallocate(int, off_t, off_t);
42
e5f14be3 43#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
320054e8
DG
44#define O_SEARCH O_PATH
45#define O_EXEC O_PATH
46
47#define O_ACCMODE (03|O_SEARCH)
48#define O_RDONLY 00
49#define O_WRONLY 01
50#define O_RDWR 02
51
52#define F_OFD_GETLK 36
53#define F_OFD_SETLK 37
54#define F_OFD_SETLKW 38
55
56#define F_DUPFD_CLOEXEC 1030
57
58#define F_RDLCK 0
59#define F_WRLCK 1
60#define F_UNLCK 2
61
62#define FD_CLOEXEC 1
63
64#define AT_FDCWD (-100)
65#define AT_SYMLINK_NOFOLLOW 0x100
66#define AT_REMOVEDIR 0x200
67#define AT_SYMLINK_FOLLOW 0x400
68#define AT_EACCESS 0x200
69
70#define POSIX_FADV_NORMAL 0
71#define POSIX_FADV_RANDOM 1
72#define POSIX_FADV_SEQUENTIAL 2
73#define POSIX_FADV_WILLNEED 3
f41256b6 74#ifndef POSIX_FADV_DONTNEED
320054e8
DG
75#define POSIX_FADV_DONTNEED 4
76#define POSIX_FADV_NOREUSE 5
f41256b6 77#endif
320054e8
DG
78
79#undef SEEK_SET
80#undef SEEK_CUR
81#undef SEEK_END
82#define SEEK_SET 0
83#define SEEK_CUR 1
84#define SEEK_END 2
85
86#ifndef S_IRUSR
87#define S_ISUID 04000
88#define S_ISGID 02000
89#define S_ISVTX 01000
90#define S_IRUSR 0400
91#define S_IWUSR 0200
92#define S_IXUSR 0100
93#define S_IRWXU 0700
94#define S_IRGRP 0040
95#define S_IWGRP 0020
96#define S_IXGRP 0010
97#define S_IRWXG 0070
98#define S_IROTH 0004
99#define S_IWOTH 0002
100#define S_IXOTH 0001
101#define S_IRWXO 0007
102#endif
103
104#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
105#define AT_NO_AUTOMOUNT 0x800
106#define AT_EMPTY_PATH 0x1000
107
108#define FAPPEND O_APPEND
109#define FFSYNC O_SYNC
110#define FASYNC O_ASYNC
111#define FNONBLOCK O_NONBLOCK
112#define FNDELAY O_NDELAY
113
114#define F_OK 0
115#define R_OK 4
116#define W_OK 2
117#define X_OK 1
118#define F_ULOCK 0
119#define F_LOCK 1
120#define F_TLOCK 2
121#define F_TEST 3
122
123#define F_SETLEASE 1024
124#define F_GETLEASE 1025
125#define F_NOTIFY 1026
126#define F_CANCELLK 1029
127#define F_SETPIPE_SZ 1031
128#define F_GETPIPE_SZ 1032
129#define F_ADD_SEALS 1033
130#define F_GET_SEALS 1034
131
132#define F_SEAL_SEAL 0x0001
133#define F_SEAL_SHRINK 0x0002
134#define F_SEAL_GROW 0x0004
135#define F_SEAL_WRITE 0x0008
136
137#define F_GET_RW_HINT 1035
138#define F_SET_RW_HINT 1036
139#define F_GET_FILE_RW_HINT 1037
140#define F_SET_FILE_RW_HINT 1038
141
142#define RWF_WRITE_LIFE_NOT_SET 0
143#define RWH_WRITE_LIFE_NONE 1
144#define RWH_WRITE_LIFE_SHORT 2
145#define RWH_WRITE_LIFE_MEDIUM 3
146#define RWH_WRITE_LIFE_LONG 4
147#define RWH_WRITE_LIFE_EXTREME 5
148
149#define DN_ACCESS 0x00000001
150#define DN_MODIFY 0x00000002
151#define DN_CREATE 0x00000004
152#define DN_DELETE 0x00000008
153#define DN_RENAME 0x00000010
154#define DN_ATTRIB 0x00000020
155#define DN_MULTISHOT 0x80000000
156
157int lockf(int, int, off_t);
158#endif
159#endif
160
161#if defined(_GNU_SOURCE)
9f0d8e85 162#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
320054e8
DG
163#define F_OWNER_TID 0
164#define F_OWNER_PID 1
165#define F_OWNER_PGRP 2
166#define F_OWNER_GID 2
167struct file_handle {
168 unsigned handle_bytes;
169 int handle_type;
170 unsigned char f_handle[];
171};
9f0d8e85
DG
172#endif
173#ifdef __wasilibc_unmodified_upstream /* WASI has no F_GETOWN_EX */
320054e8
DG
174struct f_owner_ex {
175 int type;
176 pid_t pid;
177};
9f0d8e85
DG
178#endif
179#ifdef __wasilibc_unmodified_upstream /* WASI has no fallocate */
320054e8
DG
180#define FALLOC_FL_KEEP_SIZE 1
181#define FALLOC_FL_PUNCH_HOLE 2
9f0d8e85
DG
182#endif
183#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
320054e8 184#define MAX_HANDLE_SZ 128
9f0d8e85
DG
185#endif
186#ifdef __wasilibc_unmodified_upstream /* WASI has no syc_file_range */
320054e8
DG
187#define SYNC_FILE_RANGE_WAIT_BEFORE 1
188#define SYNC_FILE_RANGE_WRITE 2
189#define SYNC_FILE_RANGE_WAIT_AFTER 4
9f0d8e85
DG
190#endif
191#ifdef __wasilibc_unmodified_upstream /* WASI has no splice */
320054e8
DG
192#define SPLICE_F_MOVE 1
193#define SPLICE_F_NONBLOCK 2
194#define SPLICE_F_MORE 4
195#define SPLICE_F_GIFT 8
9f0d8e85
DG
196#endif
197#ifdef __wasilibc_unmodified_upstream /* WASI has no fallocate */
320054e8
DG
198int fallocate(int, int, off_t, off_t);
199#define fallocate64 fallocate
9f0d8e85
DG
200#endif
201#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
320054e8
DG
202int name_to_handle_at(int, const char *, struct file_handle *, int *, int);
203int open_by_handle_at(int, struct file_handle *, int);
9f0d8e85
DG
204#endif
205#ifdef __wasilibc_unmodified_upstream /* WASI has no readahead */
320054e8 206ssize_t readahead(int, off_t, size_t);
9f0d8e85
DG
207#endif
208#ifdef __wasilibc_unmodified_upstream /* WASI has no splice, syc_file_range, or tee */
320054e8
DG
209int sync_file_range(int, off_t, off_t, unsigned);
210ssize_t vmsplice(int, const struct iovec *, size_t, unsigned);
211ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned);
212ssize_t tee(int, int, size_t, unsigned);
9f0d8e85 213#endif
320054e8
DG
214#define loff_t off_t
215#endif
216
217#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
9f0d8e85 218#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
320054e8
DG
219#define F_GETLK64 F_GETLK
220#define F_SETLK64 F_SETLK
221#define F_SETLKW64 F_SETLKW
222#define flock64 flock
9f0d8e85 223#endif
320054e8
DG
224#define open64 open
225#define openat64 openat
226#define creat64 creat
9f0d8e85 227#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
320054e8 228#define lockf64 lockf
9f0d8e85 229#endif
320054e8
DG
230#define posix_fadvise64 posix_fadvise
231#define posix_fallocate64 posix_fallocate
232#define off64_t off_t
233#endif
234
235#ifdef __cplusplus
236}
237#endif
238
239#endif