MKNOD(2) SysV MKNOD(2)
NAME
mknod - make a directory, or a special or ordinary file
SYNOPSIS
int mknod (path, mode, dev)
char *path;
int mode, dev;
DESCRIPTION
mknod creates a new file with the name pointed to by path. The mode of
the new file 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
⊕ 00020#0 set group ID on execution if # is 7, 5, 3, or 1
enable mandatory file/record locking if # is 6, 4, 2, or 0
⊕ 0001000 save text image after execution
⊕ 0000777 access permissions; constructed from the following:
0000400 read by owner
0000200 write by owner
0000100 execute (search on directory) by owner
0000070 read, write, execute (search) by group
0000007 read, write, execute (search) by others
The owner ID of the file is set to the effective user ID of the process.
The group ID of the file is set to the effective group ID of the process.
Values of mode other than those above are undefined and should not be
used. The low-order nine bits of mode are modified by the process' file
mode creation mask: all bits set in the process' file mode creation mask
are cleared (see umask(2)). 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.
mknod may be invoked only by the super-user for file types other than
FIFO special.
ERRORS
mknod will fail and the new file will not be created if one or more of
the following are true:
[EPERM] The effective user ID of the process is not super-user.
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] A component of the path prefix does not exist.
[EROFS] The directory in which the file is to be created is located
on a read-only file system.
[EEXIST] The named file exists.
[EFAULT] path points outside the allocated address space of the
process.
[ENOSPC] No space is available.
[EINTR] A signal was caught during the mknod system call.
SEE ALSO
chmod(2), exec(2), umask(2).
mkdir(1) in the SysV Command Reference.
DIAGNOSTICS
A successful call returns 0. A failed call returns -1 and sets errno.
NOTES
Under other implementations, mknod fails if either of the following is
true:
[ENOLINK] path points to a remote machine and the link to that
machine is no longer active.
[EMULTIHOP] Components of path require hopping to multiple remote
machines.
If, under implementations supporting Remote File Sharing, mknod is used
to create a device in a remote directory, the major and minor device
numbers are interpreted by the server.