9.28 fcntl

#define F_DUPFD         1
#define F_DUPFD_CLOEXEC 2
#define F_GETFD         3
#define F_SETFD         4
#define F_GETFL         5
#define F_SETFL         6
#define F_GETPIPE_SZ    7
#define F_SETPIPE_SZ    8
#define F_GETLK         9
#define F_SETLK         10
#define F_SETLKW        11

#define FD_CLOEXEC      1

#define F_RDLCK 1
#define F_UNLCK 2
#define F_WRLCK 3

struct flock {
   uint16_t l_type;
   uint16_t l_whence;
   uint64_t l_start;
   uint64_t l_len;
   uint32_t l_pid;
}

int fcntl(int fd, int cmd, void *arg);

This syscall is a multiplexed syscall that performs the operations described below on the open file descriptor fd. The operation is determined by cmd and may take an optional argument arg.

The syscall’s return value will depend on the requested cmd, and is detailed along the operations below.

The valid operations are:

On failure, the syscall returns -1. The returned errno are: