Creates an ordinary file, first-in-first-out (FIFO), or special file.
#include <sys/stat.h>
int mknod (const char * Path, mode_t Mode, dev_t Device)
char *Path;
int Mode;
dev_t Device;
int mkfifo (const char *Path, mode_t Mode) const char *Path; int Mode;
The mknod subroutine creates a new regular file, special file, or FIFO file. Using the mknod subroutine to create file types (other than FIFO or special files) requires root user authority.
For the mknod subroutine to complete successfully, a process must have both search and write permission in the parent directory of the Path parameter.
The mkfifo subroutine is an interface to the mknod subroutine, where the new file to be created is a FIFO or special file. No special system privileges are required.
The new file has the following characteristics:
Upon successful completion, the mkfifo subroutine marks for update the st_atime, st_ctime, and st_mtime fields of the file. It also marks for update the st_ctime and st_mtime fields of the directory that contains the new entry.
If the new file is a character special file having the S_IMPX attribute (multiplexed character special file), when the file is used, additional path-name components can appear after the path name as if it were a directory. The additional part of the path name is available to the device driver of the file for interpretation. This feature provides a multiplexed interface to the device driver.
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
The mknod subroutine
fails and the new file is not created if one or more of the following are
true:
The mknod and mkfifo subroutine can be unsuccessful for other reasons. See "Appendix. A Base Operating System Error Codes for Services That Require Path-Name Resolution" (Appendix A, Base Operating System Error Codes for Services That Require Path-Name Resolution) for a list of additional errors.
If NFS is installed on the
system, the mknod subroutine can also fail if the following is
true:
ETIMEDOUT | The connection timed out. |
These subroutines are part of Base Operating System (BOS) Runtime.
The chmod (chmod or fchmod Subroutine) subroutine, mkdir (mkdir Subroutine) subroutine, open, openx, or creat (open, openx, open64, creat, or creat64 Subroutine) subroutine, statx subroutine, umask subroutine.
The chmod command, mkdir command, mknod command.
The mode.h file, types.h file.
Files, Directories, and File Systems for Programmers in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.