MKNOD(2)                                                              MKNOD(2)


NAME
     mknod - make a directory, or a special or ordinary file

C SYNOPSIS
     #include <sys/types.h>
     #include <sys/stat.h>

     int mknod (const char *path, mode_t mode, dev_t dev);

DESCRIPTION
     mknod creates a new file named by the path name pointed to by path.  The
     mode of the new file (including file type bits) is initialized from mode.
     The value of the file type bits which are permitted with this system call
     are those listed below.  The other types listed in sys/stat.h are made
     with other system calls, or are not supported by this operating system.

               S_IFIFO fifo special
               S_IFCHR character special
               S_IFBLK block special
               S_IFREG ordinary file

     All other mode bits are interpreted as described in chmod(2).

     The owner ID of the file is set to the effective user ID of the process.
     The group ID of the file is set to the effective group ID of the process
     or the group ID of the directory in which the file is being created.
     This is determined as follows:

          If the underlying filesystem was mounted with the BSD file creation
          semantics flag [see fstab(4)] or the S_ISGID bit is set [see
          chmod(2)] on the parent directory, then the group ID of the new file
          is set to the group ID of the parent directory, otherwise it is set
          to the effective group ID of the calling process.

     Values of mode other than those above are undefined and should not be
     used.  The low-order 9 bits of mode are modified by the process's file
     mode creation mask:  all bits set in the process's file mode creation
     mask are cleared [see umask(2)].  If mode indicates a block or character
     special file, dev is a configuration-dependent specification of a
     character or block I/O device.  If mode does not indicate a block special
     or character special device, dev is ignored.

     mknod may be invoked only by the super-user for file types other than
     FIFO special.

     mknod will fail and the new file will not be created if one or more of
     the following are true:

     [EPERM]          The effective user ID of the process is not super-user.


     [ENOTDIR]        A component of the path prefix is not a directory.

     [ENOENT]         A component of the path prefix does not exist.

     [EROFS]          The directory in which the file is to be created is
                      located on a read-only file system.

     [EEXIST]         The named file exists.

     [EFAULT]         Path points outside the allocated address space of the
                      process.

     [ENAMETOOLONG]   The length of the path argument exceeds {PATH_MAX}, or a
                      pathname component is longer than {NAME_MAX}.

     [ENOSPC]         The directory in which the entry for the new directory
                      is being placed cannot be extended because there is no
                      space left on the file system containing the directory
                      or the new directory cannot be created because there is
                      no space left on the file system that will contain the
                      directory or there are no free inodes on the file system
                      on which the directory is being created.

     [EDQUOT]         The directory in which the entry for the new node is
                      being placed cannot be extended either because the
                      user's quota of disk blocks on the file system
                      containing the directory has been exhausted or the
                      user's quota of inodes on the file system on which the
                      node is being created has been exhausted.

     [EINVAL]         If you create files of the type fifo special, character
                      special, or block special on an NFS-mounted file system.

SEE ALSO
     mkdir(1), chmod(2), exec(2), mkdir(2), umask(2), fstab(4)

DIAGNOSTICS
     Upon successful completion a value of 0 is returned.  Otherwise, a value
     of -1 is returned and errno is set to indicate the error.


                                                                        Page 2