Name

mkdir - creates a directory

Library

libc.lib

Synopsis

  #include <sys/types.h>
  #include <sys/stat.h>
  int mkdir (const char *path, mode_t mode);

Return values

The mkdir() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Detailed description

The directory path is created with the access permissions specified by mode.

Note: mode values will be ignored while directory creation.Default working directory of a process is initialized to C: \private \UID (UID of the calling application), and any data written into this C: \private \UID directory persists between phone resets.

Limitation: Parent directory time stamps will not be updated with new directory creation, created directory will be empty(i.e., it doesn’t have "." and ".." entries)


Examples

/**
*  Detailed description : This test code demonstrates usage of mkdir systemcall, it creates function
*  a  directory Example in current working directory.
**/
int main()
{
  if(mkdir("Example" , 0666) < 0 )  
  {
      printf("Directory creation failed \n");
      return -1;
  }
  printf("Directory Example created \n");
  return 0;
}

         

Output

Directory Example created

         


Errors

The mkdir system call will fail and no directory will be created if:
[ENOTDIR]
  A component of the path prefix is not a directory.(Not supported).
[ENAMETOOLONG]
  A component or an entire path name exceeded 255 characters.
[ENOENT]
  A component of the path prefix does not exist.
[EACCES]
  Search permission is denied for a component of the path prefix, or write permission is denied on the parent directory of the directory to be created(Not supported).
[ELOOP]
  Too many symbolic links were encountered in translating the pathname( Not supported).
[EROFS]
  The named file resides on a read-only file system(Not supported).
[EEXIST]
  The named file exists.
[ENOSPC]
  The new directory cannot be created because there is no space left on the file system that will contain the directory(Not supported).
[ENOSPC]
  There are no free inodes on the file system on which the directory is being created(Not supported).
[EDQUOT]
  The new directory cannot be created because the user’s quota of disk blocks on the file system that will contain the directory has been exhausted(Not supported).
[EDQUOT]
  The user’s quota of inodes on the file system on which the directory is being created has been exhausted(Not supported).
[EIO] An I/O error occurred while making the directory entry or allocating the inode(Not supported).
[EIO] An I/O error occurred while reading from or writing to the file system(Not supported).
[EFAULT]
  The path argument points outside the process’s allocated address space(Not supported).

See also

chmod, stat, umask

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top