Whamcloud - gitweb
- update b_cray_portals_merge from head
authorzab <zab>
Fri, 27 Feb 2004 21:32:23 +0000 (21:32 +0000)
committerzab <zab>
Fri, 27 Feb 2004 21:32:23 +0000 (21:32 +0000)
  (HEAD_CRAY_PORTALS_MERGE_UPDATE_CHILD_20040227_1243)
  in preparation for 2776 work
  (the bug where our future-forefathers sing and dance)

lustre/smfs/options.c

index 0b5d76c..8ff445e 100644 (file)
@@ -9,10 +9,8 @@
 #include <linux/fs.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/jbd.h>
-#include <linux/ext3_fs.h>
-#include <linux/snap.h>
 #include <linux/errno.h>
+#include <linux/lustre_idl.h>
 #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;
 }