ref: 9b76881a8e11c44aae5dfd447e1cd1bc074ec9f3
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[Metadatablocksize]; 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, Metadataunits); // showblock(1, buf); recentmetadata(buf, &d, nil); if(d->fsok) fprint(2, "fsok: %s fsok %llud != 0\n", devfile, d->fsok); else{ d->fsok = 1; d->mtime = nsec(); devwrite(Bdsuper, buf, Metadataunits); } close(devfd); exits(0); }