Answering questions that may arise related to the meaning of portions of an IEEE standard concerning specific applications.

IEEE Standards Interpretation for IEEE Std 1003.1™-2001 IEEE Standard 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 #56
Topic: ftruncate errors Relevant Sections: XSH ftruncate Page: 469- Line: 15488

The ERRORS section on the ftruncate page has a number of problems.

1. The EFBIG error for exceeding the offset maximum should not be shaded XSI.

2. The last EINVAL error is redundant. The condition is "The fildes argument references a file that was opened without write permission." This effectively means fildes is not open for writing, which is already listed as "[EBADF] or [EINVAL]".

3. The EROFS error should not be there. It was added in SUSv2, but I believe that adding it was a mistake. A file on a read-only file system cannot be opened for writing, so the fd passed to ftruncate() would not be open for writing and the proper error value for this situation is EBADF. In SUSv2 ftruncate() and truncate() were both described on the same page, and EROFS is valid for truncate(), so that may have had something to do with why the mistake was made.

4. No error value is listed for the case where ftruncate() fails because the file is smaller that the specified size. (On non-XSI systems it can either increase the file size or fail.) Presumably the appropriate error value is EINVAL.

Solution proposed:

1. Remove the XSI shading from the EFBIG error on lines 15488-15489.

2. Delete lines 15493-15494 [EINVAL] The fildes argument references a file that was opened without write permission.

3. Delete line 15495: [EROFS] The named file resides on a read-only file system.

4. Add after line 15495: The ftruncate() function may fail if:

[EINVAL] The fildes argument references a regular file and the length argument is greater than the current size of the file, and the implementation does not support the XSI option.

Interpretation Response #56
The standards states the requirements for errors for ftruncate(), and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale for Interpretation