annotate pirollback/dumpjournal.c @ 348:37b5f94de802

fluid-mnf: sensible target tty specification
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 13 Mar 2020 06:41:44 +0000
parents 79a0897dee7b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ? ' ' : '~';
48
79a0897dee7b pirollback dumpjournal utility: print some additional info
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 47
diff changeset
40 if (inf->type == 0xF4)
79a0897dee7b pirollback dumpjournal utility: print some additional info
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 47
diff changeset
41 sprintf(pathname, "parent: %x", inf->parent);
79a0897dee7b pirollback dumpjournal utility: print some additional info
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 47
diff changeset
42 else if (pathname_of_inode(ino, pathname) < 0)
47
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 strcpy(pathname, "-nopath-");
48
79a0897dee7b pirollback dumpjournal utility: print some additional info
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 47
diff changeset
44 printf("#%04X @%06X: %c%c %s\n", ino, inf->offset, typechar, delchar,
79a0897dee7b pirollback dumpjournal utility: print some additional info
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 47
diff changeset
45 pathname);
47
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 }
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 main(argc, argv)
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 char **argv;
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 {
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 int ino;
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 if (argc != 2) {
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 fprintf(stderr, "usage: %s ffs-image\n", argv[0]);
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 exit(1);
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 }
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 imgfile = argv[1];
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 read_img_file();
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 read_inodes();
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 walk_tree();
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 check_object_names();
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 parse_journal();
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 check_object_names(); /* rerun for "undeleted" objects */
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 for (ino = journal_start_ino; ino <= last_inode; ino++)
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 dump_inode(ino);
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 exit(0);
3b6296382e24 pirollback: dumpjournal utility written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 }