Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/9p/v9fs.c |
| 3 | * |
| 4 | * This file contains functions assisting in mapping VFS to 9P2000 |
| 5 | * |
| 6 | * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> |
| 7 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
Eric Van Hensbergen | 42e8c50 | 2006-03-25 03:07:28 -0800 | [diff] [blame] | 10 | * it under the terms of the GNU General Public License version 2 |
| 11 | * as published by the Free Software Foundation. |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to: |
| 20 | * Free Software Foundation |
| 21 | * 51 Franklin Street, Fifth Floor |
| 22 | * Boston, MA 02111-1301 USA |
| 23 | * |
| 24 | */ |
| 25 | |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 26 | #include <linux/module.h> |
| 27 | #include <linux/errno.h> |
| 28 | #include <linux/fs.h> |
Al Viro | 914e263 | 2006-10-18 13:55:46 -0400 | [diff] [blame] | 29 | #include <linux/sched.h> |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 30 | #include <linux/parser.h> |
| 31 | #include <linux/idr.h> |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 32 | #include <net/9p/9p.h> |
| 33 | #include <net/9p/transport.h> |
| 34 | #include <net/9p/conn.h> |
| 35 | #include <net/9p/client.h> |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 36 | #include "v9fs.h" |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 37 | #include "v9fs_vfs.h" |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 38 | |
| 39 | /* |
| 40 | * Option Parsing (code inspired by NFS code) |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 41 | * NOTE: each transport will parse its own options |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 42 | */ |
| 43 | |
| 44 | enum { |
| 45 | /* Options that take integer arguments */ |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 46 | Opt_debug, Opt_msize, Opt_dfltuid, Opt_dfltgid, Opt_afid, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 47 | /* String options */ |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 48 | Opt_uname, Opt_remotename, Opt_trans, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 49 | /* Options that take no arguments */ |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 50 | Opt_legacy, Opt_nodevmap, |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 51 | /* Cache options */ |
| 52 | Opt_cache_loose, |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 53 | /* Access options */ |
| 54 | Opt_access, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 55 | /* Error token */ |
| 56 | Opt_err |
| 57 | }; |
| 58 | |
| 59 | static match_table_t tokens = { |
Eric Van Hensbergen | 9e2f668 | 2007-07-13 13:05:21 -0500 | [diff] [blame] | 60 | {Opt_debug, "debug=%x"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 61 | {Opt_msize, "msize=%u"}, |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 62 | {Opt_dfltuid, "dfltuid=%u"}, |
| 63 | {Opt_dfltgid, "dfltgid=%u"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 64 | {Opt_afid, "afid=%u"}, |
Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 65 | {Opt_uname, "uname=%s"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 66 | {Opt_remotename, "aname=%s"}, |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 67 | {Opt_trans, "trans=%s"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 68 | {Opt_legacy, "noextend"}, |
| 69 | {Opt_nodevmap, "nodevmap"}, |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 70 | {Opt_cache_loose, "cache=loose"}, |
| 71 | {Opt_cache_loose, "loose"}, |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 72 | {Opt_access, "access=%s"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 73 | {Opt_err, NULL} |
| 74 | }; |
| 75 | |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 76 | /** |
| 77 | * v9fs_parse_options - parse mount options into session structure |
| 78 | * @options: options string passed from mount |
| 79 | * @v9ses: existing v9fs session information |
| 80 | * |
| 81 | */ |
| 82 | |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 83 | static void v9fs_parse_options(struct v9fs_session_info *v9ses) |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 84 | { |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 85 | char *options = v9ses->options; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 86 | substring_t args[MAX_OPT_ARGS]; |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 87 | char *p; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 88 | int option; |
| 89 | int ret; |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 90 | char *s, *e; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 91 | |
| 92 | /* setup defaults */ |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 93 | v9ses->maxdata = 8192; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 94 | v9ses->afid = ~0; |
| 95 | v9ses->debug = 0; |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 96 | v9ses->cache = 0; |
Eric Van Hensbergen | fb0466c | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 97 | v9ses->trans = v9fs_default_trans(); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 98 | |
| 99 | if (!options) |
| 100 | return; |
| 101 | |
| 102 | while ((p = strsep(&options, ",")) != NULL) { |
| 103 | int token; |
| 104 | if (!*p) |
| 105 | continue; |
| 106 | token = match_token(p, tokens, args); |
Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 107 | if (token < Opt_uname) { |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 108 | if ((ret = match_int(&args[0], &option)) < 0) { |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 109 | P9_DPRINTK(P9_DEBUG_ERROR, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 110 | "integer field, but no integer?\n"); |
| 111 | continue; |
| 112 | } |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 113 | } |
| 114 | switch (token) { |
Eric Van Hensbergen | 9e2f668 | 2007-07-13 13:05:21 -0500 | [diff] [blame] | 115 | case Opt_debug: |
| 116 | v9ses->debug = option; |
Eric Van Hensbergen | 10fa16e | 2007-07-16 16:02:49 -0500 | [diff] [blame] | 117 | #ifdef CONFIG_NET_9P_DEBUG |
Eric Van Hensbergen | 9e2f668 | 2007-07-13 13:05:21 -0500 | [diff] [blame] | 118 | p9_debug_level = option; |
Eric Van Hensbergen | 10fa16e | 2007-07-16 16:02:49 -0500 | [diff] [blame] | 119 | #endif |
Eric Van Hensbergen | 9e2f668 | 2007-07-13 13:05:21 -0500 | [diff] [blame] | 120 | break; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 121 | case Opt_msize: |
| 122 | v9ses->maxdata = option; |
| 123 | break; |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 124 | case Opt_dfltuid: |
| 125 | v9ses->dfltuid = option; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 126 | break; |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 127 | case Opt_dfltgid: |
| 128 | v9ses->dfltgid = option; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 129 | break; |
| 130 | case Opt_afid: |
| 131 | v9ses->afid = option; |
| 132 | break; |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 133 | case Opt_trans: |
| 134 | v9ses->trans = v9fs_match_trans(&args[0]); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 135 | break; |
Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 136 | case Opt_uname: |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 137 | match_strcpy(v9ses->uname, &args[0]); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 138 | break; |
| 139 | case Opt_remotename: |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 140 | match_strcpy(v9ses->aname, &args[0]); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 141 | break; |
| 142 | case Opt_legacy: |
Latchesar Ionkov | 2405669 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 143 | v9ses->flags &= ~V9FS_EXTENDED; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 144 | break; |
| 145 | case Opt_nodevmap: |
| 146 | v9ses->nodev = 1; |
| 147 | break; |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 148 | case Opt_cache_loose: |
| 149 | v9ses->cache = CACHE_LOOSE; |
| 150 | break; |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 151 | |
| 152 | case Opt_access: |
| 153 | s = match_strdup(&args[0]); |
| 154 | v9ses->flags &= ~V9FS_ACCESS_MASK; |
| 155 | if (strcmp(s, "user") == 0) |
| 156 | v9ses->flags |= V9FS_ACCESS_USER; |
| 157 | else if (strcmp(s, "any") == 0) |
| 158 | v9ses->flags |= V9FS_ACCESS_ANY; |
| 159 | else { |
| 160 | v9ses->flags |= V9FS_ACCESS_SINGLE; |
| 161 | v9ses->uid = simple_strtol(s, &e, 10); |
| 162 | if (*e != '\0') |
| 163 | v9ses->uid = ~0; |
| 164 | } |
Adrian Bunk | 0a97629 | 2007-10-23 13:48:50 -0500 | [diff] [blame] | 165 | kfree(s); |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 166 | break; |
| 167 | |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 168 | default: |
| 169 | continue; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | /** |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 175 | * v9fs_session_init - initialize session |
| 176 | * @v9ses: session information structure |
| 177 | * @dev_name: device being mounted |
| 178 | * @data: options |
| 179 | * |
| 180 | */ |
| 181 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 182 | struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 183 | const char *dev_name, char *data) |
| 184 | { |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 185 | int retval = -EINVAL; |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 186 | struct p9_trans *trans = NULL; |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 187 | struct p9_fid *fid; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 188 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 189 | v9ses->uname = __getname(); |
| 190 | if (!v9ses->uname) |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 191 | return ERR_PTR(-ENOMEM); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 192 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 193 | v9ses->aname = __getname(); |
| 194 | if (!v9ses->aname) { |
| 195 | __putname(v9ses->uname); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 196 | return ERR_PTR(-ENOMEM); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 199 | v9ses->flags = V9FS_EXTENDED | V9FS_ACCESS_USER; |
| 200 | strcpy(v9ses->uname, V9FS_DEFUSER); |
| 201 | strcpy(v9ses->aname, V9FS_DEFANAME); |
| 202 | v9ses->uid = ~0; |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 203 | v9ses->dfltuid = V9FS_DEFUID; |
| 204 | v9ses->dfltgid = V9FS_DEFGID; |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 205 | v9ses->options = kstrdup(data, GFP_KERNEL); |
| 206 | v9fs_parse_options(v9ses); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 207 | |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 208 | if (v9ses->trans == NULL) { |
| 209 | retval = -EPROTONOSUPPORT; |
| 210 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 211 | "No transport defined or default transport\n"); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 212 | goto error; |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 213 | } |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 214 | |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 215 | trans = v9ses->trans->create(dev_name, v9ses->options); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 216 | if (IS_ERR(trans)) { |
| 217 | retval = PTR_ERR(trans); |
| 218 | trans = NULL; |
| 219 | goto error; |
Latchesar Ionkov | a8e63bf | 2005-09-22 21:43:51 -0700 | [diff] [blame] | 220 | } |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 221 | if ((v9ses->maxdata+P9_IOHDRSZ) > v9ses->trans->maxsize) |
| 222 | v9ses->maxdata = v9ses->trans->maxsize-P9_IOHDRSZ; |
Latchesar Ionkov | a8e63bf | 2005-09-22 21:43:51 -0700 | [diff] [blame] | 223 | |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 224 | v9ses->clnt = p9_client_create(trans, v9ses->maxdata+P9_IOHDRSZ, |
Latchesar Ionkov | 2405669 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 225 | v9fs_extended(v9ses)); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 226 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 227 | if (IS_ERR(v9ses->clnt)) { |
| 228 | retval = PTR_ERR(v9ses->clnt); |
| 229 | v9ses->clnt = NULL; |
| 230 | P9_DPRINTK(P9_DEBUG_ERROR, "problem initializing 9p client\n"); |
| 231 | goto error; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 234 | if (!v9ses->clnt->dotu) |
| 235 | v9ses->flags &= ~V9FS_EXTENDED; |
| 236 | |
| 237 | /* for legacy mode, fall back to V9FS_ACCESS_ANY */ |
| 238 | if (!v9fs_extended(v9ses) && |
| 239 | ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) { |
| 240 | |
| 241 | v9ses->flags &= ~V9FS_ACCESS_MASK; |
| 242 | v9ses->flags |= V9FS_ACCESS_ANY; |
| 243 | v9ses->uid = ~0; |
| 244 | } |
| 245 | |
| 246 | fid = p9_client_attach(v9ses->clnt, NULL, v9ses->uname, ~0, |
| 247 | v9ses->aname); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 248 | if (IS_ERR(fid)) { |
| 249 | retval = PTR_ERR(fid); |
| 250 | fid = NULL; |
| 251 | P9_DPRINTK(P9_DEBUG_ERROR, "cannot attach\n"); |
| 252 | goto error; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 255 | if ((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_SINGLE) |
| 256 | fid->uid = v9ses->uid; |
| 257 | else |
| 258 | fid->uid = ~0; |
| 259 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 260 | return fid; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 261 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 262 | error: |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 263 | v9fs_session_close(v9ses); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 264 | return ERR_PTR(retval); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /** |
| 268 | * v9fs_session_close - shutdown a session |
| 269 | * @v9ses: session information structure |
| 270 | * |
| 271 | */ |
| 272 | |
| 273 | void v9fs_session_close(struct v9fs_session_info *v9ses) |
| 274 | { |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 275 | if (v9ses->clnt) { |
| 276 | p9_client_destroy(v9ses->clnt); |
| 277 | v9ses->clnt = NULL; |
Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 278 | } |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 279 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 280 | __putname(v9ses->uname); |
| 281 | __putname(v9ses->aname); |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 282 | kfree(v9ses->options); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Eric Van Hensbergen | 322b329 | 2005-09-09 13:04:23 -0700 | [diff] [blame] | 285 | /** |
| 286 | * v9fs_session_cancel - mark transport as disconnected |
| 287 | * and cancel all pending requests. |
| 288 | */ |
| 289 | void v9fs_session_cancel(struct v9fs_session_info *v9ses) { |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 290 | P9_DPRINTK(P9_DEBUG_ERROR, "cancel session %p\n", v9ses); |
| 291 | p9_client_disconnect(v9ses->clnt); |
Eric Van Hensbergen | 322b329 | 2005-09-09 13:04:23 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 294 | extern int v9fs_error_init(void); |
| 295 | |
| 296 | /** |
| 297 | * v9fs_init - Initialize module |
| 298 | * |
| 299 | */ |
| 300 | |
| 301 | static int __init init_v9fs(void) |
| 302 | { |
Eric Van Hensbergen | f94b347 | 2007-01-26 00:57:04 -0800 | [diff] [blame] | 303 | printk(KERN_INFO "Installing v9fs 9p2000 file system support\n"); |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 304 | /* TODO: Setup list of registered trasnport modules */ |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 305 | return register_filesystem(&v9fs_fs_type); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | /** |
| 309 | * v9fs_init - shutdown module |
| 310 | * |
| 311 | */ |
| 312 | |
| 313 | static void __exit exit_v9fs(void) |
| 314 | { |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 315 | unregister_filesystem(&v9fs_fs_type); |
| 316 | } |
| 317 | |
| 318 | module_init(init_v9fs) |
| 319 | module_exit(exit_v9fs) |
| 320 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 321 | MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>"); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 322 | MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); |
| 323 | MODULE_AUTHOR("Ron Minnich <rminnich@lanl.gov>"); |
| 324 | MODULE_LICENSE("GPL"); |