aboutsummaryrefslogtreecommitdiff
path: root/src/libventi/file.c
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/file.c
parent3d77c87e81bf16aeaf52ba0f523af6708c5c4964 (diff)
downloadplan9port-d23a617a8302ef9c6b9edb0a29e3bae4737d5f00.tar.gz
plan9port-d23a617a8302ef9c6b9edb0a29e3bae4737d5f00.tar.bz2
plan9port-d23a617a8302ef9c6b9edb0a29e3bae4737d5f00.zip
Various small interface changes.
Diffstat (limited to 'src/libventi/file.c')
-rw-r--r--src/libventi/file.c32
1 files changed, 7 insertions, 25 deletions
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];