Truncating an open file under BSD 4.3

Mike Eisler mre at beatnix.UUCP
Thu Jul 28 05:36:03 AEST 1988


In article <61401 at sun.uucp> guy at gorodish.Sun.COM (Guy Harris) writes:
>
>> I also could not find a way [to truncate] with fcntl, which surprises me.
>
>Why?  "fcntl" was originally intended to manipulate descriptors, not the
>objects they referred to; subsequently, "fcntl" has turned into something
>similar to "ioctl" but different (e.g., it's used for file locking - I'm not
>sure what the *intended* difference between "fcntl" and "ioctl" is), but
>nobody's made "fcntl" do file truncation - yet.

AT&T's UN*X System V Release 3.1 does do file truncation with fcntl().
By using the same flock struct that F_SETLK, and F_GETLK use, the
intent appears to allow truncation even in the middle of the file (just
as record locks can be in the middle), but currently this isn't
implemented.  You can only truncate to the end of the file. The name
of the command is F_FREESP.

	-Mike Eisler
	{sun, uunet}!elxsi!mre



More information about the Comp.unix.questions mailing list