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_LARGEFILE 0
47#define O_BINARY 0
48
49#define O_NOCTTY 0x2000
50#define O_NDELAY O_NONBLOCK
51
52#define FNONBLOCK O_NONBLOCK
53#define FNDELAY O_NDELAY
54#define FAPPEND O_APPEND
55#define FASYNC O_ASYNC
56#define FSYNC O_SYNC
57#define FCREAT O_CREAT
58#define FTRUNC O_TRUNC
59#define FEXCL O_EXCL
60#define FNOCTTY O_NOCTTY
61#define FNOFOLLOW O_NOFOLLOW
62#define FCLOEXEC O_CLOEXEC
63#define FDIRECTORY O_DIRECTORY
64#define FSYNC O_SYNC
65#define FASYNC O_ASYNC
66#define FLARGEFILE O_LARGEFILE
67#define FBINARY O_BINARY
68
69#define F_DUPFD 0
70#define F_GETFD 1
71#define F_SETFD 2
72#define F_GETFL 3
73#define F_SETFL 4
74#define F_RDLCK 5
75#define F_WRLCK 6
76#define F_UNLCK 7
77#define F_GETLK 8
78#define F_SETLK 9
79#define F_SETLKW 10
80#define F_GETOWN 11
81#define F_SETOWN 12
82#define F_GETSIG 13
83#define F_SETSIG 14
84#define F_USER 16
85// for ioctrl
86#define F_IO 16
87
88#define AT_FDCWD -100
89#define AT_SYMLINK_NOFOLLOW 0x100
90
91#define FD_CLOEXEC 1
92// internal use, indicating file is referenced by a link
93#define __FD_OPENBYLINK 31
94// __FD_READALL is used internally to indicate to read all data
95#define __FD_READALL 2
96
97struct flock {
101 short l_type;
102 short l_whence;
103};
104
105#if VSF_LINUX_APPLET_USE_FCNTL == ENABLED
108
117# ifndef __VSF_APPLET__
119# endif
120#endif
121
122#if defined(__VSF_APPLET__) && (defined(__VSF_APPLET_LIB__) || defined(__VSF_APPLET_LINUX_FCNTL_LIB__))\
123 && VSF_APPLET_CFG_ABI_PATCH != ENABLED && VSF_LINUX_APPLET_USE_FCNTL == ENABLED
124
125#ifndef VSF_LINUX_APPLET_FCNTL_VPLT
126# if VSF_LINUX_USE_APPLET == ENABLED
127# define VSF_LINUX_APPLET_FCNTL_VPLT \
128 ((vsf_linux_fcntl_vplt_t *)(VSF_LINUX_APPLET_VPLT->fcntl_vplt))
129# else
130# define VSF_LINUX_APPLET_FCNTL_VPLT \
131 ((vsf_linux_fcntl_vplt_t *)vsf_vplt((void *)0))
132# endif
133#endif
134
135#define VSF_LINUX_APPLET_FCNTL_ENTRY(__NAME) \
136 VSF_APPLET_VPLT_ENTRY_FUNC_ENTRY(VSF_LINUX_APPLET_FCNTL_VPLT, __NAME)
137#define VSF_LINUX_APPLET_FCNTL_IMP(...) \
138 VSF_APPLET_VPLT_ENTRY_FUNC_IMP(VSF_LINUX_APPLET_FCNTL_VPLT, __VA_ARGS__)
139
140VSF_LINUX_APPLET_FCNTL_IMP(__fcntl_va, int, int fd, int cmd, va_list ap) {
142 return VSF_LINUX_APPLET_FCNTL_ENTRY(__fcntl_va)(fd, cmd, ap);
143}
144VSF_LINUX_APPLET_FCNTL_IMP(__open_va, int, const char *pathname, int flags, va_list ap) {
146 return VSF_LINUX_APPLET_FCNTL_ENTRY(__open_va)(pathname, flags, ap);
147}
148VSF_LINUX_APPLET_FCNTL_IMP(__openat_va, int, int dirfd, const char *pathname, int flags, va_list ap) {
150 return VSF_LINUX_APPLET_FCNTL_ENTRY(__openat_va)(dirfd, pathname, flags, ap);
151}
152VSF_LINUX_APPLET_FCNTL_IMP(creat, int, const char *pathname, mode_t mode) {
154 return VSF_LINUX_APPLET_FCNTL_ENTRY(creat)(pathname, mode);
155}
156
157VSF_APPLET_VPLT_FUNC_DECORATOR(fcntl) int fcntl(int fd, int cmd, ...) {
158 int ret;
159
160 va_list ap;
161 va_start(ap, cmd);
162 ret = ((int (*)(int fd, int cmd, va_list ap))VSF_LINUX_APPLET_FCNTL_ENTRY(__fcntl_va))(fd, cmd, ap);
163 va_end(ap);
164 return ret;
165}
166VSF_APPLET_VPLT_FUNC_DECORATOR(open) int open(const char *pathname, int flags, ...) {
167 int ret;
168
169 va_list ap;
170 va_start(ap, flags);
171 ret = ((int (*)(const char *pathname, int flags, va_list ap))VSF_LINUX_APPLET_FCNTL_ENTRY(__open_va))(pathname, flags, ap);
172 va_end(ap);
173 return ret;
174}
175VSF_APPLET_VPLT_FUNC_DECORATOR(openat) int openat(int dirfd, const char *pathname, int flags, ...) {
176 int ret;
177
178 va_list ap;
179 va_start(ap, flags);
180 ret = ((int (*)(int dirfd, const char *pathname, int flags, va_list ap))VSF_LINUX_APPLET_FCNTL_ENTRY(__openat_va))(dirfd, pathname, flags, ap);
181 va_end(ap);
182 return ret;
183}
184
185#else // __VSF_APPLET__ && VSF_LINUX_APPLET_USE_FCNTL
186
187int __fcntl_va(int fd, int cmd, va_list ap);
188int fcntl(int fd, int cmd, ...);
189int creat(const char *pathname, mode_t mode);
190int __open_va(const char *pathname, int flags, va_list ap);
191int open(const char *pathname, int flags, ...);
192int __openat_va(int dirfd, const char *pathname, int flags, va_list ap);
193int openat(int dirfd, const char *pathname, int flags, ...);
194
195#endif // __VSF_APPLET__ && VSF_LINUX_APPLET_USE_FCNTL
196
197#ifdef __cplusplus
198}
199#endif
200
201#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:1858
int __open_va(const char *pathname, int flags, va_list ap)
Definition vsf_linux_fs.c:1841
#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:3582
#define fcntl
Definition fcntl.h:18
int __fcntl_va(int fd, int cmd, va_list ap)
Definition vsf_linux_fs.c:1901
int pid_t
Definition types.h:85
unsigned int mode_t
Definition types.h:87
long off_t
Definition types.h:95
Definition fcntl.h:97
short l_type
Definition fcntl.h:101
pid_t l_pid
Definition fcntl.h:100
off_t l_start
Definition fcntl.h:98
short l_whence
Definition fcntl.h:102
off_t l_len
Definition fcntl.h:99
Definition fcntl.h:106
VSF_APPLET_VPLT_ENTRY_FUNC_DEF(creat)
vsf_vplt_info_t info
Definition fcntl.h:107
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