What is the difference between mkdir function in Linux and Windows?

11-03-2023

The copy code code is as follows:

#includeint _mkdir( const char *dirname );

Parameters:

Dirname is a pointer to the pathname of the directory.

Return value:

Each of these functions returns a value of 0 if the new directory was created. In error, the function returns–1.

Detailed explanation of mode_t parameters of mkdir function under linux

The copy code code is as follows:

#include int mkdir(const char *path, mode_t mode);

Parameters:

Path is the directory name.

Mode is directory permission.

Return value:

Returning 0 means success, returning -1 means error, and the errno value is set.

Mode mode bit:

Mode represents the authority of the new directory, and can take the following values:

s_irusrs_ireads_iwusrs_iwrites_ixusrs_iexecs_irwxuthis is equivalent to (s_irusr | s_iwusr | s_ixusr) .s_irgrpread permission bit for the group owner of the file. usually 040.s_iwgrpwrite permission bit for the group owner of the file. usually 020.s_ixg rpexecute or search permission bit for the group owner of the file. usually 010.s_irwxgthis is equivalent to (s_irgrp | s_iwgrp | s_ixgrp) .s_irothread permission bit for other users. usually 04.s_iwothwrite permission bit for other users. usually 02.s_ixothexecute or search permission bit for other users. usually 01.s_irwxothis is equivalent to (s_iroth | s_iwoth | s_ixoth).s_isuidthis is the set-user-id on execute bit, usually 04000. see how change persona.s_isgidthis is the set-group-id on execute bit, usually 02000. see how change persona.s_isvtxthis is the sticky bit, usually 01000.

S_irwxu 00700 permission means that the file owner has the permission to read, write and perform operations, s_irusr(s_iread) 00400 permission means that the file owner has the readable permission, s_iwusr(s_iwrite) 00200 permission means that the file owner has the writable permission, s_ixusr(s_iexec) 00100. It means that the owner of the file has the right to execute s_irwxg 00070, that the file user group has the right to read, write and execute operations s_irgrp 00040, that the file user group has the right to read s_iwgrp 00020, and that the file user group has the right to write s_ixgrp 00010. On behalf of this file user group, it has the permission to execute s_irwxo 00007, on behalf of other users, it has the permission to read, write and execute operations, on behalf of other users, it has the permission to read s_iwoth 00002, on behalf of other users, it has the permission to write S _ ixoth0001, and on behalf of other users, it has the permission to execute.

Next, I will give you a detailed introduction of the mkdir function in linux.

Mkdir function

Header file library:

#include #include

Function prototype:

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

Function description:

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

Return value:

If the directory is created successfully, it returns 0; Otherwise, it returns -1 and records the error in the global variable errno.

Mode mode:

S_irwxu 00700 permission means that the file owner has the permission to read, write and perform operations, s_irusr(s_iread) 00400 permission means that the file owner has the readable permission, s_iwusr(s_iwrite) 00200 permission means that the file owner has the writable permission, s_ixusr(s_iexec) 00100. It means that the owner of the file has the right to execute s_irwxg 00070, that the file user group has the right to read, write and execute operations s_irgrp 00040, that the file user group has the right to read s_iwgrp 00020, and that the file user group has the right to write s_ixgrp 00010. On behalf of this file user group, it has the permission to execute s_irwxo 00007, on behalf of other users, it has the permission to read, write and execute operations, on behalf of other users, it has the permission to read s_iwoth 00002, on behalf of other users, it has the permission to write S _ ixoth0001, and on behalf of other users, it has the permission to execute.

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us