update from Mike Karels at BSDI
[unix-history] / usr / src / lib / libc / sys / mkdir.2
CommitLineData
931b8415 1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
88b3ccf2 2.\" All rights reserved.
9c8e3df4 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
88b3ccf2 5.\"
931b8415 6.\" @(#)mkdir.2 6.7 (Berkeley) %G%
9c8e3df4 7.\"
931b8415
CL
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
9c8e3df4
KM
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.
931b8415
CL
30.Sh RETURN VALUES
31A 0 return value indicates success. A -1 return value
9c8e3df4 32indicates an error, and an error code is stored in
931b8415
CL
33.Va errno .
34.Sh ERRORS
35.Fn Mkdir
9c8e3df4 36will fail and no directory will be created if:
931b8415
CL
37.Bl -tag -width ENAMETOOLO
38.It Bq Er ENOTDIR
9c8e3df4 39A component of the path prefix is not a directory.
931b8415 40.It Bq Er EINVAL
b5984ffe 41The pathname contains a character with the high-order bit set.
931b8415 42.It Bq Er ENAMETOOLONG
b5984ffe
KM
43A component of a pathname exceeded 255 characters,
44or an entire path name exceeded 1023 characters.
931b8415 45.It Bq Er ENOENT
9c8e3df4 46A component of the path prefix does not exist.
931b8415 47.It Bq Er EACCES
b5984ffe 48Search permission is denied for a component of the path prefix.
931b8415 49.It Bq Er ELOOP
b5984ffe 50Too many symbolic links were encountered in translating the pathname.
931b8415
CL
51.It Bq Er EPERM
52The
53.Fa path
54argument contains a byte with the high-order bit set.
55.It Bq Er EROFS
9c8e3df4 56The named file resides on a read-only file system.
931b8415 57.It Bq Er EEXIST
9c8e3df4 58The named file exists.
931b8415 59.It Bq Er ENOSPC
fd690c8b
KM
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.
931b8415 63.It Bq Er ENOSPC
fd690c8b
KM
64The new directory cannot be created because there
65there is no space left on the file
66system that will contain the directory.
931b8415 67.It Bq Er ENOSPC
fd690c8b
KM
68There are no free inodes on the file system on which the
69directory is being created.
931b8415 70.It Bq Er EDQUOT
fd690c8b
KM
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.
931b8415 75.It Bq Er EDQUOT
fd690c8b
KM
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.
931b8415 79.It Bq Er EDQUOT
fd690c8b
KM
80The user's quota of inodes on the file system on
81which the directory is being created has been exhausted.
931b8415 82.It Bq Er EIO
b5984ffe 83An I/O error occurred while making the directory entry or allocating the inode.
931b8415 84.It Bq Er EIO
fd690c8b 85An I/O error occurred while reading from or writing to the file system.
931b8415
CL
86.It Bq Er EFAULT
87.Fa Path
9c8e3df4 88points outside the process's allocated address space.
931b8415
CL
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 .