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