aboutsummaryrefslogtreecommitdiff
path: root/src/libventi
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-03-15 01:57:29 +0000
committerrsc <devnull@localhost>2004-03-15 01:57:29 +0000
commitd23a617a8302ef9c6b9edb0a29e3bae4737d5f00 (patch)
tree0b27efa3e256d681ded36367b0ecc41d58ed8d4c /src/libventi
parent3d77c87e81bf16aeaf52ba0f523af6708c5c4964 (diff)
downloadplan9port-d23a617a8302ef9c6b9edb0a29e3bae4737d5f00.tar.gz
plan9port-d23a617a8302ef9c6b9edb0a29e3bae4737d5f00.tar.bz2
plan9port-d23a617a8302ef9c6b9edb0a29e3bae4737d5f00.zip
Various small interface changes.
Diffstat (limited to 'src/libventi')
-rw-r--r--src/libventi/cache.c7
-rw-r--r--src/libventi/entry.c14
-rw-r--r--src/libventi/file.c32
-rw-r--r--src/libventi/mkfile1
-rw-r--r--src/libventi/packet.c22
5 files changed, 32 insertions, 44 deletions
diff --git a/src/libventi/cache.c b/src/libventi/cache.c
index ed8a7f2f..dff32cd6 100644
--- a/src/libventi/cache.c
+++ b/src/libventi/cache.c
@@ -558,3 +558,10 @@ vtglobaltolocal(uchar score[VtScoreSize])
return NilBlock;
return (score[16]<<24)|(score[17]<<16)|(score[18]<<8)|score[19];
}
+
+int
+vtblockdirty(VtBlock *b)
+{
+ return 0;
+}
+
diff --git a/src/libventi/entry.c b/src/libventi/entry.c
index 59c09e9a..ca1d2009 100644
--- a/src/libventi/entry.c
+++ b/src/libventi/entry.c
@@ -31,10 +31,10 @@ vtentrypack(VtEntry *e, uchar *p, int index)
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);
@@ -62,9 +62,9 @@ vtentryunpack(VtEntry *e, uchar *p, int index)
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);
diff --git a/src/libventi/file.c b/src/libventi/file.c
index 40484117..655b3891 100644
--- a/src/libventi/file.c
+++ b/src/libventi/file.c
@@ -21,25 +21,6 @@ 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";
static char ENotDir[] = "walk in non-directory";
static char ETooBig[] = "file too big";
@@ -109,7 +90,7 @@ vtfilealloc(VtCache *c, VtBlock *b, VtFile *p, u32int offset, int mode)
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){
@@ -169,8 +150,7 @@ vtfilecreateroot(VtCache *c, int psize, int dsize, int type)
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);
@@ -679,13 +659,15 @@ static int
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;
@@ -715,7 +697,7 @@ vtfileblock(VtFile *r, u32int bn, int mode)
return nil;
if(i > DEPTH(e.type)){
if(mode == VtOREAD){
- werrstr(EBadAddr);
+ werrstr("bad address 0x%lux", (ulong)bn);
goto Err;
}
index[i] = 0;
@@ -746,7 +728,7 @@ Err:
}
int
-vtfileblockhash(VtFile *r, u32int bn, uchar score[VtScoreSize])
+vtfileblockscore(VtFile *r, u32int bn, uchar score[VtScoreSize])
{
VtBlock *b, *bb;
int index[VtPointerDepth+1];
diff --git a/src/libventi/mkfile b/src/libventi/mkfile
index 735e1e3c..24a80aa1 100644
--- a/src/libventi/mkfile
+++ b/src/libventi/mkfile
@@ -17,6 +17,7 @@ OFILES=\
hangup.$O\
mem.$O\
packet.$O\
+ parsescore.$O\
queue.$O\
root.$O\
rpc.$O\
diff --git a/src/libventi/packet.c b/src/libventi/packet.c
index c781eb39..7ca6be86 100644
--- a/src/libventi/packet.c
+++ b/src/libventi/packet.c
@@ -113,7 +113,7 @@ packetalloc(void)
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;
}
@@ -123,7 +123,7 @@ packetfree(Packet *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;
@@ -237,7 +237,7 @@ packetconsume(Packet *p, uchar *buf, int n)
{
NOTFREE(p);
if(buf && packetcopy(p, buf, 0, n) < 0)
- return 0;
+ return -1;
return packettrim(p, n, p->size-n);
}
@@ -371,7 +371,7 @@ packettrailer(Packet *p, int n)
return f->rp;
}
-int
+void
packetprefix(Packet *p, uchar *buf, int n)
{
Frag *f;
@@ -380,7 +380,7 @@ packetprefix(Packet *p, uchar *buf, int n)
NOTFREE(p);
if(n <= 0)
- return 0;
+ return;
p->size += n;
@@ -410,10 +410,9 @@ packetprefix(Packet *p, uchar *buf, int n)
n -= nn;
memmove(f->rp, buf+n, nn);
}
- return 0;
}
-int
+void
packetappend(Packet *p, uchar *buf, int n)
{
Frag *f;
@@ -422,7 +421,7 @@ packetappend(Packet *p, uchar *buf, int n)
NOTFREE(p);
if(n <= 0)
- return 0;
+ return;
p->size += n;
/* try and fix in current frag */
@@ -455,16 +454,16 @@ packetappend(Packet *p, uchar *buf, int n)
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;
@@ -477,7 +476,6 @@ packetconcat(Packet *p, Packet *pp)
pp->asize = 0;
pp->first = nil;
pp->last = nil;
- return 0;
}
uchar *