diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/fossil/epoch.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/fossil/epoch.c')
-rwxr-xr-x | sys/src/cmd/fossil/epoch.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/src/cmd/fossil/epoch.c b/sys/src/cmd/fossil/epoch.c new file mode 100755 index 000000000..6aa73bbf1 --- /dev/null +++ b/sys/src/cmd/fossil/epoch.c @@ -0,0 +1,51 @@ +#include "stdinc.h" +#include "dat.h" +#include "fns.h" + +uchar buf[65536]; + +void +usage(void) +{ + fprint(2, "usage: fossil/epoch fs [new-low-epoch]\n"); + exits("usage"); +} + +void +main(int argc, char **argv) +{ + int fd; + Header h; + Super s; + + ARGBEGIN{ + default: + usage(); + }ARGEND + + if(argc == 0 || argc > 2) + usage(); + + if((fd = open(argv[0], argc==2 ? ORDWR : OREAD)) < 0) + sysfatal("open %s: %r", argv[0]); + + if(pread(fd, buf, HeaderSize, HeaderOffset) != HeaderSize) + sysfatal("reading header: %r"); + if(!headerUnpack(&h, buf)) + sysfatal("unpacking header: %r"); + + if(pread(fd, buf, h.blockSize, (vlong)h.super*h.blockSize) != h.blockSize) + sysfatal("reading super block: %r"); + + if(!superUnpack(&s, buf)) + sysfatal("unpacking super block: %r"); + + print("epoch %d\n", s.epochLow); + if(argc == 2){ + s.epochLow = strtoul(argv[1], 0, 0); + superPack(&s, buf); + if(pwrite(fd, buf, h.blockSize, (vlong)h.super*h.blockSize) != h.blockSize) + sysfatal("writing super block: %r"); + } + exits(0); +} |