diff options
| author | Eric Van Hensbergen <ericvh@opteron.homeip.net> | 2008-02-06 20:25:03 -0500 |
|---|---|---|
| committer | Eric Van Hensbergen <ericvh@opteron.homeip.net> | 2008-02-06 20:25:03 -0500 |
| commit | 8a0dc95fd976a052e5e799ef33e6c8e3141b5dff (patch) | |
| tree | 3275903539244acd76c716662c324833aa419377 /fs/9p | |
| parent | f39335453fe79f4e12e263e7c6387dc9fb86bfff (diff) | |
9p: transport API reorganization
This merges the mux.c (including the connection interface) with trans_fd
in preparation for transport API changes. Ultimately, trans_fd will need
to be rewritten to clean it up and simplify the implementation, but this
reorganization is viewed as the first step.
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p')
| -rw-r--r-- | fs/9p/v9fs.c | 51 | ||||
| -rw-r--r-- | fs/9p/v9fs.h | 5 |
2 files changed, 13 insertions, 43 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 | ||
| 44 | enum { | 43 | enum { |
| 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 | ||
| 59 | static match_table_t tokens = { | 58 | static 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)) { |
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index db4b4193f2e2..7d3a1018db52 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * V9FS definitions. | 2 | * V9FS definitions. |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> | 4 | * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com> |
| 5 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> | 5 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
| @@ -28,7 +28,6 @@ | |||
| 28 | 28 | ||
| 29 | struct v9fs_session_info { | 29 | struct v9fs_session_info { |
| 30 | /* options */ | 30 | /* options */ |
| 31 | unsigned int maxdata; | ||
| 32 | unsigned char flags; /* session flags */ | 31 | unsigned char flags; /* session flags */ |
| 33 | unsigned char nodev; /* set to 1 if no disable device mapping */ | 32 | unsigned char nodev; /* set to 1 if no disable device mapping */ |
| 34 | unsigned short debug; /* debug level */ | 33 | unsigned short debug; /* debug level */ |
| @@ -38,10 +37,10 @@ struct v9fs_session_info { | |||
| 38 | char *options; /* copy of mount options */ | 37 | char *options; /* copy of mount options */ |
| 39 | char *uname; /* user name to mount as */ | 38 | char *uname; /* user name to mount as */ |
| 40 | char *aname; /* name of remote hierarchy being mounted */ | 39 | char *aname; /* name of remote hierarchy being mounted */ |
| 40 | unsigned int maxdata; /* max data for client interface */ | ||
| 41 | unsigned int dfltuid; /* default uid/muid for legacy support */ | 41 | unsigned int dfltuid; /* default uid/muid for legacy support */ |
| 42 | unsigned int dfltgid; /* default gid for legacy support */ | 42 | unsigned int dfltgid; /* default gid for legacy support */ |
| 43 | u32 uid; /* if ACCESS_SINGLE, the uid that has access */ | 43 | u32 uid; /* if ACCESS_SINGLE, the uid that has access */ |
| 44 | struct p9_trans_module *trans; /* 9p transport */ | ||
| 45 | struct p9_client *clnt; /* 9p client */ | 44 | struct p9_client *clnt; /* 9p client */ |
| 46 | struct dentry *debugfs_dir; | 45 | struct dentry *debugfs_dir; |
| 47 | }; | 46 | }; |
