aboutsummaryrefslogtreecommitdiffstats
path: root/lib/e2p/feature.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-02-27 18:53:34 -0500
committerTheodore Ts'o <tytso@mit.edu>2008-02-27 18:53:34 -0500
commita49670e64e28ac3b15e36cb6bd0a8135d3ecdbbb (patch)
tree30f0ecd00942e15e097ca2c253131f4d3abce3a9 /lib/e2p/feature.c
parente6bbc002c5a3d30df156d4f23bc93a7f2dbde3a1 (diff)
parent4f9abdcb306ff515a8009a1e0fd35041688133c9 (diff)
downloadandroid_external_e2fsprogs-a49670e64e28ac3b15e36cb6bd0a8135d3ecdbbb.tar.gz
android_external_e2fsprogs-a49670e64e28ac3b15e36cb6bd0a8135d3ecdbbb.tar.bz2
android_external_e2fsprogs-a49670e64e28ac3b15e36cb6bd0a8135d3ecdbbb.zip
Merge branch 'maint'
Conflicts: lib/blkid/devname.c lib/blkid/probe.c misc/mke2fs.c misc/tune2fs.c
Diffstat (limited to 'lib/e2p/feature.c')
-rw-r--r--lib/e2p/feature.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c
index 4bf56301..fc6052c1 100644
--- a/lib/e2p/feature.c
+++ b/lib/e2p/feature.c
@@ -163,9 +163,12 @@ static char *skip_over_word(char *cp)
/*
* Edit a feature set array as requested by the user. The ok_array,
* if set, allows the application to limit what features the user is
- * allowed to set or clear using this function.
+ * allowed to set or clear using this function. If clear_ok_array is set,
+ * then use it tell whether or not it is OK to clear a filesystem feature.
*/
-int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
+int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
+ __u32 *clear_ok_array, int *type_err,
+ unsigned int *mask_err)
{
char *cp, *buf, *next;
int neg;
@@ -173,6 +176,14 @@ int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
int compat_type;
int rc = 0;
+ if (!clear_ok_array)
+ clear_ok_array = ok_array;
+
+ if (type_err)
+ *type_err = 0;
+ if (mask_err)
+ *mask_err = 0;
+
buf = malloc(strlen(str)+1);
if (!buf)
return 1;
@@ -207,15 +218,35 @@ int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
rc = 1;
break;
}
- if (ok_array && !(ok_array[compat_type] & mask)) {
- rc = 1;
- break;
- }
- if (neg)
+ if (neg) {
+ if (clear_ok_array &&
+ !(clear_ok_array[compat_type] & mask)) {
+ rc = 1;
+ if (type_err)
+ *type_err = (compat_type |
+ E2P_FEATURE_NEGATE_FLAG);
+ if (mask_err)
+ *mask_err = mask;
+ break;
+ }
compat_array[compat_type] &= ~mask;
- else
+ } else {
+ if (ok_array && !(ok_array[compat_type] & mask)) {
+ rc = 1;
+ if (type_err)
+ *type_err = compat_type;
+ if (mask_err)
+ *mask_err = mask;
+ break;
+ }
compat_array[compat_type] |= mask;
+ }
}
free(buf);
return rc;
}
+
+int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
+{
+ return e2p_edit_feature2(str, compat_array, ok_array, 0, 0, 0);
+}