Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / djbunix.h / open_read.3.md

% limb manual
% open_read(3)
% limb 0.1.0
% 2023-07-24

# NAME

open_read, open_readat, open_readb, open_readatb, openb_read, openb_readat,
openbc_read, openbc_readat, openc_read, openc_readat, openc_readb,
openc_readatb - open a file for reading

open_write, open_writeat, open_writeb, open_writeatb, openb_write,
openb_writeat, openbc_write, openbc_writeat, openc_write, openc_writeat,
openc_writeb, openc_writeatb, open_create, open_createat, openc_create,
openc_createat, open_excl, open_exclat, openc_excl, openc_exclat, open_append,
open_appendat, openc_append, openc_appendat, open_trunc, open_truncat,
openc_trunc, openc_truncat - open a file for writing

# SYNOPSIS

    #include <limb/djbunix.h>

```pre hl
int open_read(const char *<em>file</em>)
int open_readat(int <em>fd</em>, const char *<em>file</em>)
int open_readb(const char *<em>file</em>)
int open_readatb(int <em>fd</em>, const char *<em>file</em>)
int openb_read(const char *<em>file</em>)
int openb_readat(int <em>fd</em>, const char *<em>file</em>)
int openbc_read(const char *<em>file</em>)
int openbc_readat(int <em>fd</em>, const char *<em>file</em>)
int openc_read(const char *<em>file</em>)
int openc_readat(int <em>fd</em>, const char *<em>file</em>)
int openc_readb(const char *<em>file</em>)
int openc_readatb(int <em>fd</em>, const char *<em>file</em>)

int open_write(const char *<em>file</em>)
int open_writeat(int <em>fd</em>, const char *<em>file</em>)
int open_writeb(const char *<em>file</em>)
int open_writeatb(int <em>fd</em>, const char *<em>file</em>)
int openb_write(const char *<em>file</em>)
int openb_writeat(int <em>fd</em>, const char *<em>file</em>)
int openbc_write(const char *<em>file</em>)
int openbc_writeat(int <em>fd</em>, const char *<em>file</em>)
int openc_write(const char *<em>file</em>)
int openc_writeat(int <em>fd</em>, const char *<em>file</em>)
int openc_writeb(const char *<em>file</em>)
int openc_writeatb(int <em>fd</em>, const char *<em>file</em>)

int open_create(const char *<em>file</em>)
int open_createat(int <em>fd</em>, const char *<em>file</em>)
int openc_create(const char *<em>file</em>)
int openc_createat(int <em>fd</em>, const char *<em>file</em>)

int open_excl(const char *<em>file</em>)
int open_exclat(int <em>fd</em>, const char *<em>file</em>)
int openc_excl(const char *<em>file</em>)
int openc_exclat(int <em>fd</em>, const char *<em>file</em>)

int open_append(const char *<em>file</em>)
int open_appendat(int <em>fd</em>, const char *<em>file</em>)
int openc_append(const char *<em>file</em>)
int openc_appendat(int <em>fd</em>, const char *<em>file</em>)

int open_trunc(const char *<em>file</em>)
int open_truncat(int <em>fd</em>, const char *<em>file</em>)
int openc_trunc(const char *<em>file</em>)
int openc_truncat(int <em>fd</em>, const char *<em>file</em>)
```

# DESCRIPTION

## Open for reading

The `open_read`() function opens the file whose name is pointed by `file` for
reading in non-blocking mode, i.e. with *O_NONBLOCK* set.

The `open_readat`() function is similar to `open_read`() except when `file` is a
relative path, in which case it is relative to the directory associated with the
file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

The `open_readb`() function is similar to `open_read`() but clears *O_NONBLOCK*
/after/ opening.

The `open_readatb`() function is similar to `open_readb`() except when `file` is
a relative path, in which case it is relative to the directory associated with
the file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

The `openb_read`() function is similar to `open_read`() but it opens the file in
blocking mode, i.e. with *O_NONBLOCK* clear.

The `openb_readat`() function is similar to `openb_read`() except when `file` is
a relative path, in which case it is relative to the directory associated with
the file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

The `openbc_read`() function is similar to `openb_read`(3) but it opens the file
with *O_CLOEXEC* set.

The `openbc_readat`() function is similar to `openbc_read`() except when `file`
is a relative path, in which case it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

The `openc_read`() function is similar to `open_read`() but with it opens the
file with *O_CLOEXEC* set.

The `openc_readat`() function is similar to `openc_read`() except when `file` is
a relative path, in which case it is relative to the directory associated with
the file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

The `openc_readb`() function is similar to `openc_read`() but clears
*O_NONBLOCK* after opening.

The `openc_readatb`() function is similar to `openc_readb`() except when `file`
is a relative path, in which case it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

## Open for writing

The `open_write`() function opens the file whose name is pointed by `file` for
writing in non-blocking mode, i.e. with *O_NONBLOCK* set.

The `open_writeat`() function is similar to `open_write`() except when `file` is
a relative path, in which case it is relative to the directory associated with
the file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

The `open_writeb`() function is similar to `open_write`() but clears
*O_NONBLOCK* after opening.

The `open_writeatb`() function is similar to `open_writeb`() except when `file`
is a relative path, in which case it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

The `openb_write`() function is similar to `open_write`() but it opens the file
in blocking mode, i.e. with *O_NONBLOCK* clear.

The `openb_writeat`() function is similar to `openb_write`() except when `file`
is a relative path, in which case it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

The `openbc_write`() function is similar to `openb_write`() but with *O_CLOEXEC*
set.

The `openbc_writeat`() function is similar to `openbc_write`() except when
`file` is a relative path, in which case it is relative to the directory
associated with the file descriptor `fd`, which may be *AT_FDCWD* to use the
current working directory.

The `openc_write`() function is similar to `open_write`() but with *O_CLOEXEC*
set.

The `openc_writeat`() function is similar to `openc_write`() except when `file`
is a relative path, in which case it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

The `openc_writeb`() function is similar to `openc_write`() but clears
*O_NONBLOCK* after opening.

The `openc_writeatb`() function is similar to `openc_writeb`() except when
`file` is a relative path, in which case it is relative to the directory
associated with the file descriptor `fd`, which may be *AT_FDCWD* to use the
current working directory.

### Creating file if needed

The `open_create`() function is similar to `open_write`() but it creates the
file if it doesn't exist.

The `open_createat`() function is similar to `open_create`() except when `file`
is a relative path, in which case it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

The `openc_create`() function is similar to `open_create`() but with *O_CLOEXEC*
set.

The `openc_createat`() function is similar to `openc_create`() except when
`file` is a relative path, in which case it is relative to the directory
associated with the file descriptor `fd`, which may be *AT_FDCWD* to use the
current working directory.

### Creating file or failing

The `open_excl`() function is similar to `open_create`() but it fails if the
file exists.

The `open_exclat`() function is similar to `open_excl`() except when `file` is a
relative path, in which case it is relative to the directory associated with the
file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

The `openc_excl`() function is similar to `open_excl`() but with *O_CLOEXEC*
set.

The `openc_exclat`() function is similar to `openc_excl`() except when `file` is
a relative path, in which case it is relative to the directory associated with
the file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

### Creating file and/or in append mode

The `open_append`() function is similar to `open_create`(3 but the file is
opened in append-mode (i.e. it has *O_APPEND* set).

The `open_appendat`() function is similar to `open_append`() except when `file`
is a relative path, in which case it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

The `openc_append`() function is similar to `open_append`() but with *O_CLOEXEC*
set.

The `openc_appendat`() function is similar to `openc_append`() except when
`file` is a relative path, in which case it is relative to the directory
associated with the file descriptor `fd`, which may be *AT_FDCWD* to use the
current working directory.

### Creating file or truncating

The `open_trunc`() function is similar to `open_create`() but it truncates the
file if it exists.

The `open_truncat`() function is similar to `open_trunc`() except when `file` is
a relative path, in which case it is relative to the directory associated with
the file descriptor `fd`, which may be *AT_FDCWD* to use the current working
directory.

The `openc_trunc`() function is similar to `open_trunc`() but with *O_CLOEXEC*
set.

The `openc_truncat`() function is similar to `openc_trunc`() except when `file`
is a relative path, in which case it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

# RETURN VALUE

These functions return the opened file descriptor on success. Otherwise they
return -1 and set `errno` to indicate the error.

# ERRORS

The `open_*at{,b}`() family of functions may fail and set `errno` for any of the
errors described for [openat](3); the other functions may fail and set `errno`
for any of the errors described for [open](3).

The `open_*b`() family of functions may also fail and set `errno` for any of the
errors described for [ndelay_off](3).