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 | * |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 6 | * Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com> |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 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> |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 33 | #include <net/9p/client.h> |
Eric Van Hensbergen | 8b81ef5 | 2008-10-13 18:45:25 -0500 | [diff] [blame] | 34 | #include <net/9p/transport.h> |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 35 | #include "v9fs.h" |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 36 | #include "v9fs_vfs.h" |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 37 | |
| 38 | /* |
| 39 | * Option Parsing (code inspired by NFS code) |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 40 | * NOTE: each transport will parse its own options |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 41 | */ |
| 42 | |
| 43 | enum { |
| 44 | /* Options that take integer arguments */ |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 45 | Opt_debug, Opt_dfltuid, Opt_dfltgid, Opt_afid, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 46 | /* String options */ |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 47 | Opt_uname, Opt_remotename, Opt_trans, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 48 | /* Options that take no arguments */ |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 49 | Opt_nodevmap, |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 50 | /* Cache options */ |
| 51 | Opt_cache_loose, |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 52 | /* Access options */ |
| 53 | Opt_access, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 54 | /* Error token */ |
| 55 | Opt_err |
| 56 | }; |
| 57 | |
Steven Whitehouse | a447c09 | 2008-10-13 10:46:57 +0100 | [diff] [blame] | 58 | static const match_table_t tokens = { |
Eric Van Hensbergen | 9e2f668 | 2007-07-13 13:05:21 -0500 | [diff] [blame] | 59 | {Opt_debug, "debug=%x"}, |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 60 | {Opt_dfltuid, "dfltuid=%u"}, |
| 61 | {Opt_dfltgid, "dfltgid=%u"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 62 | {Opt_afid, "afid=%u"}, |
Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 63 | {Opt_uname, "uname=%s"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 64 | {Opt_remotename, "aname=%s"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 65 | {Opt_nodevmap, "nodevmap"}, |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 66 | {Opt_cache_loose, "cache=loose"}, |
| 67 | {Opt_cache_loose, "loose"}, |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 68 | {Opt_access, "access=%s"}, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 69 | {Opt_err, NULL} |
| 70 | }; |
| 71 | |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 72 | /** |
| 73 | * v9fs_parse_options - parse mount options into session structure |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 74 | * @v9ses: existing v9fs session information |
| 75 | * |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 76 | * Return 0 upon success, -ERRNO upon failure. |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 77 | */ |
| 78 | |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 79 | static int v9fs_parse_options(struct v9fs_session_info *v9ses) |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 80 | { |
Latchesar Ionkov | 8999e04 | 2007-11-06 08:02:53 -0600 | [diff] [blame] | 81 | char *options; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 82 | substring_t args[MAX_OPT_ARGS]; |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 83 | char *p; |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 84 | int option = 0; |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 85 | char *s, *e; |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 86 | int ret = 0; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 87 | |
| 88 | /* setup defaults */ |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 89 | v9ses->afid = ~0; |
| 90 | v9ses->debug = 0; |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 91 | v9ses->cache = 0; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 92 | |
Latchesar Ionkov | 8999e04 | 2007-11-06 08:02:53 -0600 | [diff] [blame] | 93 | if (!v9ses->options) |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 94 | return 0; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 95 | |
Latchesar Ionkov | 8999e04 | 2007-11-06 08:02:53 -0600 | [diff] [blame] | 96 | options = kstrdup(v9ses->options, GFP_KERNEL); |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 97 | if (!options) { |
| 98 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 99 | "failed to allocate copy of option string\n"); |
| 100 | return -ENOMEM; |
| 101 | } |
| 102 | |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 103 | while ((p = strsep(&options, ",")) != NULL) { |
| 104 | int token; |
| 105 | if (!*p) |
| 106 | continue; |
| 107 | token = match_token(p, tokens, args); |
Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 108 | if (token < Opt_uname) { |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 109 | int r = match_int(&args[0], &option); |
| 110 | if (r < 0) { |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 111 | P9_DPRINTK(P9_DEBUG_ERROR, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 112 | "integer field, but no integer?\n"); |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 113 | ret = r; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 114 | continue; |
| 115 | } |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 116 | } |
| 117 | switch (token) { |
Eric Van Hensbergen | 9e2f668 | 2007-07-13 13:05:21 -0500 | [diff] [blame] | 118 | case Opt_debug: |
| 119 | v9ses->debug = option; |
Eric Van Hensbergen | 10fa16e | 2007-07-16 16:02:49 -0500 | [diff] [blame] | 120 | #ifdef CONFIG_NET_9P_DEBUG |
Eric Van Hensbergen | 9e2f668 | 2007-07-13 13:05:21 -0500 | [diff] [blame] | 121 | p9_debug_level = option; |
Eric Van Hensbergen | 10fa16e | 2007-07-16 16:02:49 -0500 | [diff] [blame] | 122 | #endif |
Eric Van Hensbergen | 9e2f668 | 2007-07-13 13:05:21 -0500 | [diff] [blame] | 123 | break; |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 124 | |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 125 | case Opt_dfltuid: |
| 126 | v9ses->dfltuid = option; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 127 | break; |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 128 | case Opt_dfltgid: |
| 129 | v9ses->dfltgid = option; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 130 | break; |
| 131 | case Opt_afid: |
| 132 | v9ses->afid = option; |
| 133 | break; |
Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 134 | case Opt_uname: |
Markus Armbruster | b32a09d | 2008-02-26 09:57:11 -0600 | [diff] [blame] | 135 | match_strlcpy(v9ses->uname, &args[0], PATH_MAX); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 136 | break; |
| 137 | case Opt_remotename: |
Markus Armbruster | b32a09d | 2008-02-26 09:57:11 -0600 | [diff] [blame] | 138 | match_strlcpy(v9ses->aname, &args[0], PATH_MAX); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 139 | break; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 140 | case Opt_nodevmap: |
| 141 | v9ses->nodev = 1; |
| 142 | break; |
Eric Van Hensbergen | e03abc0 | 2007-02-11 13:21:39 -0600 | [diff] [blame] | 143 | case Opt_cache_loose: |
| 144 | v9ses->cache = CACHE_LOOSE; |
| 145 | break; |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 146 | |
| 147 | case Opt_access: |
| 148 | s = match_strdup(&args[0]); |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 149 | if (!s) { |
| 150 | P9_DPRINTK(P9_DEBUG_ERROR, |
| 151 | "failed to allocate copy" |
| 152 | " of option argument\n"); |
| 153 | ret = -ENOMEM; |
| 154 | break; |
| 155 | } |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 156 | v9ses->flags &= ~V9FS_ACCESS_MASK; |
| 157 | if (strcmp(s, "user") == 0) |
| 158 | v9ses->flags |= V9FS_ACCESS_USER; |
| 159 | else if (strcmp(s, "any") == 0) |
| 160 | v9ses->flags |= V9FS_ACCESS_ANY; |
| 161 | else { |
| 162 | v9ses->flags |= V9FS_ACCESS_SINGLE; |
Julia Lawall | f1d9e45 | 2008-12-19 16:50:22 -0600 | [diff] [blame] | 163 | v9ses->uid = simple_strtoul(s, &e, 10); |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 164 | if (*e != '\0') |
| 165 | v9ses->uid = ~0; |
| 166 | } |
Adrian Bunk | 0a97629 | 2007-10-23 13:48:50 -0500 | [diff] [blame] | 167 | kfree(s); |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 168 | break; |
| 169 | |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 170 | default: |
| 171 | continue; |
| 172 | } |
| 173 | } |
Latchesar Ionkov | 8999e04 | 2007-11-06 08:02:53 -0600 | [diff] [blame] | 174 | kfree(options); |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 175 | return ret; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | /** |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 179 | * v9fs_session_init - initialize session |
| 180 | * @v9ses: session information structure |
| 181 | * @dev_name: device being mounted |
| 182 | * @data: options |
| 183 | * |
| 184 | */ |
| 185 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 186 | struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 187 | const char *dev_name, char *data) |
| 188 | { |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 189 | int retval = -EINVAL; |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 190 | struct p9_fid *fid; |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 191 | int rc; |
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->uname = __getname(); |
| 194 | if (!v9ses->uname) |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 195 | return ERR_PTR(-ENOMEM); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 196 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 197 | v9ses->aname = __getname(); |
| 198 | if (!v9ses->aname) { |
| 199 | __putname(v9ses->uname); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 200 | return ERR_PTR(-ENOMEM); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 203 | v9ses->flags = V9FS_EXTENDED | V9FS_ACCESS_USER; |
| 204 | strcpy(v9ses->uname, V9FS_DEFUSER); |
| 205 | strcpy(v9ses->aname, V9FS_DEFANAME); |
| 206 | v9ses->uid = ~0; |
Latchesar Ionkov | bd32b82 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 207 | v9ses->dfltuid = V9FS_DEFUID; |
| 208 | v9ses->dfltgid = V9FS_DEFGID; |
Eric Van Hensbergen | 887b3ec | 2008-05-08 20:26:37 -0500 | [diff] [blame] | 209 | if (data) { |
| 210 | v9ses->options = kstrdup(data, GFP_KERNEL); |
| 211 | if (!v9ses->options) { |
| 212 | P9_DPRINTK(P9_DEBUG_ERROR, |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 213 | "failed to allocate copy of option string\n"); |
Eric Van Hensbergen | 887b3ec | 2008-05-08 20:26:37 -0500 | [diff] [blame] | 214 | retval = -ENOMEM; |
| 215 | goto error; |
| 216 | } |
Jim Meyering | ab31267 | 2008-03-06 17:10:28 -0600 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | rc = v9fs_parse_options(v9ses); |
| 220 | if (rc < 0) { |
| 221 | retval = rc; |
| 222 | goto error; |
| 223 | } |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 224 | |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 225 | v9ses->clnt = p9_client_create(dev_name, v9ses->options); |
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 | |
Eric Van Hensbergen | fbedadc | 2008-10-13 20:36:16 -0500 | [diff] [blame] | 237 | v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ; |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 238 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 239 | /* for legacy mode, fall back to V9FS_ACCESS_ANY */ |
| 240 | if (!v9fs_extended(v9ses) && |
| 241 | ((v9ses->flags&V9FS_ACCESS_MASK) == V9FS_ACCESS_USER)) { |
| 242 | |
| 243 | v9ses->flags &= ~V9FS_ACCESS_MASK; |
| 244 | v9ses->flags |= V9FS_ACCESS_ANY; |
| 245 | v9ses->uid = ~0; |
| 246 | } |
| 247 | |
| 248 | fid = p9_client_attach(v9ses->clnt, NULL, v9ses->uname, ~0, |
| 249 | v9ses->aname); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 250 | if (IS_ERR(fid)) { |
| 251 | retval = PTR_ERR(fid); |
| 252 | fid = NULL; |
| 253 | P9_DPRINTK(P9_DEBUG_ERROR, "cannot attach\n"); |
| 254 | goto error; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 257 | if ((v9ses->flags & V9FS_ACCESS_MASK) == V9FS_ACCESS_SINGLE) |
| 258 | fid->uid = v9ses->uid; |
| 259 | else |
| 260 | fid->uid = ~0; |
| 261 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 262 | return fid; |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 263 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 264 | error: |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 265 | return ERR_PTR(retval); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | /** |
| 269 | * v9fs_session_close - shutdown a session |
| 270 | * @v9ses: session information structure |
| 271 | * |
| 272 | */ |
| 273 | |
| 274 | void v9fs_session_close(struct v9fs_session_info *v9ses) |
| 275 | { |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 276 | if (v9ses->clnt) { |
| 277 | p9_client_destroy(v9ses->clnt); |
| 278 | v9ses->clnt = NULL; |
Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 279 | } |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 280 | |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 281 | __putname(v9ses->uname); |
| 282 | __putname(v9ses->aname); |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 283 | kfree(v9ses->options); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Eric Van Hensbergen | 322b329 | 2005-09-09 13:04:23 -0700 | [diff] [blame] | 286 | /** |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 287 | * v9fs_session_cancel - terminate a session |
| 288 | * @v9ses: session to terminate |
| 289 | * |
| 290 | * mark transport as disconnected and cancel all pending requests. |
Eric Van Hensbergen | 322b329 | 2005-09-09 13:04:23 -0700 | [diff] [blame] | 291 | */ |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 292 | |
Eric Van Hensbergen | 322b329 | 2005-09-09 13:04:23 -0700 | [diff] [blame] | 293 | void v9fs_session_cancel(struct v9fs_session_info *v9ses) { |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 294 | P9_DPRINTK(P9_DEBUG_ERROR, "cancel session %p\n", v9ses); |
| 295 | p9_client_disconnect(v9ses->clnt); |
Eric Van Hensbergen | 322b329 | 2005-09-09 13:04:23 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 298 | extern int v9fs_error_init(void); |
| 299 | |
| 300 | /** |
| 301 | * v9fs_init - Initialize module |
| 302 | * |
| 303 | */ |
| 304 | |
| 305 | static int __init init_v9fs(void) |
| 306 | { |
Eric Van Hensbergen | f94b347 | 2007-01-26 00:57:04 -0800 | [diff] [blame] | 307 | printk(KERN_INFO "Installing v9fs 9p2000 file system support\n"); |
Eric Van Hensbergen | a80d923 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 308 | /* TODO: Setup list of registered trasnport modules */ |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 309 | return register_filesystem(&v9fs_fs_type); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | /** |
| 313 | * v9fs_init - shutdown module |
| 314 | * |
| 315 | */ |
| 316 | |
| 317 | static void __exit exit_v9fs(void) |
| 318 | { |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 319 | unregister_filesystem(&v9fs_fs_type); |
| 320 | } |
| 321 | |
| 322 | module_init(init_v9fs) |
| 323 | module_exit(exit_v9fs) |
| 324 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 325 | MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>"); |
Eric Van Hensbergen | 9e82cf6 | 2005-09-09 13:04:20 -0700 | [diff] [blame] | 326 | MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>"); |
| 327 | MODULE_AUTHOR("Ron Minnich <rminnich@lanl.gov>"); |
| 328 | MODULE_LICENSE("GPL"); |