Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkdir.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkdir.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkdir.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkdir.html on line 8
Create a subdirectory
#include <sys/types.h>
#include <sys/stat.h>
int mkdir( const char *path,
mode_t mode );
- path
- The name of the directory that you want to create.
- mode
- The permissions for the directory, modified by the process's
file-creation mask (see
umask()).
The access permissions for the file or directory are specified as a
combination of bits defined in the <sys/stat.h> header
file.
For more information, see
“Access permissions”
in the documentation for stat().
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The mkdir() function creates a new subdirectory named
path. The path can be relative to the current
working directory or it can be an absolute path name.
The directory's owner ID is set to the process's effective user ID.
The directory's group ID is set to the group ID of the parent directory (if
the parent set-group ID bit is set) or to the process's effective group ID.
The newly created directory is empty.
The mkdir() function
marks the st_atime, st_ctime, and
st_mtime fields of the directory for update. Also, the
st_ctime and st_mtime fields of the parent directory
are also updated.
0, or -1 if an error occurs
(errno is set).
- EACCES
- Search permission is denied for a component of path,
or write permission is denied on the parent directory of
path.
- EEXIST
- The directory named by path already exists.
- ELOOP
- Too many levels of symbolic links.
- EMLINK
- The link count of the parent directory would exceed
LINK_MAX.
- ENAMETOOLONG
- The length of path exceeds PATH_MAX,
or a pathname component is longer than NAME_MAX.
- ENOENT
- A pathname component in the specified path does not
exist, or path is an empty string.
- ENOSPC
- The filesystem does not contain enough space to hold the contents of
the new directory or to extend the parent directory.
- ENOSYS
- This function is not supported for this path.
- ENOTDIR
- A component of path is not a directory.
- EROFS
- The parent directory resides on a read-only filesystem.
To make a new directory called
/src in /hd:
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
int main( void )
{
(void)mkdir( "/hd/src",
S_IRWXU |
S_IRGRP | S_IXGRP |
S_IROTH | S_IXOTH );
return EXIT_SUCCESS;
}
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
chdir(),
chmod(),
errno,
fchdir(),
getcwd(),
mknod(),
rmdir(),
stat(),
umask()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkdir.html on line 232
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/m/mkdir.html on line 232