Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "stdinc.h"
2
#include "dat.h"
3
#include "fns.h"
4
 
5
uchar buf[65536];
6
 
7
void
8
usage(void)
9
{
10
	fprint(2, "usage: fossil/epoch fs [new-low-epoch]\n");
11
	exits("usage");
12
}
13
 
14
void
15
main(int argc, char **argv)
16
{
17
	int fd;
18
	Header h;
19
	Super s;
20
 
21
	ARGBEGIN{
22
	default:
23
		usage();
24
	}ARGEND
25
 
26
	if(argc == 0 || argc > 2)
27
		usage();
28
 
29
	if((fd = open(argv[0], argc==2 ? ORDWR : OREAD)) < 0)
30
		sysfatal("open %s: %r", argv[0]);
31
 
32
	if(pread(fd, buf, HeaderSize, HeaderOffset) != HeaderSize)
33
		sysfatal("reading header: %r");
34
	if(!headerUnpack(&h, buf))
35
		sysfatal("unpacking header: %r");
36
 
37
	if(pread(fd, buf, h.blockSize, (vlong)h.super*h.blockSize) != h.blockSize)
38
		sysfatal("reading super block: %r");
39
 
40
	if(!superUnpack(&s, buf))
41
		sysfatal("unpacking super block: %r");
42
 
43
	print("epoch %d\n", s.epochLow);
44
	if(argc == 2){
45
		s.epochLow = strtoul(argv[1], 0, 0);
46
		superPack(&s, buf);
47
		if(pwrite(fd, buf, h.blockSize, (vlong)h.super*h.blockSize) != h.blockSize)
48
			sysfatal("writing super block: %r");
49
	}
50
	exits(0);
51
}