commit - 3d77c87e81bf16aeaf52ba0f523af6708c5c4964
commit + d23a617a8302ef9c6b9edb0a29e3bae4737d5f00
blob - a828101a3e1d1d6033158eb6762c925715dbc177
blob + 557d242082c81d32ab0dcdf755dc6931ee18bc5e
--- include/venti.h
+++ include/venti.h
int packettrim(Packet*, int offset, int n);
uchar *packetheader(Packet*, int n);
uchar *packettrailer(Packet*, int n);
-int packetprefix(Packet*, uchar *buf, int n);
-int packetappend(Packet*, uchar *buf, int n);
-int packetconcat(Packet*, Packet*);
+void packetprefix(Packet*, uchar *buf, int n);
+void packetappend(Packet*, uchar *buf, int n);
+void packetconcat(Packet*, Packet*);
uchar *packetpeek(Packet*, uchar *buf, int offset, int n);
int packetcopy(Packet*, uchar *buf, int offset, int n);
int packetfragments(Packet*, IOchunk*, int nio, int offset);
*/
typedef struct VtFcall VtFcall;
-typedef struct VtSha1 VtSha1;
typedef struct VtConn VtConn;
typedef struct VtEntry VtEntry;
typedef struct VtRoot VtRoot;
VtMaxType,
VtTypeDepthMask = 7,
+ VtTypeBaseMask = ~VtTypeDepthMask,
};
/* convert to/from on-disk type numbers */
enum
{
VtEntryActive = 1<<0, /* entry is in use */
- VtEntryDir = 1<<1, /* a directory */
- VtEntryDepthShift = 2, /* shift for pointer depth */
- VtEntryDepthMask = 7<<2, /* mask for pointer depth */
+ _VtEntryDir = 1<<1, /* a directory */
+ _VtEntryDepthShift = 2, /* shift for pointer depth */
+ _VtEntryDepthMask = 7<<2, /* mask for pointer depth */
VtEntryLocal = 1<<5, /* for local storage only */
};
enum
/*
* parse score: mungs s
*/
-int vtparsescore(char *s, uint len, char **prefix, uchar[VtScoreSize]);
+int vtparsescore(char *s, char **prefix, uchar[VtScoreSize]);
/*
* formatting
int vtblockwrite(VtBlock*);
VtBlock *vtblockcopy(VtBlock*);
void vtblockduplock(VtBlock*);
+int vtblockdirty(VtBlock*);
/*
* Hash tree file tree.
*/
typedef struct VtFile VtFile;
+struct VtFile
+{
+ QLock lk;
+ int ref;
+ int local;
+ VtBlock *b; /* block containing this file */
+ uchar score[VtScoreSize]; /* score of block containing this file */
+/* immutable */
+ VtCache *c;
+ int mode;
+ u32int gen;
+ int dsize;
+ int dir;
+ VtFile *parent;
+ int epb; /* entries per block in parent */
+ u32int offset; /* entry offset in parent */
+};
+
enum
{
VtOREAD,
VtFile *vtfileopen(VtFile*, u32int, int);
VtFile *vtfilecreate(VtFile*, int psize, int dsize, int dir);
VtBlock *vtfileblock(VtFile*, u32int, int mode);
-int vtfileblockhash(VtFile*, u32int, uchar[VtScoreSize]);
long vtfileread(VtFile*, void*, long, vlong);
long vtfilewrite(VtFile*, void*, long, vlong);
int vtfileflush(VtFile*);
void vtfileincref(VtFile*);
void vtfileclose(VtFile*);
int vtfilegetentry(VtFile*, VtEntry*);
+int vtfilesetentry(VtFile*, VtEntry*);
int vtfileblockscore(VtFile*, u32int, uchar[VtScoreSize]);
u32int vtfilegetdirsize(VtFile*);
int vtfilesetdirsize(VtFile*, u32int);
int vtfilelock(VtFile*, int);
int vtfilelock2(VtFile*, VtFile*, int);
int vtfileflushbefore(VtFile*, u64int);
+int vtfiletruncate(VtFile*);
+uvlong vtfilegetsize(VtFile*);
+int vtfilesetsize(VtFile*, uvlong);
+int vtfileremove(VtFile*);
#if defined(__cplusplus)
}
blob - ed8a7f2fcf4eddb5f4e3e1bbee8fd82bec18f8d8
blob + dff32cd60609909627d96ca45962f514d5414e96
--- src/libventi/cache.c
+++ src/libventi/cache.c
return NilBlock;
return (score[16]<<24)|(score[17]<<16)|(score[18]<<8)|score[19];
}
+
+int
+vtblockdirty(VtBlock *b)
+{
+ return 0;
+}
+
blob - 59c09e9afaa1e5f2acbc7cfb736e7357812a5e4a
blob + ca1d200926bd4e2c87f15fc8bd87156aea2b4c03
--- src/libventi/entry.c
+++ src/libventi/entry.c
U16PUT(p, e->dsize);
p += 2;
depth = e->type&VtTypeDepthMask;
- flags = (e->flags&~(VtEntryDir|VtEntryDepthShift));
- flags |= depth << VtEntryDepthShift;
- if(e->type - depth == VtEntryDir)
- flags |= VtEntryDir;
+ flags = (e->flags&~(_VtEntryDir|_VtEntryDepthMask));
+ flags |= depth << _VtEntryDepthShift;
+ if(e->type - depth == VtDirType)
+ flags |= _VtEntryDir;
U8PUT(p, flags);
p++;
memset(p, 0, 5);
e->dsize = U16GET(p);
p += 2;
e->flags = U8GET(p);
- e->type = (e->flags&VtEntryDir) ? VtDirType : VtDataType;
- e->type += (e->flags & VtEntryDepthMask) >> VtEntryDepthShift;
- e->flags &= ~(VtEntryDir|VtEntryDepthMask);
+ e->type = (e->flags&_VtEntryDir) ? VtDirType : VtDataType;
+ e->type += (e->flags & _VtEntryDepthMask) >> _VtEntryDepthShift;
+ e->flags &= ~(_VtEntryDir|_VtEntryDepthMask);
p++;
p += 5;
e->size = U48GET(p);
blob - 4048411753230892ccd1e6d55e78e85ea6a2a3bc
blob + 655b3891556108e7c778499403a1067e245673a6
--- src/libventi/file.c
+++ src/libventi/file.c
enum
{
MaxBlock = (1UL<<31),
-};
-
-struct VtFile
-{
- QLock lk;
- int ref;
- int local;
- VtBlock *b; /* block containing this file */
- uchar score[VtScoreSize]; /* score of block containing this file */
-
-/* immutable */
- VtCache *c;
- int mode;
- u32int gen;
- int dsize;
- int dir;
- VtFile *parent;
- int epb; /* entries per block in parent */
- u32int offset; /* entry offset in parent */
};
static char EBadEntry[] = "bad VtEntry";
r->mode = mode;
r->dsize = e.dsize;
r->gen = e.gen;
- r->dir = (e.flags & VtEntryDir) != 0;
+ r->dir = (e.type & VtTypeBaseMask) == VtDirType;
r->ref = 1;
r->parent = p;
if(p){
e.flags = VtEntryActive;
e.psize = psize;
e.dsize = dsize;
- if(type == VtDirType)
- e.flags |= VtEntryDir;
+ e.type = type;
memmove(e.score, vtzeroscore, VtScoreSize);
return vtfileopenroot(c, &e);
mkindices(VtEntry *e, u32int bn, int *index)
{
int i, np;
+ u32int obn;
+ obn = bn;
memset(index, 0, VtPointerDepth*sizeof(int));
np = e->psize/VtScoreSize;
for(i=0; bn > 0; i++){
if(i >= VtPointerDepth){
- werrstr(EBadAddr);
+ werrstr("bad address 0x%lux", (ulong)bn);
return -1;
}
index[i] = bn % np;
return nil;
if(i > DEPTH(e.type)){
if(mode == VtOREAD){
- werrstr(EBadAddr);
+ werrstr("bad address 0x%lux", (ulong)bn);
goto Err;
}
index[i] = 0;
}
int
-vtfileblockhash(VtFile *r, u32int bn, uchar score[VtScoreSize])
+vtfileblockscore(VtFile *r, u32int bn, uchar score[VtScoreSize])
{
VtBlock *b, *bb;
int index[VtPointerDepth+1];
blob - 735e1e3c647037aae5a8eda3c9b2f5d6a673d765
blob + 24a80aa12b76cc518e7291a1cd539032001773e3
--- src/libventi/mkfile
+++ src/libventi/mkfile
hangup.$O\
mem.$O\
packet.$O\
+ parsescore.$O\
queue.$O\
root.$O\
rpc.$O\
blob - c781eb391311e2aea90461267089380865e1e662
blob + 7ca6be8639a99af7d212a1b005b7464cebb174c6
--- src/libventi/packet.c
+++ src/libventi/packet.c
p->last = nil;
p->next = nil;
-if(1)fprint(2, "packetalloc %p from %08lux %08lux %08lux\n", p, *((uint*)&p+2), *((uint*)&p+3), *((uint*)&p+4));
+if(0)fprint(2, "packetalloc %p from %08lux %08lux %08lux\n", p, *((uint*)&p+2), *((uint*)&p+3), *((uint*)&p+4));
return p;
}
{
Frag *f, *ff;
-if(1)fprint(2, "packetfree %p from %08lux\n", p, getcallerpc(&p));
+if(0)fprint(2, "packetfree %p from %08lux\n", p, getcallerpc(&p));
if(p == nil)
return;
{
NOTFREE(p);
if(buf && packetcopy(p, buf, 0, n) < 0)
- return 0;
+ return -1;
return packettrim(p, n, p->size-n);
}
return f->rp;
}
-int
+void
packetprefix(Packet *p, uchar *buf, int n)
{
Frag *f;
NOTFREE(p);
if(n <= 0)
- return 0;
+ return;
p->size += n;
n -= nn;
memmove(f->rp, buf+n, nn);
}
- return 0;
}
-int
+void
packetappend(Packet *p, uchar *buf, int n)
{
Frag *f;
NOTFREE(p);
if(n <= 0)
- return 0;
+ return;
p->size += n;
/* try and fix in current frag */
buf += nn;
n -= nn;
}
- return 0;
+ return;
}
-int
+void
packetconcat(Packet *p, Packet *pp)
{
NOTFREE(p);
NOTFREE(pp);
if(pp->size == 0)
- return 0;
+ return;
p->size += pp->size;
p->asize += pp->asize;
pp->asize = 0;
pp->first = nil;
pp->last = nil;
- return 0;
}
uchar *