ref: b3e875d7db45fca0cde9f4efa12872f61afc54d7
parent: 285644aadb1b58735651a5068703372f8fc9adac
author: 9ferno <gophone2015@gmail.com>
date: Sun Jan 15 03:49:43 EST 2023
binary extents files
--- a/9p.c
+++ b/9p.c
@@ -1644,7 +1644,8 @@
oldblkno = rel2abs(d, d->size/Maxdatablocksize);
oldbuf = egetbufchk(oldblkno, nlastdatablocks(lastdatablksize),
Bwritable, Tdata, d->path, getcallerpc(&dbuf));
- if(newbuf->xiobuf+(newbuf->io->len*Blocksize)-sizeof(u64) < newbuf->io->buf+lastdatablksize)
+ if(newbuf->xiobuf+(newbuf->io->len*Blocksize)-sizeof(u64)
+ < newbuf->io->buf+lastdatablksize)
panic("writefullappend last block overstepping the bounds");
memcpy(newbuf->io->buf, oldbuf->io->buf, lastdatablksize);
newbufsize = lastdatablksize;
@@ -1652,7 +1653,8 @@
/* add the contents of append to those new blocks */
howmuch = Maxdatablocksize-newbufsize;
- if(newbuf->xiobuf+(newbuf->io->len*Blocksize)-sizeof(u64) < newbuf->io->buf+newbufsize+howmuch)
+ if(newbuf->xiobuf+(newbuf->io->len*Blocksize)-sizeof(u64)
+ < newbuf->io->buf+newbufsize+howmuch)
panic("writefullappend contents overstepping the bounds");
memcpy(newbuf->io->buf+newbufsize, dbuf->append, howmuch);
--- a/blk.c
+++ b/blk.c
@@ -47,7 +47,7 @@
{
int j, k;
Dentry *d;
- u64 i;
+ u64 i, start, end, nunits, *p;
Name *nm;
showdentryhdr(fd, buf);
@@ -68,6 +68,16 @@
fprint(fd, "%c", nm->name[k]);
fprint(fd, " %llud\n", nm->noffset);
}
+ }else if((d->flags&~Fsys) == Fe){
+ p = (u64*)d->buf;
+ for(i = d->size/(3*sizeof(u64)); i>0; i++){
+ start = *p++;
+ end = *p++;
+ nunits = *p++;
+ if(start == 0 && end == 0)
+ return;
+ fprint(fd, "%llud %llud %llud\n", start, end, nunits);
+ }
}else{
fprint(fd, "%s", d->buf);
}
@@ -94,7 +104,7 @@
showdata(int fd, u8 *buf)
{
Data *da;
- u64 i;
+ u64 i, start, end, nunits, *p;
u8 k;
Name *nm;
@@ -108,6 +118,19 @@
for(k = 0; k < Nfirst; k++)
fprint(fd, "%c", nm->name[k]);
fprint(fd, " %llud\n", nm->noffset);
+ }
+ }else if((da->flags&~Fsys) == Fe){
+ /* extents file, show extents */
+ /* assuming that the extents fit in 1048556 bytes */
+ /* else, we need to worry about the offset */
+ p = (u64*)da->buf;
+ for(i = (da->len*Blocksize -Ddataidssize)/(3*sizeof(u64)); i>0; i++){
+ start = *p++;
+ end = *p++;
+ nunits = *p++;
+ if(start == 0 && end == 0)
+ return;
+ fprint(fd, "%llud %llud %llud\n", start, end, nunits);
}
}else{
fprint(fd, "%s", (s8*)da->buf);
--- a/sub.c
+++ b/sub.c
@@ -192,7 +192,7 @@
}
void
-reamfile(u64 dblkno, u64 qpath, char *name, u64 size, u64 pdblkno, u64 pqpath, u64 preli)
+reamfile(u64 dblkno, u64 qpath, char *name, u64 size, u64 pdblkno, u64 pqpath, u64 preli, u8 flags)
{
Iobuf *b;
Dentry *d;
@@ -203,6 +203,7 @@
USED(name);
/* d->namelen = strlen(name);
strcpy(d->name, name);*/
+ d->flags = flags;
d->uid = d->muid = d->gid = -1;
d->mode =
((DMREAD) << 6) |
@@ -623,11 +624,11 @@
strncpy((s8*)d->buf, cbuf, d->size);
putbuf(b, 1);
- reamfile(Bdctl, Qpctl, "ctl", 0, Bda, Qpa, 5);
- reamfile(Bdfrees, Qpfrees, "frees", 0, Bda, Qpa, 6);
+ reamfile(Bdctl, Qpctl, "ctl", 0, Bda, Qpa, 5, 0);
+ reamfile(Bdfrees, Qpfrees, "frees", 0, Bda, Qpa, 6, Fe);
reamfile(Bdusersstaging, Qpusersstaging, "staging",
- 0, Bdusers, Qpusers, 4);
+ 0, Bdusers, Qpusers, 4, 0);
}
void
@@ -669,11 +670,11 @@
strncpy(config.service, service, Servicelen);
reamfile(config.config.dest[0], Qpconfig0, "config.0",
- 0, Bdbkp, Qpbkp, 3);
+ 0, Bdbkp, Qpbkp, 3, 0);
reamfile(config.root.dest[0], Qproot0, "root.0",
- 0, Bdbkp, Qpbkp, 4);
+ 0, Bdbkp, Qpbkp, 4, 0);
reamfile(config.super.dest[0], Qpsuper0, "super.0",
- 0, Bdbkp, Qpbkp, 5);
+ 0, Bdbkp, Qpbkp, 5, 0);
putbuf(sbuf, 1);
if(chatty9p > 1)