setting mode using creat function prob!

Go down

setting mode using creat function prob!

Post by mightyganesh on Fri Mar 12, 2010 11:18 am

i got a problem in setting mode to the files created by the creat() function!

if we create a new file which does not exist already using the create command we are not able to set the correct rights correctly
i gave creat("newfile",0777);
but the ls -l newfile command showed me -rwxrwxr-x

if i give the option as 0000 its working normally! i mean i got ---------- as the rights confused
avatar
mightyganesh

Posts : 53
Points : 92
Join date : 2010-02-26
Age : 29

View user profile http://ganeshguna.blogspot.com

Back to top Go down

Re: setting mode using creat function prob!

Post by Christopher on Fri Mar 12, 2010 11:50 am

same problem here !!!
avatar
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 29

View user profile http://unixcpp.saveboard.com

Back to top Go down

Re: setting mode using creat function prob!

Post by urvershi on Fri Mar 12, 2010 11:55 am

I too hav d same problem.......

urvershi

Posts : 21
Points : 70
Join date : 2010-02-26

View user profile

Back to top Go down

Re: setting mode using creat function prob!

Post by Maithreyi on Fri Mar 12, 2010 1:01 pm

That is caused by umask! By default the umask is set to 002 in our home directory.To allow write permission for others,make the umask to 000.So before creating the file, use umask(0) and then create the file.This will ensure the file permission is rwx for owner,group and others.

Google umask to read more about it.

And enter umask at $ prompt.You will get the value as 0002

Maithreyi

Posts : 76
Points : 142
Join date : 2010-03-03
Age : 30
Location : Haldia

View user profile

Back to top Go down

Re: setting mode using creat function prob!

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum