Set file size in SYSV

William Kucharski kucharsk at uts.amdahl.com
Tue Aug 15 12:27:06 AEST 1989


In article <19072 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
 >In article <18lG02Em4aQn01 at amdahl.uts.amdahl.com> kucharsk at uts.amdahl.com
 >(William Kucharski) writes:
 >>int
 >>ftruncate(fd, length)
 >[much deleted]
 >>	if (filebuf.st_size < length) {
 >>		/* extend file length */
 >
 >The 4BSD ftruncate() call will not extend files.  (If it did,
 >it would probably have been called `fsetsize'; and a function
 >like this one should probably be so called.)

Well, it may not be a good porting guide, but my SunOS 4.0 man page says:

DESCRIPTION
     truncate() causes the file  referred  to  by  path  (or  for
     ftruncate()  the  object  referred  to by fd) to have a size
     equal to length bytes.  If the file  was  previously  longer
     than  length, the extra bytes are removed from the file.  If
     it was shorter, bytes between the old and  new  lengths  are
     read  as  zeroes. [...]

-- 
					William Kucharski

ARPA: kucharsk at uts.amdahl.com
UUCP: ...!{ames,apple,decwrl,sun,uunet}!amdahl!kucharsk

Disclaimer:  The opinions expressed above are my own, and may not agree with
	     those of any other sentient being, not to mention those of my 
	     employer.  So there.



More information about the Comp.unix.questions mailing list