mknod(2)
NAME
mknod − make a directory or a special file
SYNTAX
int mknod(path, mode, dev)
char *path;
int mode, dev;
DESCRIPTION
The mknod system call creates a new file whose name is path. The mode of the new file (including special file bits) is initialized from mode, where the value of mode is interpreted as follows:
0170000 file type; one of the following:
0010000 fifo special
0020000 character special
0040000 directory
0060000 block special
0100000 or 0000000 ordinary file
0004000 set user ID on execution
0002000 set group ID on execution
0001000 save text image after execution
0000777 access permissions: constructed from the following
000400 read by owner
0000200 write by owner
execute (search on directory) by owner
0000070 read, write, execute (search) by group
0000007 read, write, execute (search) by others
The file’s owner ID is set to the process’s effective user ID. The file’s group ID is set to the process’s effective group ID.
Values of mode other than those above are undefined and should not be used. The low-order 9 bits of mode are modified by the process’s file mode creation mask: all bits set in the process’s file mode creation mask are cleared. For further information, see umask(.). If mode indicates a block or character special file, dev is a configuration dependent specification of a character or block I/O device. If mode does not indicate a block special or character special device, dev is ignored.
The mknod system call may be invoked only by the super-user for file types other than FIFO special.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
DIAGNOSTICS
The mknod system call will fail and the file mode will be unchanged if:
[EPERM] The process’s effective user ID is not super-user.
[EINVAL] The pathname contains a character with the high-order bit set.
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] A component of the path prefix does not exist.
[EROFS] The named file resides on a read-only file system.
[EEXIST] The named file exists.
[EFAULT] Path points outside the process’s allocated address space.
[ELOOP] Too many symbolic links were encountered in translating the pathname.
[ENAMETOOLONG]
A component of a pathname exceeded 255 characters, or an entire pathname exceeded 1023 characters.
[EACCES] Search permission is denied for a component of the path prefix.
[EIO] An I/O error occurred while making the directory entry or allocating the inode.
[ENOSPC] The directory in which the entry for the new node is being placed cannot be extended because there is no space left on the file system.
[ENOSPC] There are no free inodes on the file system on which the node is being created.
[EDQUOT] The directory in which the entry for the new node 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 node is being created has been exhausted.
[ESTALE] The file handle given in the argument is invalid. The file referred to by that file handle no longer exists or has been revoked.
[ETIMEDOUT] A "connect" request or remote file operation failed because the connected party did not properly respond after a period of time which is dependent on the communications protocol.