Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 1 | /* |
Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 2 | * linux/fs/9p/fcall.c |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 3 | * |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 4 | * This file contains functions to perform synchronous 9P calls |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 5 | * |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 6 | * Copyright (C) 2004 by Latchesar Ionkov <lucho@ionkov.net> |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 7 | * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> |
| 8 | * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> |
| 9 | * |
| 10 | * 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] | 11 | * it under the terms of the GNU General Public License version 2 |
| 12 | * as published by the Free Software Foundation. |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to: |
| 21 | * Free Software Foundation |
| 22 | * 51 Franklin Street, Fifth Floor |
| 23 | * Boston, MA 02111-1301 USA |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #include <linux/config.h> |
| 28 | #include <linux/module.h> |
| 29 | #include <linux/errno.h> |
| 30 | #include <linux/fs.h> |
| 31 | #include <linux/idr.h> |
| 32 | |
| 33 | #include "debug.h" |
| 34 | #include "v9fs.h" |
| 35 | #include "9p.h" |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 36 | #include "conv.h" |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 37 | #include "mux.h" |
| 38 | |
| 39 | /** |
| 40 | * v9fs_t_version - negotiate protocol parameters with sever |
| 41 | * @v9ses: 9P2000 session information |
| 42 | * @msize: requested max size packet |
| 43 | * @version: requested version.extension string |
| 44 | * @fcall: pointer to response fcall pointer |
| 45 | * |
| 46 | */ |
| 47 | |
| 48 | int |
| 49 | v9fs_t_version(struct v9fs_session_info *v9ses, u32 msize, |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 50 | char *version, struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 51 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 52 | int ret; |
| 53 | struct v9fs_fcall *tc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 54 | |
| 55 | dprintk(DEBUG_9P, "msize: %d version: %s\n", msize, version); |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 56 | tc = v9fs_create_tversion(msize, version); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 57 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 58 | if (!IS_ERR(tc)) { |
| 59 | ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); |
| 60 | kfree(tc); |
| 61 | } else |
| 62 | ret = PTR_ERR(tc); |
| 63 | |
| 64 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | /** |
| 68 | * v9fs_t_attach - mount the server |
| 69 | * @v9ses: 9P2000 session information |
| 70 | * @uname: user name doing the attach |
| 71 | * @aname: remote name being attached to |
| 72 | * @fid: mount fid to attatch to root node |
| 73 | * @afid: authentication fid (in this case result key) |
| 74 | * @fcall: pointer to response fcall pointer |
| 75 | * |
| 76 | */ |
| 77 | |
| 78 | int |
| 79 | v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname, |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 80 | u32 fid, u32 afid, struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 81 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 82 | int ret; |
| 83 | struct v9fs_fcall* tc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 84 | |
| 85 | dprintk(DEBUG_9P, "uname '%s' aname '%s' fid %d afid %d\n", uname, |
| 86 | aname, fid, afid); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 87 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 88 | tc = v9fs_create_tattach(fid, afid, uname, aname); |
| 89 | if (!IS_ERR(tc)) { |
| 90 | ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); |
| 91 | kfree(tc); |
| 92 | } else |
| 93 | ret = PTR_ERR(tc); |
| 94 | |
| 95 | return ret; |
Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | static void v9fs_t_clunk_cb(void *a, struct v9fs_fcall *tc, |
| 99 | struct v9fs_fcall *rc, int err) |
| 100 | { |
| 101 | int fid; |
| 102 | struct v9fs_session_info *v9ses; |
| 103 | |
| 104 | if (err) |
| 105 | return; |
| 106 | |
| 107 | fid = tc->params.tclunk.fid; |
| 108 | kfree(tc); |
| 109 | |
| 110 | if (!rc) |
| 111 | return; |
| 112 | |
Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 113 | v9ses = a; |
| 114 | if (rc->id == RCLUNK) |
| 115 | v9fs_put_idpool(fid, &v9ses->fidpool); |
| 116 | |
| 117 | kfree(rc); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /** |
| 121 | * v9fs_t_clunk - release a fid (finish a transaction) |
| 122 | * @v9ses: 9P2000 session information |
| 123 | * @fid: fid to release |
| 124 | * @fcall: pointer to response fcall pointer |
| 125 | * |
| 126 | */ |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 127 | |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 128 | int |
Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 129 | v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 130 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 131 | int ret; |
Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 132 | struct v9fs_fcall *tc, *rc; |
| 133 | |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 134 | dprintk(DEBUG_9P, "fid %d\n", fid); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 135 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 136 | rc = NULL; |
| 137 | tc = v9fs_create_tclunk(fid); |
| 138 | if (!IS_ERR(tc)) |
| 139 | ret = v9fs_mux_rpc(v9ses->mux, tc, &rc); |
| 140 | else |
| 141 | ret = PTR_ERR(tc); |
Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 142 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 143 | if (ret) |
| 144 | dprintk(DEBUG_ERROR, "failed fid %d err %d\n", fid, ret); |
| 145 | |
| 146 | v9fs_t_clunk_cb(v9ses, tc, rc, ret); |
| 147 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Adrian Bunk | 29c6e48 | 2006-03-24 03:15:52 -0800 | [diff] [blame] | 150 | #if 0 |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 151 | /** |
| 152 | * v9fs_v9fs_t_flush - flush a pending transaction |
| 153 | * @v9ses: 9P2000 session information |
Russ Cox | 4a26c24 | 2006-03-25 03:07:24 -0800 | [diff] [blame] | 154 | * @tag: tag to release |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 155 | * |
| 156 | */ |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 157 | int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 158 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 159 | int ret; |
| 160 | struct v9fs_fcall *tc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 161 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 162 | dprintk(DEBUG_9P, "oldtag %d\n", oldtag); |
| 163 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 164 | tc = v9fs_create_tflush(oldtag); |
| 165 | if (!IS_ERR(tc)) { |
| 166 | ret = v9fs_mux_rpc(v9ses->mux, tc, NULL); |
| 167 | kfree(tc); |
| 168 | } else |
| 169 | ret = PTR_ERR(tc); |
| 170 | |
| 171 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 172 | } |
Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 173 | #endif |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 174 | |
| 175 | /** |
| 176 | * v9fs_t_stat - read a file's meta-data |
| 177 | * @v9ses: 9P2000 session information |
| 178 | * @fid: fid pointing to file or directory to get info about |
| 179 | * @fcall: pointer to response fcall |
| 180 | * |
| 181 | */ |
| 182 | |
| 183 | int |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 184 | v9fs_t_stat(struct v9fs_session_info *v9ses, u32 fid, struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 185 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 186 | int ret; |
| 187 | struct v9fs_fcall *tc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 188 | |
| 189 | dprintk(DEBUG_9P, "fid %d\n", fid); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 190 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 191 | ret = -ENOMEM; |
| 192 | tc = v9fs_create_tstat(fid); |
| 193 | if (!IS_ERR(tc)) { |
| 194 | ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); |
| 195 | kfree(tc); |
| 196 | } else |
| 197 | ret = PTR_ERR(tc); |
| 198 | |
| 199 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | /** |
| 203 | * v9fs_t_wstat - write a file's meta-data |
| 204 | * @v9ses: 9P2000 session information |
| 205 | * @fid: fid pointing to file or directory to write info about |
| 206 | * @stat: metadata |
| 207 | * @fcall: pointer to response fcall |
| 208 | * |
| 209 | */ |
| 210 | |
| 211 | int |
| 212 | v9fs_t_wstat(struct v9fs_session_info *v9ses, u32 fid, |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 213 | struct v9fs_wstat *wstat, struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 214 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 215 | int ret; |
| 216 | struct v9fs_fcall *tc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 217 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 218 | dprintk(DEBUG_9P, "fid %d\n", fid); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 219 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 220 | tc = v9fs_create_twstat(fid, wstat, v9ses->extended); |
| 221 | if (!IS_ERR(tc)) { |
| 222 | ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); |
| 223 | kfree(tc); |
| 224 | } else |
| 225 | ret = PTR_ERR(tc); |
| 226 | |
| 227 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | /** |
| 231 | * v9fs_t_walk - walk a fid to a new file or directory |
| 232 | * @v9ses: 9P2000 session information |
| 233 | * @fid: fid to walk |
| 234 | * @newfid: new fid (for clone operations) |
| 235 | * @name: path to walk fid to |
| 236 | * @fcall: pointer to response fcall |
| 237 | * |
| 238 | */ |
| 239 | |
| 240 | /* TODO: support multiple walk */ |
| 241 | |
| 242 | int |
| 243 | v9fs_t_walk(struct v9fs_session_info *v9ses, u32 fid, u32 newfid, |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 244 | char *name, struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 245 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 246 | int ret; |
| 247 | struct v9fs_fcall *tc; |
| 248 | int nwname; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 249 | |
| 250 | dprintk(DEBUG_9P, "fid %d newfid %d wname '%s'\n", fid, newfid, name); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 251 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 252 | if (name) |
| 253 | nwname = 1; |
| 254 | else |
| 255 | nwname = 0; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 256 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 257 | tc = v9fs_create_twalk(fid, newfid, nwname, &name); |
| 258 | if (!IS_ERR(tc)) { |
| 259 | ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); |
| 260 | kfree(tc); |
| 261 | } else |
| 262 | ret = PTR_ERR(tc); |
| 263 | |
| 264 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /** |
| 268 | * v9fs_t_open - open a file |
| 269 | * |
| 270 | * @v9ses - 9P2000 session information |
| 271 | * @fid - fid to open |
| 272 | * @mode - mode to open file (R, RW, etc) |
| 273 | * @fcall - pointer to response fcall |
| 274 | * |
| 275 | */ |
| 276 | |
| 277 | int |
| 278 | v9fs_t_open(struct v9fs_session_info *v9ses, u32 fid, u8 mode, |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 279 | struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 280 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 281 | int ret; |
| 282 | struct v9fs_fcall *tc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 283 | |
| 284 | dprintk(DEBUG_9P, "fid %d mode %d\n", fid, mode); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 285 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 286 | tc = v9fs_create_topen(fid, mode); |
| 287 | if (!IS_ERR(tc)) { |
| 288 | ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); |
| 289 | kfree(tc); |
| 290 | } else |
| 291 | ret = PTR_ERR(tc); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 292 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 293 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | /** |
| 297 | * v9fs_t_remove - remove a file or directory |
| 298 | * @v9ses: 9P2000 session information |
| 299 | * @fid: fid to remove |
| 300 | * @fcall: pointer to response fcall |
| 301 | * |
| 302 | */ |
| 303 | |
| 304 | int |
| 305 | v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid, |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 306 | struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 307 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 308 | int ret; |
| 309 | struct v9fs_fcall *tc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 310 | |
| 311 | dprintk(DEBUG_9P, "fid %d\n", fid); |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 312 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 313 | tc = v9fs_create_tremove(fid); |
| 314 | if (!IS_ERR(tc)) { |
| 315 | ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); |
| 316 | kfree(tc); |
| 317 | } else |
| 318 | ret = PTR_ERR(tc); |
| 319 | |
| 320 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | /** |
| 324 | * v9fs_t_create - create a file or directory |
| 325 | * @v9ses: 9P2000 session information |
| 326 | * @fid: fid to create |
| 327 | * @name: name of the file or directory to create |
| 328 | * @perm: permissions to create with |
| 329 | * @mode: mode to open file (R, RW, etc) |
| 330 | * @fcall: pointer to response fcall |
| 331 | * |
| 332 | */ |
| 333 | |
| 334 | int |
Latchesar Ionkov | 16cce6d | 2006-03-25 03:07:26 -0800 | [diff] [blame] | 335 | v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, u32 perm, |
| 336 | u8 mode, char *extension, struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 337 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 338 | int ret; |
| 339 | struct v9fs_fcall *tc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 340 | |
| 341 | dprintk(DEBUG_9P, "fid %d name '%s' perm %x mode %d\n", |
| 342 | fid, name, perm, mode); |
| 343 | |
Latchesar Ionkov | 16cce6d | 2006-03-25 03:07:26 -0800 | [diff] [blame] | 344 | tc = v9fs_create_tcreate(fid, name, perm, mode, extension, |
| 345 | v9ses->extended); |
| 346 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 347 | if (!IS_ERR(tc)) { |
| 348 | ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); |
| 349 | kfree(tc); |
| 350 | } else |
| 351 | ret = PTR_ERR(tc); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 352 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 353 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | /** |
| 357 | * v9fs_t_read - read data |
| 358 | * @v9ses: 9P2000 session information |
| 359 | * @fid: fid to read from |
| 360 | * @offset: offset to start read at |
| 361 | * @count: how many bytes to read |
| 362 | * @fcall: pointer to response fcall (with data) |
| 363 | * |
| 364 | */ |
| 365 | |
| 366 | int |
| 367 | v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid, u64 offset, |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 368 | u32 count, struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 369 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 370 | int ret; |
| 371 | struct v9fs_fcall *tc, *rc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 372 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 373 | dprintk(DEBUG_9P, "fid %d offset 0x%llux count 0x%x\n", fid, |
| 374 | (long long unsigned) offset, count); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 375 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 376 | tc = v9fs_create_tread(fid, offset, count); |
| 377 | if (!IS_ERR(tc)) { |
| 378 | ret = v9fs_mux_rpc(v9ses->mux, tc, &rc); |
| 379 | if (!ret) |
| 380 | ret = rc->params.rread.count; |
| 381 | if (rcp) |
| 382 | *rcp = rc; |
| 383 | else |
| 384 | kfree(rc); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 385 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 386 | kfree(tc); |
| 387 | } else |
| 388 | ret = PTR_ERR(tc); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 389 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 390 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | /** |
| 394 | * v9fs_t_write - write data |
| 395 | * @v9ses: 9P2000 session information |
| 396 | * @fid: fid to write to |
| 397 | * @offset: offset to start write at |
| 398 | * @count: how many bytes to write |
| 399 | * @fcall: pointer to response fcall |
| 400 | * |
| 401 | */ |
| 402 | |
| 403 | int |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 404 | v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, u64 offset, u32 count, |
| 405 | const char __user *data, struct v9fs_fcall **rcp) |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 406 | { |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 407 | int ret; |
| 408 | struct v9fs_fcall *tc, *rc; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 409 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 410 | dprintk(DEBUG_9P, "fid %d offset 0x%llux count 0x%x\n", fid, |
| 411 | (long long unsigned) offset, count); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 412 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 413 | tc = v9fs_create_twrite(fid, offset, count, data); |
| 414 | if (!IS_ERR(tc)) { |
| 415 | ret = v9fs_mux_rpc(v9ses->mux, tc, &rc); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 416 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 417 | if (!ret) |
| 418 | ret = rc->params.rwrite.count; |
| 419 | if (rcp) |
| 420 | *rcp = rc; |
| 421 | else |
| 422 | kfree(rc); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 423 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 424 | kfree(tc); |
| 425 | } else |
| 426 | ret = PTR_ERR(tc); |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 427 | |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 428 | return ret; |
Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 429 | } |
Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 430 | |