Subject: Re: Versioning filesystem in NetBSD
To: Thilo Jeremias <jeremias@optushome.com.au>
From: Johnny Billquist <bqt@softjar.se>
List: current-users
Date: 08/29/2006 10:49:28
Thilo Jeremias wrote:
> Johnny Billquist wrote:
> 
>> Don't know enough about portalfs and other stuff in Unix to tell if 
>> any could be adopted to something similar to VMS.
>> VMS isn't exactly copy on write either. There is a lot more (and less) 
>> to it.
> 
> Admited, the last time I used that was '89 so I don't really remember.
> (But I'm curious, and as far as I remember an env-var specified how many 
> versions to keep, and in the editor, a save created a new version.
> -- easy to undo bad changes even after several modifications.

VMS basically works like this:
Each file can have a number of versions available. The filename can 
either explicitly tell which version you're referring to, it can be 
implied, or there are a few "special" version numbers.

Explicit version number: open for read is obvious. Create will delete 
the old contents, and you'll write new data to the file instead. Open 
for append and the old data is still around, but the file before the 
append as such is no longer around. You can also open the file with 
write access, and overwrite parts of the data.

Version 0 and -1 is special. Version 0 on open for read or append means 
you select the newest version of the file existing. Version 0 on create 
means create a new version with a number one larger than the current 
highest number now existing.
Version -1 means the oldest existing version.

If no version number is given, it normally defaults to version 0. So, by 
just opening a file for reading without specifying a version number 
means you'll get the latest version. If you then write the data back to 
the same filename, you'll get a new version of the file written (as 
typically editors do).

VMS also automatically can delete old versions of a file. It's not 
associated with a logical name (which would be the VMS thing most like 
environment variables). Instead, this is an attribute of the file. Each 
file have information on how many versions of the file to keep. (Hmm, 
thinking of it, I might remember wrong, and that it's actually kept in 
the directory information as well, but anyway, you get the idea... 
TOPS-20 do the same thing, so I might be confusing them... Different 
files can have different number of versions kept.)

You can also explicitly remove old versions with the PURGE command, 
telling how many versions you want to keep.
Commands dealing with files can also wildcard the version numbers, just 
as the filenames themself.

If one program rewrites a file that another program have open, then the 
changes will be visible immediately. However, for this to happen, both 
programs must also allow this to be possible. When you access files in 
VMS, you also give information on how other programs are allowed to 
access the file while you have it open. Deleted files are only actually 
removed when the last program that have the file open closes it.
There are a lot more tricks available in this area, but I don't think we 
need to talk about those things here.

With this information available perhaps someone can help with 
information if anything similar have been implemented, or would be 
possible to implement in Unix. I haven't seen any myself, but I haven't 
really been searching either.

	Johnny