Commit bb8ffdfc authored by Eric Van Hensbergen's avatar Eric Van Hensbergen Committed by Eric Van Hensbergen

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: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent ab31267d
...@@ -64,21 +64,30 @@ static match_table_t tokens = { ...@@ -64,21 +64,30 @@ static match_table_t tokens = {
* @options: options string passed from mount * @options: options string passed from mount
* @v9ses: existing v9fs session information * @v9ses: existing v9fs session information
* *
* Return 0 upon success, -ERRNO upon failure
*/ */
static void parse_opts(char *options, struct p9_client *clnt) static int parse_opts(char *opts, struct p9_client *clnt)
{ {
char *options;
char *p; char *p;
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
int option; int option;
int ret; int ret = 0;
clnt->trans_mod = v9fs_default_trans(); clnt->trans_mod = v9fs_default_trans();
clnt->dotu = 1; clnt->dotu = 1;
clnt->msize = 8192; clnt->msize = 8192;
if (!options) if (!opts)
return; return 0;
options = kstrdup(opts, GFP_KERNEL);
if (!options) {
P9_DPRINTK(P9_DEBUG_ERROR,
"failed to allocate copy of option string\n");
return -ENOMEM;
}
while ((p = strsep(&options, ",")) != NULL) { while ((p = strsep(&options, ",")) != NULL) {
int token; int token;
...@@ -86,10 +95,11 @@ static void parse_opts(char *options, struct p9_client *clnt) ...@@ -86,10 +95,11 @@ static void parse_opts(char *options, struct p9_client *clnt)
continue; continue;
token = match_token(p, tokens, args); token = match_token(p, tokens, args);
if (token < Opt_trans) { if (token < Opt_trans) {
ret = match_int(&args[0], &option); int r = match_int(&args[0], &option);
if (ret < 0) { if (r < 0) {
P9_DPRINTK(P9_DEBUG_ERROR, P9_DPRINTK(P9_DEBUG_ERROR,
"integer field, but no integer?\n"); "integer field, but no integer?\n");
ret = r;
continue; continue;
} }
} }
...@@ -107,6 +117,8 @@ static void parse_opts(char *options, struct p9_client *clnt) ...@@ -107,6 +117,8 @@ static void parse_opts(char *options, struct p9_client *clnt)
continue; continue;
} }
} }
kfree(options);
return ret;
} }
...@@ -138,6 +150,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) ...@@ -138,6 +150,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
if (!clnt) if (!clnt)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
clnt->trans = NULL;
spin_lock_init(&clnt->lock); spin_lock_init(&clnt->lock);
INIT_LIST_HEAD(&clnt->fidlist); INIT_LIST_HEAD(&clnt->fidlist);
clnt->fidpool = p9_idpool_create(); clnt->fidpool = p9_idpool_create();
...@@ -147,7 +160,10 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) ...@@ -147,7 +160,10 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
goto error; goto error;
} }
parse_opts(options, clnt); err = parse_opts(options, clnt);
if (err < 0)
goto error;
if (clnt->trans_mod == NULL) { if (clnt->trans_mod == NULL) {
err = -EPROTONOSUPPORT; err = -EPROTONOSUPPORT;
P9_DPRINTK(P9_DEBUG_ERROR, P9_DPRINTK(P9_DEBUG_ERROR,
......
...@@ -1196,35 +1196,46 @@ void p9_conn_cancel(struct p9_conn *m, int err) ...@@ -1196,35 +1196,46 @@ void p9_conn_cancel(struct p9_conn *m, int err)
} }
/** /**
* v9fs_parse_options - parse mount options into session structure * parse_options - parse mount options into session structure
* @options: options string passed from mount * @options: options string passed from mount
* @opts: transport-specific structure to parse options into * @opts: transport-specific structure to parse options into
* *
* Returns 0 upon success, -ERRNO upon failure
*/ */
static void parse_opts(char *options, struct p9_fd_opts *opts) static int parse_opts(char *params, struct p9_fd_opts *opts)
{ {
char *p; char *p;
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
int option; int option;
char *options;
int ret; int ret;
opts->port = P9_PORT; opts->port = P9_PORT;
opts->rfd = ~0; opts->rfd = ~0;
opts->wfd = ~0; opts->wfd = ~0;
if (!options) if (!params)
return; return 0;
options = kstrdup(params, GFP_KERNEL);
if (!options) {
P9_DPRINTK(P9_DEBUG_ERROR,
"failed to allocate copy of option string\n");
return -ENOMEM;
}
while ((p = strsep(&options, ",")) != NULL) { while ((p = strsep(&options, ",")) != NULL) {
int token; int token;
int r;
if (!*p) if (!*p)
continue; continue;
token = match_token(p, tokens, args); token = match_token(p, tokens, args);
ret = match_int(&args[0], &option); r = match_int(&args[0], &option);
if (ret < 0) { if (r < 0) {
P9_DPRINTK(P9_DEBUG_ERROR, P9_DPRINTK(P9_DEBUG_ERROR,
"integer field, but no integer?\n"); "integer field, but no integer?\n");
ret = r;
continue; continue;
} }
switch (token) { switch (token) {
...@@ -1241,6 +1252,8 @@ static void parse_opts(char *options, struct p9_fd_opts *opts) ...@@ -1241,6 +1252,8 @@ static void parse_opts(char *options, struct p9_fd_opts *opts)
continue; continue;
} }
} }
kfree(options);
return 0;
} }
static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd) 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,7 +1443,9 @@ p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu)
struct p9_fd_opts opts; struct p9_fd_opts opts;
struct p9_trans_fd *p; struct p9_trans_fd *p;
parse_opts(args, &opts); err = parse_opts(args, &opts);
if (err < 0)
return ERR_PTR(err);
csocket = NULL; csocket = NULL;
trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment