[Ocfs2-tools-devel] [PATCH v2] libocfs2: Make feature strings a proper API proper API

Joel Becker Joel.Becker at oracle.com
Sat Jul 19 02:29:09 PDT 2008


The feature string functions are used in multiple places.  They belong
as a proper API in ocfs2.h  As such, move the required prototypes there,
give the functions and structures the appropriate prefixes, and remove
feature_string.h.

In addition, a DEBUG_EXE section is added to test the functions.  It
parses feature options and prints what mkfs and tunefs would do with them.

Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
 include/ocfs2/feature_string.h |   59 ----------
 include/ocfs2/ocfs2.h          |   30 +++++-
 libocfs2/feature_string.c      |  229 +++++++++++++++++++++++++++++++---------
 libocfs2/ocfs2_err.et          |    3 +
 mkfs.ocfs2/mkfs.c              |   50 +++++----
 mkfs.ocfs2/mkfs.h              |    3 +-
 tunefs.ocfs2/features.c        |   39 ++++---
 tunefs.ocfs2/format_slotmap.c  |    4 +-
 tunefs.ocfs2/tunefs.c          |    7 +-
 tunefs.ocfs2/tunefs.h          |    4 +-
 10 files changed, 261 insertions(+), 167 deletions(-)
 delete mode 100644 include/ocfs2/feature_string.h

diff --git a/include/ocfs2/feature_string.h b/include/ocfs2/feature_string.h
deleted file mode 100644
index 650dda8..0000000
--- a/include/ocfs2/feature_string.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * feature_strings.h
- *
- * Routines for analyzing a feature string.
- *
- * Copyright (C) 2007 Oracle.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License, version 2,  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 __FEATURE_STRING_H
-#define __FEATURE_STRING_H
-
-#include <ocfs2/ocfs2.h>
-
-struct fs_feature_flags {
-	const char *ff_str;
-	/* this flag is the feature's own flag. */
-	fs_options ff_own_flags;
-	/*
-	 * this flag includes the feature's own flag and
-	 * all the other features' flag it depends on.
-	 */
-	fs_options ff_flags;
-};
-
-enum feature_level_indexes {
-	FEATURE_LEVEL_DEFAULT = 0,
-	FEATURE_LEVEL_MAX_COMPAT,
-	FEATURE_LEVEL_MAX_FEATURES,
-};
-
-errcode_t parse_feature(const char *opts,
-			fs_options *feature_flags,
-			fs_options *reverse_flags);
-
-int parse_feature_level(const char *typestr,
-			enum feature_level_indexes *index);
-
-int merge_feature_flags_with_level(fs_options *dest,
-				   int index,
-				   fs_options *feature_set,
-				   fs_options *reverse_set);
-#endif /* __FEATURE_STIRNG_H */
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index a6908c0..7c21d28 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -209,12 +209,12 @@ struct _ocfs2_devices {
 	struct ocfs2_slot_map_data *map; /* Mounted nodes, must be freed */
 };
 
-typedef struct _fs_options fs_options;
+typedef struct _ocfs2_fs_options ocfs2_fs_options;
 
-struct _fs_options {
-	uint32_t compat;
-	uint32_t incompat;
-	uint32_t ro_compat;
+struct _ocfs2_fs_options {
+	uint32_t opt_compat;
+	uint32_t opt_incompat;
+	uint32_t opt_ro_compat;
 };
 
 errcode_t ocfs2_malloc(unsigned long size, void *ptr);
@@ -625,6 +625,26 @@ errcode_t ocfs2_get_last_cluster_offset(ocfs2_filesys *fs,
 					struct ocfs2_dinode *di,
 					uint32_t *v_cluster);
 
+/* Filesystem features */
+enum ocfs2_feature_levels {
+	OCFS2_FEATURE_LEVEL_DEFAULT = 0,
+	OCFS2_FEATURE_LEVEL_MAX_COMPAT,
+	OCFS2_FEATURE_LEVEL_MAX_FEATURES,
+};
+
+errcode_t ocfs2_parse_feature(const char *opts,
+			      ocfs2_fs_options *feature_flags,
+			      ocfs2_fs_options *reverse_flags);
+
+errcode_t ocfs2_parse_feature_level(const char *typestr,
+				    enum ocfs2_feature_levels *level);
+
+errcode_t ocfs2_merge_feature_flags_with_level(ocfs2_fs_options *dest,
+					       int level,
+					       ocfs2_fs_options *feature_set,
+					       ocfs2_fs_options *reverse_set);
+
+
 /* These are deprecated names - don't use them */
 int ocfs2_get_backup_super_offset(ocfs2_filesys *fs,
 				  uint64_t *blocks, size_t len);
diff --git a/libocfs2/feature_string.c b/libocfs2/feature_string.c
index 6d3408e..4dc6a19 100644
--- a/libocfs2/feature_string.c
+++ b/libocfs2/feature_string.c
@@ -22,33 +22,45 @@
  * Boston, MA 021110-1307, USA.
  *
  */
-#include "ocfs2/feature_string.h"
+
+#include "ocfs2/ocfs2.h"
+
+struct fs_feature_flags {
+	const char *ff_str;
+	/* this flag is the feature's own flag. */
+	ocfs2_fs_options ff_own_flags;
+	/*
+	 * this flag includes the feature's own flag and
+	 * all the other features' flag it depends on.
+	 */
+	ocfs2_fs_options ff_flags;
+};
 
 struct feature_level_translation {
 	const char *fl_str;
-	enum feature_level_indexes fl_type;
+	enum ocfs2_feature_levels fl_type;
 };
 
 static struct feature_level_translation ocfs2_feature_levels_table[] = {
-	{"default", FEATURE_LEVEL_DEFAULT},
-	{"max-compat", FEATURE_LEVEL_MAX_COMPAT},
-	{"max-features", FEATURE_LEVEL_MAX_FEATURES},
-	{NULL, FEATURE_LEVEL_DEFAULT},
+	{"default", OCFS2_FEATURE_LEVEL_DEFAULT},
+	{"max-compat", OCFS2_FEATURE_LEVEL_MAX_COMPAT},
+	{"max-features", OCFS2_FEATURE_LEVEL_MAX_FEATURES},
+	{NULL, OCFS2_FEATURE_LEVEL_DEFAULT},
 };
 
-static fs_options feature_level_defaults[] = {
+static ocfs2_fs_options feature_level_defaults[] = {
 	{OCFS2_FEATURE_COMPAT_BACKUP_SB,
 	 OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC,
-	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN},  /* FEATURE_LEVEL_DEFAULT */
+	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN},  /* OCFS2_FEATURE_LEVEL_DEFAULT */
 
 	{OCFS2_FEATURE_COMPAT_BACKUP_SB,
 	 0,
-	 0}, /* FEATURE_LEVEL_MAX_COMPAT */
+	 0}, /* OCFS2_FEATURE_LEVEL_MAX_COMPAT */
 
 	{OCFS2_FEATURE_COMPAT_BACKUP_SB,
 	 OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC |
 	 OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP,
-	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN}, /* FEATURE_LEVEL_MAX_FEATURES */
+	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN}, /* OCFS2_FEATURE_LEVEL_MAX_FEATURES */
 };
 
 static struct fs_feature_flags ocfs2_supported_features[] = {
@@ -85,24 +97,24 @@ static struct fs_feature_flags ocfs2_supported_features[] = {
 	},
 };
 
-static inline void merge_features(fs_options *features,
-				  fs_options new_features)
+static inline void merge_features(ocfs2_fs_options *features,
+				  ocfs2_fs_options new_features)
 {
-	features->compat |= new_features.compat;
-	features->incompat |= new_features.incompat;
-	features->ro_compat |= new_features.ro_compat;
+	features->opt_compat |= new_features.opt_compat;
+	features->opt_incompat |= new_features.opt_incompat;
+	features->opt_ro_compat |= new_features.opt_ro_compat;
 }
 
 /* Get the feature level according to the value set by "--fs-feature-level". */
-int parse_feature_level(const char *typestr,
-			 enum feature_level_indexes *index)
+errcode_t ocfs2_parse_feature_level(const char *typestr,
+				    enum ocfs2_feature_levels *level)
 {
 	int i;
 
 	for(i = 0; ocfs2_feature_levels_table[i].fl_str; i++) {
 		if (strcmp(typestr,
 			  ocfs2_feature_levels_table[i].fl_str) == 0) {
-			*index = ocfs2_feature_levels_table[i].fl_type;
+			*level = ocfs2_feature_levels_table[i].fl_type;
 			break;
 		}
 	}
@@ -114,19 +126,19 @@ int parse_feature_level(const char *typestr,
 	return 0;
 }
 
-static int check_feature_flags(fs_options *fs_flags,
-			       fs_options *fs_r_flags)
+static int check_feature_flags(ocfs2_fs_options *fs_flags,
+			       ocfs2_fs_options *fs_r_flags)
 {
 	int ret = 1;
 
-	if (fs_r_flags->compat &&
-	    fs_flags->compat & fs_r_flags->compat)
+	if (fs_r_flags->opt_compat &&
+	    fs_flags->opt_compat & fs_r_flags->opt_compat)
 		ret = 0;
-	else if (fs_r_flags->incompat &&
-		 fs_flags->incompat & fs_r_flags->incompat)
+	else if (fs_r_flags->opt_incompat &&
+		 fs_flags->opt_incompat & fs_r_flags->opt_incompat)
 		ret = 0;
-	else if (fs_r_flags->ro_compat &&
-		 fs_flags->ro_compat & fs_r_flags->ro_compat)
+	else if (fs_r_flags->opt_ro_compat &&
+		 fs_flags->opt_ro_compat & fs_r_flags->opt_ro_compat)
 		ret = 0;
 
 	return ret;
@@ -139,20 +151,20 @@ static int check_feature_flags(fs_options *fs_flags,
  * feature_set: all the features a user set by "--fs-features".
  * reverse_set: all the features a user want to clear by "--fs-features".
  */
-int merge_feature_flags_with_level(fs_options *dest,
-				   int index,
-				   fs_options *feature_set,
-				   fs_options *reverse_set)
+errcode_t ocfs2_merge_feature_flags_with_level(ocfs2_fs_options *dest,
+					       int level,
+					       ocfs2_fs_options *feature_set,
+					       ocfs2_fs_options *reverse_set)
 {
 	int i;
-	fs_options level_set = feature_level_defaults[index];
+	ocfs2_fs_options level_set = feature_level_defaults[level];
 	/*
 	 * "Check whether the user asked for a flag to be set and cleared,
 	 * which is illegal. The feature_set and reverse_set are both set
 	 * by "--fs-features", so they shouldn't collide with each other.
 	 */
 	if (!check_feature_flags(feature_set, reverse_set))
-		return 0;
+		return OCFS2_ET_CONFLICTING_FEATURES;
 
 	/* Now combine all the features the user has set. */
 	*dest = level_set;
@@ -163,24 +175,24 @@ int merge_feature_flags_with_level(fs_options *dest,
 	 * and other features which depend on them.
 	 */
 	for(i = 0; ocfs2_supported_features[i].ff_str; i++) {
-		if ((reverse_set->compat &
-			ocfs2_supported_features[i].ff_flags.compat) ||
-		    (reverse_set->incompat &
-			ocfs2_supported_features[i].ff_flags.incompat) ||
-		    (reverse_set->ro_compat &
-			ocfs2_supported_features[i].ff_flags.ro_compat)) {
-			dest->compat &=
-			~ocfs2_supported_features[i].ff_own_flags.compat;
-
-			dest->incompat &=
-			~ocfs2_supported_features[i].ff_own_flags.incompat;
-
-			dest->ro_compat &=
-			~ocfs2_supported_features[i].ff_own_flags.ro_compat;
+		if ((reverse_set->opt_compat &
+			ocfs2_supported_features[i].ff_flags.opt_compat) ||
+		    (reverse_set->opt_incompat &
+			ocfs2_supported_features[i].ff_flags.opt_incompat) ||
+		    (reverse_set->opt_ro_compat &
+			ocfs2_supported_features[i].ff_flags.opt_ro_compat)) {
+			dest->opt_compat &=
+			~ocfs2_supported_features[i].ff_own_flags.opt_compat;
+
+			dest->opt_incompat &=
+			~ocfs2_supported_features[i].ff_own_flags.opt_incompat;
+
+			dest->opt_ro_compat &=
+			~ocfs2_supported_features[i].ff_own_flags.opt_ro_compat;
 		}
 	}
 
-	return 1;
+	return 0;
 }
 
 /*
@@ -191,15 +203,15 @@ int merge_feature_flags_with_level(fs_options *dest,
  *
  * For those the user want to set, they are stored in "feature_flags".
  */
-errcode_t parse_feature(const char *opts,
-		        fs_options *feature_flags,
-		        fs_options *reverse_flags)
+errcode_t ocfs2_parse_feature(const char *opts,
+			      ocfs2_fs_options *feature_flags,
+			      ocfs2_fs_options *reverse_flags)
 {
 	char *options, *token, *next, *p, *arg;
 	int i, reverse = 0;
 
-	memset(feature_flags, 0, sizeof(fs_options));
-	memset(reverse_flags, 0, sizeof(fs_options));
+	memset(feature_flags, 0, sizeof(ocfs2_fs_options));
+	memset(reverse_flags, 0, sizeof(ocfs2_fs_options));
 
 	options = strdup(opts);
 	for (token = options; token && *token; token = next) {
@@ -240,3 +252,116 @@ errcode_t parse_feature(const char *opts,
 
 	return 0;
 }
+
+
+#ifdef DEBUG_EXE
+
+#include <stdio.h>
+#include <getopt.h>
+
+#include "ocfs2/ocfs2.h"
+
+static void print_features(char *desc, ocfs2_fs_options *feature_set)
+{
+	int i;
+
+	fprintf(stdout, "%s:\n", desc);
+
+	fprintf(stdout, "COMPAT:\t\t");
+	for(i = 0; ocfs2_supported_features[i].ff_str; i++)
+		if (feature_set->opt_compat &
+		    ocfs2_supported_features[i].ff_own_flags.opt_compat)
+			fprintf(stdout, " %s",
+				ocfs2_supported_features[i].ff_str);
+	fprintf(stdout, "\n");
+	fprintf(stdout, "RO_COMPAT:\t");
+	for(i = 0; ocfs2_supported_features[i].ff_str; i++)
+		if (feature_set->opt_ro_compat &
+		    ocfs2_supported_features[i].ff_own_flags.opt_ro_compat)
+			fprintf(stdout, " %s",
+				ocfs2_supported_features[i].ff_str);
+	fprintf(stdout, "\n");
+	fprintf(stdout, "INCOMPAT:\t");
+	for(i = 0; ocfs2_supported_features[i].ff_str; i++)
+		if (feature_set->opt_incompat &
+		    ocfs2_supported_features[i].ff_own_flags.opt_incompat)
+			fprintf(stdout, " %s",
+				ocfs2_supported_features[i].ff_str);
+	fprintf(stdout, "\n\n");
+}
+
+extern int optind, optopt, opterr;
+extern char *optarg;
+int main(int argc, char *argv[])
+{
+	int c;
+	enum ocfs2_feature_levels level = OCFS2_FEATURE_LEVEL_DEFAULT;
+	errcode_t err;
+	char *feature_string = NULL;
+	char *level_string = NULL;
+	ocfs2_fs_options set_features, clear_features, mkfs_features;
+
+	initialize_ocfs_error_table();
+
+	opterr = 0;
+	memset(&set_features, 0, sizeof(ocfs2_fs_options));
+	memset(&clear_features, 0, sizeof(ocfs2_fs_options));
+	while ((c = getopt(argc, argv, ":l:s:")) != EOF) {
+		switch (c) {
+		case 'l':
+			if (level_string)
+				free(level_string);
+			level_string = strdup(optarg);
+			err = ocfs2_parse_feature_level(optarg, &level);
+			if (err) {
+				com_err(argv[0], err,
+					"while parsing the feature level string");
+				exit(1);
+			}
+			break;
+
+		case 's':
+			if (feature_string)
+				free(feature_string);
+			feature_string = strdup(optarg);
+			memset(&set_features, 0, sizeof(ocfs2_fs_options));
+			memset(&clear_features, 0, sizeof(ocfs2_fs_options));
+			err = ocfs2_parse_feature(optarg, &set_features,
+						  &clear_features);
+			if (err) {
+				com_err(argv[0], err,
+					"while parsing the feature string");
+				exit(1);
+			}
+			break;
+
+		default:
+			fprintf(stderr, "%s: Invalid argument: '-%c'\n",
+				argv[0], optopt);
+			exit(1);
+			break;
+		}
+	}
+
+	memset(&mkfs_features, 0, sizeof(ocfs2_fs_options));
+	err = ocfs2_merge_feature_flags_with_level(&mkfs_features, level,
+						   &set_features,
+						   &clear_features);
+	if (err) {
+		com_err(argv[0], err,
+			"while trying to reconcile default and specified features");
+		exit(1);
+	}
+
+	print_features("\nmkfs.ocfs2 would set these features",
+		       &mkfs_features);
+	print_features("tunefs.ocfs2 would set these features",
+		       &set_features);
+	print_features("tunefs.ocfs2 would clear these features",
+		       &clear_features);
+
+	return 0;
+}
+
+
+#endif /* DEBUG_EXE */
diff --git a/libocfs2/ocfs2_err.et b/libocfs2/ocfs2_err.et
index 35dee5a..9b33a3b 100644
--- a/libocfs2/ocfs2_err.et
+++ b/libocfs2/ocfs2_err.et
@@ -60,6 +60,9 @@ ec	OCFS2_ET_UNSUPP_FEATURE,
 ec	OCFS2_ET_RO_UNSUPP_FEATURE,
 	"Unsupported read-only feature(s) found"
 
+ec	OCFS2_ET_CONFLICTING_FEATURES,
+	"Conflicting features specified"
+
 ec	OCFS2_ET_BAD_INODE_MAGIC,
 	"Bad magic number in inode"
 
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 8a1074d..dce7cab 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -526,8 +526,8 @@ get_state(int argc, char **argv)
 	enum ocfs2_fs_types fs_type = FS_DEFAULT;
 	int mount = -1;
 	int no_backup_super = -1;
-	enum feature_level_indexes index = FEATURE_LEVEL_DEFAULT;
-	fs_options feature_flags ={0,0,0}, reverse_flags = {0,0,0};
+	enum ocfs2_feature_levels level = OCFS2_FEATURE_LEVEL_DEFAULT;
+	ocfs2_fs_options feature_flags = {0,0,0}, reverse_flags = {0,0,0};
 
 	static struct option long_options[] = {
 		{ "block-size", 1, 0, 'b' },
@@ -681,7 +681,7 @@ get_state(int argc, char **argv)
 			break;
 
 		case FEATURE_LEVEL:
-			ret = parse_feature_level(optarg, &index);
+			ret = ocfs2_parse_feature_level(optarg, &level);
 			if (ret) {
 				com_err(progname, ret,
 					"when parsing fs-feature-level string");
@@ -690,9 +690,9 @@ get_state(int argc, char **argv)
 			break;
 
 		case FEATURES_OPTION:
-			ret = parse_feature(optarg,
-					    &feature_flags,
-					    &reverse_flags);
+			ret = ocfs2_parse_feature(optarg,
+						  &feature_flags,
+						  &reverse_flags);
 			if (ret) {
 				com_err(progname, ret,
 					"when parsing fs-features string");
@@ -794,20 +794,22 @@ get_state(int argc, char **argv)
 
 	s->fs_type = fs_type;
 
-	if(!merge_feature_flags_with_level(&s->feature_flags,
-					   index,
-					   &feature_flags, &reverse_flags)) {
-		com_err(s->progname, 0,
-			"Incompatible feature flags"
-			" were specified\n");
+	ret = ocfs2_merge_feature_flags_with_level(&s->feature_flags,
+						   level,
+						   &feature_flags,
+						   &reverse_flags);
+	if (ret) {
+		com_err(s->progname, ret,
+			"while reconciling specified features with chosen "
+			"defaults");
 		exit(1);
 	}
 
-	if (s->feature_flags.incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT)
+	if (s->feature_flags.opt_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT)
 		s->mount = MOUNT_LOCAL;
 	else
 		s->mount = MOUNT_CLUSTER;
-	if (s->feature_flags.compat & OCFS2_FEATURE_COMPAT_BACKUP_SB)
+	if (s->feature_flags.opt_compat & OCFS2_FEATURE_COMPAT_BACKUP_SB)
 		s->no_backup_super = 0;
 	else
 		s->no_backup_super = 1;
@@ -1846,18 +1848,18 @@ format_superblock(State *s, SystemFileDiskRecord *rec,
 	di->id2.i_super.s_first_cluster_group = s->first_cluster_group_blkno;
 
 	if (s->hb_dev) {
-		s->feature_flags.incompat =
+		s->feature_flags.opt_incompat =
 				 	OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV;
-		s->feature_flags.compat = 0;
-		s->feature_flags.ro_compat = 0;
+		s->feature_flags.opt_compat = 0;
+		s->feature_flags.opt_ro_compat = 0;
 	}
 
 	if (s->mount == MOUNT_LOCAL)
-		s->feature_flags.incompat |=
-					 OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT;
+		s->feature_flags.opt_incompat |=
+			OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT;
 
 	if (s->cluster_stack) {
-		s->feature_flags.incompat |=
+		s->feature_flags.opt_incompat |=
 			(OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP|
 			 OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK);
 		memcpy(di->id2.i_super.s_cluster_info.ci_stack,
@@ -1872,11 +1874,11 @@ format_superblock(State *s, SystemFileDiskRecord *rec,
 	 * "s->no_backup_super" according to the features in get_state,
 	 * so it is safe to clear the flag here.
 	 */
-	s->feature_flags.compat &= !OCFS2_FEATURE_COMPAT_BACKUP_SB;
+	s->feature_flags.opt_compat &= !OCFS2_FEATURE_COMPAT_BACKUP_SB;
 
-	di->id2.i_super.s_feature_incompat = s->feature_flags.incompat;
-	di->id2.i_super.s_feature_compat = s->feature_flags.compat;
-	di->id2.i_super.s_feature_ro_compat = s->feature_flags.ro_compat;
+	di->id2.i_super.s_feature_incompat = s->feature_flags.opt_incompat;
+	di->id2.i_super.s_feature_compat = s->feature_flags.opt_compat;
+	di->id2.i_super.s_feature_ro_compat = s->feature_flags.opt_ro_compat;
 
 	strcpy((char *)di->id2.i_super.s_label, s->vol_label);
 	memcpy(di->id2.i_super.s_uuid, s->uuid, 16);
diff --git a/mkfs.ocfs2/mkfs.h b/mkfs.ocfs2/mkfs.h
index 6159cfb..fc66bb3 100644
--- a/mkfs.ocfs2/mkfs.h
+++ b/mkfs.ocfs2/mkfs.h
@@ -50,7 +50,6 @@
 #include <signal.h>
 #include <libgen.h>
 
-#include "ocfs2/feature_string.h"
 
 #ifndef MAX
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
@@ -238,7 +237,7 @@ struct _State {
 	uint32_t first_cluster_group;
 	uint64_t first_cluster_group_blkno;
 
-	fs_options feature_flags;
+	ocfs2_fs_options feature_flags;
 
 	enum ocfs2_fs_types fs_type;
 };
diff --git a/tunefs.ocfs2/features.c b/tunefs.ocfs2/features.c
index 36307c8..b597cd0 100644
--- a/tunefs.ocfs2/features.c
+++ b/tunefs.ocfs2/features.c
@@ -53,27 +53,30 @@ errcode_t feature_check(ocfs2_filesys *fs)
 	errcode_t ret = 1;
 	int sparse_on = ocfs2_sparse_alloc(OCFS2_RAW_SB(fs->fs_super));
 
-	if (opts.set_feature.compat & ~TUNEFS_COMPAT_SET ||
-	    opts.set_feature.ro_compat & ~TUNEFS_RO_COMPAT_SET ||
-	    opts.set_feature.incompat & ~TUNEFS_INCOMPAT_SET)
+	if (opts.set_feature.opt_compat & ~TUNEFS_COMPAT_SET ||
+	    opts.set_feature.opt_ro_compat & ~TUNEFS_RO_COMPAT_SET ||
+	    opts.set_feature.opt_incompat & ~TUNEFS_INCOMPAT_SET)
 		goto bail;
 
-	if (opts.clear_feature.compat & ~TUNEFS_COMPAT_CLEAR ||
-	    opts.clear_feature.ro_compat & ~TUNEFS_RO_COMPAT_CLEAR ||
-	    opts.clear_feature.incompat & ~TUNEFS_INCOMPAT_CLEAR)
+	if (opts.clear_feature.opt_compat & ~TUNEFS_COMPAT_CLEAR ||
+	    opts.clear_feature.opt_ro_compat & ~TUNEFS_RO_COMPAT_CLEAR ||
+	    opts.clear_feature.opt_incompat & ~TUNEFS_INCOMPAT_CLEAR)
 		goto bail;
 
-	if (opts.set_feature.incompat & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC) {
+	if (opts.set_feature.opt_incompat &
+	    OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC) {
 		/*
 		 * Allow sparse to pass on an already-sparse file
 		 * system if the user asked for unwritten extents.
 		 */
 		if (ocfs2_sparse_alloc(OCFS2_RAW_SB(fs->fs_super)) && 
-		    !(opts.set_feature.ro_compat & OCFS2_FEATURE_RO_COMPAT_UNWRITTEN))
+		    !(opts.set_feature.opt_ro_compat &
+		      OCFS2_FEATURE_RO_COMPAT_UNWRITTEN))
 			goto bail;
 
 		sparse_on = 1;
-	} else if (opts.clear_feature.incompat & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC) {
+	} else if (opts.clear_feature.opt_incompat &
+		   OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC) {
 		if (!ocfs2_sparse_alloc(OCFS2_RAW_SB(fs->fs_super)))
 			goto bail;
 
@@ -82,7 +85,8 @@ errcode_t feature_check(ocfs2_filesys *fs)
 		 * off unwritten extents.
 		 */
 		if (ocfs2_writes_unwritten_extents(OCFS2_RAW_SB(fs->fs_super)))
-			opts.clear_feature.ro_compat |= OCFS2_FEATURE_RO_COMPAT_UNWRITTEN;
+			opts.clear_feature.opt_ro_compat |=
+				OCFS2_FEATURE_RO_COMPAT_UNWRITTEN;
 
 		sparse_on = 0;
 		ret = clear_sparse_file_check(fs, opts.progname, 0);
@@ -90,7 +94,8 @@ errcode_t feature_check(ocfs2_filesys *fs)
 			goto bail;
 	}
 
-	if (opts.set_feature.ro_compat & OCFS2_FEATURE_RO_COMPAT_UNWRITTEN) {
+	if (opts.set_feature.opt_ro_compat &
+	    OCFS2_FEATURE_RO_COMPAT_UNWRITTEN) {
 		/*
 		 * Disallow setting of unwritten extents unless we
 		 * either have sparse file support, or will also be
@@ -106,7 +111,7 @@ errcode_t feature_check(ocfs2_filesys *fs)
 		if (OCFS2_HAS_RO_COMPAT_FEATURE(OCFS2_RAW_SB(fs->fs_super),
 					OCFS2_FEATURE_RO_COMPAT_UNWRITTEN))
 		    goto bail;
-	} else if (opts.clear_feature.ro_compat &
+	} else if (opts.clear_feature.opt_ro_compat &
 		   OCFS2_FEATURE_RO_COMPAT_UNWRITTEN) {
 		if (!ocfs2_writes_unwritten_extents(OCFS2_RAW_SB(fs->fs_super)))
 			goto bail;
@@ -132,20 +137,20 @@ errcode_t update_feature(ocfs2_filesys *fs)
 {
 	errcode_t ret = 0;
 
-	if (opts.set_feature.incompat & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC)
+	if (opts.set_feature.opt_incompat & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC)
 		ret = set_sparse_file_flag(fs, opts.progname);
-	else if (opts.clear_feature.incompat
+	else if (opts.clear_feature.opt_incompat
 		 & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC ||
-		 opts.clear_feature.ro_compat
+		 opts.clear_feature.opt_ro_compat
 		 & OCFS2_FEATURE_RO_COMPAT_UNWRITTEN)
 		ret = clear_sparse_file_flag(fs, opts.progname);
 	if (ret)
 		goto bail;
 
-	if (opts.set_feature.ro_compat & OCFS2_FEATURE_RO_COMPAT_UNWRITTEN)
+	if (opts.set_feature.opt_ro_compat & OCFS2_FEATURE_RO_COMPAT_UNWRITTEN)
 		set_unwritten_extents_flag(fs);
 
-	if ((opts.set_feature.incompat | opts.clear_feature.incompat) &
+	if ((opts.set_feature.opt_incompat | opts.clear_feature.opt_incompat) &
 	    OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP)
 		ret = reformat_slot_map(fs);
 
diff --git a/tunefs.ocfs2/format_slotmap.c b/tunefs.ocfs2/format_slotmap.c
index 99c8f25..75aec4d 100644
--- a/tunefs.ocfs2/format_slotmap.c
+++ b/tunefs.ocfs2/format_slotmap.c
@@ -37,14 +37,14 @@ errcode_t reformat_slot_map(ocfs2_filesys *fs)
 	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
 	int extended = ocfs2_uses_extended_slot_map(super);
 
-	if (opts.set_feature.incompat &
+	if (opts.set_feature.opt_incompat &
 	    OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP) {
 		if (extended) {
 			printf("Feature \"extended-slotmap\" is already enabled, skipping\n");
 			goto out;
 		}
 		OCFS2_SET_INCOMPAT_FEATURE(super, OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP);
-	} else if (opts.clear_feature.incompat &
+	} else if (opts.clear_feature.opt_incompat &
 		   OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP) {
 		if (!extended) {
 			printf("Feature \"extended-slotmap\" is not enabled, skipping\n");
diff --git a/tunefs.ocfs2/tunefs.c b/tunefs.ocfs2/tunefs.c
index ab47555..8f70a39 100644
--- a/tunefs.ocfs2/tunefs.c
+++ b/tunefs.ocfs2/tunefs.c
@@ -26,7 +26,6 @@
  */
 
 #include <tunefs.h>
-#include <ocfs2/feature_string.h>
 
 #define WHOAMI "tunefs.ocfs2"
 
@@ -317,9 +316,9 @@ static void get_options(int argc, char **argv)
 			break;
 
 		case FEATURES_OPTION:
-			ret = parse_feature(optarg,
-					    &opts.set_feature,
-					    &opts.clear_feature);
+			ret = ocfs2_parse_feature(optarg,
+						  &opts.set_feature,
+						  &opts.clear_feature);
 			if (ret) {
 				com_err(opts.progname, ret,
 					"when parsing --fs-features string");
diff --git a/tunefs.ocfs2/tunefs.h b/tunefs.ocfs2/tunefs.h
index c7b4acf..d3c7d73 100644
--- a/tunefs.ocfs2/tunefs.h
+++ b/tunefs.ocfs2/tunefs.h
@@ -90,8 +90,8 @@ typedef struct _ocfs2_tune_opts {
 	int backup_super;
 	int update_cluster;
 	int list_sparse;
-	fs_options set_feature;
-	fs_options clear_feature;
+	ocfs2_fs_options set_feature;
+	ocfs2_fs_options clear_feature;
 	char *feature_string;
 	time_t tune_time;
 } ocfs2_tune_opts;
-- 
1.5.6.2

-- 

Life's Little Instruction Book #3

	"Watch a sunrise at least once a year."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list