1MKDIR(2)                   Linux Programmer's Manual                  MKDIR(2)
2
3
4

NAME

6       mkdir - create a directory
7

SYNOPSIS

9       #include <sys/stat.h>
10       #include <sys/types.h>
11
12       int mkdir(const char *pathname, mode_t mode);
13

DESCRIPTION

15       mkdir() attempts to create a directory named pathname.
16
17       The  parameter mode specifies the permissions to use. It is modified by
18       the process's umask in the usual way: the permissions  of  the  created
19       directory  are  (mode & ~umask & 0777).  Other mode bits of the created
20       directory depend on the operating system.  For Linux, see below.
21
22       The newly created directory will be owned by the effective user  ID  of
23       the process.  If the directory containing the file has the set-group-ID
24       bit set, or if the filesystem is mounted with BSD group semantics,  the
25       new  directory will inherit the group ownership from its parent; other‐
26       wise it will be owned by the effective group ID of the process.
27
28       If the parent directory has the set-group-ID bit set then so  will  the
29       newly created directory.
30
31

RETURN VALUE

33       mkdir()  returns  zero on success, or -1 if an error occurred (in which
34       case, errno is set appropriately).
35

ERRORS

37       EACCES The parent directory does not  allow  write  permission  to  the
38              process,  or  one  of  the directories in pathname did not allow
39              search permission.  (See also path_resolution(2).)
40
41       EEXIST pathname already exists (not necessarily as a directory).   This
42              includes the case where pathname is a symbolic link, dangling or
43              not.
44
45       EFAULT pathname points outside your accessible address space.
46
47       ELOOP  Too many symbolic links were encountered in resolving pathname.
48
49       ENAMETOOLONG
50              pathname was too long.
51
52       ENOENT A directory component in pathname does not exist or  is  a  dan‐
53              gling symbolic link.
54
55       ENOMEM Insufficient kernel memory was available.
56
57       ENOSPC The  device  containing  pathname has no room for the new direc‐
58              tory.
59
60       ENOSPC The new directory cannot be  created  because  the  user's  disk
61              quota is exhausted.
62
63       ENOTDIR
64              A  component  used as a directory in pathname is not, in fact, a
65              directory.
66
67       EPERM  The filesystem containing pathname does not support the creation
68              of directories.
69
70       EROFS  pathname refers to a file on a read-only filesystem.
71

CONFORMING TO

73       SVr4, BSD, POSIX.1-2001.
74

NOTES

76       Under  Linux  apart from the permission bits, only the S_ISVTX mode bit
77       is honored. That is, under Linux the created  directory  actually  gets
78       mode (mode & ~umask & 01777).  See also stat(2).
79
80       There  are  many  infelicities in the protocol underlying NFS.  Some of
81       these affect mkdir().
82

SEE ALSO

84       mkdir(1), chmod(2), mkdirat(2), mknod(2), mount(2), path_resolution(2),
85       rmdir(2), stat(2), umask(2), unlink(2)
86
87
88
89Linux 2.4                         2003-12-09                          MKDIR(2)
Impressum