mknod(3)mknod(3)NAMEmknod - makes a directory, or a special or ordinary file.
SYNOPSIS
#include <sys/types.h> #include <sys/stat.h>
int mknod (const char *path, mode_t mode, dev_t dev );
LIBRARY
SVR4 Library (libsvr4)
PARAMETERS
Names the new file. If the final component of the path parameter names
a symbolic link, the link will be traversed and pathname resolution
will continue. Specifies the file type, attributes, and access permis‐
sions. This parameter is constructed by logically ORing values
described in the sys/mode.h header file. Depends upon the configura‐
tion and is used only if the mode parameter specifies a block or char‐
acter special file. If the file you specify is a remote file, the
value of the device parameter must be meaningful on the node where the
file resides.
DESCRIPTION
The mknod() function creates a new file named by the path name pointed
to by the path. The file type and permissions of the new file are ini‐
tialized from mode.
The file type is specified in mode by the S_IFMT bits, which must be
set to one of the following values:
The file access permissions are specified in mode by the 0007777 bits,
and may be constructed by an OR of the following values:
────────────────────────────────────────────────────────────
Octal Value Symbolic Mode Meaning
────────────────────────────────────────────────────────────
S_ISUID 04000 Set user ID on execution
S_ISGID 020#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.
S_ISVTX 01000 Save text image after execu‐
tion
S_IRWXU 00700 Read, write, execute by owner
S_IRUSR 00400 Read by owner
S_IWUSR 02000 Write by owner
S_IXUSR 00100 Execute (search if a direc‐
tory) by owner
S_IRWXG 00070 Read, write execute by group
S_IRGRP 00040 Read by Group
S_IWGRP 00020 Write by Group
S_IXGRP 00010 Execute by Group
S_IRWXO 00007 Read, write, execute,
(search) by others
S_IROTH 00004 Read by others
S_IWOTH 00002 Write by others
S_IXOTH 00001 Execute 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. However, if the S_ISGID bit is set in the parent direc‐
tory, then the group ID of the file is inherited from the parent. If
the group ID of the new file does not match the effective group ID or
one of the supplementary group IDs, the S_ISGID bit is cleared.
RETURN VALUES
Success. Failure.
ERRORS
If the mknod() function fails, the new file is not created and errno
may be set to one of the following values: A component of the path pre‐
fix denies search permission, or write permission is denied on the par‐
ent directory of the FIFO to be created. The directory in which the
entry for the new link is being placed cannot be extended because the
user's quota of disk blocks or inodes on the file system is exhausted.
The named file exists. While accessing the file system, an I/O error
occurred. An invalid argument has been specified. The length of the
path parameter exceeds PATH_MAX or a pathname component is longer than
NAME_MAX. A component of the path prefix does not exist or the path
parameter points to an empty string. The directory that would contain
the new file cannot be extended or the file system is out of file allo‐
cation resources. A component of the path prefix is not a directory.
The mode parameter specifies a file type other than FIFO and the call‐
ing process does not have the sufficient privilege. The directory in
which the file is to be created is located on a read-only file system.
The process is attempting to create a non-FIFO special file and does
not have the mknod effective privilege. The process does not have
write permission to the parent directory with respect to one of the
system's configured access policies. The process possesses the allow‐
macaccess privilege but its sensitivity label does not dominate that of
the parent directory. The process has a WILDCARD sensitivity label but
does not possess the allowmacaccess effective privilege. The process
posssesses the allowmacaccess effective privilege but does not possess
ilnofloat and the process information level would cause the directory
information label to float such that it is no longer dominated by its
sensitivity level.
RELATED INFORMATION
Functions: chmod(2), mkdir(2), open(2), umask(2), stat(2)
Commands: chmod(1), mkdir(1)mknod(3)