From patchwork Sun Jul 1 13:48:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 168420 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 02E172C01E6 for ; Sun, 1 Jul 2012 23:41:36 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932439Ab2GANle (ORCPT ); Sun, 1 Jul 2012 09:41:34 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:36672 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932438Ab2GANle (ORCPT ); Sun, 1 Jul 2012 09:41:34 -0400 Received: by mail-pz0-f46.google.com with SMTP id y13so6319540dad.19 for ; Sun, 01 Jul 2012 06:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=ZxQZNzRB25eL1cN+2Reu3T+EVWpXE0CtaG4yJv6Vbk0=; b=mKAo0FPLmp/7lIhDPeskgDHj1Y1VZKqLY4h32Dup8gh6/mDCZA85YhTcCl25FEFyh1 QTG0IoXpPRkxKmkv4Ydb4JAYiIc75SQmMX0SQqtduY7UkjfXMO/lhY4WB19dZpXG+1TW 8014oiiT95xwUwpY7g0FXdvxoql6DRhmHgtxn/Wv7UFdlLpf7Z7jLf9Hzx4gP8S/fLdN q3Ig/jkQXBvY/19E3ihtvSjn0HZ1UbtsT8OMvWGP9RZQG4gJ6UsTOrL6UY5WJFqG6Zbf oEKL/Eyo+Y3rYPeH0NHpL0Yw76d6eYQGYl0VkdkZDBSGZ4WaMfUq4PEOz1iaN+B9M10E yj/g== Received: by 10.68.226.131 with SMTP id rs3mr21756053pbc.62.1341150093864; Sun, 01 Jul 2012 06:41:33 -0700 (PDT) Received: from localhost.localdomain ([182.92.247.2]) by mx.google.com with ESMTPS id ql3sm10544254pbc.72.2012.07.01.06.41.31 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Jul 2012 06:41:33 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Zheng Liu Subject: [PATCH 24/35 v3] debugfs: make dump and cat cmd support inline data Date: Sun, 1 Jul 2012 21:48:47 +0800 Message-Id: <1341150538-32047-25-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1341150538-32047-1-git-send-email-wenqing.lz@taobao.com> References: <1341150538-32047-1-git-send-email-wenqing.lz@taobao.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zheng Liu dump and cat command use the same function to read data. We can directly read the data from inode. Signed-off-by: Zheng Liu --- debugfs/dump.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/debugfs/dump.c b/debugfs/dump.c index a15a0b7..10ebe7a 100644 --- a/debugfs/dump.c +++ b/debugfs/dump.c @@ -113,6 +113,36 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd, if (debugfs_read_inode(ino, &inode, cmdname)) return; + if (ext2fs_has_inline_data(current_fs, ino)) { + struct ext2_inode_large *inode; + struct inline_data idata; + void *inline_start; + int inline_size; + + retval = ext2fs_get_mem(EXT2_INODE_SIZE(current_fs->super), + &inode); + if (retval) + return; + + retval = ext2fs_read_inode_full(current_fs, ino, (void *)inode, + EXT2_INODE_SIZE(current_fs->super)); + if (retval) + goto out; + write(fd, inode->i_block, EXT4_MIN_INLINE_DATA_SIZE); + + ext2fs_iget_extra_inode(current_fs, inode, &idata); + if (idata.inline_off == EXT4_MIN_INLINE_DATA_SIZE) + goto out; + + inline_start = ext2fs_get_inline_xattr_pos(inode, &idata); + inline_size = idata.inline_size - EXT4_MIN_INLINE_DATA_SIZE; + write(fd, inline_start, inline_size); + +out: + ext2fs_free_mem(&inode); + return; + } + retval = ext2fs_file_open(current_fs, ino, 0, &e2_file); if (retval) { com_err(cmdname, retval, "while opening ext2 file");