1 #include <u.h>
2 #include <libc.h>
3
4 void
usage(void)5 usage(void)
6 {
7 fprint(2, "usage: fossil/last disk\n");
8 exits("usage");
9 }
10
11 void
main(int argc,char ** argv)12 main(int argc, char **argv)
13 {
14 int fd, bs, addr;
15 char buf[20];
16
17 ARGBEGIN{
18 default:
19 usage();
20 }ARGEND
21
22 if(argc != 1)
23 usage();
24
25 if((fd = open(argv[0], OREAD)) < 0)
26 sysfatal("open %s: %r", argv[0]);
27
28 werrstr("end of file");
29 if(seek(fd, 131072, 0) < 0 || readn(fd, buf, 20) != 20)
30 sysfatal("error reading %s: %r", argv[0]);
31 fmtinstall('H', encodefmt);
32 if(memcmp(buf, "\x37\x76\xAE\x89", 4) != 0)
33 sysfatal("bad magic %.4H != 3776AE89", buf);
34 bs = buf[7]|(buf[6]<<8);
35 addr = (buf[8]<<24)|(buf[9]<<16)|(buf[10]<<8)|buf[11];
36 if(seek(fd, (vlong)bs*addr+34, 0) < 0 || readn(fd, buf, 20) != 20)
37 sysfatal("error reading %s: %r", argv[0]);
38 print("vac:%.20lH\n", buf);
39 exits(0);
40 }
41