[Ocfs2-tools-devel] [PATCH 1/1] Ocfs2-tools: Check device before doing all kinds of debugfs's cmds.

Tristan Ye tristan.ye at oracle.com
Tue Aug 17 21:05:49 PDT 2010


To keep an unification and void segfault when referring to a NULL *fs pointer,
we'd better check device first in the head of all do_xxx() commands.

Currently, do_icheck() and do_stat() were being lack of such protection.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 debugfs.ocfs2/commands.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index 1f60049..b36bad5 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -1044,6 +1044,9 @@ static void do_stat (char **args)
 	const char *stat_usage = "usage: stat [-t|-T] <filespec>";
 	int index = 1, traverse = 1;
 
+	if (check_device_open())
+		return;
+
 	if (!args[index]) {
 		fprintf(stderr, "%s\n", stat_usage);
 		return ;
@@ -1951,6 +1954,9 @@ static void do_icheck(char **args)
 	int i;
 	FILE *out;
 
+	if (check_device_open())
+		return;
+
 	if (!args[1]) {
 		fprintf(stderr, "%s\n", testb_usage);
 		return;
-- 
1.5.5




More information about the Ocfs2-tools-devel mailing list