ref: e82f565015fd0b75085d8d2a4f1aaca53e875f64
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; u8 buf[Rawblocksize]; 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("Dentry1 size %d Namelen %llud\n", sizeof(Dentry1), Namelen); print("Dentry size %d\n", sizeof(Dentry)); } devread(blkno, buf); showblock(1, buf); exits(0); }