Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

close(2)

creat(2)

dup(2)

fcntl(2)

intro(2)

lseek(2)

read(2)

getmsg(2)

putmsg(2)

umask(2)

write(2)

CREAT(2)                             SysV                             CREAT(2)



NAME
     creat -Ccreat a file for reading or writing

SYNOPSIS
     #include <fcntl.h>
     #include <sys/stat.h>
     #include <sys/types.h>

     int creat (path, mode)
     const char *path;
     mode_t mode;

DESCRIPTION
     The creat function  creates a new ordinary file or prepares to rewrite an
     existing file named by the pathname pointed to by path.

     The creat function

          creat(path, mode);

     is equivalent to

          open (path, O_WRONLY | O_CREAT | O_TRUNC, mode);

     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
     The named file is created unless one or more of the following are true:

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

     [EAGAIN]      The file exists, mandatory file/record locking is set, and
                   there are outstanding record locks on the file (see
                   chmod(2)).

     [EFAULT]      path points outside the allocated address space of the
                   process.

     [EINTR]       A signal was caught during the creat system call.

     [EIO]         A hangup or error occurred during a STREAMS creat.

     [EISDIR]      The named file is a directory.

     [EMFILE]      NOFILES file descriptors are currently open.

     [ENFILE]      The system file table is full.

     [ENOENT]      The O_CREAT flag is not set and the named file does not
                   exist, or O_CREAT is set and the path prefix does not
                   exist, or the path argument points to the empty string.

     [ENOMEM]      The system is unable to allocate a send descriptor.

     [ENOSR]       Unable to allocate a Stream.

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

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

     [ENXIO]       A STREAMS module or driver creat routine failed.

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

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

     [ENAMETOOLONG]
                   The length of the path string exceeds PATH_MAX, or a
                   pathname component is longer than NAME_MAX.

SEE ALSO
     chmod(2), close(2), creat(2), dup(2), fcntl(2), intro(2), lseek(2),
     read(2), getmsg(2), putmsg(2), umask(2), write(2).

DIAGNOSTICS
     Upon successful completion, a nonnegative integer representing the file
     descriptor is returned.  Otherwise, a value of -1 is returned and errno
     is set as indicated under "Errors."

NOTES
     Under other implementations, creat fails if any of the following are
     true:

     [EMULTIHOP]   Components of path require hopping to multiple remote
                   machines.

     [ENOLINK]     path points to a remote machine and the link to that
                   machine is no longer active.

     [ENOSPC]      No space left on device.

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