Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!ll-xn!cit-vax!mangler From: mangler@cit-vax.UUCP Newsgroups: comp.unix.wizards Subject: Re: Backups on Live Systems Message-ID: <3114@cit-vax.Caltech.Edu> Date: Mon, 29-Jun-87 02:33:03 EDT Article-I.D.: cit-vax.3114 Posted: Mon Jun 29 02:33:03 1987 Date-Received: Tue, 30-Jun-87 02:13:14 EDT References: <132@dvm.UUCP> <725@aramis.rutgers.edu> <20070@sun.uucp> <1589@oliveb.UUCP> Organization: California Institute of Technology Lines: 34 Summary: file versions In article <1589@oliveb.UUCP>, jerry@oliveb.UUCP (Jerry F Aguirre) writes: > The most obvious example of this is if the user is editing a file at the > time that the dump begins. Say he has just decided to write out all his > laborious changes. The first thing done is to "create" the file which > truncates it to zero length. Then it begins copying from the temp file > to the edited file. If the dump begins at this time then the dumped > file will be at zero length! The solution to this is file versions. TOPS-10 did this fairly nicely; when you did the equivalent of creat(), you got an unnamed temporary file (actually, its name was blank), and when you were finished writing it, you could either close it normally, in which case it replaced the old version, or you could flush it (this was automatic if your program died). While the new version was being written, everybody still saw the old version intact. Just think, you could do "sed s/foo/bar/ myfile" without explicit temporary files. To add this to Unix, you'd need two new facilities: a relative of creat() to create a file with zero links, yielding a file descriptor; and an "flink" call to make a link to a file given a file descriptor. [N.B. flink() should unlink the target if necessary, like rename()]. Perhaps nicer would be to build flink() into close(), making close() take a filename, and if you give NULL as the filename, you get the old behavior. Nicer still would be to have the modified creat() stash away the filename and pointer to the directory inode for later use by the close routine, but with BSD long filenames, it might be difficult to find a place for it. None of this should be terribly difficult to implement, but you'd have to change all your programs if you want to take advantage of it. (Although stdio might be able to do some of it for you, all those programs that never call close() would lose...) Don Speck speck@vlsi.caltech.edu {seismo,rutgers,ames}!cit-vax!speck