How can a file be truncated on System V??

Gregory Kemnitz kemnitz at mitisft.Convergent.COM
Sat Apr 29 04:04:47 AEST 1989


There is an ULTRIX (I think) function

ftruncate(fd, length)
int fd, length;

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??

--Greg



More information about the Comp.unix.wizards mailing list