Linux function mkdir cannot allow full resolution

I am testing the mkdir function to create a new directory:

 folder = mkdir("./linux", 511); 

or

  folder = mkdir("./linux", 0777); 

or

 folder = mkdir("./linux", S_IRWXU | S_IRWXG | S_IRWXO); 

As you can see, I am trying to allow full permission for the directory, but here what appears with ls -l | grep linux ls -l | grep linux :

 drwxr-xr-x 2 manuzhang manuzhang 4096 2012-01-04 06:53 linux 

Why can't I allow write access for the group and others?

Update :
it is strange how you guys told me that I tried umask . It works with either umask(S_IWGRP) or umask(S_IWOTH) , but it crashes with umask(S_IWGRP | S_IWOTH) , any ideas?

+4
source share
3 answers

From man 2 mkdir :

Argument mode indicates permissions to use. It is modified by the umask process in the usual way: permissions of the created directory (mode and ~ umask and 0777).

I suggest you look at your umask - it is probably set to 0022 . Try chmod post- mkdir .

+5
source

Permissions set by system calls like mkdir and open are always masked in relation to the current umask process. You can change the current umask using the umask() function; be sure to return it when done.

+2
source

Check the umask function: man 2 umask

0
source

Source: https://habr.com/ru/post/1389165/


All Articles