


MKDIR(2V)                 SYSTEM CALLS                  MKDIR(2V)



NAME
     mkdir - make a directory file

SYNOPSIS
     int mkdir(path, mode)
     char *path;
     int mode;

SYSTEM V SYNOPSIS
     #include <sys/types.h>
     #include <sys/stat.h>

     int mkdir(path, mode)
     char *path;
     mode_t mode;

DESCRIPTION
     mkdir() creates a new directory file with  name  _p_a_t_h.   The
     mode mask of the new directory is initialized from _m_o_d_e.

     The low-order 9 bits of _m_o_d_e (the file  access  permissions)
     are  modified  such  that all bits set in the process's file
     mode creation mask are cleared (see umask(2V)).

     The set-GID bit of _m_o_d_e is ignored.  The set-GID bit of  the
     new file is inherited from that of the parent directory.

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

     The directory's group ID is set to either:

          o+  the effective  group  ID  of  the  process,  if  the
             filesystem  was  not  mounted  with  the  BSD  file-
             creation semantics  flag  (see  mount(2V))  and  the
             set-GID bit of the parent directory is clear, or

          o+  the group ID of the directory in which the  file  is
             created.

     Upon successful completion, mkdir()  marks  for  update  the
     st_atime,  st_ctime,  and  st_mtime  fields of the directory
     (see stat(2V)).  The st_ctime and  st_mtime  fields  of  the
     directory's parent directory are also marked for update.

RETURN VALUES
     mkdir() returns:

     0    on success.

     -1   on failure and sets errno to indicate the error.




Sun Release 4.1   Last change: 21 January 1990                  1






MKDIR(2V)                 SYSTEM CALLS                  MKDIR(2V)



ERRORS
     mkdir() will fail and no directory will be created if:

     EACCES              Search permission is denied for  a  com-
                         ponent of the path prefix of _p_a_t_h.

                         Write permission is denied on the parent
                         directory   of   the   directory  to  be
                         created.

     EDQUOT              The directory in which the entry for the
                         new  file  is  being  placed  cannot  be
                         extended because  the  user's  quota  of
                         disk  blocks on the file system contain-
                         ing the directory has been exhausted.

                         The  new  directory  cannot  be  created
                         because  the user's quota of disk blocks
                         on the file system  which  will  contain
                         the directory has been exhausted.

                         The user's quota of inodes on  the  file
                         system   on  which  the  file  is  being
                         created has been exhausted.

     EEXIST              The file referred to by _p_a_t_h exists.

     EFAULT              _p_a_t_h points outside the process's  allo-
                         cated address space.

     EIO                 An I/O error occurred while reading from
                         or writing to the file system.

     ELOOP               Too many symbolic links were encountered
                         in translating _p_a_t_h.

     EMLINK              The link count of the  parent  directory
                         would     exceed     {LINK_MAX}     (see
                         pathconf(2V)).

     ENAMETOOLONG        The length of the path argument  exceeds
                         {PATH_MAX}.

                         A  pathname  component  is  longer  than
                         {NAME_MAX} while {_POSIX_NO_TRUNC} is in
                         effect (see pathconf(2V)).

     ENOENT              A component of the path prefix  of  _p_a_t_h
                         does not exist.

     ENOSPC              The directory in which the entry for the
                         new  file  is  being  placed  cannot  be



Sun Release 4.1   Last change: 21 January 1990                  2






MKDIR(2V)                 SYSTEM CALLS                  MKDIR(2V)



                         extended because there is no space  left
                         on the file system containing the direc-
                         tory.

                         The  new  directory  cannot  be  created
                         because  there  is  no space left on the
                         file  system  which  will  contain   the
                         directory.

                         There are no free  inodes  on  the  file
                         system   on  which  the  file  is  being
                         created.

     ENOTDIR             A component of the path prefix  of  _p_a_t_h
                         is not a directory.

     EROFS               _p_a_t_h The parent directory of the  direc-
                         tory  to  be  created resides on a read-
                         only file system.

SYSTEM V ERRORS
     In addition to the above, the following may also occur:

     ENOENT              _p_a_t_h points to a null pathname.

SEE ALSO
     chmod(2V), mount(2V), rmdir(2V), stat(2V), umask(2V)




























Sun Release 4.1   Last change: 21 January 1990                  3



