mknod(2)
NAME
mknod − make a directory or a special file
SYNTAX
int mknod(name, mode, addr)
char *name;
int mode, addr;
DESCRIPTION
The mknod system call creates the new directory or special file specified by name (null terminated string). The mode of the new file (including directory and special file bits) is initialized from mode. The protection part of the mode is modified by the mode mask of the process. For further information, see umask(2). The value of mode created by a bitwise or of the following:
0170000 file type:
0010000 fifo special
0020000 character special
0040000 directory
0060000 block special
0120000 symbolic link
0100000 or 0000000 ordinary file
0004000 set user ID on execution
0002000 set group ID on execution
0001000 save text image after execution
0000777 mode permissions:
0000400 read by owner
0000200 write by owner
0000100 execute (search on directory) by owner
0000040 read by group
0000020 write by group
0000010 execute (search on directory) by group
0000004 read by other
0000002 write by other
0000001 execute (search on directory) by other
The first block pointer of the inode is initialized from addr. For ordinary files and directories, addr is normally zero. In the case of a special file, addr specifies which special file.
RESTRICTIONS
The mknod call may be invoked only by the superuser for file types other than FIFO special.
RETURN VALUE
If unsuccessful, returns a −1, and the global variable errno indicates the error code.
DIAGNOSTICS
The mknod call will fail if:
[EACCES] Access to a directory file denied.
[EACCES] A component of the path prefix denies search permission.
[EEXIST] The named file exists.
[EFAULT] The specified name points outside the allocated address space of the process.
[ENOENT] A component of the path prefix does not exist.
[ENOTDIR] A component of the path prefix is not a directory.
[ENOSPC] No inodes are available on the device.
[EPERM] The effective user ID does not match the owner of the file, and the effective user ID is not the superuser.
[EROFS] The named file resides on a read-only file system.
ASSEMBLER
(mknod = 14.)
sys mknod; name; mode; addr