Why won’t the following code create a file with permissions read and write for user, group, and other?
char data[10] = "123456789";
int fh = open("test.txt", O_RDWR|O_CREAT, 0666);
write(fh, data, 10);
printf(strerror(errno));
close(fh);
Produces this file:
-rw-r--r-- 1 pc users 9 Nov 15 16:15 test.txt
What does that mean? I specifically asked for r+w in all categories.
Reset your user mask using the
umask()system call before callingopen().