[Ocfs2-tools-devel] [PATCH 04/23] libocfs2: ocfs2_parse_feature() checks for conflicts too.

Joel Becker joel.becker at oracle.com
Mon Aug 11 17:31:56 PDT 2008


We don't allow --fs-features options to conflict.  That is,
"sparse,nosparse" is illegal, whether explicit or from a dependency.
Rather than have subprograms check this themselves, do it in
feature_string.c

Signed-off-by: Joel Becker <joel.becker at oracle.com>
Signed-off-by: Mark Fasheh <mfasheh at suse.com>
---
 libocfs2/feature_string.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/libocfs2/feature_string.c b/libocfs2/feature_string.c
index 0765f29..5f1b566 100644
--- a/libocfs2/feature_string.c
+++ b/libocfs2/feature_string.c
@@ -361,10 +361,19 @@ errcode_t ocfs2_merge_feature_flags_with_level(ocfs2_fs_options *dest,
 					       ocfs2_fs_options *reverse_set)
 {
 	ocfs2_fs_options level_set = feature_level_defaults[level];
+
 	/*
-	 * "Check whether the user asked for a flag to be set and cleared,
+	 * Ensure that all dependancies are correct in the reverse set.
+	 * A reverse set from ocfs2_parse_feature() will be correct, but
+	 * a hand-built one might not be.
+	 */
+	ocfs2_feature_clear_deps(reverse_set);
+
+	/*
+	 * 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.
+	 * by "--fs-features", so they shouldn't collide with each other,
+	 * but a hand-built one might have problems.
 	 */
 	if (!check_feature_flags(feature_set, reverse_set))
 		return OCFS2_ET_CONFLICTING_FEATURES;
@@ -373,13 +382,6 @@ errcode_t ocfs2_merge_feature_flags_with_level(ocfs2_fs_options *dest,
 	*dest = level_set;
 	merge_features(dest, *feature_set);
 
-	/*
-	 * Ensure that all dependancies are correct in the reverse set.
-	 * A reverse set from ocfs2_parse_feature() will be correct, but
-	 * a hand-built one might not be.
-	 */
-	ocfs2_feature_clear_deps(reverse_set);
-
 	/* Now clear the reverse set from our destination */
 	dest->opt_compat &= ~reverse_set->opt_compat;
 	dest->opt_ro_compat &= ~reverse_set->opt_ro_compat;
@@ -444,6 +446,14 @@ errcode_t ocfs2_parse_feature(const char *opts,
 	free(options);
 	ocfs2_feature_clear_deps(reverse_flags);
 
+	/*
+	 * 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_flags, reverse_flags))
+		return OCFS2_ET_CONFLICTING_FEATURES;
+
 	return 0;
 }
 
-- 
1.5.6.3




More information about the Ocfs2-tools-devel mailing list