diff ffstools/tiffs-rd/ls.c @ 238:0b13839f782c

tiffs IVA: lsino (non-specific) implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 26 Jan 2014 23:32:42 +0000
parents 317936902be4
children 28ea957a9d8a
line wrap: on
line diff
--- a/ffstools/tiffs-rd/ls.c	Sun Jan 26 21:12:15 2014 +0000
+++ b/ffstools/tiffs-rd/ls.c	Sun Jan 26 23:32:42 2014 +0000
@@ -174,3 +174,99 @@
 		ls_by_pathname(argv[optind]);
 	exit(0);
 }
+
+lsino_all()
+{
+	int ino, last_ino = 0;
+	struct inode_info *inf;
+	char pathname[PATHNAME_BUF_SIZE], typech;
+	int pathstat;
+	char descend_str[8], sibling_str[8];
+
+	for (ino = 1; ino < inode_limit; ino++) {
+		if (!validate_inode(ino))
+			continue;
+		if (ino != last_ino + 1)
+			printf("GAP in inode numbers\n");
+		inf = inode_info[ino];
+		pathstat = pathname_of_inode(ino, pathname);
+		if (pathstat < 0)
+			strcpy(pathname, "-nopath-");
+		switch (inf->type) {
+		case 0x00:
+			typech = '~';
+			break;
+		case 0xE1:
+		case 0xF1:
+			typech = 'f';
+			break;
+		case 0xF2:
+			typech = 'd';
+			break;
+		case 0xF3:
+			typech = 'l';
+			break;
+		case 0xF4:
+			typech = '.';
+			break;
+		default:
+			typech = '?';
+		}
+		printf("#%04x %c %s\n", ino, typech, pathname);
+		if (inf->type && !(inf->type & 0x10))
+			printf("\tread-only object\n");
+		if (ino == root_inode)
+			printf("\tactive root\n");
+		else if (inf->nparents < 1)
+			printf("\torphan\n");
+		else if (inf->nparents > 1)
+			printf("\tparent: #%x (%d)\n", inf->parent,
+				inf->nparents);
+		else if (pathstat < 0 || verbose2)
+			printf("\tparent: #%x\n", inf->parent);
+		if (verbose2 > 1) {
+			if (inf->descend)
+				sprintf(descend_str, "#%x", inf->descend);
+			else
+				strcpy(descend_str, "null");
+			if (inf->sibling)
+				sprintf(sibling_str, "#%x", inf->sibling);
+			else
+				strcpy(sibling_str, "null");
+			printf("\tchild: %s, sibling: %s\n",
+				descend_str, sibling_str);
+		}
+		if (!inf->len)
+			printf("\treclaimed\n");
+		last_ino = ino;
+	}
+	exit(0);
+}
+
+cmd_lsino(argc, argv)
+	char **argv;
+{
+	extern int optind;
+	int c;
+
+	read_ffs_image();
+	find_inode_block();
+	alloc_inode_table();
+	find_root_inode();
+	treewalk_all();
+
+	optind = 0;
+	while ((c = getopt(argc, argv, "v")) != EOF)
+		switch (c) {
+		case 'v':
+			verbose2++;
+			continue;
+		default:
+			fprintf(stderr, "usage: lsino [-v[v]] [ino...]\n");
+			exit(1);
+		}
+	if (optind >= argc)
+		return lsino_all();
+	fprintf(stderr, "lsino of specific inodes not implemented yet\n");
+	exit(1);
+}