diff options
author | Eric Van Hensbergen <ericvh@ericvh-desktop.(none)> | 2008-03-07 11:53:53 -0500 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@opteron.9grid.us> | 2008-05-14 20:23:26 -0400 |
commit | bb8ffdfc3e3b32ad9fcdb8da289088d3b22794e5 (patch) | |
tree | fbe3dc4e19b5ca63b0cb548476cbb02cbfc59ee9 /net | |
parent | ab31267dfeddf80b2e483f077c8b03905993722b (diff) |
9p: propagate parse_option changes to client and transports
Propagate changes that were made to the parse_options code to the
other parse options pieces present in the other modules. Looks like
the client parse options was probably corrupting the parse string
and causing problems for others.
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/9p/client.c | 30 | ||||
-rw-r--r-- | net/9p/trans_fd.c | 29 |
2 files changed, 45 insertions, 14 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index 84e087e24146..553c34e9f296 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -64,21 +64,30 @@ static match_table_t tokens = { | |||
64 | * @options: options string passed from mount | 64 | * @options: options string passed from mount |
65 | * @v9ses: existing v9fs session information | 65 | * @v9ses: existing v9fs session information |
66 | * | 66 | * |
67 | * Return 0 upon success, -ERRNO upon failure | ||
67 | */ | 68 | */ |
68 | 69 | ||
69 | static void parse_opts(char *options, struct p9_client *clnt) | 70 | static int parse_opts(char *opts, struct p9_client *clnt) |
70 | { | 71 | { |
72 | char *options; | ||
71 | char *p; | 73 | char *p; |
72 | substring_t args[MAX_OPT_ARGS]; | 74 | substring_t args[MAX_OPT_ARGS]; |
73 | int option; | 75 | int option; |
74 | int ret; | 76 | int ret = 0; |
75 | 77 | ||
76 | clnt->trans_mod = v9fs_default_trans(); | 78 | clnt->trans_mod = v9fs_default_trans(); |
77 | clnt->dotu = 1; | 79 | clnt->dotu = 1; |
78 | clnt->msize = 8192; | 80 | clnt->msize = 8192; |
79 | 81 | ||
80 | if (!options) | 82 | if (!opts) |
81 | return; | 83 | return 0; |
84 | |||
85 | options = kstrdup(opts, GFP_KERNEL); | ||
86 | if (!options) { | ||
87 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
88 | "failed to allocate copy of option string\n"); | ||
89 | return -ENOMEM; | ||
90 | } | ||
82 | 91 | ||
83 | while ((p = strsep(&options, ",")) != NULL) { | 92 | while ((p = strsep(&options, ",")) != NULL) { |
84 | int token; | 93 | int token; |
@@ -86,10 +95,11 @@ static void parse_opts(char *options, struct p9_client *clnt) | |||
86 | continue; | 95 | continue; |
87 | token = match_token(p, tokens, args); | 96 | token = match_token(p, tokens, args); |
88 | if (token < Opt_trans) { | 97 | if (token < Opt_trans) { |
89 | ret = match_int(&args[0], &option); | 98 | int r = match_int(&args[0], &option); |
90 | if (ret < 0) { | 99 | if (r < 0) { |
91 | P9_DPRINTK(P9_DEBUG_ERROR, | 100 | P9_DPRINTK(P9_DEBUG_ERROR, |
92 | "integer field, but no integer?\n"); | 101 | "integer field, but no integer?\n"); |
102 | ret = r; | ||
93 | continue; | 103 | continue; |
94 | } | 104 | } |
95 | } | 105 | } |
@@ -107,6 +117,8 @@ static void parse_opts(char *options, struct p9_client *clnt) | |||
107 | continue; | 117 | continue; |
108 | } | 118 | } |
109 | } | 119 | } |
120 | kfree(options); | ||
121 | return ret; | ||
110 | } | 122 | } |
111 | 123 | ||
112 | 124 | ||
@@ -138,6 +150,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
138 | if (!clnt) | 150 | if (!clnt) |
139 | return ERR_PTR(-ENOMEM); | 151 | return ERR_PTR(-ENOMEM); |
140 | 152 | ||
153 | clnt->trans = NULL; | ||
141 | spin_lock_init(&clnt->lock); | 154 | spin_lock_init(&clnt->lock); |
142 | INIT_LIST_HEAD(&clnt->fidlist); | 155 | INIT_LIST_HEAD(&clnt->fidlist); |
143 | clnt->fidpool = p9_idpool_create(); | 156 | clnt->fidpool = p9_idpool_create(); |
@@ -147,7 +160,10 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) | |||
147 | goto error; | 160 | goto error; |
148 | } | 161 | } |
149 | 162 | ||
150 | parse_opts(options, clnt); | 163 | err = parse_opts(options, clnt); |
164 | if (err < 0) | ||
165 | goto error; | ||
166 | |||
151 | if (clnt->trans_mod == NULL) { | 167 | if (clnt->trans_mod == NULL) { |
152 | err = -EPROTONOSUPPORT; | 168 | err = -EPROTONOSUPPORT; |
153 | P9_DPRINTK(P9_DEBUG_ERROR, | 169 | P9_DPRINTK(P9_DEBUG_ERROR, |
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index c6eda999fa7d..97b103b70499 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -1196,35 +1196,46 @@ void p9_conn_cancel(struct p9_conn *m, int err) | |||
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | /** | 1198 | /** |
1199 | * v9fs_parse_options - parse mount options into session structure | 1199 | * parse_options - parse mount options into session structure |
1200 | * @options: options string passed from mount | 1200 | * @options: options string passed from mount |
1201 | * @opts: transport-specific structure to parse options into | 1201 | * @opts: transport-specific structure to parse options into |
1202 | * | 1202 | * |
1203 | * Returns 0 upon success, -ERRNO upon failure | ||
1203 | */ | 1204 | */ |
1204 | 1205 | ||
1205 | static void parse_opts(char *options, struct p9_fd_opts *opts) | 1206 | static int parse_opts(char *params, struct p9_fd_opts *opts) |
1206 | { | 1207 | { |
1207 | char *p; | 1208 | char *p; |
1208 | substring_t args[MAX_OPT_ARGS]; | 1209 | substring_t args[MAX_OPT_ARGS]; |
1209 | int option; | 1210 | int option; |
1211 | char *options; | ||
1210 | int ret; | 1212 | int ret; |
1211 | 1213 | ||
1212 | opts->port = P9_PORT; | 1214 | opts->port = P9_PORT; |
1213 | opts->rfd = ~0; | 1215 | opts->rfd = ~0; |
1214 | opts->wfd = ~0; | 1216 | opts->wfd = ~0; |
1215 | 1217 | ||
1216 | if (!options) | 1218 | if (!params) |
1217 | return; | 1219 | return 0; |
1220 | |||
1221 | options = kstrdup(params, GFP_KERNEL); | ||
1222 | if (!options) { | ||
1223 | P9_DPRINTK(P9_DEBUG_ERROR, | ||
1224 | "failed to allocate copy of option string\n"); | ||
1225 | return -ENOMEM; | ||
1226 | } | ||
1218 | 1227 | ||
1219 | while ((p = strsep(&options, ",")) != NULL) { | 1228 | while ((p = strsep(&options, ",")) != NULL) { |
1220 | int token; | 1229 | int token; |
1230 | int r; | ||
1221 | if (!*p) | 1231 | if (!*p) |
1222 | continue; | 1232 | continue; |
1223 | token = match_token(p, tokens, args); | 1233 | token = match_token(p, tokens, args); |
1224 | ret = match_int(&args[0], &option); | 1234 | r = match_int(&args[0], &option); |
1225 | if (ret < 0) { | 1235 | if (r < 0) { |
1226 | P9_DPRINTK(P9_DEBUG_ERROR, | 1236 | P9_DPRINTK(P9_DEBUG_ERROR, |
1227 | "integer field, but no integer?\n"); | 1237 | "integer field, but no integer?\n"); |
1238 | ret = r; | ||
1228 | continue; | 1239 | continue; |
1229 | } | 1240 | } |
1230 | switch (token) { | 1241 | switch (token) { |
@@ -1241,6 +1252,8 @@ static void parse_opts(char *options, struct p9_fd_opts *opts) | |||
1241 | continue; | 1252 | continue; |
1242 | } | 1253 | } |
1243 | } | 1254 | } |
1255 | kfree(options); | ||
1256 | return 0; | ||
1244 | } | 1257 | } |
1245 | 1258 | ||
1246 | static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd) | 1259 | static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd) |
@@ -1430,7 +1443,9 @@ p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu) | |||
1430 | struct p9_fd_opts opts; | 1443 | struct p9_fd_opts opts; |
1431 | struct p9_trans_fd *p; | 1444 | struct p9_trans_fd *p; |
1432 | 1445 | ||
1433 | parse_opts(args, &opts); | 1446 | err = parse_opts(args, &opts); |
1447 | if (err < 0) | ||
1448 | return ERR_PTR(err); | ||
1434 | 1449 | ||
1435 | csocket = NULL; | 1450 | csocket = NULL; |
1436 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); | 1451 | trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); |