code: mafs

ref: e82f565015fd0b75085d8d2a4f1aaca53e875f64
dir: /tests/reli.c/

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

/*
	write out a single formatted block based on the tag
	./6.reli 23; ./6.reli 24;  ./6.reli 74
	./6.reli 75; ./6.reli 3100 '
 */

int debug = 0;
char *devfile = nil;

static void
usage(void)
{
	fprint(2, "usage: reli [-D] reli\n");
	exits("usage");
}

void
drilldown(u8 tag, u64 reli)
{
	print("%s reli %llud is at [%llud]\n", tagnames[tag], reli, reli/nperindunit(tag));
	if(tag > Tind0)
		drilldown(tag-1, reli%nperindunit(tag));
}

void
main(int argc, char *argv[])
{
	u64 reli;
	u8 tag;

	ARGBEGIN{
	default:	usage();
	case 'D':	debug++; break;
	}ARGEND

	if(argc != 1)
		usage();

	reli = atoll(argv[0]);
	print("reli %llud\n", reli);

	if(reli > maxreli(Maxtind-1) || reli > 57731387017ULL)
		exits("invalid reli");

	if(reli < Ndblock){
		print("dblock[%llud]\n", reli);
	}else{
		tag = rel2tind(reli);
		print("iblock[%d]\n", tag-Tind0);
		drilldown(tag, reli-tagstartreli(tag));
	}
	exits(0);
}