MKNOD(2) | System Calls Manual | MKNOD(2) |
mknod
, mknodat
— make a special file node
#include
<sys/stat.h>
int
mknod
(const char *path,
mode_t mode, dev_t dev);
int
mknodat
(int
fd, const char
*path, mode_t mode,
dev_t dev);
The device special file path is created with the major and minor device numbers extracted from mode. The access permissions of path are constrained by the umask(2) of the parent process.
If mode indicates a block or character special file, dev is a configuration-dependent specification of a character or block I/O device and the superblock of the device. If mode does not indicate a block special or character special device, dev is ignored.
mknod
()
requires super-user privileges.
The
mknodat
()
system call is equivalent to mknod
() except in the
case where path specifies a relative path. In this
case the newly created fifo file is created relative to the directory
associated with the file descriptor fd instead of the
current working directory. If mknodat
() is passed
the special value AT_FDCWD
in the
fd parameter, the current working directory is used
and the behavior is identical to a call to
mknod
().
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
mknod
() will fail and the file will be not
created if:
EACCES
]EACCES
]EDQUOT
]EDQUOT
]EEXIST
]EFAULT
]EINVAL
]EIO
]ELOOP
]ENAMETOOLONG
]{NAME_MAX}
characters or an entire path name exceeds
{PATH_MAX}
characters.ENOENT
]ENOSPC
]ENOSPC
]ENOTDIR
]EPERM
]EROFS
]In addition to the errors returned by the
mknod
(), the mknodat
()
function may fail if:
#include
<unistd.h>
The include file has changed.
A mknod
() function call appeared in
Version 6 AT&T UNIX. The
mknodat
() system call appeared in macOS 13.0.
June 4, 1993 | BSD 4 |