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)                             BSD                              CREAT(2)



NAME
     creat - create a new file

SYNOPSIS
     creat(name, mode)
     char *name;

DESCRIPTION
     This interface is 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 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 it is
     truncated to zero length.

     The file is also opened for writing, and its file descriptor is returned.

     A new file created by creat will have its st_atime, st_mtime, st_ctime
     (UNIX system-modified, accessed, attributes-changed times) all set to
     identical values.

ERRORS
     creat will fail and the file will not be created or truncated if any of
     the following occur:

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

     [ENAMETOOLONG]   A component of a pathname exceeded 255 characters, or an
                      entire pathname exceeded 1023 characters.

     [ENOENT]         The named file does not exist or path points to an empty
                      string.

     [ELOOP]          Too many symbolic links were encountered in translating
                      the pathname.

     [EACCES]         Search permission is denied for a component of the path
                      prefix.

     [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.

     [ENFILE]         The system file table is full.

     [ENOSPC]         The directory in which the entry for the new file is
                      being placed cannot be extended because there is no
                      space left on the file system containing the directory.

     [ENOSPC]         There are no free inodes on the file system on which the
                      file is being created.

     [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.

     [EIO]            An I/O error occurred while making the directory entry
                      or allocating the inode.

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

     [EDQUOT]         The directory in which the entry for the new file is
                      being placed cannot be extended because the user's quota
                      of disk blocks on the file system containing the
                      directory has been exhausted.

     [EDQUOT]         The user's quota of inodes on the file system on which
                      the file is being created has been exhausted.


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

DIAGNOSTICS
     A successful call returns a non-negative integer file descriptor that
     only permits writing.  A failed call returns -1 and sets errno to
     indicate the error.

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

     Some implementations also define the following error:

     [EINVAL]         The pathname contains a character with the high-order
                      bit set.

     [EDQUOT]         The directory in which the entry for the new file is
                      being placed cannot be extended because the user's quota
                      of disk blocks on the file system containing the
                      directory has been exhausted.

     [EDQUOT]         The user's quota of inodes on the file system on which
                      the file is being created has been exhausted.

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