Whamcloud - gitweb
ChangeLog, e2p.h, feature.c:
authorTheodore Ts'o <tytso@mit.edu>
Sat, 23 Oct 1999 01:01:09 +0000 (01:01 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 23 Oct 1999 01:01:09 +0000 (01:01 +0000)
  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.

lib/e2p/ChangeLog
lib/e2p/e2p.h
lib/e2p/feature.c

index 0aa3db8..c136417 100644 (file)
@@ -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
index a56bcf2..2ccbecc 100644 (file)
@@ -26,7 +26,7 @@ int setversion (int fd, unsigned long version);
 
 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);
index f25ee91..00b5336 100644 (file)
@@ -167,22 +167,25 @@ static char *skip_over_blanks(char *cp)
 
 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 @@ int e2p_edit_feature(char *str, __u32 *compat_array)
                }
                if (e2p_string2feature(cp, &compat, &mask))
                        return 1;
+               if (ok_array && !(ok_array[compat] & mask))
+                       return 1;
                if (neg)
                        compat_array[compat] &= ~mask;
                else