Re: ftruncate not extending files?

Jens-Uwe Mager (jum@anubis.han.de)
Sat, 3 Mar 2001 00:41:14 +0100


On Fri, 2 Mar 2001 10:17:14 GMT, Malcolm Beattie <mbeattie@sable.ox.ac.uk> wrote:
>bert hubert writes:
>> I would've sworn, based on the fact that I saw people do it, that ftruncate
>> was a legitimate way to extend a file
>
>Well it's not SuSv2 standards compliant:
>
> http://www.opengroup.org/onlinepubs/007908799/xsh/ftruncate.html
>
> If the file previously was larger than length, the extra data is
> discarded. If it was previously shorter than length, it is
> unspecified whether the file is changed or its size increased. If
> ^^^^^^^^^^^
> the file is extended, the extended area appears as if it were
> zero-filled.
>
>How "legitimate" relates to "SuSv2 standards compliant" is your call.

It is interesting to compare the wording of the Solaris man page, it
sounds pretty much like the SuSv2 paragraph above, but without the
restriction that the result is unspecified, it guarantees the extending
is a legitimate operation. Sounds like the SuSv2 authors chickened out
on that issue, most of the Unix platforms I know (including SunOS 4&5,
HP/UX, IRIX, Tru64, AIX and various *BSD) do happily extend a file on
truncate.

-- 
Jens-Uwe Mager	<pgp-mailto:62CFDB25>

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/