aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/v9fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/9p/v9fs.c')
-rw-r--r--fs/9p/v9fs.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index fbb12dadba83..9b0f0222e8bb 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * This file contains functions assisting in mapping VFS to 9P2000 4 * This file contains functions assisting in mapping VFS to 9P2000
5 * 5 *
6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 6 * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,6 @@
31#include <linux/idr.h> 31#include <linux/idr.h>
32#include <net/9p/9p.h> 32#include <net/9p/9p.h>
33#include <net/9p/transport.h> 33#include <net/9p/transport.h>
34#include <net/9p/conn.h>
35#include <net/9p/client.h> 34#include <net/9p/client.h>
36#include "v9fs.h" 35#include "v9fs.h"
37#include "v9fs_vfs.h" 36#include "v9fs_vfs.h"
@@ -43,11 +42,11 @@
43 42
44enum { 43enum {
45 /* Options that take integer arguments */ 44 /* Options that take integer arguments */
46 Opt_debug, Opt_msize, Opt_dfltuid, Opt_dfltgid, Opt_afid, 45 Opt_debug, Opt_dfltuid, Opt_dfltgid, Opt_afid,
47 /* String options */ 46 /* String options */
48 Opt_uname, Opt_remotename, Opt_trans, 47 Opt_uname, Opt_remotename, Opt_trans,
49 /* Options that take no arguments */ 48 /* Options that take no arguments */
50 Opt_legacy, Opt_nodevmap, 49 Opt_nodevmap,
51 /* Cache options */ 50 /* Cache options */
52 Opt_cache_loose, 51 Opt_cache_loose,
53 /* Access options */ 52 /* Access options */
@@ -58,14 +57,11 @@ enum {
58 57
59static match_table_t tokens = { 58static match_table_t tokens = {
60 {Opt_debug, "debug=%x"}, 59 {Opt_debug, "debug=%x"},
61 {Opt_msize, "msize=%u"},
62 {Opt_dfltuid, "dfltuid=%u"}, 60 {Opt_dfltuid, "dfltuid=%u"},
63 {Opt_dfltgid, "dfltgid=%u"}, 61 {Opt_dfltgid, "dfltgid=%u"},
64 {Opt_afid, "afid=%u"}, 62 {Opt_afid, "afid=%u"},
65 {Opt_uname, "uname=%s"}, 63 {Opt_uname, "uname=%s"},
66 {Opt_remotename, "aname=%s"}, 64 {Opt_remotename, "aname=%s"},
67 {Opt_trans, "trans=%s"},
68 {Opt_legacy, "noextend"},
69 {Opt_nodevmap, "nodevmap"}, 65 {Opt_nodevmap, "nodevmap"},
70 {Opt_cache_loose, "cache=loose"}, 66 {Opt_cache_loose, "cache=loose"},
71 {Opt_cache_loose, "loose"}, 67 {Opt_cache_loose, "loose"},
@@ -85,16 +81,14 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
85 char *options; 81 char *options;
86 substring_t args[MAX_OPT_ARGS]; 82 substring_t args[MAX_OPT_ARGS];
87 char *p; 83 char *p;
88 int option; 84 int option = 0;
89 int ret;
90 char *s, *e; 85 char *s, *e;
86 int ret;
91 87
92 /* setup defaults */ 88 /* setup defaults */
93 v9ses->maxdata = 8192;
94 v9ses->afid = ~0; 89 v9ses->afid = ~0;
95 v9ses->debug = 0; 90 v9ses->debug = 0;
96 v9ses->cache = 0; 91 v9ses->cache = 0;
97 v9ses->trans = v9fs_default_trans();
98 92
99 if (!v9ses->options) 93 if (!v9ses->options)
100 return; 94 return;
@@ -106,7 +100,8 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
106 continue; 100 continue;
107 token = match_token(p, tokens, args); 101 token = match_token(p, tokens, args);
108 if (token < Opt_uname) { 102 if (token < Opt_uname) {
109 if ((ret = match_int(&args[0], &option)) < 0) { 103 ret = match_int(&args[0], &option);
104 if (ret < 0) {
110 P9_DPRINTK(P9_DEBUG_ERROR, 105 P9_DPRINTK(P9_DEBUG_ERROR,
111 "integer field, but no integer?\n"); 106 "integer field, but no integer?\n");
112 continue; 107 continue;
@@ -119,9 +114,7 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
119 p9_debug_level = option; 114 p9_debug_level = option;
120#endif 115#endif
121 break; 116 break;
122 case Opt_msize: 117
123 v9ses->maxdata = option;
124 break;
125 case Opt_dfltuid: 118 case Opt_dfltuid:
126 v9ses->dfltuid = option; 119 v9ses->dfltuid = option;
127 break; 120 break;
@@ -131,18 +124,12 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
131 case Opt_afid: 124 case Opt_afid:
132 v9ses->afid = option; 125 v9ses->afid = option;
133 break; 126 break;
134 case Opt_trans:
135 v9ses->trans = v9fs_match_trans(&args[0]);
136 break;
137 case Opt_uname: 127 case Opt_uname:
138 match_strcpy(v9ses->uname, &args[0]); 128 match_strcpy(v9ses->uname, &args[0]);
139 break; 129 break;
140 case Opt_remotename: 130 case Opt_remotename:
141 match_strcpy(v9ses->aname, &args[0]); 131 match_strcpy(v9ses->aname, &args[0]);
142 break; 132 break;
143 case Opt_legacy:
144 v9ses->flags &= ~V9FS_EXTENDED;
145 break;
146 case Opt_nodevmap: 133 case Opt_nodevmap:
147 v9ses->nodev = 1; 134 v9ses->nodev = 1;
148 break; 135 break;
@@ -185,7 +172,6 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
185 const char *dev_name, char *data) 172 const char *dev_name, char *data)
186{ 173{
187 int retval = -EINVAL; 174 int retval = -EINVAL;
188 struct p9_trans *trans = NULL;
189 struct p9_fid *fid; 175 struct p9_fid *fid;
190 176
191 v9ses->uname = __getname(); 177 v9ses->uname = __getname();
@@ -207,24 +193,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
207 v9ses->options = kstrdup(data, GFP_KERNEL); 193 v9ses->options = kstrdup(data, GFP_KERNEL);
208 v9fs_parse_options(v9ses); 194 v9fs_parse_options(v9ses);
209 195
210 if (v9ses->trans == NULL) { 196 v9ses->clnt = p9_client_create(dev_name, v9ses->options);
211 retval = -EPROTONOSUPPORT;
212 P9_DPRINTK(P9_DEBUG_ERROR,
213 "No transport defined or default transport\n");
214 goto error;
215 }
216
217 trans = v9ses->trans->create(dev_name, v9ses->options);
218 if (IS_ERR(trans)) {
219 retval = PTR_ERR(trans);
220 trans = NULL;
221 goto error;
222 }
223 if ((v9ses->maxdata+P9_IOHDRSZ) > v9ses->trans->maxsize)
224 v9ses->maxdata = v9ses->trans->maxsize-P9_IOHDRSZ;
225
226 v9ses->clnt = p9_client_create(trans, v9ses->maxdata+P9_IOHDRSZ,
227 v9fs_extended(v9ses));
228 197
229 if (IS_ERR(v9ses->clnt)) { 198 if (IS_ERR(v9ses->clnt)) {
230 retval = PTR_ERR(v9ses->clnt); 199 retval = PTR_ERR(v9ses->clnt);
@@ -236,6 +205,8 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
236 if (!v9ses->clnt->dotu) 205 if (!v9ses->clnt->dotu)
237 v9ses->flags &= ~V9FS_EXTENDED; 206 v9ses->flags &= ~V9FS_EXTENDED;
238 207
208 v9ses->maxdata = v9ses->clnt->msize;
209
239 /* for legacy mode, fall back to V9FS_ACCESS_ANY */ 210 /* for legacy mode, fall back to V9FS_ACCESS_ANY */
240 if (!v9fs_extended(v9ses) && 211 if (!v9fs_extended(v9ses) &&
241 ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) { 212 ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) {