linux mkdir function can't authorize full permission

后端 未结 3 2034
一个人的身影
一个人的身影 2020-12-17 03:46

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

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

or

 folder = mk         


        
相关标签:
3条回答
  • 2020-12-17 04:15

    Check the umask function: man 2 umask

    0 讨论(0)
  • 2020-12-17 04:18

    From man 2 mkdir:

    The argument mode specifies the permissions to use. It is modified by the process's umask in the usual way: the permissions of the created directory are (mode & ~umask & 0777).

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

    0 讨论(0)
  • 2020-12-17 04:38

    Permissions set by system calls like mkdir and open are always masked against the current process's umask. You can change the current umask using the umask() function; make sure to set it back when you're done.

    0 讨论(0)
提交回复
热议问题