Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)

write(2)

close(2)

chmod(2)

umask(2)

CREAT(2)

NAME

creat − create a new file

USAGE

creat(name, mode)
char *name;

DESCRIPTION

This interface has been made obsolete by open(2). 

Creat creates a new file or prepares to rewrite an existing file called name, given as the address of a null-terminated string.  If the file did not exist, it is created with mode, as modified by the process’ mode mask (see umask(2)).  Also see chmod(2) for the construction of the mode argument. 

If the file did exist, its mode and owner remain unchanged, but its contents are discarded.  (The file is truncated to zero length.)  The file is also opened for writing, and its file descriptor is returned. 

NOTES

The mode given is arbitrary; it need not allow writing.  In the past, a mode did not allow writing let programs construct a simple exclusive locking mechanism.  This function has been replaced by the O_EXCL open mode, or flock(2) facility. 

DOMAIN/IX does not recognize write-only files, i.e., modes with 2 in either the owner, group, or others position.  DOMAIN/IX will act as if the file is readable, even if mode is set to 2.  However, it does change the mode to include read permission for the owner.  See chmod(2). 

RETURN VALUE

The value −1 is returned if an error occurs.  Otherwise, the call returns a non-negative descriptor that only permits writing. 

ERRORS

Creat will fail and the file will not be created or truncated if one of the following occur:

[EPERM] The argument contains a byte with the high-order bit set. 

[ENOTDIR] A component of the path prefix is not a directory. 

[EACCES] A needed directory does not have search permission. 

[EACCES] The file does not exist and the directory in which it would be created is not writable. 

[EACCES] The file exists, but it is unwritable. 

[EISDIR] The file is a directory. 

[EMFILE] There are already too many files open. 

[EROFS] The named file resides on a read-only file system. 

[ENXIO] The file is a character-special or block-special file, and the associated device does not exist. 

[ETXTBSY] The file is a pure procedure (shared text) file that is being executed. 

[EFAULT] Name points outside the process’ allocated address space. 

[ELOOP] The call encountered too many symbolic links in translating the pathname. 

[EOPNOTSUPP]
The file was a socket (not currently implemented).

RELATED INFORMATION

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

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026