lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-Id: <1375436989-18948-7-git-send-email-wenqing.lz@taobao.com> Date: Fri, 2 Aug 2013 17:49:33 +0800 From: Zheng Liu <gnehzuil.liu@...il.com> To: linux-ext4@...r.kernel.org Cc: Theodore Ts'o <tytso@....edu>, Zheng Liu <wenqing.lz@...bao.com> Subject: [PATCH v1 06/22] debugfs: make stat command support inline data From: Zheng Liu <wenqing.lz@...bao.com> If there is an inode with inline data, we just print the size of inline data in stat command. Signed-off-by: Theodore Ts'o <tytso@....edu> Signed-off-by: Zheng Liu <wenqing.lz@...bao.com> --- debugfs/debugfs.c | 11 +++++++++++ lib/ext2fs/ext2fs.h | 1 + lib/ext2fs/inline_data.c | 27 +++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 969dbe0..2837ee6 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -704,6 +704,15 @@ static void dump_extents(FILE *f, const char *prefix, ext2_ino_t ino, fprintf(f, "\n"); } +static void dump_inline_data(FILE *out, const char *prefix, ext2_ino_t inode_num) +{ + int size; + + fprintf(out, "%sINLINE DATA:\n %s", prefix, prefix); + size = ext2fs_inline_data_get_size(current_fs, inode_num); + fprintf(out, " The size of inline data: %d", size); +} + void internal_dump_inode(FILE *out, const char *prefix, ext2_ino_t inode_num, struct ext2_inode *inode, int do_dump_blocks) @@ -837,6 +846,8 @@ void internal_dump_inode(FILE *out, const char *prefix, if (inode->i_flags & EXT4_EXTENTS_FL) dump_extents(out, prefix, inode_num, DUMP_LEAF_EXTENTS|DUMP_NODE_EXTENTS, 0, 0); + else if (inode->i_flags & EXT4_INLINE_DATA_FL) + dump_inline_data(out, prefix, inode_num); else dump_blocks(out, prefix, inode_num); } diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 7b05b48..6e3bf6e 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1344,6 +1344,7 @@ extern errcode_t ext2fs_get_memalign(unsigned long size, /* inline_data.c */ extern int ext2fs_inode_has_inline_data(ext2_filsys fs, ext2_ino_t ino); +extern int ext2fs_inline_data_get_size(ext2_filsys fs, ext2_ino_t ino); extern errcode_t ext2fs_inline_data_iterate(ext2_filsys fs, ext2_ino_t ino, int flags, diff --git a/lib/ext2fs/inline_data.c b/lib/ext2fs/inline_data.c index 922c959..1220418 100644 --- a/lib/ext2fs/inline_data.c +++ b/lib/ext2fs/inline_data.c @@ -80,6 +80,33 @@ int ext2fs_inode_has_inline_data(ext2_filsys fs, ext2_ino_t ino) return (inode.i_flags & EXT4_INLINE_DATA_FL); } +int ext2fs_inline_data_get_size(ext2_filsys fs, ext2_ino_t ino) +{ + struct ext2_inode_large *inode; + struct inline_data data; + errcode_t retval = 0; + int size = 0; + + retval = ext2fs_get_mem(EXT2_INODE_SIZE(fs->super), &inode); + if (retval) + return 0; + retval = ext2fs_read_inode_full(fs, ino, (void *)inode, + EXT2_INODE_SIZE(fs->super)); + if (retval) + goto out; + + if (inode->i_flags & EXT4_INLINE_DATA_FL) { + retval = ext2fs_inline_data_find(fs, inode, &data); + if (retval) + goto out; + size = data.inline_size; + } + +out: + ext2fs_free_mem(&inode); + return size; +} + errcode_t ext2fs_inline_data_iterate(ext2_filsys fs, ext2_ino_t ino, int flags, -- 1.7.9.7 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists