mknod is a function in the GNU C library, glibc, which makes special files, such as files which correspond to devices. It is included for compatibility with 4.4BSD. Its prototype is:

int mknod(const char *filename, int mode, int dev)

where filename is the name of the special file to create, mode specifies the mode of the file (possibly including special file bits, such as S_IFCHR or S_IFBLK for character or block files), and dev is an integer specifying which device the file refers to; its interpretation varies. mknod returns 0 on success, and returns -1 on error, as well as setting errno accordingly:

  1. EPERM - only the superuser can create special files. This process is not running as the superuser.
  2. ENOSPC - No space left in filesystem or directory for the new special file.
  3. EROFS - Read-only filesystem.
  4. EEXIST - File already exists -- old file must be unlinked first.

The mknod function happens unsurprisingly to form the base for the mknod program, which in the GNU system is part of GNU coreutils.

(Information mostly paraphrased from the GNU C Library Reference Manual, which is under the GNU Free Documentation License.)

Log in or register to write something here or to contact authors.