I have an issue with the permissions I get when I use the mkdir system call. I know for a fact I'm calling it right, it's in octal, all that. I've tested it where the mode input is an integer that I can do math with and definitely is 511 in decimal.
#include <sys/stat.h>
#include <sys/types.h>
#include <cstdlib>
int main (int argc, char* argv[]) {
if (mkdir(argv[argc-1], 0777) == -1) {
perror(argv[0]);
return EXIT_FAILURE;
} // if
return EXIT_SUCCESS;
} // main
But when I create a directory and check the permissions, it's always 0755 instead of 0777.
Access: (0755/drwxr-xr-x)
When I use the mkdir utility or chmod or whatever it can set to 0777 perfectly. It's just the system call that's not working.
It also works fine for lesser permissions, like if I set the mode to 0111.
Your umask is 0022?
Check it with
$ umask
from your shell.
In this case, set to zero the umask with
$ umask 0
and try again with your program
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With