view pirollback/dumpjournal.c @ 92:708f2452d1ae

armdis: full ldr/str decoding implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 30 Mar 2014 01:47:28 +0000
parents 79a0897dee7b
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "types.h"
#include "struct.h"
#include "pathname.h"

extern char *imgfile;
extern struct inode_info inode[];
extern int last_inode;
extern int journal_start_ino;

dump_inode(ino)
{
	struct inode_info *inf;
	char pathname[PATHNAME_BUF_SIZE];
	int typechar, delchar;

	inf = inode + ino;
	switch (inf->type) {
	case 0xE1:
		typechar = 'j';
		break;
	case 0xF1:
		typechar = 'f';
		break;
	case 0xF2:
		typechar = 'd';
		break;
	case 0xF4:
		typechar = '.';
		break;
	default:
		fprintf(stderr, "dumping inode #%x: unexpected type %02X\n",
			ino, inf->type);
		exit(1);
	}
	delchar = inf->flash->type ? ' ' : '~';
	if (inf->type == 0xF4)
		sprintf(pathname, "parent: %x", inf->parent);
	else if (pathname_of_inode(ino, pathname) < 0)
		strcpy(pathname, "-nopath-");
	printf("#%04X @%06X: %c%c %s\n", ino, inf->offset, typechar, delchar,
		pathname);
}

main(argc, argv)
	char **argv;
{
	int ino;

	if (argc != 2) {
		fprintf(stderr, "usage: %s ffs-image\n", argv[0]);
		exit(1);
	}
	imgfile = argv[1];
	read_img_file();
	read_inodes();
	walk_tree();
	check_object_names();
	parse_journal();
	check_object_names();	/* rerun for "undeleted" objects */
	for (ino = journal_start_ino; ino <= last_inode; ino++)
		dump_inode(ino);
	exit(0);
}