Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ll-xn!cit-vax!mangler From: mangler@cit-vax.Caltech.Edu (System Mangler) Newsgroups: comp.unix.wizards Subject: a creat() hack Message-ID: <3921@cit-vax.Caltech.Edu> Date: Mon, 7-Sep-87 22:11:33 EDT Article-I.D.: cit-vax.3921 Posted: Mon Sep 7 22:11:33 1987 Date-Received: Tue, 8-Sep-87 06:16:31 EDT Organization: California Institute of Technology Lines: 20 Keywords: creat truncate versions efficiency creat() clobbers the file before anything is written. I wonder if this behaviour is necessary. Consider an alternate implementation, which instead of truncating the file upon creat(), just sets a "deferred truncate" flag. Upon a close() or lseek(), the file is truncated at the file pointer position if the flag is still set, and then the flag is reset. If the old and new sizes are similar, we've saved ourselves a lot of block allocation/deallocation. (Look at 4.3bsd rwhod sometime). If a long-running program does a creat() and the machine crashes before anything is written, the original contents of the file are left untouched, gaining some of the utility of multiple versions. If you copy a file over itself, it doesn't clobber the file. Other than tail -f, how much would this break? Don Speck speck@vlsi.caltech.edu {amdahl,rutgers}! die and n of