NAME
open_write_closeat, open_write_close, open_writev_closeat, open_writev_close - open, write & close a file
SYNOPSIS
#include <limb/unix-transactional.h>
int open_write_closeat(int fd, const char *file, const char *data, size_t dlen) int open_write_close(const char *file, const char *data, size_t dlen) int open_writev_closeat(int fd, const char *file, const struct iovec *v, unsigned n) int open_writev_close(const char *file, const struct iovec *v, unsigned n)
DESCRIPTION
The open_write_closeat() function will write the data pointed by data of
length dlen bytes into a file named file. If file describes a relative
path, it is relative to the directory associated with the file descriptor fd,
which may be AT_FDCWD to use the current working directory.
It actually creates a new temporary file into which all data is written first,
and then renames it to file. As such, any error will leave any previously
existing file of the same name unchanged (and the temporary file will have been
removed).
The open_write_close() macro is similar to open_write_closeat() except
relative paths are relative to the current working directory.
The open_writev_closeat() function is similar to open_write_closeat(),
except the data to be written will be gathered from the array pointed by v of
n vectors.
The open_writev_close() macro is similar to open_writev_closeat() except
relative paths are relative to the current working directory.
RETURN VALUE
These functions return 1 on success. Otherwise they return 0 and set errno to
indicate the error.
ERRORS
These functions may fail and set errno for the errors described for
open_tmpat(3) and renameat(3).
The open_write_close() and open_write_closeat() functions may also fail and
set errno for the errors described for allwrite(3).
The open_writev_close() and open_writev_closeat() functions may also fail
and set errno for the errors described for allwritev(3).