Let me introduce the _mkdir function of Windows below
Copy Code code as follows:
#include <direct.h>
int _mkdir (const char *dirname);
Parameters:
DirName is the directory's path name pointer
return value:
If the new directory is created, each of these features returns a value of 0. In error, the function returns –1
Detailed explanation of mkdir function mode_t parameters in Linux
Copy Code code as follows:
#include <sys/stat.h>
int mkdir (const char *path, mode_t mode);
Parameters:
Path is a directory name
Mode is directory permissions
return value:
A return of 0 indicates a success, a return of 1 indicates an error, and a errno value is set.
Mode mode bit:
Mode represents the permissions for the new directory, and you can take the following values:
S_irusr
S_iread
S_iwusr
S_iwrite
S_ixusr
S_iexec
S_irwxu
This is equivalent to (S_IRUSR | S_IWUSR | S_IXUSR).
S_irgrp
Read permission bit for the group owner of the file. Usually 040.
S_iwgrp
Write permission bit for the group owner of the file. Usually 020.
S_ixgrp
Execute or search permission bit for the group owner of the file. Usually 010.
S_irwxg
This is equivalent to (S_IRGRP | S_iwgrp | S_IXGRP).
S_iroth
Read permission bit for the other users. usually 04.
S_iwoth
Write permission bit for other users. usually 02.
S_ixoth
Execute or search permission bit for other users. usually 01.
S_irwxo
This is equivalent to (S_iroth | S_iwoth | S_ixoth).
S_isuid
This is the Set-user-id on execute bit, usually 04000. How to change persona.
S_isgid
This is the Set-group-id on execute bit, usually 02000. How to change persona.
S_isvtx
This is the sticky bit, usually 01000.
S_irwxu 00700 permissions to represent the file owner with read, write, and execute operations
S_IRUSR (s_iread) 00400 permissions, on behalf of the file owner with readable permission
S_IWUSR (s_iwrite) 00200 permissions, on behalf of which the file owner has writable permissions
S_IXUSR (s_iexec) 00100 permissions, on behalf of which the owner of the file has permission to execute
S_irwxg 00070 permissions to represent the file user group with read, write, and execute actions
S_IRGRP 00040 permissions to represent the file user group with readable permissions
S_IWGRP 00020 permissions to represent the file user group with writable permissions
S_IXGRP 00010 permissions, representing the permissions that the file user group has to execute
S_irwxo 00007 permissions to read, write, and perform operations on behalf of other users
S_iroth 00004 permissions, on behalf of other users to have Read permission
S_iwoth 00002 permissions to have writable permissions on behalf of other users
S_ixoth 00001 permissions, on behalf of other users have Execute permissions
Here to give you a detailed introduction to the Linux mkdir function in detail
mkdir function
Header File Library:
#include <sys/stat.h>
#include <sys/types.h>
Function Prototypes:
int mkdir (const char *pathname, mode_t mode);
Function Description:
The mkdir () function creates a directory named by parameter pathname in mode, mode defines the permissions for the newly created directory.
return value:
Returns 0 if the directory creation succeeds, or 1, and logs the error to the global variable errno.
Mode mode:
S_irwxu 00700 permissions to represent the file owner with read, write, and execute operations
S_IRUSR (s_iread) 00400 permissions, on behalf of the file owner with readable permission
S_IWUSR (s_iwrite) 00200 permissions, on behalf of which the file owner has writable permissions
S_IXUSR (s_iexec) 00100 permissions, on behalf of which the owner of the file has permission to execute
S_irwxg 00070 permissions to represent the file user group with read, write, and execute actions
S_IRGRP 00040 permissions to represent the file user group with readable permissions
S_IWGRP 00020 permissions to represent the file user group with writable permissions
S_IXGRP 00010 permissions, representing the permissions that the file user group has to execute
S_irwxo 00007 permissions to read, write, and perform operations on behalf of other users
S_iroth 00004 permissions, on behalf of other users to have Read permission
S_iwoth 00002 permissions to have writable permissions on behalf of other users
S_ixoth 00001 permissions, on behalf of other users have Execute permissions