2022-10-10 18:45:26 +00:00
|
|
|
#ifndef _FCNTL_H
|
|
|
|
#define _FCNTL_H
|
|
|
|
|
2022-10-12 09:57:49 +00:00
|
|
|
/* Open for reading only. */
|
2022-10-10 18:45:26 +00:00
|
|
|
#define O_RDONLY 1
|
2022-10-12 09:57:49 +00:00
|
|
|
/* Open for writing only. */
|
2022-10-11 19:07:21 +00:00
|
|
|
#define O_WRONLY 2
|
2022-10-12 09:57:49 +00:00
|
|
|
/* Open for reading and writing. */
|
2022-10-11 19:07:21 +00:00
|
|
|
#define O_RDWR 3
|
2022-10-21 19:51:03 +00:00
|
|
|
/* Open without blocking. */
|
|
|
|
#define O_NONBLOCK 4
|
2022-10-22 08:28:02 +00:00
|
|
|
/* Close the opened file descriptor on a call to execve(). */
|
|
|
|
#define O_CLOEXEC 8
|
2022-10-23 12:46:27 +00:00
|
|
|
/* Refuse to open the file if it is not a directory. */
|
|
|
|
#define O_DIRECTORY 16
|
2022-10-27 05:43:55 +00:00
|
|
|
/* Truncate the file on open. */
|
|
|
|
#define O_TRUNC 32
|
|
|
|
/* Create the file if it doesn't exist. */
|
|
|
|
#define O_CREAT 64
|
|
|
|
/* Open the file for appending. */
|
|
|
|
#define O_APPEND 128
|
2022-10-27 05:55:59 +00:00
|
|
|
/* Fail to open the file if it already exists. */
|
|
|
|
#define O_EXCL 256
|
2022-10-10 18:45:26 +00:00
|
|
|
|
2022-10-15 09:16:34 +00:00
|
|
|
/* Duplicate a file descriptor. */
|
|
|
|
#define F_DUPFD 0
|
2022-10-21 16:34:31 +00:00
|
|
|
/* Is a file descriptor a TTY? */
|
|
|
|
#define F_ISTTY 1
|
2022-10-27 15:17:24 +00:00
|
|
|
/* Get the file descriptor flags. */
|
|
|
|
#define F_GETFD 2
|
|
|
|
/* Set the file descriptor flags. */
|
|
|
|
#define F_SETFD 3
|
|
|
|
|
|
|
|
/* Close the file descriptor on a call to execve(). */
|
|
|
|
#define FD_CLOEXEC 1
|
2022-10-15 09:16:34 +00:00
|
|
|
|
2022-10-10 18:45:26 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2022-10-12 09:57:49 +00:00
|
|
|
/* Opens the file specified by pathname. Returns a file descriptor on success, or -1 on error. */
|
2022-10-27 05:52:57 +00:00
|
|
|
int open(const char* pathname, int flags, ...);
|
2022-10-10 18:45:26 +00:00
|
|
|
|
2022-10-15 09:16:34 +00:00
|
|
|
/* Performs an operation on the file descriptor fd determined by cmd. */
|
|
|
|
int fcntl(int fd, int cmd, ...);
|
|
|
|
|
2022-10-10 18:45:26 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|