WG15 Defect Report Ref: 9945-1-38
Topic: errors and fstat with file off_t


This is an approved interpretation of 9945-1:1990.

.

Last update: 1997-05-20


                                                                9945-1-90 #38
	Classification:  No change


 _____________________________________________________________________________


	Topic:			errors and fstat with file off_t
	Relevant Sections:	5.3.1.4


Defect Report:
-----------------------

4. Section 5.3.1.4 open() Errors -
Assume off_t can take the values between -7 and 7. Assume also that an
Ada binding has created a file 8 bytes big. Shall open() work or fail?
If fail, with what error code? If work, what does fstat() return?

(Paul Wanish IBM)

WG15 response for ISO/IEC 9945-1:1990 (IEEE Std 1003.1-1990)
--------------------------------------------------

ISO/IEC 9945-1:1990 does not specify error conditions for
open() or for fstat() for the case where the file size cannot be
represented in an object of type off_t.  A conforming
implementation could define such error conditions.

Unless such an error condition is defined by the implementation,
open() must succeed in this example.  The value in the st_size
field of the structure returned by fstat() on the file
descriptor returned by this open() is unspecified for the case
where the actual value is larger than can be stored in an object
of type off_t.

A call to fstat() must fail if it is impossible to represent the
file size in a variable of type off_t.  When this occurs,
erreno must be set to a non-zero value that is not one of the
values specified for fstat() by POSIX.1.

Rationale for Interpretation:
-----------------------------

An implementation of fstat() might express the failure to set
the st_size field by setting the values of the fields other than
st_size in the structure pointed to by the buf argument to the
proper values.  fstat() could return -1 with errno set to a
value defined by the implementation, and documented to mean that
the file size exceeds the size that can be stored in type
off_t.  Such an implementation of fstat() could even store
the true file size in an implementation-defined member of
the stat structure, of some appropriate type.

It is suggested that a future revision of ISO/IEC 9945-1
specify the behavior of stat() and fstat() when used on files
whose sizes cannot be represented in variables of type off_t.
This condition can arise when file systems are mounted from a
remote POSIX.1 system on which off_t is a larger type than on
the local system.
 _____________________________________________________________________________