I made a little project some weeks ago, but it somehow didn't work anymore recently (or at least, not like it previously worked).
It had to create a file with open()
, and fill it with some content.
[...]
int fd=open(filename, O_RDWR | O_CREAT);
/* write content */
close(fd);
[...]
The problem was just that it recently didn't create the file with the right permissions anymore (it was created with 0110
when the problem was occurring)
I now know that I just have to specify the permissions like this :
int fd=open(filename, O_RDWR | O_CREAT, 0700); /* (for instance) */
But the project still worked on some computers (Didn't work on OSX, but did work on a Linux, on which it was created with 0640
, so it still worked because I still had reading permission).
So here is my question:
- How are those default permissions defined for
open()
function at file creation?
(If I don't explicitly pass it to my open()
call as a parameter.)