<p dir="ltr">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. </p>
<div class="gmail_quote">On Sep 14, 2013 12:33 AM, "Hongyi Shen" <<a href="mailto:hshen4@stevens.edu">hshen4@stevens.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
                
        
        
                <div title="Page 79">
                        <div>
                                <div>
                                        <div>
                                                <p><font face="Courier">In open() function:</font></p><p><span style="font-size:10pt;font-family:Courier">int open(const char *pathname, int oflag, ... /* mode_t mode */ ); </span></p><p><span style="font-size:10pt;font-family:Courier"><br>
</span></p><p><font face="Courier">Both <i>oflag</i> and <i>mode could </i>control the file's permission. So both of them call stat() inside? </font></p><p><font face="Courier"><b><font size="4">Question: What if they are conflict with each other? (like O_RDONLY and mode 0777 together)</font></b></font></p>
<p><font face="Courier"><br></font></p><p><font face="Courier">When doing the HW, my function's option is </font>open(dst, O_WRONLY | O_CREAT | O_TRUNC, src_st.st_mode), it works fine when I copy a executable shell script. </p>
<p>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.</p><p><br></p><p><font face="Courier"> </font></p>
                                        </div>
                                </div>
                        </div>
                </div></div>
<br>_______________________________________________<br>
cs631apue mailing list<br>
<a href="mailto:cs631apue@lists.stevens.edu">cs631apue@lists.stevens.edu</a><br>
<a href="https://lists.stevens.edu/mailman/listinfo/cs631apue" target="_blank">https://lists.stevens.edu/mailman/listinfo/cs631apue</a><br>
<br></blockquote></div>