ref: b5d191e8cfa4fac05a02ea309df2541a2652ff23
dir: /blk.c/
#include <u.h> #include <libc.h> #include "dat.h" #include "fns.h" void showind(int fd, u8 *buf) { int j; u64 *lbuf; lbuf = (u64*)buf; for(j = 0; j<Nindperblock; j++) fprint(fd, " %d %llud\n", j, lbuf[j]); } void showdentry(int fd, u8 *buf) { int j; Dentry *d; d = (Dentry*)buf; fprint(fd, "qid.version %ud\n", d->qid.version); fprint(fd, "qid.path %llud\n", d->qid.path); 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, "mode %uo\n", d->mode); fprint(fd, "uid %d\n", d->uid); fprint(fd, "gid %d\n", d->gid); fprint(fd, "muid %d\n", d->muid); 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]); fprint(fd, "name %s\n", d->name); } void showmagic(int fd, u8 *buf) { fprint(fd, "%s", (char*)buf+256); } void showconfig(int fd, u8 *buf) { fprint(fd, "%s", (char*)buf); } void showsuper(int fd, u8 *buf) { Superb *s; s = (Superb*)buf; fprint(fd, "start %llud\n", s->start); fprint(fd, "tfree %llud\n", s->tfree); fprint(fd, "qidgen %llud\n", s->qidgen); fprint(fd, "frees %llud\n", s->frees); fprint(fd, "fsok %llud\n", s->fsok); } void showdata(int fd, u8 *buf) { fprint(fd, "%s", (char*)buf); } void showblock(int fd, u8 *buf) { Content *t; t = (Content*)buf; if(t->type < Maxtind) fprint(fd, "%s %llud\n", tagnames[t->type], t->path); if(t->type == Tdentry){ showdentry(fd, buf); }else if(t->path == Qpmagic){ showmagic(fd, buf); }else if(t->path == Qpconfig || t->path == Qpconfig0 || t->path == Qpconfig1){ showconfig(fd, buf); }else if(t->path == Qpsuper || t->path == Qpsuper0 || t->path == Qpsuper1){ showsuper(fd, buf); }else if(t->type == Tdata){ showdata(fd, buf); }else if(t->type >= Tind0 && t->type < Maxtind){ showind(fd, buf); }else if(t->type != 0 || t->path != 0){ fprint(fd, "unknown tag type %d path %llud\n", t->type, t->path); } }