ref: 9d6dd137f507104276e42157ac86f34c0bb6f317
parent: dc6c8525bacd30794e6e7b7ad6604d112411f8e4
author: 9ferno <gophone2015@gmail.com>
date: Wed Oct 26 09:19:58 EDT 2022
moved the Tag to the end of the block as a check that contents were written and removed the dirty byte
--- a/9p.c
+++ b/9p.c
@@ -436,7 +436,7 @@
Iobuf *dbuf, *cbuf;
u64 reli, blkno;
Dentry *dchild, *dparent;
- Tag *ct;
+ Content *ct;
u64 zblkno; /* zero'ed dentry that can be reused */
Aux *aux;
u32 perm;
@@ -603,7 +603,7 @@
return;
}
dchild = &cbuf->io->d;
- ct = (Tag*)cbuf->io;
+ ct = (Content*)cbuf->io;
/* nothing to do for already zero'ed out slots */
if(ct->path == Qpnone){
--- a/blk.c
+++ b/blk.c
@@ -69,24 +69,24 @@
void
showblock(int fd, u8 *buf)
{
- Tag *t;
+ Content *t;
- t = (Tag*)buf;
+ t = (Content*)buf;
if(t->type < Maxtind)
- fprint(fd, "%s %llud%s\n", tagnames[t->type], t->path, t->dirty?" dirty":"");
+ fprint(fd, "%s %llud\n", tagnames[t->type], t->path);
if(t->type == Tdentry){
- showdentry(fd, buf+sizeof(Tag));
+ showdentry(fd, buf);
}else if(t->path == Qpmagic){
- showmagic(fd, buf+sizeof(Tag));
+ showmagic(fd, buf);
}else if(t->path == Qpconfig || t->path == Qpconfig0 || t->path == Qpconfig1){
- showconfig(fd, buf+sizeof(Tag));
+ showconfig(fd, buf);
}else if(t->path == Qpsuper || t->path == Qpsuper0 || t->path == Qpsuper1){
- showsuper(fd, buf+sizeof(Tag));
+ showsuper(fd, buf);
}else if(t->type == Tdata){
- showdata(fd, buf+sizeof(Tag));
+ showdata(fd, buf);
}else if(t->type >= Tind0 && t->type < Maxtind){
- showind(fd, buf+sizeof(Tag));
- }else if(t->type != 0 || t->path != 0 || t->dirty != 0){
+ showind(fd, buf);
+ }else if(t->type != 0 || t->path != 0){
fprint(fd, "unknown tag type %d path %llud\n", t->type, t->path);
}
}
\ No newline at end of file
--- a/dat.h
+++ b/dat.h
@@ -116,11 +116,8 @@
/* DONT TOUCH, this is the disk structure */
struct Tag
{
- u64 path; /* Qid.path, unique identifier */
u8 type; /* Tmagic, Tdentry, Tdata, Tindn */
- u8 dirty; /* is 1, when being written to.
- Identifies dirty data on a crash.
- This byte position is denoted by the enum Nthdirty. */
+ u64 path; /* Qid.path, unique identifier */
};
/* DONT TOUCH, this is the disk structure */
@@ -191,12 +188,12 @@
};
struct Content /* used to unmarshall the disk contents */
{
- Tag;
union{
u8 buf[Blocksize];
u64 bufa[Nindperblock];
Dentry d;
};
+ Tag;
};
#pragma pack off
--- a/dentry.c
+++ b/dentry.c
@@ -319,7 +319,8 @@
child = &buf->io->d;
cqpath = child->qid.path;
mode = child->mode;
- memcpy(&ct, buf->io, sizeof(Tag));
+ ct.type = buf->io->type;
+ ct.path = buf->io->path;
putbuf(buf);
/* nothing to do for already zero'ed out slots */
--- a/dev.c
+++ b/dev.c
@@ -31,30 +31,6 @@
}
int
-devwritedirty(u64 blkno, u8 dirty)
-{
- int n;
-
- if((n = pwrite(devfd, &dirty, 1, blkno*Rawblocksize +Nthdirty)) != 1)
- panic("devwrite failed: %r\n");
- return n;
-}
-
-int
-devwritedirtyclear(u64 blkno)
-{
- return devwritedirty(blkno, 0);
-}
-
-/* obsolete
-int
-devwritedirtyset(u64 blkno)
-{
- return devwritedirty(blkno, 1);
-}
-*/
-
-int
devwrite(u64 blkno, void *b)
{
int n;
--- a/find.c
+++ b/find.c
@@ -102,15 +102,15 @@
walkindir(u64 blkno, u16 tag, u16 bottomtag, u64 qpath, s8 depth)
{
u8 buf[Rawblocksize], *cbuf;
- Tag *t, *ct;
+ Content *t, *ct;
u64 cblkno, *bufa;
int i;
devread(blkno, buf);
- t = (Tag*)buf;
+ t = (Content*)buf;
if(checkvalid(blkno, t, tag, qpath)){
if(t->type == Tind0){
- bufa = (u64*)(buf+sizeof(Tag));
+ bufa = (u64*)buf;
for(i = 0; i<Nindperblock; i++){
cblkno = bufa[i];
if(cblkno == 0)
@@ -117,7 +117,7 @@
return;
cbuf = malloc(Rawblocksize);
devread(cblkno, cbuf);
- ct = (Tag*)cbuf;
+ ct = (Content*)cbuf;
if(ct->type == Tdentry && ct->type == bottomtag)
/* another directory */
walkdentry(cblkno, depth);
@@ -126,7 +126,7 @@
free(cbuf);
}
}else{
- bufa = (u64*)(buf+sizeof(Tag));
+ bufa = (u64*)buf;
cbuf = malloc(Rawblocksize);
for(i = 0; i<Nindperblock; i++){
cblkno = bufa[i];
@@ -167,14 +167,14 @@
{
u8 buf[Rawblocksize], *cbuf;
Dentry *d;
- Tag *t, *ct;
+ Content *t, *ct;
u64 cblkno;
int i;
u8 isdir;
devread(blkno, buf);
- t = (Tag*)buf;
- d = (Dentry*)(buf+sizeof(Tag));
+ t = (Content*)buf;
+ d = (Dentry*)buf;
isdir = (d->mode & DMDIR) > 0;
showdepth(depth);
print("%llud:%s\n", blkno, d->name);
@@ -195,7 +195,7 @@
return;
cbuf = malloc(Rawblocksize);
devread(cblkno, cbuf);
- ct = (Tag*)cbuf;
+ ct = (Content*)cbuf;
if(isdir)
walkdentry(cblkno, depth+1);
else
@@ -208,7 +208,7 @@
if(cblkno == 0)
return;
devread(cblkno, cbuf);
- ct = (Tag*)cbuf;
+ ct = (Content*)cbuf;
if(ct->type == Tind0+i){
walkindir(cblkno, Tind0+i, isdir ? Tdentry : Tdata, d->qid.path, depth);
}else{
--- a/fns.h
+++ b/fns.h
@@ -11,7 +11,6 @@
int devread(u64 blkno, void *b);
u64 devsize(void);
int devwrite(u64 blkno, void *b);
-int devwritedirtyclear(u64 blkno);
/* show blocks */
void showblock(int fd, u8 *buf);
--- a/free.c
+++ b/free.c
@@ -58,7 +58,7 @@
}
int
-checkvalid(u64 blkno, Tag *t, s16 tag, u64 qpath)
+checkvalid(u64 blkno, Content *t, s16 tag, u64 qpath)
{
if(t->type != tag || t->path != qpath){
/* if(chatty9p) */
@@ -76,10 +76,10 @@
checkblock(u64 blkno, s16 tag, u64 qpath)
{
u8 buf[Rawblocksize];
- Tag *t;
+ Content *t;
devread(blkno, buf);
- t = (Tag*)buf;
+ t = (Content*)buf;
return checkvalid(blkno, t, tag, qpath);
}
@@ -90,7 +90,7 @@
buf = emalloc(Rawblocksize);
devread(blkno, buf);
- loadextents(&frees, buf+sizeof(Tag), (Rawblocksize)-sizeof(Tag));
+ loadextents(&frees, buf, (Rawblocksize)-sizeof(Tag));
free(buf);
}
@@ -98,15 +98,15 @@
walkindir(u64 blkno, u16 tag, u16 bottomtag, u64 qpath)
{
u8 buf[Rawblocksize], cbuf[Rawblocksize];
- Tag *t;
+ Content *t;
u64 cblkno, *bufa;
int i;
devread(blkno, buf);
- t = (Tag*)buf;
+ t = (Content*)buf;
if(checkvalid(blkno, t, tag, qpath)){
if(t->type == Tind0){
- bufa = (u64*)(buf+sizeof(Tag));
+ bufa = (u64*)buf;
for(i = 0; i<Nindperblock; i++){
cblkno = bufa[i];
if(cblkno == 0)
@@ -114,7 +114,7 @@
loadfreeextents(cblkno);
}
}else{
- bufa = (u64*)(buf+sizeof(Tag));
+ bufa = (u64*)buf;
for(i = 0; i<Nindperblock; i++){
cblkno = bufa[i];
if(cblkno == 0)
@@ -133,13 +133,13 @@
u64 size;
u8 buf[Rawblocksize], cbuf[Rawblocksize];
Dentry *d;
- Tag *t;
+ Content *t;
u64 cblkno;
int i;
devread(dblkno, buf);
- t = (Tag*)buf;
- d = (Dentry*)(buf+sizeof(Tag));
+ t = (Content*)buf;
+ d = (Dentry*)buf;
size = d->size;
if(size == 0)
panic("loadfreeextents size == 0");
--- a/tests/test.0/blocks/10
+++ b/tests/test.0/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666329175295312888
--- a/tests/test.0/blocks/11
+++ b/tests/test.0/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666329175295317307
--- a/tests/test.0/blocks/12
+++ b/tests/test.0/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666329175295319284
--- a/tests/test.0/blocks/13
+++ b/tests/test.0/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666329175295323928
--- a/tests/test.0/blocks/14
+++ b/tests/test.0/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666329175295325863
--- a/tests/test.0/blocks/15
+++ b/tests/test.0/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666329175295327710
--- a/tests/test.1/blocks/10
+++ b/tests/test.1/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666331993065536646
--- a/tests/test.1/blocks/11
+++ b/tests/test.1/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666331993065540434
--- a/tests/test.1/blocks/12
+++ b/tests/test.1/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666331993065542088
--- a/tests/test.1/blocks/13
+++ b/tests/test.1/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666331993065546043
--- a/tests/test.1/blocks/14
+++ b/tests/test.1/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666331993065547831
--- a/tests/test.1/blocks/15
+++ b/tests/test.1/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666331993065549444
--- a/tests/test.2/blocks/10
+++ b/tests/test.2/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666332446276265491
--- a/tests/test.2/blocks/11
+++ b/tests/test.2/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666332446276270426
--- a/tests/test.2/blocks/12
+++ b/tests/test.2/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666332446276272441
--- a/tests/test.2/blocks/13
+++ b/tests/test.2/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666332446276277133
--- a/tests/test.2/blocks/14
+++ b/tests/test.2/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666332446276279179
--- a/tests/test.2/blocks/15
+++ b/tests/test.2/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666332446276281041
--- a/tests/test.3/blocks/10
+++ b/tests/test.3/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666355236185882933
--- a/tests/test.3/blocks/11
+++ b/tests/test.3/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666355236185888080
--- a/tests/test.3/blocks/12
+++ b/tests/test.3/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666355236185889788
--- a/tests/test.3/blocks/13
+++ b/tests/test.3/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666355236185894127
--- a/tests/test.3/blocks/14
+++ b/tests/test.3/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666355236185895736
--- a/tests/test.3/blocks/15
+++ b/tests/test.3/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666355236185900190
--- a/tests/test.6/blocks/10
+++ b/tests/test.6/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333071921971487
--- a/tests/test.6/blocks/11
+++ b/tests/test.6/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333071921975242
--- a/tests/test.6/blocks/12
+++ b/tests/test.6/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333071921977005
--- a/tests/test.6/blocks/13
+++ b/tests/test.6/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333071921981139
--- a/tests/test.6/blocks/14
+++ b/tests/test.6/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333071921983052
--- a/tests/test.6/blocks/15
+++ b/tests/test.6/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333071921985035
--- a/tests/test.8/blocks/10
+++ b/tests/test.8/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333567328049920
--- a/tests/test.8/blocks/11
+++ b/tests/test.8/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333567328054661
--- a/tests/test.8/blocks/12
+++ b/tests/test.8/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333567328056600
--- a/tests/test.8/blocks/13
+++ b/tests/test.8/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333567328061403
--- a/tests/test.8/blocks/14
+++ b/tests/test.8/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333567328063282
--- a/tests/test.8/blocks/15
+++ b/tests/test.8/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333567328064911
--- a/tests/test.9/blocks/10
+++ b/tests/test.9/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333673570015211
--- a/tests/test.9/blocks/11
+++ b/tests/test.9/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333673570020286
--- a/tests/test.9/blocks/12
+++ b/tests/test.9/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333673570022487
--- a/tests/test.9/blocks/13
+++ b/tests/test.9/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333673570027272
--- a/tests/test.9/blocks/14
+++ b/tests/test.9/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333673570029174
--- a/tests/test.9/blocks/15
+++ b/tests/test.9/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666333673570030766
--- a/tests/test.b/blocks/10
+++ b/tests/test.b/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359855817803137
--- a/tests/test.b/blocks/11
+++ b/tests/test.b/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359855817807985
--- a/tests/test.b/blocks/12
+++ b/tests/test.b/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359855817810192
--- a/tests/test.b/blocks/13
+++ b/tests/test.b/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359855817814624
--- a/tests/test.b/blocks/14
+++ b/tests/test.b/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359855817816538
--- a/tests/test.b/blocks/15
+++ b/tests/test.b/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359855817818278
--- a/tests/test.d/blocks/10
+++ b/tests/test.d/blocks/10
@@ -1,7 +1,7 @@
Tdentry 8
qid.version 0
qid.path 8
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359865759946606
--- a/tests/test.d/blocks/11
+++ b/tests/test.d/blocks/11
@@ -1,7 +1,7 @@
Tdentry 9
qid.version 0
qid.path 9
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359865759948486
--- a/tests/test.d/blocks/12
+++ b/tests/test.d/blocks/12
@@ -1,7 +1,7 @@
Tdentry 10
qid.version 0
qid.path 10
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359865759953319
--- a/tests/test.d/blocks/13
+++ b/tests/test.d/blocks/13
@@ -1,7 +1,7 @@
Tdentry 11
qid.version 0
qid.path 11
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359865759955235
--- a/tests/test.d/blocks/14
+++ b/tests/test.d/blocks/14
@@ -1,7 +1,7 @@
Tdentry 12
qid.version 0
qid.path 12
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359865759956872
--- a/tests/test.d/blocks/15
+++ b/tests/test.d/blocks/15
@@ -1,7 +1,7 @@
Tdentry 13
qid.version 0
qid.path 13
-size 502
+size 503
pdblkno 9
pqpath 7
mtime 1666359865759962493
--- a/tests/testpkdstruct.c
+++ b/tests/testpkdstruct.c
@@ -7,12 +7,32 @@
typedef unsigned long long u64;
typedef struct Spanid Spanid;
+typedef struct Tag Tag;
+/*
+ this program shows inconsistent behaviour when returning packed structs.
+ Everything works fine if the Tag is defined with this definition.
+ Bottom line: Cannot count on return values of packed structures.
+struct Tag
+{
+ u8 type;
+ u64 path;
+};
+
+ */
+
#pragma pack on
+struct Tag
+{
+ u64 path; /* Qid.path, unique identifier */
+ u8 type; /* Tmagic, Tdentry, Tdata, Tindn */
+};
struct Spanid /* Spanid identifier */
{
- u64 blkno; /* starting block number */
u16 len; /* number of blocks */
+ u64 blkno; /* starting block number */
+ Tag;
+// Tag1;
};
#pragma pack off
@@ -23,12 +43,17 @@
{
t[0].blkno = 888888;
t[0].len = 9;
+ t[0].type = 9;
+ t[0].path = 789789;
}
Spanid
get(int i)
{
- print("get t[i] blkno %llud len %d\n", t[i].blkno, t[i].len);
+ print("get t[i] blkno %llud len %d"
+ " type %d path %llud\n",
+ t[i].blkno, t[i].len,
+ t[i].type, t[i].path);
return t[i];
}
@@ -47,7 +72,10 @@
save();
s = get(0);
- print(" blkno %llud len %d\n", s.blkno, s.len);
+ print(" blkno %llud len %d"
+ " type %d path %llud\n",
+ s.blkno, s.len,
+ s.type, s.path);
s.blkno = 77777;
s.len = 8;
--- a/used.c
+++ b/used.c
@@ -54,12 +54,12 @@
}
int
-checkvalid(u64 blkno, Tag *t, s16 tagtype, u64 qpath)
+checkvalid(u64 blkno, Content *t, s16 tagtype, u64 qpath)
{
- if(t->type != tagtype || t->path != qpath || t->dirty != 0){
+ if(t->type != tagtype || t->path != qpath){
/* if(debug) */
- fprint(2, "checkblock invalid %llud tag/path expected %s/%llud actual %s/%llud dirty %d\n",
- blkno, tagnames[tagtype], qpath, tagnames[t->type], t->path, t->dirty);
+ fprint(2, "checkblock invalid %llud tag/path expected %s/%llud actual %s/%llud\n",
+ blkno, tagnames[tagtype], qpath, tagnames[t->type], t->path);
fprint(2, "used: %llud\n", blkno);
return 0;
}
@@ -73,10 +73,10 @@
checkblock(u64 blkno, s16 tag, u64 qpath)
{
u8 buf[Rawblocksize];
- Tag *t;
+ Content *t;
devread(blkno, buf);
- t = (Tag*)buf;
+ t = (Content*)buf;
return checkvalid(blkno, t, tag, qpath);
}
@@ -84,15 +84,15 @@
walkindir(u64 blkno, u16 tag, u16 bottomtag, u64 qpath)
{
u8 buf[Rawblocksize], *cbuf;
- Tag *t, *ct;
+ Content *t, *ct;
u64 cblkno, *bufa;
int i;
devread(blkno, buf);
- t = (Tag*)buf;
+ t = (Content*)buf;
if(checkvalid(blkno, t, tag, qpath)){
if(t->type == Tind0){
- bufa = (u64*)(buf+sizeof(Tag));
+ bufa = (u64*)buf;
for(i = 0; i<Nindperblock; i++){
cblkno = bufa[i];
if(cblkno == 0)
@@ -99,7 +99,7 @@
return;
cbuf = malloc(Rawblocksize);
devread(cblkno, cbuf);
- ct = (Tag*)cbuf;
+ ct = (Content*)cbuf;
if(ct->type == Tdentry && ct->type == bottomtag)
walkdentry(cblkno);
else
@@ -107,7 +107,7 @@
free(cbuf);
}
}else{
- bufa = (u64*)(buf+sizeof(Tag));
+ bufa = (u64*)buf;
cbuf = malloc(Rawblocksize);
for(i = 0; i<Nindperblock; i++){
cblkno = bufa[i];
@@ -128,14 +128,14 @@
{
u8 buf[Rawblocksize], *cbuf;
Dentry *d;
- Tag *t, *ct;
+ Content *t, *ct;
u64 cblkno;
int i;
u8 isdir;
devread(blkno, buf);
- t = (Tag*)buf;
- d = (Dentry*)(buf+sizeof(Tag));
+ t = (Content*)buf;
+ d = (Dentry*)buf;
isdir = (d->mode & DMDIR) > 0;
if(debug)
print("walkdentry %llud tag %s name %s d->qid.path %llud\n",
@@ -157,7 +157,7 @@
return;
cbuf = malloc(Rawblocksize);
devread(cblkno, cbuf);
- ct = (Tag*)cbuf;
+ ct = (Content*)cbuf;
if(isdir)
walkdentry(cblkno);
else
@@ -170,7 +170,7 @@
if(cblkno == 0)
return;
devread(cblkno, cbuf);
- ct = (Tag*)cbuf;
+ ct = (Content*)cbuf;
if(ct->type == Tind0+i){
walkindir(cblkno, Tind0+i, isdir ? Tdentry : Tdata, d->qid.path);
}else{
--- a/writer.c
+++ b/writer.c
@@ -164,14 +164,11 @@
}
if(chatty9p > 4)
dprint("dowrite p->blkno %llud locked\n", p->blkno);
- p->io->dirty = 1;
if((n = devwrite(p->blkno, p->payload)) != Rawblocksize){
dprint("%s\n", errstring[Esystem]);
panic("error writing block %llud: %llud bytes: %r\n",
p->blkno, n);
}
- p->io->dirty = 0;
- devwritedirtyclear(p->blkno);
n = p->blkno;
if(chatty9p > 4)
dprint("dowrite %llud wunlock()'ed\n", n);