man(1) Manual page archive

sys-creat(2) - Unix First Edition Manual Page
11/3/71SYS_CREAT (II)

NAME creat -- create a new file
SYNOPSIS sys creat; name; mode / creat = 8.(file descriptor in r0)

DESCRIPTION creat creates a new file or prepares to rewrite anexisting file called name; name is the address of a null--

terminated string. If the file did not exist, it is givenmode mode; if it did exist, its mode and owner remain unchanged but it is truncated to 0 length. The file is also opened for writing, and its filedescriptor is returned in r0.

The mode given is arbitrary; it need not allow writing.This feature is used by programs which deal with temporary files of fixed names. The creation is done with a modethat forbids writing. Then if a second instance of the program attempts a creat, an error is returned and theprogram knows that the name is unusable for the moment. If the last link to an open file is removed, the file isnot destroyed until the file is closed.

SEE_ALSO write, close
DIAGNOSTICS The error bit (c--bit) may be set if: a needed directory isnot readable; the file does not exist and the directory in

which it is to be created is not writable; the file doesexist and is unwritable; the file is a directory.

OWNER ken, dmr