FreeCalypso > hg > freecalypso-reveng
annotate pirollback/dumpjournal.c @ 47:3b6296382e24
pirollback: dumpjournal utility written, works
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 07 Jul 2013 06:52:04 +0000 |
parents | |
children | 79a0897dee7b |
rev | line source |
---|---|
47
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 #include <stdio.h> |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 #include <stdlib.h> |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 #include <string.h> |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 #include <strings.h> |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include "types.h" |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include "struct.h" |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include "pathname.h" |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 extern char *imgfile; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 extern struct inode_info inode[]; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 extern int last_inode; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 extern int journal_start_ino; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 dump_inode(ino) |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 { |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 struct inode_info *inf; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 char pathname[PATHNAME_BUF_SIZE]; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 int typechar, delchar; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 inf = inode + ino; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 switch (inf->type) { |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 case 0xE1: |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 typechar = 'j'; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 break; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 case 0xF1: |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 typechar = 'f'; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 break; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 case 0xF2: |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 typechar = 'd'; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 break; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 case 0xF4: |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 typechar = '.'; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 break; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 default: |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 fprintf(stderr, "dumping inode #%x: unexpected type %02X\n", |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 ino, inf->type); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 exit(1); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 } |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 delchar = inf->flash->type ? ' ' : '~'; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 if (pathname_of_inode(ino, pathname) < 0) |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 strcpy(pathname, "-nopath-"); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 printf("#%04X: %c%c %s\n", ino, typechar, delchar, pathname); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 } |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 main(argc, argv) |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 char **argv; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 { |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 int ino; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 if (argc != 2) { |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 fprintf(stderr, "usage: %s ffs-image\n", argv[0]); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 exit(1); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 imgfile = argv[1]; |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 read_img_file(); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 read_inodes(); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 walk_tree(); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 check_object_names(); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 parse_journal(); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 check_object_names(); /* rerun for "undeleted" objects */ |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 for (ino = journal_start_ino; ino <= last_inode; ino++) |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 dump_inode(ino); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 exit(0); |
3b6296382e24
pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 } |