up | Inhaltsverzeichniss | Kommentar

Manual page for CREAT(2)

creat - create a new file or rewrite an existing one

SYNOPSIS

#include <sys/file.h>
#include <sys/stat.h>
#include <fcntl.h>

int creat(const char *path, mode_t mode);

DESCRIPTION

The creat function creates a new file or prepares to rewrite an existing file whose pathname is given by path. If the file did not exist previously, then the file is created with permission bits set to the value of the mode argument, modified by the process's mode mask (see umask.2 Also see chmod.2 for the construction of the mode argument.

The created file is opened for writing, and its file descriptor is returned. If the file already existed, its mode and owner remain unchanged but it is truncated to zero length.

The function call:

creat(path, mode);

is equivalent to:

open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);

RETURN VALUE

Upon successful completion, creat returns a nonnegative integer representing the lowest numbered unused file descriptor. Otherwise, the function returns -1 and sets errno to indicate the error.

ERRORS

See open.2 for possible error conditions and errno values.

SEE ALSO

chmod(2), close(2), open(2), umask(2), write(2)


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97