Mkdir function in Linux

Source: Internet
Author: User
Code:
  1. Mkdir function in Linux
  2.  
  3. Prototype: int mkdir (const char * filename, mode_t Mode)
  4. If the return value is 0, the operation is successful. If the return value is-1, an error occurs. This function must contain header files.
  5. # Include <sys/STAT. h>
  6. # Include <sys/types. h>
  7.  
  8. Mode indicates the permission of the new directory. You can use the following values:
  9. S_irusr
  10. S_iread
  11. Read Permission bit for the owner of the file. on Alibaba systems this bit is 0400. s_iread is an obsolete synonym provided for BSD compatibility.
  12. S_iwusr
  13. S_iwrite
  14. Write Permission bit for the owner of the file. Usually 0200. s_iwrite is an obsolete synonym provided for BSD compatibility.
  15. S_ixusr
  16. S_iexec
  17. Execute (for ordinary files) or search (for directories) Permission bit for the owner of the file. Usually 0100. s_iexec is an obsolete synonym provided for BSD compatibility.
  18. S_irwxu
  19. This is equivalent to (s_irusr | s_iwusr | s_ixusr ).
  20. S_irgrp
  21. Read Permission bit for the group owner of the file. Usually 040.
  22. S_iwgrp
  23. Write Permission bit for the group owner of the file. Usually 020.
  24. S_ixgrp
  25. Execute or search permission bit for the group owner of the file. Usually 010.
  26. S_irwxg
  27. This is equivalent to (s_irgrp | s_iwgrp | s_ixgrp ).
  28. S_iroth
  29. Read Permission bit for other users. Usually 04.
  30. S_iwoth
  31. Write Permission bit for other users. Usually 02.
  32. S_ixoth
  33. Execute or search permission bit for other users. Usually 01.
  34. S_irwxo
  35. This is equivalent to (s_iroth | s_iwoth | s_ixoth ).
  36. S_isuid
  37. This is the set-user-id on execute bit, usually 04000. See how change persona.
  38. S_isgid
  39. This is the set-group-ID on execute bit, usually 02000. See how change persona.
  40. S_isvtx
  41. This is the sticky bits, usually 01000.

Mkdir function in Linux
Header file Library:

 

# Include <sys/STAT. h>

 

# Include <sys/types. h>

 

Function prototype:

 

Int mkdir (const char * pathname, mode_t mode );

 

Function Description:

 

The mkdir () function creates a directory named after the pathname parameter in mode, and mode defines the permission for creating a new directory.

 

Return Value:

 

If the directory is successfully created, 0 is returned; otherwise,-1 is returned and an error is recorded in the global variable errno.

 

Mode:

 
S_irwxu 00700 permission indicates that the owner of the file has the permission to read, write, and execute operations.
S_irusr (s_iread) 00400 permission indicates that the object owner has the readable permission.
S_iwusr (s_iwrite) 00200 permission indicates that the file owner has the write permission.
S_ixusr (s_iexec) 00100 permission indicates that the file owner has the permission to execute the file.
S_irwxg 00070 permission, which indicates that the file user group has the read, write, and execution permissions.
S_irgrp 00040 permission, which indicates that the file user group has the readable permission
S_iwgrp 00020 permission, which indicates that the file user group has the write permission
S_ixgrp 00010 permission, which indicates that the file user group has the execution permission
S_irwxo 00007 permission indicates that other users have the read, write, and execute permissions
S_iroth 00004 permission, which indicates that other users have the readable permission
S_iwoth 00002 permission, indicating that other users have the write permission
S_ixoth 00001 permission indicates that other users have the execution permission
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.