venti updates

This commit is contained in:
rsc
2005-07-24 20:15:44 +00:00
parent 7ba8aa0c70
commit 23fb2edb22
13 changed files with 166 additions and 48 deletions

View File

@@ -4,6 +4,8 @@
#include "fns.h"
#include "error.h"
#define debug 0
/*
* locking order is upwards. A thread can hold the lock for a VacFile
* and then acquire the lock of its parent
@@ -122,12 +124,16 @@ Err:
VacFile*
_vacfileroot(VacFs *fs, VtFile *r)
{
int redirected;
char err[ERRMAX];
VtBlock *b;
VtFile *r0, *r1, *r2;
MetaBlock mb;
MetaEntry me;
VacFile *root, *mr;
redirected = 0;
Top:
b = nil;
root = nil;
mr = nil;
@@ -137,13 +143,30 @@ _vacfileroot(VacFs *fs, VtFile *r)
if(vtfilelock(r, -1) < 0)
return nil;
r0 = vtfileopen(r, 0, fs->mode);
if(debug)
fprint(2, "r0 %p\n", r0);
if(r0 == nil)
goto Err;
r1 = vtfileopen(r, 1, fs->mode);
if(r1 == nil)
goto Err;
r2 = vtfileopen(r, 2, fs->mode);
if(r2 == nil)
if(debug)
fprint(2, "r2 %p\n", r2);
if(r2 == nil){
/*
* some vac files (e.g., from fossil)
* have an extra layer of indirection.
*/
rerrstr(err, sizeof err);
if(!redirected && strstr(err, "not active")){
vtfileunlock(r);
r = r0;
goto Top;
}
goto Err;
}
r1 = vtfileopen(r, 1, fs->mode);
if(debug)
fprint(2, "r1 %p\n", r1);
if(r1 == nil)
goto Err;
mr = filealloc(fs);