From patchwork Thu Jun 12 07:12:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 4339781 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EFCDBBEEAA for ; Thu, 12 Jun 2014 07:11:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FDFB2028D for ; Thu, 12 Jun 2014 07:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B7EC2020E for ; Thu, 12 Jun 2014 07:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932136AbaFLHLf (ORCPT ); Thu, 12 Jun 2014 03:11:35 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:58509 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932111AbaFLHLf (ORCPT ); Thu, 12 Jun 2014 03:11:35 -0400 X-IronPort-AV: E=Sophos;i="5.00,694,1396972800"; d="scan'208";a="31800694" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 12 Jun 2014 15:08:51 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s5C7BS3j007982 for ; Thu, 12 Jun 2014 15:11:28 +0800 Received: from adam-work.lan (10.167.226.24) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 12 Jun 2014 15:11:28 +0800 From: Qu Wenruo To: Subject: [PATCH v2 1/2] btrfs-progs: Add human readable flags output string for extent flags. Date: Thu, 12 Jun 2014 15:12:31 +0800 Message-ID: <1402557152-5495-1-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.0.0 MIME-Version: 1.0 X-Originating-IP: [10.167.226.24] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Current btrfs-debug-tree outputs extent flags as numbers, which makes it hard to understand and need to check the source to understand the meaning. This patch will convert numberic flags output to human readable strings. Signed-off-by: Qu Wenruo --- changlog: v2: none --- print-tree.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/print-tree.c b/print-tree.c index 7263b09..7f831ad 100644 --- a/print-tree.c +++ b/print-tree.c @@ -242,6 +242,25 @@ static void print_file_extent_item(struct extent_buffer *eb, btrfs_file_extent_compression(eb, fi)); } +/* Caller should ensure sizeof(*ret) >= 16("DATA|TREE_BLOCK") */ +static void extent_flags_to_str(u64 flags, char *ret) +{ + int empty = 1; + + if (flags & BTRFS_EXTENT_FLAG_DATA) { + empty = 0; + strcpy(ret, "DATA"); + } + if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) { + if (!empty) { + empty = 0; + strcat(ret, "|"); + } + strcat(ret, "TREE_BLOCK"); + } + return; +} + static void print_extent_item(struct extent_buffer *eb, int slot, int metadata) { struct btrfs_extent_item *ei; @@ -255,6 +274,7 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int metadata) u32 item_size = btrfs_item_size_nr(eb, slot); u64 flags; u64 offset; + char flags_str[32] = {0}; if (item_size < sizeof(*ei)) { #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 @@ -271,11 +291,12 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int metadata) ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item); flags = btrfs_extent_flags(eb, ei); + extent_flags_to_str(flags, flags_str); - printf("\t\textent refs %llu gen %llu flags %llu\n", + printf("\t\textent refs %llu gen %llu flags %s\n", (unsigned long long)btrfs_extent_refs(eb, ei), (unsigned long long)btrfs_extent_generation(eb, ei), - (unsigned long long)flags); + flags_str); if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK && !metadata) { struct btrfs_tree_block_info *info;