Path: utzoo!attcan!uunet!cs.utexas.edu!usc!apple!amdahl!kucharsk From: kucharsk@uts.amdahl.com (William Kucharski) Newsgroups: comp.unix.questions Subject: Re: Set file size in SYSV Keywords: How Message-ID:Date: 15 Aug 89 02:27:06 GMT References: <708@msa3b.UUCP> <18lG02Em4aQn01@amdahl.uts.amdahl.com> <19072@mimsy.UUCP> Reply-To: kucharsk@amdahl.uts.amdahl.com (William Kucharski) Organization: Amdahl Coup, UTS Products Hen House Lines: 32 In article <19072@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >In article <18lG02Em4aQn01@amdahl.uts.amdahl.com> kucharsk@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@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.