+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
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);
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) {
}
if (e2p_string2feature(cp, &compat, &mask))
return 1;
+ if (ok_array && !(ok_array[compat] & mask))
+ return 1;
if (neg)
compat_array[compat] &= ~mask;
else