From patchwork Sat Sep 22 04:00:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [11/21,v5] debugfs: handle inline_data feature in bmap command Date: Fri, 21 Sep 2012 18:00:59 -0000 From: Zheng Liu X-Patchwork-Id: 186084 Message-Id: <1348286469-31690-12-git-send-email-wenqing.lz@taobao.com> To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, Zheng Liu From: Zheng Liu If an inode has inline data, bmap command will return the physical block of this inode. Signed-off-by: Zheng Liu --- lib/ext2fs/bmap.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c index 16d51e0..4746a1f 100644 --- a/lib/ext2fs/bmap.c +++ b/lib/ext2fs/bmap.c @@ -264,6 +264,21 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, block_buf = buf; } + if (inode->i_flags & EXT4_INLINE_DATA_FL) { + unsigned long group, block, offset; + + group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super); + if (group > fs->group_desc_count) + return EXT2_ET_BAD_INODE_NUM; + offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) * + EXT2_INODE_SIZE(fs->super); + block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); + if (!ext2fs_inode_table_loc(fs, (unsigned) group)) + return EXT2_ET_MISSING_INODE_TABLE; + *phys_blk = ext2fs_inode_table_loc(fs, group) + block; + goto done; + } + if (inode->i_flags & EXT4_EXTENTS_FL) { retval = ext2fs_extent_open2(fs, ino, inode, &handle); if (retval)