samedi 23 juillet 2016

mkdir system call creates permissions 0755 instead of 0777

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)

Aucun commentaire:

Enregistrer un commentaire