[cs631apue] File permission Control use oflag and mode

Tejas Nadkarni tnadkarn at stevens.edu
Sat Sep 14 07:32:08 EDT 2013


I used stat to pull attributes and then fchmod and fchown to set them after
I finished copying the file. Didn't run into any issues. In open I used
static permissions to allow me to write to the file and then it gets
overwritten with the above.
On Sep 14, 2013 12:33 AM, "Hongyi Shen" <hshen4 at stevens.edu> wrote:

>   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.
>
>
>
>
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20130914/28b17ca2/attachment.html>


More information about the cs631apue mailing list