From patchwork Fri Nov 13 06:13:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Yang X-Patchwork-Id: 544068 X-Patchwork-Delegate: david.oberhollenzer@sigma-star.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EF1DF140281 for ; Fri, 13 Nov 2015 17:27:10 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zx7nu-0006Q9-P6; Fri, 13 Nov 2015 06:25:46 +0000 Received: from [59.151.112.132] (helo=heian.cn.fujitsu.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zx7kX-0001vC-Oh for linux-mtd@lists.infradead.org; Fri, 13 Nov 2015 06:22:24 +0000 X-IronPort-AV: E=Sophos;i="5.20,242,1444665600"; d="scan'208";a="420134" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 13 Nov 2015 14:20:57 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id tAD6KSi3010302; Fri, 13 Nov 2015 14:20:28 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 13 Nov 2015 14:21:08 +0800 From: Dongsheng Yang To: , , Subject: [PATCH v3 26/27] ubifs: ubifs_dump: dump data in hex format Date: Fri, 13 Nov 2015 14:13:37 +0800 Message-ID: <1447395218-7061-27-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1447395218-7061-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1447395218-7061-1-git-send-email-yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.66] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151112_222220_535188_A76FE108 X-CRM114-Status: UNSURE ( 8.58 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dongsheng Yang Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When we dump data node, we can dump the data in it in hex format. Signed-off-by: Dongsheng Yang --- Makefile | 2 +- ubifs-utils/ubifs_dump/ubifs_dump.c | 42 ++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 0be4772..c9dbc58 100644 --- a/Makefile +++ b/Makefile @@ -130,7 +130,7 @@ $(foreach v,$(UBI_BINS),$(eval $(call mkdep,ubi-utils/,$(v),libubi.a ubiutils-co $(foreach v,crc16.o lpt.o compr.o devtable.o io.o hashtable.o hashtable_itr.o,$(eval UBIFS_LIBS += ../lib/$(v))) obj-ubifs_dump = $(UBIFS_LIBS) -obj-ubifs_dump += ../lib/scan.o ../lib/lprops.o +obj-ubifs_dump += ../lib/scan.o ../lib/lprops.o ../lib/hexdump.o LDFLAGS_ubifs_dump = $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(UUIDLDFLAGS) LDLIBS_ubifs_dump = -lz -llzo2 -lm -luuid $(call mkdep,ubifs-utils/ubifs_dump/,ubifs_dump,,ubi-utils/libubi.a) diff --git a/ubifs-utils/ubifs_dump/ubifs_dump.c b/ubifs-utils/ubifs_dump/ubifs_dump.c index e72b8dd..47b0c89 100644 --- a/ubifs-utils/ubifs_dump/ubifs_dump.c +++ b/ubifs-utils/ubifs_dump/ubifs_dump.c @@ -7,6 +7,7 @@ #include "key.h" #include "lpt.h" #include "scan.h" +#include "hexdump.h" #define DBG_KEY_BUF_LEN 48 @@ -252,26 +253,26 @@ void dump_node(const struct ubifs_info *c, const void *node) const struct ubifs_ino_node *ino = node; key_read(c, &ino->key, &key); - printf("\t\tkey \t\t\t%s\n", + printf("\t\tkey \t\t\t\t%s\n", dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN)); printf("\t\tcreat_sqnum \t\t\t%llu\n", (unsigned long long)le64_to_cpu(ino->creat_sqnum)); - printf("\t\tsize \t\t\t%llu\n", + printf("\t\tsize \t\t\t\t%llu\n", (unsigned long long)le64_to_cpu(ino->size)); - printf("\t\tnlink \t\t\t%u\n", le32_to_cpu(ino->nlink)); - printf("\t\tatime \t\t\t%lld.%u\n", + printf("\t\tnlink \t\t\t\t%u\n", le32_to_cpu(ino->nlink)); + printf("\t\tatime \t\t\t\t%lld.%u\n", (long long)le64_to_cpu(ino->atime_sec), le32_to_cpu(ino->atime_nsec)); - printf("\t\tmtime \t\t\t%lld.%u\n", + printf("\t\tmtime \t\t\t\t%lld.%u\n", (long long)le64_to_cpu(ino->mtime_sec), le32_to_cpu(ino->mtime_nsec)); - printf("\t\tctime \t\t\t%lld.%u\n", + printf("\t\tctime \t\t\t\t%lld.%u\n", (long long)le64_to_cpu(ino->ctime_sec), le32_to_cpu(ino->ctime_nsec)); - printf("\t\tuid \t\t\t%u\n", le32_to_cpu(ino->uid)); - printf("\t\tgid \t\t\t%u\n", le32_to_cpu(ino->gid)); - printf("\t\tmode \t\t\t%u\n", le32_to_cpu(ino->mode)); - printf("\t\tflags \t\t\t%#x\n", le32_to_cpu(ino->flags)); + printf("\t\tuid \t\t\t\t%u\n", le32_to_cpu(ino->uid)); + printf("\t\tgid \t\t\t\t%u\n", le32_to_cpu(ino->gid)); + printf("\t\tmode \t\t\t\t%u\n", le32_to_cpu(ino->mode)); + printf("\t\tflags \t\t\t\t%#x\n", le32_to_cpu(ino->flags)); printf("\t\txattr_cnt \t\t\t%u\n", le32_to_cpu(ino->xattr_cnt)); printf("\t\txattr_size \t\t\t%u\n", le32_to_cpu(ino->xattr_size)); printf("\t\txattr_names \t\t\t%u\n", le32_to_cpu(ino->xattr_names)); @@ -287,13 +288,13 @@ void dump_node(const struct ubifs_info *c, const void *node) int nlen = le16_to_cpu(dent->nlen); key_read(c, &dent->key, &key); - printf("\t\tkey \t\t\t%s\n", + printf("\t\tkey \t\t\t\t%s\n", dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN)); - printf("\t\tinum \t\t\t%llu\n", + printf("\t\tinum \t\t\t\t%llu\n", (unsigned long long)le64_to_cpu(dent->inum)); - printf("\t\ttype \t\t\t%d\n", (int)dent->type); - printf("\t\tnlen \t\t\t%d\n", nlen); - printf("\t\tname "); + printf("\t\ttype \t\t\t\t%d\n", (int)dent->type); + printf("\t\tnlen \t\t\t\t%d\n", nlen); + printf("\t\tname \t\t\t\t"); if (nlen > UBIFS_MAX_NLEN) printf("(bad name length, not printing, bad or corrupted node)"); @@ -311,12 +312,15 @@ void dump_node(const struct ubifs_info *c, const void *node) int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ; key_read(c, &dn->key, &key); - printf("\t\tkey \t\t\t%s\n", + printf("\t\tkey \t\t\t\t%s\n", dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN)); - printf("\t\tsize \t\t\t%u\n", le32_to_cpu(dn->size)); + printf("\t\tsize \t\t\t\t%u\n", le32_to_cpu(dn->size)); printf("\t\tcompr_typ \t\t\t%d\n", (int)le16_to_cpu(dn->compr_type)); printf("\t\tdata size \t\t\t%d\n", dlen); + printf("\t\tdata:\n"); + print_hex_dump("\t\t", DUMP_PREFIX_OFFSET, 32, 1, + (void *)&dn->data, dlen, 0); break; } case UBIFS_TRUN_NODE: @@ -335,8 +339,8 @@ void dump_node(const struct ubifs_info *c, const void *node) const struct ubifs_idx_node *idx = node; n = le16_to_cpu(idx->child_cnt); - printf("\t\tchild_cnt \t\t%d\n", n); - printf("\t\tlevel \t\t\t%d\n", (int)le16_to_cpu(idx->level)); + printf("\t\tchild_cnt \t\t\t%d\n", n); + printf("\t\tlevel \t\t\t\t%d\n", (int)le16_to_cpu(idx->level)); printf("\t\tBranches:\n"); for (i = 0; i < n && i < c->fanout - 1; i++) {