-
Notifications
You must be signed in to change notification settings - Fork 1
Research
Put design brainstorming here.
Different idea on implementation: Files under VCS are actually Super_SDirs Super_SDir files have an xattr identifying them as such. Have other xattr's with the following: Current version no. Number of versions.
Then, the actual file is just a directory so it just contains all of the snapshots. Each snapshot is just identified by the file name (so just using strcmp on the token in the provided path to the Fuse functions).
Writing to the FS just means adding another snapshot to the folder, and updating the current version number with setxattr.
The tree of files can be constructed by looking at the names of files.
For creating the next file name, where a file name is of the format: a[.b[.c[.d[...]]]] where a,b,c,d... are integers you look at the last integer in the string (what comes after the last . delimiter) and add 1 to it.
(See examples below)
If that file already exists, you know you have to create a new branch for the current file (as we aren't in the most recent version in the tree currently). Thus we would add another delimited integer .1 to the end of the original version number and check if that file exists. If it does, then we add a .0 (reserved for creating multiple children of the current branch) and then retry adding a .1 to that.
If it doesn't exist just add 1 to the last integer in the current path, create that file and write the contents to it.
example 1: at most recent changes on branch
versions:
...
1.2.2 <- current version number set by setxattr on the supersdir
1.1.2
going to save would write to 1.2.3
example 2: not at most recent changes in branch
versions:
...
1.2.2 <- current version number set by setxattr
1.2.3
will create 1.2.2.1
example 3: not at most recent changes in branch AND another version from the current version
versions:
...
1.2.2 <- current version number set by setxattr
1.2.2.1
1.2.3
will create 1.2.2.0.1 as the next child from 1.2.2 when a write occurs.
Continuing, if we were to revert again to version 1.2.2, the state would be as follows:
...
1.2.2 <- current version
1.2.2.1
1.2.2.0.1
1.2.3
another write would create 1.2.2.0.0.1