Truncating an existing file (and lockf question)

Edward T Spire ets at wrkgrp.COM
Fri Apr 26 00:44:30 AEST 1991


In article <16836 at chaph.usc.edu> jeenglis at alcor.usc.edu (Joe English) writes:
>nto0302 at dsacg3.dsac.dla.mil (Bob Fisher) writes:
>>How can I truncate the end of a large file without copying the part
>>to be preserved to a new file and then doing a remove/rename?
>>
>>This is for SVR3 but may need ported to BSD4.3.
>
>Check for a system call called 'truncate' or 'ftruncate'.
>SunOS has these, but the man pages are (as usual) unclear
>as to whether they're from BSD, System V, both, or neither.
>I seem to remember seeing this under both BSD4.3 and SVR3.

ftruncate() seems to work everywhere we've tried, except
SCO/Unix.  W/ SCO/Unix, chsize() takes the same parms as
ftruncate() and does the same thing...

========================================================================

Ed Spire                           email: ets at wrkgrp.com      (on uunet)
The Workstation Group              voice: 800-228-0255
6300 River Road, Suite 700            or  708-696-4800
Rosemont, Illinois  60018            fax: 708-696-2277



More information about the Comp.unix.questions mailing list