ChangeLog, e2p.h, feature.c:
feature.c (e2p_edit_feature), e2p.h: Add a new argument which allows
the calling application to limit what features the user is allowed to
set or clear using this function. Also add support for comma
separated lists.
diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog
index 0aa3db8..c136417 100644
--- a/lib/e2p/ChangeLog
+++ b/lib/e2p/ChangeLog
@@ -1,3 +1,10 @@
+1999-10-22 <tytso@valinux.com>
+
+ * feature.c (e2p_edit_feature), e2p.h: Add a new argument which
+ allows the calling application to limit what features the
+ user is allowed to set or clear using this function.
+ Also add support for comma separated lists.
+
1999-09-07 <tytso@valinux.com>
* Makefile.in, feature.c, e2p.h: New file which is used for
diff --git a/lib/e2p/e2p.h b/lib/e2p/e2p.h
index a56bcf2..2ccbecc 100644
--- a/lib/e2p/e2p.h
+++ b/lib/e2p/e2p.h
@@ -26,7 +26,7 @@
char *e2p_feature2string(int compat, unsigned int mask);
int e2p_string2feature(char *string, int *compat, unsigned int *mask);
-int e2p_edit_feature(char *str, __u32 *compat_array);
+int e2p_edit_feature(char *str, __u32 *compat_array, __u32 *ok_array);
int e2p_is_null_uuid(void *uu);
void e2p_uuid_to_str(void *uu, char *out);
diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c
index f25ee91..00b5336 100644
--- a/lib/e2p/feature.c
+++ b/lib/e2p/feature.c
@@ -167,22 +167,25 @@
char *skip_over_word(char *cp)
{
- while (*cp && !isspace(*cp))
+ while (*cp && !isspace(*cp) && *cp != ',')
cp++;
return cp;
}
-int e2p_edit_feature(char *str, __u32 *compat_array)
+/*
+ * 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.
+ */
+int e2p_edit_feature(char *str, __u32 *compat_array, __u32 *ok_array)
{
char *cp, *buf, *next;
int neg;
unsigned int compat, mask;
buf = malloc(strlen(str)+1);
- if (!buf) {
- errno = ENOMEM;
+ if (!buf)
return 1;
- }
strcpy(buf, str);
cp = buf;
while (cp && *cp) {
@@ -203,6 +206,8 @@
}
if (e2p_string2feature(cp, &compat, &mask))
return 1;
+ if (ok_array && !(ok_array[compat] & mask))
+ return 1;
if (neg)
compat_array[compat] &= ~mask;
else