Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!clyde!cbosgd!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon Allbery) Newsgroups: comp.unix.wizards Subject: Re: Backups on Live Systems Message-ID: <2766@ncoast.UUCP> Date: Thu, 2-Jul-87 20:55:31 EDT Article-I.D.: ncoast.2766 Posted: Thu Jul 2 20:55:31 1987 Date-Received: Sat, 4-Jul-87 18:02:50 EDT References: <132@dvm.UUCP> <725@aramis.rutgers.edu> <20070@sun.uucp> <1589@oliveb.UUCP> <3114@cit-vax.Caltech.Edu> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: comp.unix.wizards Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 59 As quoted from <3114@cit-vax.Caltech.Edu> by mangler@cit-vax.Caltech.Edu (System Mangler): +--------------- | 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. +--------------- Why? One easy and compatible way to do it is as follows: Store a version number for a file in the inode. (Yes, inode-based versions, not path-based ones. This is necessary given the UNIX way of doing things.) A good place would be byte 39 of the block array, given that the blocks only fill bytes 0-38. On the other hand, 255 generations may be too few. The inode must also contain the inode number of the previous version, so that previous versions can be retrieved. When a file is creat()'ed, an empty, unnamed (link count = 0) is allocated; data is written to this file. When it is close()'ed,, either directly or by exit(), the inode is updated, then the inode and the original are swapped within the i-list for the file system. Thus, the inode number never changes between versions of a file (otherwise, it has to change every directory entry the file has). To specify a version of a file, you use an extension of the current naming scheme; append a slash and the version number to the file name. When namei() gets to a file and there is a slash and a valid number afterward, it can follow the chain back to the correct inode. Programs aborting via kill() (and possibly by exit(n) for n != 0 or n < 0 or etc.) would have the new inodes deallocated, leaving the previous version intact. Programs which don't know about version numbers then get the version seman- tics for free. Also, you can implement GENERATION-RETENTION-COUNT as yet another variable in the u block, with a system call to get or set it. This means that directories can't have versions. Then again, there isn't much reason for them to have them anyway. Any comments? ++Brandon -- ---- Moderator for comp.sources.misc and comp.binaries.ibm.pc ---- Brandon S. Allbery !cbosgd!hal!ncoast!allbery ('til Aug. 1) aXcess Company {ames,mit-eddie,harvard,talcott}!necntc!ncoast!allbery 6615 Center St. #A1-105 {well,sun,pyramid,ihnp4}!hoptoad!ncoast!allbery Mentor, OH 44060-4101 necntc!ncoast!allbery@harvard.HARVARD.EDU (Internet) +01 216 974 9210 ncoast!allbery@CWRU.EDU (CSnet -- if you dare) NCOAST ADMIN GROUP Brandon Allbery on 157/504 (Fidonet/Matrix/whatever) * ncoast -- Public Access UN*X -- (216) 781-6201, 24 hrs., 300/1200/2400 baud * * ncoast is proud to be carrying alt.all -- contact me for more information *