diff options
author | Prem Karat <prem.karat@linux.vnet.ibm.com> | 2011-05-06 09:05:32 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2011-07-23 10:32:49 -0400 |
commit | 4d63055fa9657aa402da25575045c23f37c3da05 (patch) | |
tree | 6d85570570026eed3cbb50a1ab835bbe686e326b /net/9p | |
parent | a2dd43bb0d7b9ce28f8a39254c25840c0730498e (diff) |
fs/9p: Clean-up get_protocol_version() to use strcmp
Signed-off-by: Prem Karat <prem.karat@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p')
-rw-r--r-- | net/9p/client.c | 47 | ||||
-rw-r--r-- | net/9p/mod.c | 4 |
2 files changed, 35 insertions, 16 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index 7dd4e78878d6..431eaef697c7 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -72,23 +72,22 @@ inline int p9_is_proto_dotu(struct p9_client *clnt) | |||
72 | EXPORT_SYMBOL(p9_is_proto_dotu); | 72 | EXPORT_SYMBOL(p9_is_proto_dotu); |
73 | 73 | ||
74 | /* Interpret mount option for protocol version */ | 74 | /* Interpret mount option for protocol version */ |
75 | static int get_protocol_version(const substring_t *name) | 75 | static int get_protocol_version(char *s) |
76 | { | 76 | { |
77 | int version = -EINVAL; | 77 | int version = -EINVAL; |
78 | 78 | ||
79 | if (!strncmp("9p2000", name->from, name->to-name->from)) { | 79 | if (!strcmp(s, "9p2000")) { |
80 | version = p9_proto_legacy; | 80 | version = p9_proto_legacy; |
81 | P9_DPRINTK(P9_DEBUG_9P, "Protocol version: Legacy\n"); | 81 | P9_DPRINTK(P9_DEBUG_9P, "Protocol version: Legacy\n"); |
82 | } else if (!strncmp("9p2000.u", name->from, name->to-name->from)) { | 82 | } else if (!strcmp(s, "9p2000.u")) { |
83 | version = p9_proto_2000u; | 83 | version = p9_proto_2000u; |
84 | P9_DPRINTK(P9_DEBUG_9P, "Protocol version: 9P2000.u\n"); | 84 | P9_DPRINTK(P9_DEBUG_9P, "Protocol version: 9P2000.u\n"); |
85 | } else if (!strncmp("9p2000.L", name->from, name->to-name->from)) { | 85 | } else if (!strcmp(s, "9p2000.L")) { |
86 | version = p9_proto_2000L; | 86 | version = p9_proto_2000L; |
87 | P9_DPRINTK(P9_DEBUG_9P, "Protocol version: 9P2000.L\n"); | 87 | P9_DPRINTK(P9_DEBUG_9P, "Protocol version: 9P2000.L\n"); |
88 | } else { | 88 | } else |
89 | P9_DPRINTK(P9_DEBUG_ERROR, "Unknown protocol version %s. ", | 89 | printk(KERN_INFO "9p: Unknown protocol version %s.\n", s); |
90 | name->from); | 90 | |
91 | } | ||
92 | return version; | 91 | return version; |
93 | } | 92 | } |
94 | 93 | ||
@@ -106,6 +105,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
106 | char *p; | 105 | char *p; |
107 | substring_t args[MAX_OPT_ARGS]; | 106 | substring_t args[MAX_OPT_ARGS]; |
108 | int option; | 107 | int option; |
108 | char *s; | ||
109 | int ret = 0; | 109 | int ret = 0; |
110 | 110 | ||
111 | clnt->proto_version = p9_proto_2000u; | 111 | clnt->proto_version = p9_proto_2000u; |
@@ -141,22 +141,41 @@ static int parse_opts(char *opts, struct p9_client *clnt) | |||
141 | clnt->msize = option; | 141 | clnt->msize = option; |
142 | break; | 142 | break; |
143 | case Opt_trans: | 143 | case Opt_trans: |
144 | clnt->trans_mod = v9fs_get_trans_by_name(&args[0]); | 144 | s = match_strdup(&args[0]); |
145 | if(clnt->trans_mod == NULL) { | 145 | if (!s) { |
146 | ret = -ENOMEM; | ||
146 | P9_DPRINTK(P9_DEBUG_ERROR, | 147 | P9_DPRINTK(P9_DEBUG_ERROR, |
147 | "Could not find request transport: %s\n", | 148 | "problem allocating copy of trans arg\n"); |
148 | (char *) &args[0]); | 149 | goto free_and_return; |
150 | } | ||
151 | clnt->trans_mod = v9fs_get_trans_by_name(s); | ||
152 | if (clnt->trans_mod == NULL) { | ||
153 | printk(KERN_INFO | ||
154 | "9p: Could not find " | ||
155 | "request transport: %s\n", s); | ||
149 | ret = -EINVAL; | 156 | ret = -EINVAL; |
157 | kfree(s); | ||
150 | goto free_and_return; | 158 | goto free_and_return; |
151 | } | 159 | } |
160 | kfree(s); | ||
152 | break; | 161 | break; |
153 | case Opt_legacy: | 162 | case Opt_legacy: |
154 | clnt->proto_version = p9_proto_legacy; | 163 | clnt->proto_version = p9_proto_legacy; |
155 | break; | 164 | break; |
156 | case Opt_version: | 165 | case Opt_version: |
157 | ret = get_protocol_version(&args[0]); | 166 | s = match_strdup(&args[0]); |
158 | if (ret == -EINVAL) | 167 | if (!s) { |
168 | ret = -ENOMEM; | ||
169 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
170 | "problem allocating copy of version arg\n"); | ||
171 | goto free_and_return; | ||
172 | } | ||
173 | ret = get_protocol_version(s); | ||
174 | if (ret == -EINVAL) { | ||
175 | kfree(s); | ||
159 | goto free_and_return; | 176 | goto free_and_return; |
177 | } | ||
178 | kfree(s); | ||
160 | clnt->proto_version = ret; | 179 | clnt->proto_version = ret; |
161 | break; | 180 | break; |
162 | default: | 181 | default: |
diff --git a/net/9p/mod.c b/net/9p/mod.c index 72c398275051..2664d1292291 100644 --- a/net/9p/mod.c +++ b/net/9p/mod.c | |||
@@ -80,14 +80,14 @@ EXPORT_SYMBOL(v9fs_unregister_trans); | |||
80 | * @name: string identifying transport | 80 | * @name: string identifying transport |
81 | * | 81 | * |
82 | */ | 82 | */ |
83 | struct p9_trans_module *v9fs_get_trans_by_name(const substring_t *name) | 83 | struct p9_trans_module *v9fs_get_trans_by_name(char *s) |
84 | { | 84 | { |
85 | struct p9_trans_module *t, *found = NULL; | 85 | struct p9_trans_module *t, *found = NULL; |
86 | 86 | ||
87 | spin_lock(&v9fs_trans_lock); | 87 | spin_lock(&v9fs_trans_lock); |
88 | 88 | ||
89 | list_for_each_entry(t, &v9fs_trans_list, list) | 89 | list_for_each_entry(t, &v9fs_trans_list, list) |
90 | if (strncmp(t->name, name->from, name->to-name->from) == 0 && | 90 | if (strcmp(t->name, s) == 0 && |
91 | try_module_get(t->owner)) { | 91 | try_module_get(t->owner)) { |
92 | found = t; | 92 | found = t; |
93 | break; | 93 | break; |