.TH OPEN 2 .UC 4 .SH NAME creat, open, mkdir, mknod \- create or open a file, special file, or directory .SH SYNOPSIS .nf .B #include .B #include .B int creat (const char *file_name, mode_t mode); .B int mknod (const char *file_name, mode_t mode, dev_t dev); .B int mkdir (const char *file_name, mode_t mode); .B int open (const char *file_name, int flag, ...); .fi .SH DESCRIPTION .B open() opens the file specified by .I file_name , with modes set according to the .I flag parameter. .PP The bit fields of .I flag are : .PP .B O_RDONLY .PP .B O_WRONLY .PP .B O_RDWR .PP .B O_CREAT - create if it doesn't exist. Note that if this flag is specified, and additional parameter .I mode_t mode must be passed to open specifying permissions on the created file. This is modified by .B umask in the usual way, with the permissions of the created file becoming ( .B ~umask & .I mode ) .PP .B O_EXCL .PP .B O_NOCTTY - not implemented. .PP .B O_TRUNC .PP .B O_APPEND .PP .B O_NONBLOCK .PP .B O_NDELAY - not implemented. .PP .B creat() is a more specific version of .B open() which is used to create .I file_name. The behavior of .B creat ( .I file_name, mode ) is the same as .PP .B open ( .I file_name, O_CREAT | O_WRONLY, O_TRUNC, .I mode ); .PP .B mkdir() is identical to .B creat(), only a directory is created instead of a normal file. .PP .B mknod() is identical to .B creat(), only .I dev specifies the device number that is associated with .I file_name .SH ERRORS .B -EACCESS is returned if the directory does not have execute permissions .PP .B -EINVAL is returned if there are no more filedescriptors available in the system or for the process. These maximums are specified in .B NR_OPEN and .B NR_FILE , both defined in .I linux/include/linux/fs.h with defaults of 20 and 64 respectively. .PP .B -EISDIR is returned if you attempt to open a directory with access flags of anything but O_RDONLY, or with O_CREATE, or O_TRUNC flags set. .PP .B -ELOOP is returned if circular links are encountered. .PP .B -ENOENT is returned if a portion of the specified path is missing. .PP .B -EPERM is returned if the permissions for the file or directory do not allow the requested action. .SH FILES linux/fs/open.c .br linux/fs/namei.c .br /usr/include/linux/sys.h .br /usr/include/unistd.h .SH SEE ALSO close(2), fopen(3), link(2), unlink(2), umask(2) .SH BUGS .B O_NCTTY , .B O_NDELAY are not yet implemented. .PP The stock distribution of linux supports a maximum of 20 open file descriptors per process, as specified in the .B NR_OPEN macro in .I linux/include/linux/fs.h . This is easily expanded to 32, but since certain internal bitmaps are implemented in 32 bit integers, further expansion will prove difficult, although changing the .B close_on_exec field of .B task_struct, which is defined in .I linux/include/linux/sched.h and other related fields to be long long instead of long will allow a maximum of 64 file descriptors per process. .PP The stock persystem limit is 64 open file descriptors, as specified in the .B NR_FILES macro in .I linux/include/linux/fs.h. This is an artificial limit, and is easily circumvented by recompiling the kernel with a larger value.