ftruncate (was Set file size in SYSV)

Guy Harris guy at auspex.auspex.com
Thu Aug 17 04:10:07 AEST 1989


>This is either a bug in the SunOS manpage (there are, it seems, many
>such) or---in this particular case, more likely---Yet Another Difference
>between SunOS and 4BSD.  Here the function is useful, but the name is
>bad.

It is Yet Another Difference between SunOS 4.x and 4BSD.  The name is
unfortunate, but I guess they didn't feel like adding a new call.  S5R4
will do all the file size adjusting functions with F_FREESP, and said
call is ultimately intended to let you punch holes in files as well (the
name is still arguably unfortunate, for although the "truncate" and
"punch a hole" functions do free up disk blocks, the "extend" function,
while I think it may not consume disk blocks on file systems that
support "holes", does grow the file). 

I've never been wild about using "fcntl" for stuff like that anyway; you
can write wrappers to perform the different F_FREESP functions, if you
want, and give them better names....



More information about the Comp.unix.questions mailing list