ref: 334cd4d87fc9fd8e48183128e9d60de669ab29fe
dir: /blk.c/
#include <u.h> #include <libc.h> #include "dat.h" #include "fns.h" void showdentryhdr(int fd, u8 *buf) { Dentry *d; d = (Dentry*)buf; fprint(fd, "name %s\n", d->name); fprint(fd, "uid %d\n", d->uid); fprint(fd, "gid %d\n", d->gid); fprint(fd, "muid %d\n", d->muid); fprint(fd, "size %llud\n", d->size); fprint(fd, "pdblkno %llud\n", d->pdblkno); fprint(fd, "pqpath %llud\n", d->pqpath); fprint(fd, "mtime %llud\n", d->mtime); fprint(fd, "path %llud\n", d->path); fprint(fd, "version %ud\n", d->version); fprint(fd, "mode %uo\n", d->mode); } void showmagic(int fd, u8 *d) { fprint(fd, "%s", ((Dentry*)d)->buf); } void showconfig(int fd, u8 *d) { fprint(fd, "%s", ((Dentry*)d)->buf); } void showsuper(int fd, u8 *d) { Dentry *s; s = (Dentry*)d; fprint(fd, "qidgen %llud\n", s->qidgen); fprint(fd, "fsok %llud\n", s->fsok); } void showdentry(int fd, u8 *buf) { int j; Dentry *d; showdentryhdr(fd, buf); d = (Dentry*)buf; if(d->path == Qpconfig || d->path == Qpconfig0) showconfig(fd, buf); else if(d->path == Qpsuper || d->path == Qpsuper0) showsuper(fd, buf); else if(d->path == Qpmagic) showmagic(fd, buf); else if(d->size <= Ddatasize && (d->mode&DMDIR) == 0 && d->path != Qproot0){ fprint(fd, "%s", d->buf); }else{ fprint(fd, "direct blocks\n"); for(j = 0; j<Ndblock; j++) fprint(fd, " %d %llud\n", j, d->dblocks[j]); fprint(fd, "indirect blocks\n"); for(j = 0; j<Niblock; j++) fprint(fd, " %d %llud\n", j, d->iblocks[j]); } } void showind(int fd, u8 *buf) { int j; Indirect *t; t = (Indirect*)buf; for(j = 0; j<Nindperblock; j++) fprint(fd, " %d %llud\n", j, t->bufa[j]); } void showdata(int fd, u8 *buf) { Data *c; c = (Data*)buf; fprint(fd, "%s", (s8*)c->buf); } void showblock(int fd, u8 *buf) { Data *t; Dentry *d; u8 tag; Indirect *r; tag = buf[0]; d = (Dentry*)buf; t = (Data*)buf; r = (Indirect*)buf; if(tag == Tblank){ fprint(fd, "%s\n", tagnames[tag]); return; }else if(tag == Tdentry){ fprint(fd, "%s %llud %d\n", tagnames[tag], d->path, d->ver); showdentry(fd, buf); return; }else if(tag == Tdata){ fprint(fd, "%s %d %llud %llud\n", tagnames[tag], t->len, t->dblkno, t->path); showdata(fd, buf); return; }else if(tag < Maxtind) fprint(fd, "%s %d %llud %llud\n", tagnames[tag], r->ver, r->dblkno, r->path); if(t->tag >= Tind0 && t->tag < Maxtind) showind(fd, buf); else if(t->tag != 0 || t->path != 0) fprint(fd, "unknown tag type %d path %llud\n", t->tag, t->path); }