| MKNOD(2) | System Calls Manual | MKNOD(2) |
mknod, mknodat
— make a special file node
Standard C Library (libc, -lc)
#include
<sys/stat.h>
int
mknod(const
char *path, mode_t
mode, dev_t
dev);
#include
<sys/stat.h>
#include <fcntl.h>
int
mknodat(int
fd, const char
*path, mode_t mode,
dev_t dev);
mknod with S_IFIFO
specified in mode and 0 in dev
makes a FIFO file. This call is respectively a portable alias for
mkfifo(2) and
mkfifoat(2).
mknod with S_IFCHR
or S_IFBLK in mode makes a
device special file. The file path is created with the
major and minor device numbers specified by dev. The
access permissions of path are extracted from
mode, modified by the
umask(2) of the parent
process.
mknodat()
works the same way as mknod() except if
path is relative. In that case, it is looked up from a
directory whose file descriptor was passed as fd.
Search permission is required on this directory. fd
can be set to AT_FDCWD in order to specify the
current directory.
mknod()
requires super-user privileges for creating device special files.
The mknod() and
mknodat() functions return the value 0 if
successful; otherwise the value -1 is returned and the global
variable errno is set to indicate the error.
mknod() and
mknodat() will fail and the file will be not created
if:
EACCES]EDQUOT]EEXIST]EFAULT]EINVAL]EIO]ELOOP]ENAMETOOLONG]NAME_MAX}
characters, or an entire path name exceeded
{PATH_MAX} characters.ENOENT]ENOSPC]ENOTDIR]EOPNOTSUPP]EPERM]EROFS]In addition, mknodat() will fail if:
The mknod() function conforms to
IEEE Std 1003.1-1990 (“POSIX.1”).
mknodat() conforms to IEEE Std
1003.1-2008 (“POSIX.1”).
A mknod() function call appeared in
Version 6 AT&T UNIX.
The alias mode for mkfifo(2) and mkfifoat(2) first appeared in NetBSD 9.
| June 20, 2019 | NetBSD 11.0 |