ref: 56bd332994102b4e194819abb5e087a8895452f9
dir: /tests/reli.c/
#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] nperindunit %llud\n", tagnames[tag], reli, reli/nperindunit(tag), 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(debug) print("maxreli %llud\n", maxreli(Maxtind-1)); if(reli > maxreli(Maxtind-1)) exits("invalid reli"); if(reli < Ndblock){ print("dblock[%llud]\n", reli); }else{ tag = rel2tind(reli); print("iblock[%d] tagstartreli %llud\n", tag-Tind0, tagstartreli(tag)); drilldown(tag, reli-tagstartreli(tag)); } exits(0); }