[cs631apue] File permission Control use oflag and mode

Hongyi Shen hshen4 at stevens.edu
Sat Sep 14 00:33:21 EDT 2013


In open() function:

int open(const char *pathname, int oflag, ... /* mode_t mode */ );


Both *oflag* and *mode could *control the file's permission. So both of
them call stat() inside?

*Question: What if they are conflict with each other? (like O_RDONLY and
mode 0777 together)*


When doing the HW, my function's option is open(dst, O_WRONLY | O_CREAT |
O_TRUNC, src_st.st_mode), it works fine when I copy a executable shell
script.

But when I chmod 777 to the source script and use program to copy, the
target file's permission remains "-rwxr-xr-x". This is where this problem
from.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20130914/5a1aa137/attachment.html>


More information about the cs631apue mailing list