VSF Documented
fcntl.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_FCNTL_H__
2#define __VSF_LINUX_FCNTL_H__
3
5
6#if VSF_LINUX_CFG_RELATIVE_PATH == ENABLED
7# include "./sys/types.h"
8#else
9# include <sys/types.h>
10#endif
11#include <stdarg.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#if VSF_LINUX_CFG_WRAPPER == ENABLED
18# define fcntl VSF_LINUX_WRAPPER(fcntl)
19# define creat VSF_LINUX_WRAPPER(creat)
20# define open VSF_LINUX_WRAPPER(open)
21# define openat VSF_LINUX_WRAPPER(openat)
22#endif
23
24#define open64 open
25
26// syscalls
27
28#define __NR_fcntl fcntl
29#define __NR_creat creat
30
31#define O_RDONLY 0x0000
32#define O_WRONLY 0x0001
33#define O_RDWR 0x0002
34#define O_ACCMODE 0x0003
35
36#define O_NONBLOCK 0x0004
37#define O_APPEND 0x0008
38#define O_DIRECTORY 0x0100
39#define O_CREAT 0x0200
40#define O_TRUNC 0x0400
41#define O_EXCL 0x0800
42#define O_CLOEXEC 0x1000
43#define O_SYNC 0x2000
44#define O_ASYNC 0x4000
45#define O_NOFOLLOW 0x8000
46#define O_NOATIME 0x800000
47#define O_LARGEFILE 0
48#define O_BINARY 0
49
50#define O_NOCTTY 0x2000
51#define O_NDELAY O_NONBLOCK
52
53#define FNONBLOCK O_NONBLOCK
54#define FNDELAY O_NDELAY
55#define FAPPEND O_APPEND
56#define FASYNC O_ASYNC
57#define FSYNC O_SYNC
58#define FCREAT O_CREAT
59#define FTRUNC O_TRUNC
60#define FEXCL O_EXCL
61#define FNOCTTY O_NOCTTY
62#define FNOFOLLOW O_NOFOLLOW
63#define FCLOEXEC O_CLOEXEC
64#define FDIRECTORY O_DIRECTORY
65#define FSYNC O_SYNC
66#define FASYNC O_ASYNC
67#define FLARGEFILE O_LARGEFILE
68#define FBINARY O_BINARY
69
70#define F_DUPFD 0
71#define F_GETFD 1
72#define F_SETFD 2
73#define F_GETFL 3
74#define F_SETFL 4
75#define F_RDLCK 5
76#define F_WRLCK 6
77#define F_UNLCK 7
78#define F_GETLK 8
79#define F_SETLK 9
80#define F_SETLKW 10
81#define F_GETOWN 11
82#define F_SETOWN 12
83#define F_GETSIG 13
84#define F_SETSIG 14
85#define F_USER 16
86// for ioctrl
87#define F_IO 16
88
89#define AT_FDCWD -100
90#define AT_SYMLINK_NOFOLLOW 0x100
91
92#define FD_CLOEXEC 1
93// internal use, indicating file is referenced by a link
94#define __FD_OPENBYLINK 31
95// __FD_READALL is used internally to indicate to read all data
96#define __FD_READALL 2
97
98struct flock {
102 short l_type;
103 short l_whence;
104};
105
106#if VSF_LINUX_APPLET_USE_FCNTL == ENABLED
109
118# ifndef __VSF_APPLET__
120# endif
121#endif
122
123#if defined(__VSF_APPLET__) && (defined(__VSF_APPLET_LIB__) || defined(__VSF_APPLET_LINUX_FCNTL_LIB__))\
124 && VSF_APPLET_CFG_ABI_PATCH != ENABLED && VSF_LINUX_APPLET_USE_FCNTL == ENABLED
125
126#ifndef VSF_LINUX_APPLET_FCNTL_VPLT
127# if VSF_LINUX_USE_APPLET == ENABLED
128# define VSF_LINUX_APPLET_FCNTL_VPLT \
129 ((vsf_linux_fcntl_vplt_t *)(VSF_LINUX_APPLET_VPLT->fcntl_vplt))
130# else
131# define VSF_LINUX_APPLET_FCNTL_VPLT \
132 ((vsf_linux_fcntl_vplt_t *)vsf_vplt((void *)0))
133# endif
134#endif
135
136#define VSF_LINUX_APPLET_FCNTL_ENTRY(__NAME) \
137 VSF_APPLET_VPLT_ENTRY_FUNC_ENTRY(VSF_LINUX_APPLET_FCNTL_VPLT, __NAME)
138#define VSF_LINUX_APPLET_FCNTL_IMP(...) \
139 VSF_APPLET_VPLT_ENTRY_FUNC_IMP(VSF_LINUX_APPLET_FCNTL_VPLT, __VA_ARGS__)
140
141VSF_LINUX_APPLET_FCNTL_IMP(__fcntl_va, int, int fd, int cmd, va_list ap) {
143 return VSF_LINUX_APPLET_FCNTL_ENTRY(__fcntl_va)(fd, cmd, ap);
144}
145VSF_LINUX_APPLET_FCNTL_IMP(__open_va, int, const char *pathname, int flags, va_list ap) {
147 return VSF_LINUX_APPLET_FCNTL_ENTRY(__open_va)(pathname, flags, ap);
148}
149VSF_LINUX_APPLET_FCNTL_IMP(__openat_va, int, int dirfd, const char *pathname, int flags, va_list ap) {
151 return VSF_LINUX_APPLET_FCNTL_ENTRY(__openat_va)(dirfd, pathname, flags, ap);
152}
153VSF_LINUX_APPLET_FCNTL_IMP(creat, int, const char *pathname, mode_t mode) {
155 return VSF_LINUX_APPLET_FCNTL_ENTRY(creat)(pathname, mode);
156}
157
158VSF_APPLET_VPLT_FUNC_DECORATOR(fcntl) int fcntl(int fd, int cmd, ...) {
159 int ret;
160
161 va_list ap;
162 va_start(ap, cmd);
163 ret = ((int (*)(int fd, int cmd, va_list ap))VSF_LINUX_APPLET_FCNTL_ENTRY(__fcntl_va))(fd, cmd, ap);
164 va_end(ap);
165 return ret;
166}
167VSF_APPLET_VPLT_FUNC_DECORATOR(open) int open(const char *pathname, int flags, ...) {
168 int ret;
169
170 va_list ap;
171 va_start(ap, flags);
172 ret = ((int (*)(const char *pathname, int flags, va_list ap))VSF_LINUX_APPLET_FCNTL_ENTRY(__open_va))(pathname, flags, ap);
173 va_end(ap);
174 return ret;
175}
176VSF_APPLET_VPLT_FUNC_DECORATOR(openat) int openat(int dirfd, const char *pathname, int flags, ...) {
177 int ret;
178
179 va_list ap;
180 va_start(ap, flags);
181 ret = ((int (*)(int dirfd, const char *pathname, int flags, va_list ap))VSF_LINUX_APPLET_FCNTL_ENTRY(__openat_va))(dirfd, pathname, flags, ap);
182 va_end(ap);
183 return ret;
184}
185
186#else // __VSF_APPLET__ && VSF_LINUX_APPLET_USE_FCNTL
187
188int __fcntl_va(int fd, int cmd, va_list ap);
189int fcntl(int fd, int cmd, ...);
190int creat(const char *pathname, mode_t mode);
191int __open_va(const char *pathname, int flags, va_list ap);
192int open(const char *pathname, int flags, ...);
193int __openat_va(int dirfd, const char *pathname, int flags, va_list ap);
194int openat(int dirfd, const char *pathname, int flags, ...);
195
196#endif // __VSF_APPLET__ && VSF_LINUX_APPLET_USE_FCNTL
197
198#ifdef __cplusplus
199}
200#endif
201
202#endif
#define creat
Definition fcntl.h:19
int __openat_va(int dirfd, const char *pathname, int flags, va_list ap)
Definition vsf_linux_fs.c:1942
int __open_va(const char *pathname, int flags, va_list ap)
Definition vsf_linux_fs.c:1925
#define openat
Definition fcntl.h:21
#define open
Definition fcntl.h:20
__VSF_VPLT_DECORATOR__ vsf_linux_fcntl_vplt_t vsf_linux_fcntl_vplt
Definition vsf_linux_fs.c:3758
#define fcntl
Definition fcntl.h:18
int __fcntl_va(int fd, int cmd, va_list ap)
Definition vsf_linux_fs.c:1984
int pid_t
Definition types.h:113
unsigned int mode_t
Definition types.h:115
long off_t
Definition types.h:123
Definition fcntl.h:98
short l_type
Definition fcntl.h:102
pid_t l_pid
Definition fcntl.h:101
off_t l_start
Definition fcntl.h:99
short l_whence
Definition fcntl.h:103
off_t l_len
Definition fcntl.h:100
Definition fcntl.h:107
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(creat)
vsf_vplt_info_t info
Definition fcntl.h:108
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(open)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(__fcntl_va)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(__open_va)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(__openat_va)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(openat)
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(fcntl)
Definition vsf_cfg.h:95
#define __VSF_VPLT_DECORATOR__
Definition vsf_cfg.h:93
#define VSF_APPLET_VPLT_ENTRY_FUNC_TRACE()
Definition vsf_cfg.h:165
#define VSF_APPLET_VPLT_FUNC_DECORATOR(__NAME)
Definition vsf_linux_applet_lib.c:1
Generated from commit: vsfteam/vsf@85be636