Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

setting mode using creat function prob!

4 posters

Go down

setting mode using creat function prob! Empty setting mode using creat function prob!

Post by mightyganesh 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
mightyganesh
mightyganesh

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

http://ganeshguna.blogspot.com

Back to top Go down

setting mode using creat function prob! Empty Re: setting mode using creat function prob!

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

same problem here !!!
Christopher
Christopher
Admin

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

https://unixcpp.forumotion.com

Back to top Go down

setting mode using creat function prob! Empty Re: setting mode using creat function prob!

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

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

urvershi

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

Back to top Go down

setting mode using creat function prob! Empty Re: setting mode using creat function prob!

Post by Maithreyi 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 : 36
Location : Haldia

Back to top Go down

setting mode using creat function prob! Empty Re: setting mode using creat function prob!

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


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