mknod() — make a directory, special, or ordinary file
int mknod(const char *path, mode_t mode, dev_t dev);
system call creates a new file named by the path name pointed to by
The mode of the new file is specified by the
Symbolic constants that define the file type
and file access permission bits are found in the
header file and are used to construct the
The value of the
argument should be the bit-wise inclusive OR
of the values of the desired file type,
miscellaneous mode bits, and access permissions.
for a description of the components of the file mode.
The owner ID of the file is set to the effective-user-ID of the process.
If the set-group-ID bit of the parent directory is set,
the new file's group ID is set to the group ID of the parent directory.
Otherwise, the new file's group ID is set
to the effective-group-ID of the process.
The file access permission bits of
are modified by the process's file mode creation mask:
for each bit set in the process's file mode creation mask,
the corresponding bit in the file's mode is cleared (see
In HFS file systems, the new file is created with three base
access-control-list (ACL) entries, corresponding to the file access
permission bits (see
On JFS file systems that support access control lists, when creating
a directory or regular file, optional ACL entries are created
corresponding to the parent directory's default ACL entries (see
When creating a directory, the parent's default ACL
entries are also copied as the new directory's default ACL entries.
argument is meaningful only if
indicates a block or character special file, and is ignored otherwise.
It is an implementation- and configuration-dependent
specification of a character or block I/O device.
The value of
is created by using the
macro defined in
macro takes as arguments the major and minor device numbers,
and returns a device identification number which is of type
The value and interpretation of the major and minor device numbers
For more information, see
and the System Administration manuals for your system.
Only users having
for file types other than FIFO files.
returns the following values:
The new file is not created.
is set to indicate the error.
is set to one of the following values.
The directory in which
would be created denies write permission,
is for a FIFO file and the caller does not have
A component of the path prefix denies search permission.
The user's or group's disk quota block or inode limit
has been reached for this file system.
The named path already exists.
argument points outside the process's allocated address space.
The reliable detection of this error is implementation dependent.
Too many symbolic links were encountered in translating the path name.
The length of the specified path name exceeds
bytes, or the length of a component of the path name exceeds
is in effect.
argument is null.
A component of the path prefix does not exist.
Not enough space on the file system.
A component of the path prefix is not a directory.
The effective-user-ID of the process does not match that of a user who has
and the file type is not FIFO special.
The directory in which the file is to be created
is located on a read-only file system.
was developed by
AT&T and HP.
mknod(): SVID2, SVID3, XPG2