Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ creat(2) — Ultrix-11 3.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

close(2)

fcntl(2)

umask(2)

write(2)

creat(2)

NAME

creat − create a new file

SYNTAX

int creat(name, mode)
char *name;
int mode;

DESCRIPTION

The creat system call either creates a new file or prepares to rewrite an existing file called name (address of a null-terminated string).  If the file did not exist, it is given the specified mode, as modified by the process’s mode mask. 

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 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 mode that forbids writing.  Then if a second instance of the program attempts a creat call, an error is returned and the program knows that the name is not usable for the moment. 

RETURN VALUE

If unsuccessful, returns a −1, and the global variable errno indicates the error code. 

DIAGNOSTICS

The creat call will fail if:

[EACCES] A component of the path prefix denies search permission. 

[EACCES] The directory in which name is to be created is not writable by the user. 

[EFAULT] The specified name points outside the process’s allocated address space. 

[EISDIR] The specified name is a directory. 

[EMFILE] The maximum number of file descriptors allowed are already open. 

[ENFILE] Either no more system file descriptors are available, or there is insufficient system space to contain the inode. 

[ENOSPC] The directory to contain the file cannot be extended. 

[ENOENT] An element within path, the specified name does not exist. 

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

[ENXIO] A special file within name is not for the current system (major device number is greater than “nchrdev”). 

[EROFS] The directory in which the file is to be created is on a read-only file system. 

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

ASSEMBLER

(creat = 8.) 
sys creat; name; mode
(file descriptor in r0)

SEE ALSO

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

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