IEEE Standards Interpretations for IEEE Std 1003.1™-2001 IEEE Standard for Information Technology - Portable Operating System Interface (POSIX®)
Copyright © 2006 by the Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue New York, New York 10016-5997 USA All Rights Reserved.
Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.
IEEE Standards Department Copyrights and Permissions 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA
Interpretation Request #25
Topic: mask for file creation Relevant Sections: fopen
This relates to POSIX.1-1990 section 8.2, Lines 193-197: "All functions specified in the C Standard as creating a file shall do so as if they called the creat() function with ... a value of S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH for the mode argument." We do not have the requirement in the 2001/2003 edition. We need another interpretation request, since the requirement is no longer in the standard. We need to consider what is the best behavior for applications. Looked for C language functions affected and came up with fopen/freopen/fdopen/ tmpfile. freopen/fdopen and tmpfile reference fopen explicitly so adding wording for fopen, would handle freopen/fdopen, tmpfile would need further text.
If standard developers agree produce an interpretation that states "The standard does not speak to this issue, and as such no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor." In a future revision make the following changes: Add to the existing CX shaded block in fopen() which states: "If mode is w, wb, a, ab, w+, wb+, w+b, a+, ab+, or a+b, and the file did not previously exist, upon successful completion, the fopen() function shall mark for update the st_atime, st_ctime, and st_mtime fields of the file and the st_ctime and st_mtime fields of the parent directory." Add (also CX shaded): "If mode is w, wb, a, ab, w+, wb+, w+b, a+, ab+, or a+b, and the file did not previously exist, the fopen() function shall create a file as if it called the creat() function with a value appropriate for the /path/ argument interpreted from /filename/ and a value of S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH for the mode argument" A corresponding change is then also needed to tmpfile() to change from: "The file is opened as in fopen() for update (w+)" to: "The file is opened as in fopen() for update (w+), except implementations may restrict the permissions, either by clearing the file mode bits or setting them to the value S_IRUSR|S_IWUSR"
The standard does not speak to this issue, and as such no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor.
Rationale for Interpretation