All of lore.kernel.org
 help / color / mirror / Atom feed
From: Filipe David Borba Manana <fdmanana@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Filipe David Borba Manana <fdmanana@gmail.com>
Subject: [PATCH 4/5] Btrfs-progs: pretty print dir_item type
Date: Mon, 10 Jun 2013 20:51:34 +0100	[thread overview]
Message-ID: <1370893895-24884-5-git-send-email-fdmanana@gmail.com> (raw)
In-Reply-To: <1370893895-24884-1-git-send-email-fdmanana@gmail.com>

Instead of printing an integer, print a symbolic name which
is more human friendly. Particularly useful when using the
program btrfs-debug-tree.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---
 print-tree.c |   40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/print-tree.c b/print-tree.c
index aae47a9..4401a1a 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -25,6 +25,42 @@
 #include "disk-io.h"
 #include "print-tree.h"
 
+
+static void print_dir_item_type(struct extent_buffer *eb,
+                                struct btrfs_dir_item *di)
+{
+	u8 type = btrfs_dir_type(eb, di);
+
+	switch (type) {
+	case BTRFS_FT_REG_FILE:
+		printf("FILE");
+		break;
+	case BTRFS_FT_DIR:
+		printf("DIR");
+		break;
+	case BTRFS_FT_CHRDEV:
+		printf("CHRDEV");
+		break;
+	case BTRFS_FT_BLKDEV:
+		printf("BLKDEV");
+		break;
+	case BTRFS_FT_FIFO:
+		printf("FIFO");
+		break;
+	case BTRFS_FT_SOCK:
+		printf("SOCK");
+		break;
+	case BTRFS_FT_SYMLINK:
+		printf("SYMLINK");
+		break;
+	case BTRFS_FT_XATTR:
+		printf("XATTR");
+		break;
+	default:
+		printf("%u", type);
+	}
+}
+
 static int print_dir_item(struct extent_buffer *eb, struct btrfs_item *item,
 			  struct btrfs_dir_item *di)
 {
@@ -41,7 +77,9 @@ static int print_dir_item(struct extent_buffer *eb, struct btrfs_item *item,
 		btrfs_dir_item_key(eb, di, &location);
 		printf("\t\tlocation ");
 		btrfs_print_key(&location);
-		printf(" type %u\n", btrfs_dir_type(eb, di));
+		printf(" type ");
+		print_dir_item_type(eb, di);
+		printf("\n");
 		name_len = btrfs_dir_name_len(eb, di);
 		data_len = btrfs_dir_data_len(eb, di);
 		len = (name_len <= sizeof(namebuf))? name_len: sizeof(namebuf);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-

  parent reply	other threads:[~2013-06-10 19:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-10 19:51 [PATCH 0/5] Btrfs-progs: coalesce of patches Filipe David Borba Manana
2013-06-10 19:51 ` [PATCH 1/5] Btrfs-progs: fix closing of devices Filipe David Borba Manana
2013-06-10 20:07   ` Filipe David Borba Manana
2013-06-11 15:00     ` David Sterba
2013-06-11 16:09       ` Filipe Manana
2013-06-10 19:51 ` [PATCH 2/5] Btrfs-progs: Add missing free_extent_buffer() call to debug-tree Filipe David Borba Manana
2013-06-10 19:51 ` [PATCH 3/5] Btrfs-progs: Add missing close_ctree() calls " Filipe David Borba Manana
2013-06-10 19:51 ` Filipe David Borba Manana [this message]
2013-06-10 19:51 ` [PATCH 5/5] Btrfs-progs: Validate super block checksum Filipe David Borba Manana
2013-06-20 17:08   ` Filipe David Manana
2013-06-21 16:18     ` David Sterba
2013-06-21 16:38       ` Filipe David Manana
2013-06-10 23:52 ` [PATCH 1/5 v2] Btrfs-progs: fix closing of devices Filipe David Borba Manana
2013-06-21 16:03   ` Liu Bo
2013-06-21 16:11   ` Liu Bo
2013-06-21 16:46     ` Filipe David Manana
2013-06-26 16:41 ` [PATCH v2 1/5] " Filipe David Borba Manana
2013-06-26 16:42 ` [PATCH v2 5/5] Btrfs-progs: Validate super block checksum Filipe David Borba Manana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370893895-24884-5-git-send-email-fdmanana@gmail.com \
    --to=fdmanana@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.