# HG changeset patch # User Michael Spacefalcon # Date 1390787422 0 # Node ID 28ea957a9d8acf7db0335a75da690d96d55491d2 # Parent 0b13839f782c1787832aa938cfb0de8d9857abd7 tiffs lsino of specific inodes implemented diff -r 0b13839f782c -r 28ea957a9d8a ffstools/tiffs-rd/ls.c --- a/ffstools/tiffs-rd/ls.c Sun Jan 26 23:32:42 2014 +0000 +++ b/ffstools/tiffs-rd/ls.c Mon Jan 27 01:50:22 2014 +0000 @@ -243,11 +243,68 @@ exit(0); } +void +lsino_one(ino, assume_file) +{ + struct inode_info *inf; + char pathname[PATHNAME_BUF_SIZE], *type; + + if (!validate_inode(ino)) { + fprintf(stderr, "lsino: specified inode number is invalid\n"); + exit(1); + } + printf("inode #%x\n", ino); + inf = inode_info[ino]; + if (pathname_of_inode(ino, pathname) >= 0) + printf("Pathname: %s\n", pathname); + else + printf("No pathname found\n"); + inf = inode_info[ino]; + switch (inf->type) { + case 0x00: + type = "deleted"; + break; + case 0xE1: + type = "read-only file"; + break; + case 0xF1: + type = "file"; + break; + case 0xF2: + type = "directory"; + break; + case 0xF3: + type = "symlink"; + break; + default: + type = "???"; + } + printf("object type %02X (%s)\n", inf->type, type); + if (!inf->len) { + printf("This inode has been reclaimed\n\n"); + return; + } + if (validate_obj_name(ino, 1)) + printf("object name: %s\n", inf->dataptr); + else { + printf("No valid object name in the chunk\n\n"); + return; + } + if (inf->type == 0xF1 || inf->type == 0xE1 || + !inf->type && assume_file) { + printf("total size: %lu bytes\n", + (u_long) get_file_size(ino, !inf->type)); + if (verbose2) + ls_seg_file(ino, !inf->type); + } + putchar('\n'); +} + cmd_lsino(argc, argv) char **argv; { extern int optind; - int c; + int c, assume_file = 0, ino; read_ffs_image(); find_inode_block(); @@ -256,8 +313,11 @@ treewalk_all(); optind = 0; - while ((c = getopt(argc, argv, "v")) != EOF) + while ((c = getopt(argc, argv, "fv")) != EOF) switch (c) { + case 'f': + assume_file++; + continue; case 'v': verbose2++; continue; @@ -267,6 +327,9 @@ } if (optind >= argc) return lsino_all(); - fprintf(stderr, "lsino of specific inodes not implemented yet\n"); - exit(1); + for (; optind < argc; optind++) { + ino = strtoul(argv[optind], 0, 16); + lsino_one(ino, assume_file); + } + exit(0); }