From 944ab7139ab534cb0d4e9a2dda1cc1216ae53153 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 23 Oct 1999 01:01:09 +0000 Subject: [PATCH] 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. --- lib/e2p/ChangeLog | 7 +++++++ lib/e2p/e2p.h | 2 +- lib/e2p/feature.c | 15 ++++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) 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 + + * 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 * 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 @@ 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); 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 @@ 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 -- 1.8.3.1