Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ creat(2) — A/UX 3.0.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

close(2)

dup(2)

fcntl(2)

lseek(2)

open(2)

read(2)

umask(2)

write(2)




creat(2) creat(2)
NAME creat - creates a new file or rewrites an existing one SYNOPSIS #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int creat(path, mode) char *path; mode mode; DESCRIPTION creat creates a new ordinary file or prepares to rewrite an existing file named by the pathname pointed to by path. If the file exists, the length is truncated to 0, and the mode and owner are unchanged. Otherwise, the owner ID of the file is set to the effective user ID of the process, the group ID of the process is set to the effective group ID of the process, and the low-order 12 bits of the file mode are set to the value of mode, modified as follows: ⊕ All bits set in the file-mode-creation mask of the process are cleared. See umask(2). ⊕ Mode bit 01000 (save-text-image-after-execution bit) is cleared. See chmod(2). For the POSIX environment, the following constants for mode are defined in <sys/stat.h>: S_IRUSR read permission, owner S_IWUSR write permission, owner S_IXUSR execute/search permission, owner S_IRGRP read permission, group S_IWGRP write permission, group S_IXGRP execute/search permission, group S_IROTH read permission, others January 1992 1



creat(2) creat(2)
S_IWOTH write permission, others S_IXOTH execute/search permission, others On successful completion, the file descriptor is returned and the file is open for writing, even if the mode does not permit writing. The file pointer is set to the beginning of the file. The file descriptor is set to remain open across exec system calls (see fcntl(2)). No process can have more than the maximum number of files, OPEN_MAX, open simultaneously. mode is arbitrary; it need not allow writing. This feature is used by programs that 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 operation, an error is returned, and the program knows that the name is unusable for the moment. STATUS MESSAGES AND VALUES On successful completion, a nonnegative integer, namely the file descriptor, is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. The creat command will fail if one or more of the following conditions is true: ENOTDIR A component of the path prefix is not a directory. ENAMETOOLONG A component of a pathname exceeded NAME_MAX characters, or an entire pathname exceeded PATH_MAX. ELOOP Too many symbolic links were encountered in translating a pathname. ENOENT A component of the path prefix does not exist. EACCES Search permission is denied on a component of the path prefix. ENOENT The pathname is null. EACCES The file does not exist, and the directory in which the 2 January 1992



creat(2) creat(2)
file is to be created does not permit writing. EROFS The named file resides or would reside on a read-only file system. ETXTBSY The file is a pure-procedure (shared-text) file that is being executed. Note: If you are running the Network File System (NFS) and you are accessing a shared binary remotely, it is possible that you will not get this errno result. EACCES The file exists, and write permission is denied. EISDIR The named file is an existing directory. EMFILE The maximum number of file descriptors is currently open. EFAULT path points outside the allocated address space of the process. ENFILE The system-file table is full. LIMITATIONS The system-scheduling algorithm does not make creat a true uninterruptible operation, and a race condition may develop if creat is executed at precisely the same time by two different processes. SEE ALSO chmod(2), close(2), dup(2), fcntl(2), lseek(2), open(2), read(2), umask(2), write(2) January 1992 3

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