1 6f4d00ee 2013-09-23 0intro #include "stdinc.h"
2 6f4d00ee 2013-09-23 0intro #include "dat.h"
3 6f4d00ee 2013-09-23 0intro #include "fns.h"
5 6f4d00ee 2013-09-23 0intro uchar buf[65536];
8 6f4d00ee 2013-09-23 0intro usage(void)
10 6f4d00ee 2013-09-23 0intro fprint(2, "usage: fossil/epoch fs [new-low-epoch]\n");
11 4b576658 2013-09-23 0intro threadexitsall("usage");
15 4b576658 2013-09-23 0intro threadmain(int argc, char **argv)
26 6f4d00ee 2013-09-23 0intro if(argc == 0 || argc > 2)
29 6f4d00ee 2013-09-23 0intro if((fd = open(argv[0], argc==2 ? ORDWR : OREAD)) < 0)
30 6f4d00ee 2013-09-23 0intro sysfatal("open %s: %r", argv[0]);
32 6f4d00ee 2013-09-23 0intro if(pread(fd, buf, HeaderSize, HeaderOffset) != HeaderSize)
33 6f4d00ee 2013-09-23 0intro sysfatal("reading header: %r");
34 6f4d00ee 2013-09-23 0intro if(!headerUnpack(&h, buf))
35 6f4d00ee 2013-09-23 0intro sysfatal("unpacking header: %r");
37 6f4d00ee 2013-09-23 0intro if(pread(fd, buf, h.blockSize, (vlong)h.super*h.blockSize) != h.blockSize)
38 6f4d00ee 2013-09-23 0intro sysfatal("reading super block: %r");
40 6f4d00ee 2013-09-23 0intro if(!superUnpack(&s, buf))
41 6f4d00ee 2013-09-23 0intro sysfatal("unpacking super block: %r");
43 6f4d00ee 2013-09-23 0intro print("epoch %d\n", s.epochLow);
44 6f4d00ee 2013-09-23 0intro if(argc == 2){
45 6f4d00ee 2013-09-23 0intro s.epochLow = strtoul(argv[1], 0, 0);
46 6f4d00ee 2013-09-23 0intro superPack(&s, buf);
47 6f4d00ee 2013-09-23 0intro if(pwrite(fd, buf, h.blockSize, (vlong)h.super*h.blockSize) != h.blockSize)
48 6f4d00ee 2013-09-23 0intro sysfatal("writing super block: %r");
50 4b576658 2013-09-23 0intro threadexitsall(0);