xref: /original-bsd/lib/libc/sys/mkdir.2 (revision c8089215)
1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)mkdir.2	6.7 (Berkeley) 03/10/91
7.\"
8.Dd
9.Dt MKDIR 2
10.Os BSD 4.2
11.Sh NAME
12.Nm mkdir
13.Nd make a directory file
14.Sh SYNOPSIS
15.Fd #include <sys/stat.h>
16.Ft int
17.Fn mkdir "const char *path" "mode_t mode"
18.Sh DESCRIPTION
19The directory
20.Fa path
21is created with the access permissions specified by
22.Fa mode
23and restricted by the the
24.Xr umask 2
25of the calling process.
26.Pp
27The directory's owner ID is set to the process's effective user ID.
28The directory's group ID is set to that of the parent directory in
29which it is created.
30.Sh RETURN VALUES
31A 0 return value indicates success.  A -1 return value
32indicates an error, and an error code is stored in
33.Va errno .
34.Sh ERRORS
35.Fn Mkdir
36will fail and no directory will be created if:
37.Bl -tag -width ENAMETOOLO
38.It Bq Er ENOTDIR
39A component of the path prefix is not a directory.
40.It Bq Er EINVAL
41The pathname contains a character with the high-order bit set.
42.It Bq Er ENAMETOOLONG
43A component of a pathname exceeded 255 characters,
44or an entire path name exceeded 1023 characters.
45.It Bq Er ENOENT
46A component of the path prefix does not exist.
47.It Bq Er EACCES
48Search permission is denied for a component of the path prefix.
49.It Bq Er ELOOP
50Too many symbolic links were encountered in translating the pathname.
51.It Bq Er EPERM
52The
53.Fa path
54argument contains a byte with the high-order bit set.
55.It Bq Er EROFS
56The named file resides on a read-only file system.
57.It Bq Er EEXIST
58The named file exists.
59.It Bq Er ENOSPC
60The directory in which the entry for the new directory is being placed
61cannot be extended because there is no space left on the file
62system containing the directory.
63.It Bq Er ENOSPC
64The new directory cannot be created because there
65there is no space left on the file
66system that will contain the directory.
67.It Bq Er ENOSPC
68There are no free inodes on the file system on which the
69directory is being created.
70.It Bq Er EDQUOT
71The directory in which the entry for the new directory
72is being placed cannot be extended because the
73user's quota of disk blocks on the file system
74containing the directory has been exhausted.
75.It Bq Er EDQUOT
76The new directory cannot be created because the user's
77quota of disk blocks on the file system that will
78contain the directory has been exhausted.
79.It Bq Er EDQUOT
80The user's quota of inodes on the file system on
81which the directory is being created has been exhausted.
82.It Bq Er EIO
83An I/O error occurred while making the directory entry or allocating the inode.
84.It Bq Er EIO
85An I/O error occurred while reading from or writing to the file system.
86.It Bq Er EFAULT
87.Fa Path
88points outside the process's allocated address space.
89.El
90.Sh SEE ALSO
91.Xr chmod 2 ,
92.Xr stat 2 ,
93.Xr umask 2
94.Sh STANDARDS
95.Fn Mkdir
96conforms to IEEE Std 1003.1-1988
97.Pq Dq Tn POSIX .
98