From: zab Date: Fri, 27 Feb 2004 21:32:23 +0000 (+0000) Subject: - update b_cray_portals_merge from head X-Git-Tag: v1_7_100~1^97~13 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=de27c17502e88a9acdcbcfc22e16df652548045f;p=fs%2Flustre-release.git - update b_cray_portals_merge from head (HEAD_CRAY_PORTALS_MERGE_UPDATE_CHILD_20040227_1243) in preparation for 2776 work (the bug where our future-forefathers sing and dance) --- diff --git a/lustre/smfs/options.c b/lustre/smfs/options.c index 0b5d76c..8ff445e 100644 --- a/lustre/smfs/options.c +++ b/lustre/smfs/options.c @@ -9,10 +9,8 @@ #include #include #include -#include -#include -#include #include +#include #include "smfs_internal.h" @@ -40,56 +38,60 @@ void cleanup_option(void) option = list_entry(option_list.next, struct option, list); list_del(&option->list); SM_FREE(option->opt, strlen(option->opt) + 1); - SM_FREE(option->value, strlen(option->value) + 1); + if (option->value) + SM_FREE(option->value, strlen(option->value) + 1); SM_FREE(option, sizeof(struct option)); } SM_FREE(options, strlen(options) + 1); } int get_opt(struct option **option, char **pos) { - char *name, *value, *left; + char *name, *value, *left, *tmp; struct option *tmp_opt; - int length; + int length = 0; *pos = opt_left; if (! *opt_left) return -ENODATA; - - left = strchr(opt_left, '='); - - if (left == opt_left || !left) + left = strchr(opt_left, ','); + if (left == opt_left) return -EINVAL; + if (!left){ + left = opt_left + strlen(opt_left); + } SM_ALLOC(tmp_opt, sizeof(struct option)); - - length = left - opt_left + 1; - SM_ALLOC(name, length); - tmp_opt->opt = name; - memset(name, 0, length); - while (opt_left != left) *name++ = *opt_left++; + tmp_opt->opt = NULL; + tmp_opt->value = NULL; - opt_left ++; /*after '='*/ + tmp = opt_left; + while(tmp != left && *tmp != '=') { + length++; + tmp++; + } + SM_ALLOC(name, length + 1); + tmp_opt->opt = name; + memset(name, 0, length + 1); + while (opt_left != tmp) *name++ = *opt_left++; - left = strchr(opt_left, ','); - if (left == opt_left) { - SM_FREE(tmp_opt->opt, length); - SM_FREE(tmp_opt, sizeof(struct option)); - opt_left = *pos; - return -EINVAL; + if (*tmp == '=') { + /*this option has value*/ + opt_left ++; /*after '='*/ + if (left == opt_left) { + SM_FREE(tmp_opt->opt, length); + SM_FREE(tmp_opt, sizeof(struct option)); + opt_left = *pos; + return -EINVAL; + } + length = left - opt_left + 1; + SM_ALLOC(value, length); + tmp_opt->value = value; + memset(value, 0, length); + while (opt_left != left) *value++ = *opt_left++; } - if (!left) - left = opt_left + strlen(opt_left); - length = left - opt_left + 1; - SM_ALLOC(value, length); - tmp_opt->value = value; - memset(value, 0, length); - while (opt_left != left) *value++ = *opt_left++; - list_add(&tmp_opt->list, &option_list); - if (*opt_left == ',') opt_left ++; /*after ','*/ - *option = tmp_opt; return 0; }