Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!sun!aeras!elxsi!beatnix!mre From: mre@beatnix.UUCP (Mike Eisler) Newsgroups: comp.unix.questions Subject: Re: Truncating an open file under BSD 4.3 Keywords: Empty, !ftruncate, fcntl? Message-ID: <856@elxsi.UUCP> Date: 27 Jul 88 19:36:03 GMT References: <1392@valhalla.ee.rochester.edu> <61401@sun.uucp> Sender: news@elxsi.UUCP Reply-To: mre@beatnix.UUCP (Mike Eisler) Organization: ELXSI Super Computers, San Jose Lines: 18 In article <61401@sun.uucp> guy@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