Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mknod(2) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod

exec: execl, execv, execle, execve, execlp, execvp

mkdir

umask

fs

stat.h

chmod

mkdir

and mknod

mknod

Purpose

     Creates a directory, a special file, or an ordinary file.

Syntax

     #include <sys/stat.h>

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

Description

     The mknod system call creates a new regular file, special
     file,  or directory.   The path  parameter names  the new
     file.   If  Distributed  Services is  installed  on  your
     system, this path can cross  into another node.  Also see
     "mkdir" for  additional information on creating  a direc-
     tory.

     The mode parameter specifies the  mode of the file, which
     defines the file type and access permissions.

     The dev parameter is  configuration dependent and is used
     only if the mode parameter specifies a block or character
     special file.  dev is the ID of the device, and it corre-
     sponds to the st_rdev member of the structure returned by
     the  stat system  call.  If  the  file you  specify is  a
     remote file, the dev value must be meaningful on the node
     where the  file resides.  See "stat,  fstat" and "stat.h"
     for more information about the device ID.

     The mode  parameter is  constructed logically  OR-ing the
     values  specified  in  "chmod"  with  one  the  following
     values, which define the file type:

     S_IFDIR    Directory
     S_IFCHR    Character special file
     S_IFMPX    Multiplexed character special file
     S_IFBLK    Block special file
     S_IFREG    Regular data file
     S_IFIFO    FIFO special file.

     A complete  list of  the possible  mode values  and other
     useful macros appears in "stat.h."

     The low-order  9 bits  of mode are  modified by  the file
     mode creation mask  of the process:  each bit  set in the
     creation mask  clears the  corresponding bit in  the mode
     that is  set for the  file.  (For more  information about
     the creation mask, see "umask.")

     If the type of the new file is S_IFMPX (multiplexed char-
     acter special  file), then when  the file is  used, addi-
     tional  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 file's  device driver
     for interpretation.   This provides a  multiplexed inter-
     face to  the device driver.   The hft device  driver uses
     this feature.   (See "hft" for details  about this device
     driver.)

     The file's  owner ID  is set  to the  process's effective
     user ID.   The file's  group ID is  set to  the process's
     effective group ID.

     The mknod  system call can  be invoked only  by superuser
     for file types other than FIFO special.

Return Value

     Upon successful completion, a value of 0 is returned.  If
     the mknod  system call fails,  a value of -1  is returned
     and errno is set to indicate the error.

Diagnostics

     The  mknod system  call fails  and  the new  file is  not
     created if one or more of the following are true:

     EPERM      The process's effective user  ID is not super-
                user.

     ENOTDIR    A component of the path prefix is not a direc-
                tory.

     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     The path parameter &pointsout..

     ESTALE     The  process's root  or  current directory  is
                located in a virtual file system that has been
                unmounted.

     If  Distributed Services  is  installed  on your  system,
     mknod can also  fail if one or more of  the following are
     true:

     EDIST         The   server   has  blocked   new   inbound
                   requests.

     EDIST         Outbound requests are currently blocked.

     EDIST         The server has a  release level of Distrib-
                   uted Services that  cannot communicate with
                   this node.

     EAGAIN        The  server  is  too  busy  to  accept  the
                   request.

     ESTALE        The file  descriptor for a remote  file has
                   become obsolete.

     EPERM         The translate tables of  the server did not
                   contain any entry  for either the effective
                   user  ID  or  effective  group  ID  of  the
                   calling process.

     ENODEV        The named file is  a remote file located on
                   a  device that  has been  unmounted at  the
                   server.

     ENOMEM        Either  this node  or the  server does  not
                   have enough memory available to service the
                   request.

     ENOCONNECT    An attempt to establish  a new network con-
                   nection with a remote node failed.

     EBADCONNECT   An attempt to use  an existing network con-
                   nection with a remote node failed.

Related Information

     In this  book:  "chmod,"   "exec:  execl,  execv, execle,
     execve,  execlp, execvp,"  "mkdir,"  "umask," "fs,"  and
     "stat.h."

     The  chmod, mkdir,  and mknod  commands in  AIX Operating
     System Commands Reference.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026