Re: your mail

tl (tl@fairplay.no)
Mon, 28 Sep 1998 01:19:26 +0200 (CEST)


On Sun, 27 Sep 1998, Matthew Wilcox wrote:
> > From: Tim Smith <tzs@tzs.net>
> > It's probably better to lseek to the length you want and write a zero.
> > ftruncate is not required by POSIX to allow length to be greater than
> > the current length of the file, so using it that way is not portable.
>
> That's not what O'Reilly's POSIX.4 book tells me. in the January 1995
> edition, page 117:
>
> `ftruncate actually works on all files ... ftruncate works both ways ...
> Whatever size you pass in to ftruncate becomes the size of the shared
> memory object.'

The quoted part could easily to be interpreted to mean that POSIX doesn't
mandate it, but that it happens to work on most implementation (that's
how I would have read it). The word "actually" is the clincher there, it
shouldn't be there if the standard mandate it.

Since the POSIX standards AFAIK isn't available on the net (for free)
I made a fast lookup in Single Unix Specification (v2, aka UNIX98)
instead, since that IS available for free on the Web and includes
POSIX...

The relevant part of their description is:
'If it was previously shorter than length, it is unspecified whether
the file is changed or its size increased.'

So, no, you can't PORTABLY use ftrucate()/truncate() to lengthen
files...

> And I think Bill Gallmeister ought to know what he's talking about ;-)

Possibly, but EVEN the wording you quote suggest that it might not be
standardized... So it's definitely possible he knew what he was
talking about :-)

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