[Ocfs2-tools-commits] jlbec commits r1207 - branches/ecc/tunefs.ocfs2

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Thu Jun 22 16:39:17 CDT 2006


Author: jlbec
Date: 2006-06-22 16:39:17 -0500 (Thu, 22 Jun 2006)
New Revision: 1207

Modified:
   branches/ecc/tunefs.ocfs2/tunefs.c
Log:

tunefs.ocfs2: Create options for features.



Modified: branches/ecc/tunefs.ocfs2/tunefs.c
===================================================================
--- branches/ecc/tunefs.ocfs2/tunefs.c	2006-06-20 21:06:04 UTC (rev 1206)
+++ branches/ecc/tunefs.ocfs2/tunefs.c	2006-06-22 21:39:17 UTC (rev 1207)
@@ -45,13 +45,14 @@
 #include <ctype.h>
 #include <signal.h>
 
-#include <ocfs2.h>
-#include <ocfs2_fs.h>
-#include <ocfs1_fs_compat.h>
+#include "ocfs2.h"
+#include "ocfs2_fs.h"
+#include "ocfs1_fs_compat.h"
+#include "bitops.h"
 
-#include <jbd.h>
+#include "jbd.h"
 
-#include <kernel-list.h>
+#include "kernel-list.h"
 
 #define SYSTEM_FILE_NAME_MAX   40
 
@@ -74,6 +75,8 @@
 	int prompt;
 	time_t tune_time;
 	int fd;
+	uint32_t feature_incompat;
+	uint32_t no_feature_incompat;
 } ocfs2_tune_opts;
 
 static ocfs2_tune_opts opts;
@@ -82,11 +85,11 @@
 
 static void usage(const char *progname)
 {
-	fprintf(stderr, "usage: %s [-N number-of-node-slots] "
-			"[-L volume-label]\n"
-			"\t[-J journal-options] [-S volume-size] [-qvV] "
-			"device\n",
-			progname);
+	fprintf(stderr,
+		"usage: %s [-N number-of-node-slots] [-L volume-label]\n"
+		"       %*s [-J journal-options] [-S volume-size] [-O [^]feature[,...]]\n"
+		"       %*s [-qvV] device \n",
+		progname, strlen(progname), " ", strlen(progname), " ");
 	exit(0);
 }
 
@@ -117,12 +120,12 @@
 /* Call this with SIG_BLOCK to block and SIG_UNBLOCK to unblock */
 static void block_signals(int how)
 {
-     sigset_t sigs;
+	 sigset_t sigs;
 
-     sigfillset(&sigs);
-     sigdelset(&sigs, SIGTRAP);
-     sigdelset(&sigs, SIGSEGV);
-     sigprocmask(how, &sigs, NULL);
+	 sigfillset(&sigs);
+	 sigdelset(&sigs, SIGTRAP);
+	 sigdelset(&sigs, SIGSEGV);
+	 sigprocmask(how, &sigs, NULL);
 }
 
 static int get_number(char *arg, uint64_t *res)
@@ -167,6 +170,51 @@
 	return 0;
 }
 
+/*
+ * This big switch is so we store the "feature name" -> "feature field"
+ * mapping just once.
+ */
+static void set_feature(char *feature, int yes)
+{
+	uint32_t *incompatp = yes ? &opts.feature_incompat :
+		&opts.no_feature_incompat;
+
+	if (!strcmp(feature, "check"))
+		ocfs2_set_bit(OCFS2_FEATURE_INCOMPAT_BLOCK_CHECK,
+			      incompatp);
+	else {
+		fprintf(stderr, "%s: Invalid feature: %s\n",
+			opts.progname, feature);
+		exit(1);
+	}
+}
+
+static void parse_features(const char *features)
+{
+	char *p, *n;
+
+	p = strdup(features);
+	if (!p) {
+		fprintf(stderr, "%s: Unable to allocate memory\n",
+			opts.progname);
+		exit(1);
+	}
+
+	while (p) {
+		n = strchr(p, ',');
+		if (n) {
+			*n = '\0';
+			n++;
+		}
+		if (p[0] == '^')
+			set_feature(p + 1, 0);
+		else
+			set_feature(p, 1);
+
+		p = n;
+	}
+}
+
 /* derived from e2fsprogs */
 static void parse_journal_opts(char *progname, const char *opts,
 			       uint64_t *journal_size_in_bytes)
@@ -241,8 +289,9 @@
 		{ "verbose", 0, 0, 'v' },
 		{ "quiet", 0, 0, 'q' },
 		{ "version", 0, 0, 'V' },
-		{ "journal-options", 0, 0, 'J'},
-		{ "volume-size", 0, 0, 'S'},
+		{ "journal-options", 1, 0, 'J'},
+		{ "volume-size", 1, 0, 'S'},
+		{ "feature", 1, 0, 'O'},
 		{ 0, 0, 0, 0}
 	};
 
@@ -254,7 +303,7 @@
 	opts.prompt = 1;
 
 	while (1) {
-		c = getopt_long(argc, argv, "L:N:J:S:vqVx", long_options, 
+		c = getopt_long(argc, argv, "L:N:J:S:O:vqVx", long_options, 
 				NULL);
 
 		if (c == -1)
@@ -303,6 +352,10 @@
 			opts.vol_size = val;
 			break;
 
+		        case 'O':
+		                parse_features(optarg);
+		                break;
+
 		case 'v':
 			opts.verbose = 1;
 			break;
@@ -366,8 +419,8 @@
 
 			/* create inode for system file */
 			ret = ocfs2_new_system_inode(fs, &blkno,
-						      ocfs2_system_inodes[i].si_mode,
-						      ocfs2_system_inodes[i].si_iflags);
+						     ocfs2_system_inodes[i].si_mode,
+						     ocfs2_system_inodes[i].si_iflags);
 			if (ret)
 				goto bail;
 




More information about the Ocfs2-tools-commits mailing list