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

Joel Becker joel.becker at oracle.com
Fri Jul 25 19:07:42 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>
---
 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 5240b95..db095cf 100644
--- a/libocfs2/feature_string.c
+++ b/libocfs2/feature_string.c
@@ -355,10 +355,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;
@@ -367,13 +376,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;
@@ -438,6 +440,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