The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
fcntl.h File Reference

file open flags and open(). More...

#include <sys/types.h>

Go to the source code of this file.

Macros

#define O_RDONLY   0x0000
#define O_WRONLY   0x0001
#define O_RDWR   0x0002
#define O_ACCMODE   0x0003
#define O_CREAT   0x0040
#define O_EXCL   0x0080
#define O_TRUNC   0x0200
#define O_APPEND   0x0400
#define O_NONBLOCK   0x0800
#define O_DIRECTORY   0x10000
#define O_CLOEXEC   0x80000
#define AT_FDCWD   (-100)
#define AT_SYMLINK_NOFOLLOW   0x100
#define AT_REMOVEDIR   0x200
#define AT_SYMLINK_FOLLOW   0x400
#define AT_EACCESS   0x200
#define F_DUPFD   0
#define F_GETFD   1
#define F_SETFD   2
#define F_GETFL   3
#define F_SETFL   4
#define F_DUPFD_CLOEXEC   1030
#define FD_CLOEXEC   1

Functions

int openat (int dirfd, const char *path, int flags,...)
int fcntl (int fd, int cmd,...)
 control an open file descriptor.
int open (const char *path, int flags,...)
 open a file.
int creat (const char *path, mode_t mode)
 create a file, or truncate it if it exists, and open it for writing: open(path, O_WRONLY | O_CREAT | O_TRUNC, mode).

Detailed Description

file open flags and open().

the O_ values are ABI and must match the kernel side in src/kernel/vfs/file.h exactly.

Macro Definition Documentation

◆ O_RDONLY

#define O_RDONLY   0x0000

◆ O_WRONLY

#define O_WRONLY   0x0001

◆ O_RDWR

#define O_RDWR   0x0002

◆ O_ACCMODE

#define O_ACCMODE   0x0003

◆ O_CREAT

#define O_CREAT   0x0040

◆ O_EXCL

#define O_EXCL   0x0080

◆ O_TRUNC

#define O_TRUNC   0x0200

◆ O_APPEND

#define O_APPEND   0x0400

◆ O_NONBLOCK

#define O_NONBLOCK   0x0800

◆ O_DIRECTORY

#define O_DIRECTORY   0x10000

◆ O_CLOEXEC

#define O_CLOEXEC   0x80000

◆ AT_FDCWD

#define AT_FDCWD   (-100)

◆ AT_SYMLINK_NOFOLLOW

#define AT_SYMLINK_NOFOLLOW   0x100

◆ AT_REMOVEDIR

#define AT_REMOVEDIR   0x200

◆ AT_SYMLINK_FOLLOW

#define AT_SYMLINK_FOLLOW   0x400

◆ AT_EACCESS

#define AT_EACCESS   0x200

◆ F_DUPFD

#define F_DUPFD   0

◆ F_GETFD

#define F_GETFD   1

◆ F_SETFD

#define F_SETFD   2

◆ F_GETFL

#define F_GETFL   3

◆ F_SETFL

#define F_SETFL   4

◆ F_DUPFD_CLOEXEC

#define F_DUPFD_CLOEXEC   1030

◆ FD_CLOEXEC

#define FD_CLOEXEC   1

Function Documentation

◆ openat()

int openat ( int dirfd,
const char * path,
int flags,
... )

◆ fcntl()

int fcntl ( int fd,
int cmd,
... )

control an open file descriptor.

Parameters
fdthe descriptor.
cmdan F_ command.
...the command's int argument, if it takes one.
Returns
the command's result, or -1 (errno set).

◆ open()

int open ( const char * path,
int flags,
... )

open a file.

Parameters
paththe file's path.
flagsone access mode, plus creation and status flags.
...with O_CREAT, the mode_t for a new file.
Returns
the lowest free file descriptor, or -1 (errno set).

◆ creat()

int creat ( const char * path,
mode_t mode )

create a file, or truncate it if it exists, and open it for writing: open(path, O_WRONLY | O_CREAT | O_TRUNC, mode).

Returns
a file descriptor, or -1 (errno set).