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_IWUSR Write permission, owner
S_IXUSR Execute permission, owner
S_IRGRP Read permission, group
S_IWGRP Write permission, group
S_IXGRP Execute permission, group
S_IROTH Read permission, others
S_IWOTH Write permission, others
S_IXOTH Execute permission, others
In addition, we also have S_IRWXU,S_IRWXG and S_IRWXO.

umask

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().

Compile…

View original post 7 more words

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: