📄 creat.2
字号:
.\" SCCSID: @(#)creat.2 2.3 5/7/87.TH creat 2.\" Last modified by BAM on 2-Aug-85 1000 .\".SH Namecreat \- create a new file.SH Syntax.nf#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>.PP#include <limits.h> /*Definition of OPEN_MAX*/creat(\fIname, mode\fP)char *\fIname\fP;mode_t \fImode\fP; .fi.SH Description.NXR "creat system call".NXA "creat system call" "open system call".NXR "file" "creating"The .PN creatsystem call creates a new file or prepares to rewrite an existing file called .IR name ,given as the address of a null-terminated string.If the file did not exist, it is givenmode.IR mode ,as modified by the process's mode mask.For further information, see .MS umask 2 .Also, see .MS chmod 2for the construction of the.I modeargument..PPIf the file did exist, its mode and owner remain unchanged,but it is truncated to zero length..PPThe file is also opened for writing, and its file descriptoris returned..PPThe.I modegiven is arbitrary; it need not allowwriting.This feature has been used in the past byprograms to construct a simple exclusive lockingmechanism. It is replaced by the O_EXCL openmode, or .MS flock 2facility..PPNo process may have more than OPEN_MAX files simultaneously..SH Return ValuesThe value \-1 is returned if an error occurs. Otherwise,the call returns a non-negative descriptor that permits onlywriting. .SH EnvironmentDiffers from the System V definition in thatELOOP and ENXIO are possible error conditions, butENFILE and ENOSPC are not..SH DiagnosticsThe.PN creatsystem callfails and the file is not created or truncated under the followingconditions:.TP 15[ENOTDIR]A component of the path prefix is not a directory..TP 15[EACCES]Search permission is denied for a component of the path prefix..TP 15[EACCES]The file does not exist, and the directoryin which it is to be created is not writable..TP 15[EACCES]The file exists, but it is unwritable..TP 15[EISDIR]The file is a directory..TP 15[EMFILE]Too many files are open..TP 15[EROFS]The named file resides on a read-only file system..TP 15[ENXIO]The file is a character special or block special file, andthe associated device does not exist..TP 15[ETXTBSY]The file is a pure procedure (shared text) file that is beingexecuted..TP 15[EFAULT]The.I namepoints outside the process's allocated address space..TP 15[ELOOP]Too many symbolic links were encountered in translating thepathname..TP 15[EOPNOTSUPP]The file is a socket, which is not implemented..TP 15[ENAMETOOLONG]A component of a pathname exceeded 255 characters, or an entirepathname exceeded 1023 characters..TP 15[ENOENT]The named file does not exist. .TP 15[ENFILE]The system file table is full..TP 15[ENOSPC]The directory in which the entry for the new file is beingplaced cannot be extended, because there is no space left onthe file system containing the directory..TP 15[ENOSPC]There are no free inodes on the file system on which thefile is being created..TP 15[EDQUOT]The directory in which the entry for the new file is being placedcannot be extended because the user's quota of disk blocks on thefile system containing the directory has been exhausted..TP 15[EDQUOT]The user's quota of inodes on the file system on which thefile is being created has been exhausted..TP 15[EIO]An I/O error occurred while making the directory entryor allocating the inode..TP 15[ESTALE]The ``file handle'' given in the argument is invalid. The filereferred to by that file handle no longer exists or has been revoked..TP 15[ETIMEDOUT]A connect request or remote file operation failedbecause the connected partydid not properly respond after a periodof time that is dependent on the communications protocol..SH See Alsoclose(2), chmod(2), open(2), umask(2), write(2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -