code: mafs

ref: 5c21eca829380c28769f79beabb7cc51f1787f97
dir: /blk.c/

View raw version
#include <u.h>
#include <libc.h>
#include "dat.h"
#include "fns.h"

void
showind0(u8 *buf)
{
	int j;
	Spanid *s;

	for(j = 0, s=(Spanid*)buf; j<Nspanidperblock; j++)
		print("	%d %llud %d\n", j, s[j].blkno, s[j].len);
}
void
showind(u8 *buf)
{
	int j;
	u64 *lbuf;

	lbuf = (u64*)buf;
	for(j = 0; j<Nindperblock; j++)
		print("	%d %llud\n", j, lbuf[j]);
}
void
showdentry(u8 *buf)
{
	int j;
	Dentry *d;

	d = (Dentry*)buf;
	print("qid.version %ud\n", d->qid.version);
	print("qid.path %llud\n", d->qid.path);
	print("size %llud\n", d->size);
	print("pdblkno %llud\n", d->pdblkno);
	print("pqpath %llud\n", d->pqpath);
	print("mtime %llud\n", d->mtime);
	print("mode %uo\n", d->mode);
	print("uid %d\n", d->uid);
	print("gid %d\n", d->gid);
	print("muid %d\n", d->muid);
	print("direct spans\n");
	for(j = 0; j<Ndspanid; j++)
		print("	%d %llud %d\n", j, d->dspans[j].blkno, d->dspans[j].len);
	print("indirect blocks\n");
	for(j = 0; j<Niblock; j++)
		print("	%d %llud\n", j, d->iblocks[j]);
	print("name %s\n", d->name);
}
void
showmagic(u8 *buf)
{
	print("%s", (char*)buf+256);
}
void
showconfig(u8 *buf)
{
	print("%s", (char*)buf);
}
void
showsuper(u8 *buf)
{
	Superb *s;

	s = (Superb*)buf;
	print("start %llud\n", s->start);
	print("tfree %llud\n", s->tfree);
	print("qidgen %llud\n", s->qidgen);
	print("frees %llud\n", s->frees);
	print("fsok %llud\n", s->fsok);
}
void
showdata(u8 *buf)
{
	print("%s", (char*)buf);
}

void
showblock(u8 *buf)
{
	Tag *t;

	t = (Tag*)buf;
	if(t->type < Maxtind)
		print("%s %d %llud\n", tagnames[t->type], t->len, t->path);
	if(t->type == Tdentry){
		showdentry(buf+sizeof(Tag));
	}else if(t->path == Qpmagic){
		showmagic(buf+sizeof(Tag));
	}else if(t->path == Qpconfig || t->path == Qpconfig0 || t->path == Qpconfig1){
		showconfig(buf+sizeof(Tag));
	}else if(t->path == Qpsuper || t->path == Qpsuper0 || t->path == Qpsuper1){
		showsuper(buf+sizeof(Tag));
	}else if(t->type == Tdata){
		showdata(buf+sizeof(Tag));
	}else if(t->type == Tind0){
		showind0(buf+sizeof(Tag));
	}else if(t->type > Tind0 && t->type < Maxtind){
		showind(buf+sizeof(Tag));
	}else if(t->type != 0 || t->path != 0 || t->dirty != 0 || t->len != 0){
		print("unknown tag type %d path %llud\n", t->type, t->path);
	}
}