comparison 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
comparison
equal deleted inserted replaced
46:78ac405716db 47:3b6296382e24
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <strings.h>
5 #include "types.h"
6 #include "struct.h"
7 #include "pathname.h"
8
9 extern char *imgfile;
10 extern struct inode_info inode[];
11 extern int last_inode;
12 extern int journal_start_ino;
13
14 dump_inode(ino)
15 {
16 struct inode_info *inf;
17 char pathname[PATHNAME_BUF_SIZE];
18 int typechar, delchar;
19
20 inf = inode + ino;
21 switch (inf->type) {
22 case 0xE1:
23 typechar = 'j';
24 break;
25 case 0xF1:
26 typechar = 'f';
27 break;
28 case 0xF2:
29 typechar = 'd';
30 break;
31 case 0xF4:
32 typechar = '.';
33 break;
34 default:
35 fprintf(stderr, "dumping inode #%x: unexpected type %02X\n",
36 ino, inf->type);
37 exit(1);
38 }
39 delchar = inf->flash->type ? ' ' : '~';
40 if (pathname_of_inode(ino, pathname) < 0)
41 strcpy(pathname, "-nopath-");
42 printf("#%04X: %c%c %s\n", ino, typechar, delchar, pathname);
43 }
44
45 main(argc, argv)
46 char **argv;
47 {
48 int ino;
49
50 if (argc != 2) {
51 fprintf(stderr, "usage: %s ffs-image\n", argv[0]);
52 exit(1);
53 }
54 imgfile = argv[1];
55 read_img_file();
56 read_inodes();
57 walk_tree();
58 check_object_names();
59 parse_journal();
60 check_object_names(); /* rerun for "undeleted" objects */
61 for (ino = journal_start_ino; ino <= last_inode; ino++)
62 dump_inode(ino);
63 exit(0);
64 }