CREAT(2) UNIX Programmer's Manual CREAT(2) NAME creat - create a new file SYNOPSIS creat(name, mode) char *name; DESCRIPTION _C_r_e_a_t creates a new file or prepares to rewrite an existing file called _n_a_m_e, given as the address of a null-terminated string. If the file did not exist, it is given mode _m_o_d_e, as modified by the process's mode mask (see _u_m_a_s_k(2)). Also see _c_h_m_o_d(2) for the construction of the _m_o_d_e argument. If the file did exist, its mode and owner remain unchanged but it is truncated to 0 length. The file is also opened for writing, and its file descriptor is returned. The _m_o_d_e 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 mode that forbids writing. Then if a second instance of the program attempts a _c_r_e_a_t, an error is returned and the program knows that the name is unusable for the moment. RETURN VALUE Upon successful completion, a value of 0 is returned. Oth- erwise, a value of -1 is returned and _e_r_r_n_o is set to indi- cate the error. ERRORS _C_r_e_a_t will fail and the file will not be created if: [EINVAL] The path name contains a non-ASCII byte. [ENOTDIR] A component of the path prefix is not a directory. [EACCES] A component of the path prefix denies search permission. [EACCES] The directory in which the file is to be created is not writeable by the user. [EISDIR] The named file is a directory. [EROFS] The directory in which the file is to be created is on a read-only file system. [EMFILE] The maximum number of file descriptors Printed 7/30/83 1 CREAT(2) UNIX Programmer's Manual CREAT(2) allowed are already open. [ETXTBSY] The file is a pure procedure (shared text) file that is being executed. [EQUOT] The disk quota for the directory in which the file was to be created would have been exceeded. [EFAULT] _N_a_m_e points outside the process's allo- cated address space. [ELOOP] Too many symbolic links were encountered in translating the path name. SEE ALSO chmod(2), close(2), umask(2), write(2) ASSEMBLER (creat = 8.) sys creat; name; mode (file descriptor in r0) Printed 7/30/83 2