diff pirollback/inopath.c @ 45:18472a2ccf55

pirollback: pathname reconstruction implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 06 Jul 2013 22:06:38 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pirollback/inopath.c	Sat Jul 06 22:06:38 2013 +0000
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "pathname.h"
+
+extern char *imgfile;
+extern int last_inode;
+
+main(argc, argv)
+	char **argv;
+{
+	int ino;
+	char *strtoul_endp;
+	char pathname[PATHNAME_BUF_SIZE];
+
+	if (argc != 3) {
+usage:		fprintf(stderr, "usage: %s ffs-image inode\n", argv[0]);
+		exit(1);
+	}
+	imgfile = argv[1];
+	ino = strtoul(argv[2], &strtoul_endp, 16);
+	if (!argv[2][0] || *strtoul_endp)
+		goto usage;
+	read_img_file();
+	read_inodes();
+	if (ino < 1 || ino > last_inode) {
+		fprintf(stderr, "%s: bad inode number specified\n", argv[0]);
+		exit(1);
+	}
+	walk_tree();
+	check_object_names();
+	if (pathname_of_inode(ino, pathname) < 0) {
+		fprintf(stderr, "unable to get the pathname\n");
+		exit(1);
+	}
+	printf("%s\n", pathname);
+	exit(0);
+}