How can a file be truncated on System V??

T. William Wells bill at twwells.uucp
Sun Apr 30 06:16:44 AEST 1989


In article <651 at mitisft.Convergent.COM> kemnitz at mitisft.Convergent.COM (Gregory Kemnitz) writes:
: There is an ULTRIX (I think) function
:
: ftruncate(fd, length)
: int fd, length;

(Actually, BSD)

: that takes a file pointed at by fd and truncates the file to length bytes.
: The file descriptor may be only open for writing (which rules out dumping
: length bytes to a temporary file and copying them back, which involves
: read access).  How would one implement such a function in System V (I have
: tried the obvious ways, ie fcntl(), etc).  Do you have to write something
: to edit the inode to do this??

You don't do it with a standard system call. I once had occasion to
look long and hard for this and didn't find it.

---
Bill                            { uunet | novavax } !twwells!bill



More information about the Comp.unix.wizards mailing list