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);
int
mknodat
(int
fd, const char
*path, mode_t mode,
dev_t dev);
The file system node path is created with the file type and access permissions specified in mode. The access permissions are modified by the process's umask value.
If mode indicates a block or character special file, dev is a configuration dependent specification denoting a particular device on the system. Otherwise, dev is ignored.
The
mknod
()
system call 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 device node 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
().
The mknod
() function returns the
value 0 if successful; otherwise the value -1 is returned and
the global variable errno is set to indicate the
error.
The mknod
() system call will fail and the
file will be not created if:
ENOTDIR
]ENAMETOOLONG
]ENOENT
]EACCES
]ELOOP
]EPERM
]EIO
]ENOSPC
]ENOSPC
]EDQUOT
]EDQUOT
]EROFS
]EEXIST
]EFAULT
]EINVAL
]In addition to the errors returned by the
mknod
(), the mknodat
() may
fail if:
The mknodat
() system call follows The Open
Group Extended API Set 2 specification.
The mknod
() function appeared in
Version 4 AT&T UNIX. The
mknodat
() system call appeared in
FreeBSD 8.0.
December 1, 2017 | Debian |