ref: 84d66beb90246495861436c041297528298ba74f
dir: /block.c/
#include <u.h> #include <libc.h> #include "dat.h" #include "fns.h" /* write out a single formatted block based on the tag */ int debug = 0; char *devfile = nil; static void usage(void) { fprint(2, "usage: block [-D] fsfile blkidx\n"); exits("usage"); } void main(int argc, char *argv[]) { u64 size, blkno, nunits; u8 buf[Blocksize]; ARGBEGIN{ default: usage(); case 'D': debug++; break; }ARGEND if(argc != 2) usage(); devfile = argv[0]; if(devfile == nil) sysfatal("no disk file"); blkno = atoi(argv[1]); if (access(devfile, AREAD|AWRITE) == -1) sysfatal("%s cannot access device", devfile); size = devinit(devfile); if(size == 0) panic("null size %s", devfile); if(debug){ print("Dentry size %d\n", sizeof(Dentry)); print("Dentryhdr size %d Ddatasize %llud Namelen %d\n", sizeof(Dentryhdr), Ddatasize, Namelen); } // nunits = size/Blocksize; devread(blkno, buf, 1); showblock(1, buf); close(devfd); exits(0); }