diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-10-10 14:53:09 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-10-12 23:12:22 -0400 |
commit | a25f0e73a7db95d6930f2af67d758be07737d044 (patch) | |
tree | 53211fcc5c0d89d17ca629560f1688f6407e818c /debugfs | |
parent | f0eae15c36d3334c0461ba3f2d4d401a954902ab (diff) | |
download | e2fsprogs-a25f0e73a7db95d6930f2af67d758be07737d044.tar.gz |
debugfs: Fix ncheck when printing pathnames for multiple hardlinks in a directory
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'debugfs')
-rw-r--r-- | debugfs/ncheck.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/debugfs/ncheck.c b/debugfs/ncheck.c index 22fa29ff..abb38a87 100644 --- a/debugfs/ncheck.c +++ b/debugfs/ncheck.c @@ -23,7 +23,7 @@ struct inode_walk_struct { int inodes_left; int num_inodes; int position; - ext2_ino_t parent; + char *parent; }; static int ncheck_proc(struct ext2_dir_entry *dirent, @@ -42,16 +42,8 @@ static int ncheck_proc(struct ext2_dir_entry *dirent, return 0; for (i=0; i < iw->num_inodes; i++) { if (iw->iarray[i] == dirent->inode) { - retval = ext2fs_get_pathname(current_fs, iw->parent, - iw->iarray[i], - &pathname); - if (retval) - com_err("ncheck", retval, - "while resolving pathname for " - "inode %d (%d)", iw->parent, - iw->iarray[i]); - else - printf("%u\t%s\n", iw->iarray[i], pathname); + printf("%u\t%s/%*s\n", iw->iarray[i], iw->parent, + (dirent->name_len & 0xFF), dirent->name); } } if (!iw->inodes_left) @@ -124,10 +116,17 @@ void do_ncheck(int argc, char **argv) goto next; iw.position = 0; - iw.parent = ino; + + retval = ext2fs_get_pathname(current_fs, ino, 0, &iw.parent); + if (retval) { + com_err("ncheck", retval, + "while calling ext2fs_get_pathname"); + goto next; + } retval = ext2fs_dir_iterate(current_fs, ino, 0, 0, ncheck_proc, &iw); + ext2fs_free_mem(&iw.parent); if (retval) { com_err("ncheck", retval, "while calling ext2_dir_iterate"); |