File permissions and umask()

Promethean Sacrifice

Access permissions can be specified during creation of files.

The above code creates a file with default permission : execute permissions for writer (permissions could very well depend on the system).
Unix, as we know, allows three kinds of file access mainly : own

S_IRUSR Read permission, owner
S_IWUSRWrite permission, owner
S_IXUSRExecute permission, owner
S_IRGRPRead permission, group
S_IWGRPWrite permission, group
S_IXGRPExecute permission, group
S_IROTHRead permission, others
S_IWOTHWrite permission, others
S_IXOTHExecute permission, others
In addition, we also have S_IRWXU,S_IRWXG and S_IRWXO.


In practise, no matter what access permissions are specified, every file permission value specified is modified by the calling process umask value. A umask specifies some access rights to be taken away . This value is inherited from the parent proces, and can be modified or queried using the umask() system call.

The following code demonstrates file permissions and umask().


View original post 7 more words

About Khuram Ali

Programming... Programming and Programming...!!!

Posted on May 13, 2013, in System Programming.. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: