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

02-16-2023

The editor of this article will introduce the difference between the mkdir function in Linux and Windows in detail. The content is detailed, the steps are clear, and the details are handled properly. To help you solve your doubts, follow the editor's ideas and slowly deepen, let's learn new knowledge together.

Copy the code The code is as follows:

#includeint _mkdir( const char *dirname );

Parameters:

dirname is the path name pointer of the directory

Return Values:

Each of these functions returns a value of 0 if the new directory was created at the time. If there is an error, the function returns – 1

Detailed explanation of the mode_t parameter of the mkdir function under linux

Copy code The code is as follows:

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

Parameters:

path is the directory name

mode is the directory permission

Return value:

Return 0 means success, return -1 means error, and the errno value will be set.

mode bit:

mode indicates the authority of the new directory, and 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 forthe 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 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. see how change persona.
s_isgid
this is the set-group-id on execute bit, usually 02000. see how change persona.
s_isvtx
this is the sticky bit, usually 01000.

s_irwxu 00700 authority, representing the The file owner has the permission to read, write and execute operations
s_irusr(s_iread) 00400 permission, which means the file owner has the read permission
s_iwusr(s_iwrite) 00200 permission, which means the file owner has the permission Writable permission
s_ixusr(s_iexec) 00100 permission means that the owner of the file has the execution permission
s_irwxg 00070 permission means the file user group has the permission to read, write and execute operations
s_irgrp 00040 permission means that the file user group has readable permission
s_iwgrp 00020 permission means that the file user group has writable permission
s_ixgrp 00010 permission means that the file user group has execution permission
s_irwxo 00007 permissions, on behalf of other users have read, write and executeOperational permissions
s_iroth 00004 permission means that other users have readable permission
s_iwoth 00002 permission means other users have writable permission
s_ixoth 00001 permission means other users have execution permission

Let’s give you a detailed introduction to 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 mode with parameters The directory named by pathname, mode defines the permissions of the newly created directory.

Return value:

If the directory is created successfully, it will return 0; otherwise it will return -1, and record the error to the global variable errno middle.

mode mode:

s_irwxu 00700 permission, which means the owner of the file has the permission to read, write and execute operations
s_irusr(s_iread) 00400 authority means the file owner has readable authority
s_iwusr(s_iwrite) 00200 authority means the file owner has writable authority
s_ixusr(s_iexec) 00100 authority means The owner of the file has the permission to execute
s_irwxg 00070 permission, which means the file user group has the permission to read, write and execute operations
s_irgrp 00040 permission, which means the file user group has the read permission
s_iwgrp 00020 permission means that the file user group has writable permission
s_ixgrp 00010 permission means that the file user group has execution permission
s_irwxo 00007 permission means other users have read, write and execute permissions Operation permission
s_iroth 00004 permission, which means other users have readable permission
s_iwoth 00002 permission, which means other users have writable permission
s_ixoth 00001 permission, which means other usersOther users have 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