How to create file with permission 666?

E

Eric J.Hu

Hi,

I have a question about the open function in linux. I want to create a file with permission 666(read and write by others), the code as following:

open("/tmp/test", O_CREAT, 0666);

But the file always can not set the others write permission, could someone help me on this question?


Thanks,
Eric
 
K

Keith Thompson

Eric J.Hu said:
I have a question about the open function in linux. I want to create a
file with permission 666(read and write by others), the code as following:

open("/tmp/test", O_CREAT, 0666);

But the file always can not set the others write permission, could someone
help me on this question?

Not here. Try comp.unix.programmer.
 
J

junky_fellow

Eric said:
Hi,

I have a question about the open function in linux. I want to create a file with permission 666(read and write by others), the code as following:

open("/tmp/test", O_CREAT, 0666);

But the file always can not set the others write permission, could someone help me on this question?


Thanks,
Eric

<OT>
The third argument mode specified in the open system call, is modified
by the process's
"umask". The permissions of the created file are (mode & ~umask).
I guess the umask set for your process is 022.
You may see the current umask setting by command "umask".
See the man page for umask for details.
<OT>
 
E

Eric J.Hu

Junky_fellow,

Great thanks! It works, the problem is my umask was set to 022.


Regards,
Eric
------------------------------------------
 
C

Christopher Benson-Manica

Eric J.Hu said:
[-- text/plain, encoding quoted-printable, charset: iso-8859-1, 14 lines --]
I have a question about the open function in linux. I want to create a file with permission 666(read and write by others), the code as following:
(snipped)

And when you post to comp.unix.programmer as Keith recommended, I'm
quite sure they would appreciate it if you would avoid posting
multipart-encoded messages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top