ref: a6e9ab0ced8523fb8099afa4547dc27793e27462
dir: /fsok.c/
#include <u.h> #include <libc.h> #include "dat.h" #include "fns.h" /* do Super.fsok = 1 disk/fsok fsfile */ int debug = 0; char *devfile = nil, *freesfile = nil; static void usage(void) { fprint(2, "usage: fsok [-D] fsfile\n"); exits("usage"); } void main(int argc, char *argv[]) { u64 size; s8 buf[Blocksize]; Dentry *d; ARGBEGIN{ default: usage(); case 'D': debug++; break; }ARGEND if(argc != 1) usage(); devfile = argv[0]; if(devfile == nil) sysfatal("no disk file"); if (access(devfile, AREAD|AWRITE) == -1) sysfatal("%s cannot access device", devfile); size = devinit(devfile); if(size == 0) panic("null size %s", devfile); devread(Bdsuper, buf, 1); // showblock(1, buf); d = (Dentry*)buf; if(d->fsok) fprint(2, "fsok: %s fsok is already %llud\n", devfile, d->fsok); else{ d->fsok = 1; d->mtime = nsec(); devwrite(Bdsuper, buf, 1); } close(devfd); exits(0); }