public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: chris.mason@oracle.com
Cc: linux-btrfs@vger.kernel.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH -V2 2/6] btrfs-progs: Add debug-btrfs command
Date: Thu,  4 Feb 2010 23:14:03 +0530	[thread overview]
Message-ID: <1265305447-30780-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1265305447-30780-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 Makefile                       |    3 ++
 debugbtrfs/Makefile            |   44 +++++++++++++++++++++++++++++
 debugbtrfs/cmds.c              |   27 ++++++++++++++++++
 debugbtrfs/debug_btrfs.c       |   59 ++++++++++++++++++++++++++++++++++++++++
 debugbtrfs/debug_btrfs.h       |   29 +++++++++++++++++++
 debugbtrfs/debug_btrfs_cmds.ct |   24 ++++++++++++++++
 6 files changed, 186 insertions(+), 0 deletions(-)
 create mode 100644 debugbtrfs/Makefile
 create mode 100644 debugbtrfs/cmds.c
 create mode 100644 debugbtrfs/debug_btrfs.c
 create mode 100644 debugbtrfs/debug_btrfs.h
 create mode 100644 debugbtrfs/debug_btrfs_cmds.ct

diff --git a/Makefile b/Makefile
index a30c212..3efd405 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,9 @@ bindir = $(prefix)/bin
 LIBS=-luuid
 
 SUBDIRS=lib misc man
+ifneq ($(E2FSPRGS_BUILD_DIR),)
+	SUBDIRS += debugbtrfs
+endif
 
 # make C=1 to enable sparse
 ifdef C
diff --git a/debugbtrfs/Makefile b/debugbtrfs/Makefile
new file mode 100644
index 0000000..348160b
--- /dev/null
+++ b/debugbtrfs/Makefile
@@ -0,0 +1,44 @@
+CC=gcc
+AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2
+CFLAGS = -g -Werror -Os -I$(E2FSPRGS_BUILD_DIR)/lib/ -I../lib/
+
+#
+CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
+		-Wuninitialized -Wshadow -Wundef
+DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
+
+INSTALL= install
+prefix ?= /usr/local
+bindir = $(prefix)/bin
+LIBS=-L$(E2FSPRGS_BUILD_DIR)/lib/ss -lss -ldl -lcom_err -luuid
+TOPDIR=../
+
+MK_CMDS= _SS_DIR_OVERRIDE=$(E2FSPRGS_BUILD_DIR)/lib/ss $(E2FSPRGS_BUILD_DIR)/lib/ss/mk_cmds
+
+progs = debug-btrfs
+
+# make C=1 to enable sparse
+ifdef C
+	check=sparse $(CHECKFLAGS)
+else
+	check=ls
+endif
+
+.c.o:
+	$(check) $<
+	$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
+
+all: $(progs)
+
+debug_btrfs_cmds.c: debug_btrfs_cmds.ct
+	$(MK_CMDS) debug_btrfs_cmds.ct
+
+debug-btrfs: $(TOPDIR)/lib/libbtrfs.a  debug_btrfs.o cmds.o debug_btrfs_cmds.o
+	$(CC) $(CFLAGS) -o debug-btrfs $^ $(TOPDIR)/lib/libbtrfs.a $(LDFLAGS) $(LIBS)
+
+clean:
+	rm -f *.o debug_btrfs_cmds.c
+	rm -f .*.d
+	rm -f debug-btrfs
+
+-include .*.d
diff --git a/debugbtrfs/cmds.c b/debugbtrfs/cmds.c
new file mode 100644
index 0000000..f5ed877
--- /dev/null
+++ b/debugbtrfs/cmds.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright IBM Corporation, 2010
+ * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+#include <stdio.h>
+#include "debug_btrfs.h"
+
+void do_show_debugfs_params(int argc, char *argv[])
+{
+        FILE *out = stdout;
+        fprintf(out, "Filesystem in use: %s\n", current_device);
+}
diff --git a/debugbtrfs/debug_btrfs.c b/debugbtrfs/debug_btrfs.c
new file mode 100644
index 0000000..44d6f64
--- /dev/null
+++ b/debugbtrfs/debug_btrfs.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright IBM Corporation, 2010
+ * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ss/ss.h>
+#include "debug_btrfs.h"
+
+extern ss_request_table btrfs_debug_cmds;
+const char *current_device;
+
+void usage(char *prg)
+{
+	fprintf(stderr, "Usage: %s device\n", prg);
+	exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+	int sci_idx;
+	int retval;
+
+	if (argc < 2)
+		usage(argv[0]);
+
+	current_device = argv[1];
+	sci_idx = ss_create_invocation("debug-btrfs", "0.0", NULL,
+				&btrfs_debug_cmds, &retval);
+	if (retval) {
+		ss_perror(sci_idx, retval, "create invocation");
+		exit(1);
+	}
+	ss_get_readline(sci_idx);
+	(void) ss_add_request_table (sci_idx, &ss_std_requests, 1, &retval);
+        if (retval) {
+                ss_perror(sci_idx, retval, "adding standard requests");
+                exit (1);
+        }
+	ss_listen(sci_idx);
+	ss_delete_invocation(sci_idx);
+
+	return 0;
+}
diff --git a/debugbtrfs/debug_btrfs.h b/debugbtrfs/debug_btrfs.h
new file mode 100644
index 0000000..55d7b17
--- /dev/null
+++ b/debugbtrfs/debug_btrfs.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright IBM Corporation, 2010
+ * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+#ifndef DEBUG_BTRFS_H
+#define DEBUG_BTRFS_H
+#include <getopt.h>
+
+extern const char *current_device;
+static inline void reset_getopt(void)
+{
+	optind = 0;
+}
+#endif
diff --git a/debugbtrfs/debug_btrfs_cmds.ct b/debugbtrfs/debug_btrfs_cmds.ct
new file mode 100644
index 0000000..29095d3
--- /dev/null
+++ b/debugbtrfs/debug_btrfs_cmds.ct
@@ -0,0 +1,24 @@
+# Copyright IBM Corporation, 2010
+# Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License v2 as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 021110-1307, USA.
+
+command_table btrfs_debug_cmds;
+
+request do_show_debugfs_params, "Show btrfs_debug parameters",
+	show_debugfs_params, params;
+
+end;
+
-- 
1.7.0.rc0.48.gdace5


  reply	other threads:[~2010-02-04 17:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-04 17:44 [PATCH -V2 1/6] btrfs-progs: Move files around Aneesh Kumar K.V
2010-02-04 17:44 ` Aneesh Kumar K.V [this message]
2010-02-04 17:44 ` [PATCH -V2 3/6] debug-btrfs: Add open file system command Aneesh Kumar K.V
2010-02-04 17:44 ` [PATCH -V2 4/6] debug-btrfs: Add command to dump each of the btrfs trees Aneesh Kumar K.V
2010-02-04 17:44 ` [PATCH -V2 5/6] debug-btrfs: Add pager support Aneesh Kumar K.V
2010-02-04 17:44 ` [PATCH -V2 6/6] debug-btrfs: Add print_inode command Aneesh Kumar K.V
2010-02-04 17:48 ` Add debug-btrfs (btrfs file system debugger) Aneesh Kumar K. V

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=1265305447-30780-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=chris.mason@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox