[Ocfs2-tools-commits] smushran commits r1200 - in trunk/debugfs.ocfs2: . include

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Tue May 23 13:26:46 CDT 2006


Author: smushran
Signed-off-by: mfasheh
Date: 2006-05-23 13:26:45 -0500 (Tue, 23 May 2006)
New Revision: 1200

Modified:
   trunk/debugfs.ocfs2/include/main.h
   trunk/debugfs.ocfs2/main.c
Log:
debugfs allows single cmds to be issued using the -R parameter
Signed-off-by: mfasheh

Modified: trunk/debugfs.ocfs2/include/main.h
===================================================================
--- trunk/debugfs.ocfs2/include/main.h	2006-05-23 17:01:30 UTC (rev 1199)
+++ trunk/debugfs.ocfs2/include/main.h	2006-05-23 18:26:45 UTC (rev 1200)
@@ -88,6 +88,7 @@
 	int allow_write;
 	int no_prompt;
 	char *cmd_file;
+	char *one_cmd;
 	char *device;
 } dbgfs_opts;
 

Modified: trunk/debugfs.ocfs2/main.c
===================================================================
--- trunk/debugfs.ocfs2/main.c	2006-05-23 17:01:30 UTC (rev 1199)
+++ trunk/debugfs.ocfs2/main.c	2006-05-23 18:26:45 UTC (rev 1200)
@@ -51,8 +51,9 @@
 	g_print ("usage: %s -l [<logentry> ... [allow|off|deny]] ...\n", progname);
 	g_print ("usage: %s -d, --decode <lockres>\n", progname);
 	g_print ("usage: %s -e, --encode <lock type> <block num> <generation>\n", progname);
-	g_print ("usage: %s [-f cmdfile] [-V] [-w] [-n] [-?] [device]\n", progname);
+	g_print ("usage: %s [-f cmdfile] [-R request] [-V] [-w] [-n] [-?] [device]\n", progname);
 	g_print ("\t-f, --file <cmdfile>\tExecute commands in cmdfile\n");
+	g_print ("\t-R, --request <command>\t Execute a single command\n");
 	g_print ("\t-w, --write\t\tOpen in read-write mode instead of the default of read-only\n");
 	g_print ("\t-V, --version\t\tShow version\n");
 	g_print ("\t-n, --noprompt\t\tHide prompt\n");
@@ -188,6 +189,7 @@
 	int c;
 	static struct option long_options[] = {
 		{ "file", 1, 0, 'f' },
+		{ "request", 1, 0, 'R' },
 		{ "version", 0, 0, 'V' },
 		{ "help", 0, 0, '?' },
 		{ "write", 0, 0, '?' },
@@ -202,7 +204,7 @@
 		if (decodemode || encodemode || logmode)
 			break;
 
-		c = getopt_long(argc, argv, "lf:deV?wn", long_options, NULL);
+		c = getopt_long(argc, argv, "lf:R:deV?wn", long_options, NULL);
 		if (c == -1)
 			break;
 
@@ -215,6 +217,14 @@
 			}
 			break;
 
+		case 'R':
+			opts->one_cmd = strdup(optarg);
+			if (!strlen(opts->one_cmd)) {
+				usage(gbls.progname);
+				exit(1);
+			}
+			break;
+
 		case 'd':
 			decodemode++;
 			break;
@@ -464,15 +474,17 @@
 	if (!opts.cmd_file)
 		gbls.interactive++;
 
-	if (!opts.no_prompt)
-		print_version (gbls.progname);
-
 	if (opts.device) {
 		line = g_strdup_printf ("open %s", opts.device);
 		do_command (line);
 		g_free (line);
 	}
 
+	if (opts.one_cmd) {
+		do_command (opts.one_cmd);
+		goto bail;
+	}
+
 	if (opts.cmd_file) {
 		cmd = fopen(opts.cmd_file, "r");
 		if (!cmd) {
@@ -481,6 +493,9 @@
 		}
 	}
 
+	if (!opts.no_prompt)
+		print_version (gbls.progname);
+
 	while (1) {
 		line = get_line(cmd, opts.no_prompt);
 




More information about the Ocfs2-tools-commits mailing list