| 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 | { | 
| Latchesar Ionkov | 343f1fe | 2006-05-15 09:44:18 -0700 | [diff] [blame] | 101 | 	int fid, id; | 
| Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 102 | 	struct v9fs_session_info *v9ses; | 
 | 103 |  | 
| Latchesar Ionkov | 343f1fe | 2006-05-15 09:44:18 -0700 | [diff] [blame] | 104 | 	id = 0; | 
| Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 105 | 	fid = tc->params.tclunk.fid; | 
| Latchesar Ionkov | 343f1fe | 2006-05-15 09:44:18 -0700 | [diff] [blame] | 106 | 	if (rc) | 
 | 107 | 		id = rc->id; | 
 | 108 |  | 
| Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 109 | 	kfree(tc); | 
| Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 110 | 	kfree(rc); | 
| Latchesar Ionkov | 343f1fe | 2006-05-15 09:44:18 -0700 | [diff] [blame] | 111 | 	if (id == RCLUNK) { | 
 | 112 | 		v9ses = a; | 
 | 113 | 		v9fs_put_idpool(fid, &v9ses->fidpool); | 
 | 114 | 	} | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 115 | } | 
 | 116 |  | 
 | 117 | /** | 
 | 118 |  * v9fs_t_clunk - release a fid (finish a transaction) | 
 | 119 |  * @v9ses: 9P2000 session information | 
 | 120 |  * @fid: fid to release | 
 | 121 |  * @fcall: pointer to response fcall pointer | 
 | 122 |  * | 
 | 123 |  */ | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 124 |  | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 125 | int | 
| Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 126 | v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 127 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 128 | 	int ret; | 
| Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 129 | 	struct v9fs_fcall *tc, *rc; | 
 | 130 |  | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 131 | 	dprintk(DEBUG_9P, "fid %d\n", fid); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 132 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 133 | 	rc = NULL; | 
 | 134 | 	tc = v9fs_create_tclunk(fid); | 
 | 135 | 	if (!IS_ERR(tc)) | 
 | 136 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, &rc); | 
 | 137 | 	else | 
 | 138 | 		ret = PTR_ERR(tc); | 
| Latchesar Ionkov | 3cf6429 | 2006-01-08 01:04:58 -0800 | [diff] [blame] | 139 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 140 | 	if (ret) | 
 | 141 | 		dprintk(DEBUG_ERROR, "failed fid %d err %d\n", fid, ret); | 
 | 142 |  | 
 | 143 | 	v9fs_t_clunk_cb(v9ses, tc, rc, ret); | 
 | 144 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 145 | } | 
 | 146 |  | 
| Adrian Bunk | 29c6e48 | 2006-03-24 03:15:52 -0800 | [diff] [blame] | 147 | #if 0 | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 148 | /** | 
 | 149 |  * v9fs_v9fs_t_flush - flush a pending transaction | 
 | 150 |  * @v9ses: 9P2000 session information | 
| Russ Cox | 4a26c24 | 2006-03-25 03:07:24 -0800 | [diff] [blame] | 151 |  * @tag: tag to release | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 152 |  * | 
 | 153 |  */ | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 154 | int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 155 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 156 | 	int ret; | 
 | 157 | 	struct v9fs_fcall *tc; | 
| 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 | 	dprintk(DEBUG_9P, "oldtag %d\n", oldtag); | 
 | 160 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 161 | 	tc = v9fs_create_tflush(oldtag); | 
 | 162 | 	if (!IS_ERR(tc)) { | 
 | 163 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, NULL); | 
 | 164 | 		kfree(tc); | 
 | 165 | 	} else | 
 | 166 | 		ret = PTR_ERR(tc); | 
 | 167 |  | 
 | 168 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 169 | } | 
| Eric Van Hensbergen | 67543e5 | 2006-03-25 03:07:29 -0800 | [diff] [blame] | 170 | #endif | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 171 |  | 
 | 172 | /** | 
 | 173 |  * v9fs_t_stat - read a file's meta-data | 
 | 174 |  * @v9ses: 9P2000 session information | 
 | 175 |  * @fid: fid pointing to file or directory to get info about | 
 | 176 |  * @fcall: pointer to response fcall | 
 | 177 |  * | 
 | 178 |  */ | 
 | 179 |  | 
 | 180 | int | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 181 | 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] | 182 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 183 | 	int ret; | 
 | 184 | 	struct v9fs_fcall *tc; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 185 |  | 
 | 186 | 	dprintk(DEBUG_9P, "fid %d\n", fid); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 187 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 188 | 	ret = -ENOMEM; | 
 | 189 | 	tc = v9fs_create_tstat(fid); | 
 | 190 | 	if (!IS_ERR(tc)) { | 
 | 191 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); | 
 | 192 | 		kfree(tc); | 
 | 193 | 	} else | 
 | 194 | 		ret = PTR_ERR(tc); | 
 | 195 |  | 
 | 196 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 197 | } | 
 | 198 |  | 
 | 199 | /** | 
 | 200 |  * v9fs_t_wstat - write a file's meta-data | 
 | 201 |  * @v9ses: 9P2000 session information | 
 | 202 |  * @fid: fid pointing to file or directory to write info about | 
 | 203 |  * @stat: metadata | 
 | 204 |  * @fcall: pointer to response fcall | 
 | 205 |  * | 
 | 206 |  */ | 
 | 207 |  | 
 | 208 | int | 
 | 209 | v9fs_t_wstat(struct v9fs_session_info *v9ses, u32 fid, | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 210 | 	     struct v9fs_wstat *wstat, struct v9fs_fcall **rcp) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 211 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 212 | 	int ret; | 
 | 213 | 	struct v9fs_fcall *tc; | 
| 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 | 	dprintk(DEBUG_9P, "fid %d\n", fid); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 216 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 217 | 	tc = v9fs_create_twstat(fid, wstat, v9ses->extended); | 
 | 218 | 	if (!IS_ERR(tc)) { | 
 | 219 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); | 
 | 220 | 		kfree(tc); | 
 | 221 | 	} else | 
 | 222 | 		ret = PTR_ERR(tc); | 
 | 223 |  | 
 | 224 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 225 | } | 
 | 226 |  | 
 | 227 | /** | 
 | 228 |  * v9fs_t_walk - walk a fid to a new file or directory | 
 | 229 |  * @v9ses: 9P2000 session information | 
 | 230 |  * @fid: fid to walk | 
 | 231 |  * @newfid: new fid (for clone operations) | 
 | 232 |  * @name: path to walk fid to | 
 | 233 |  * @fcall: pointer to response fcall | 
 | 234 |  * | 
 | 235 |  */ | 
 | 236 |  | 
 | 237 | /* TODO: support multiple walk */ | 
 | 238 |  | 
 | 239 | int | 
 | 240 | v9fs_t_walk(struct v9fs_session_info *v9ses, u32 fid, u32 newfid, | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 241 | 	    char *name, struct v9fs_fcall **rcp) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 242 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 243 | 	int ret; | 
 | 244 | 	struct v9fs_fcall *tc; | 
 | 245 | 	int nwname; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 246 |  | 
 | 247 | 	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] | 248 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 249 | 	if (name) | 
 | 250 | 		nwname = 1; | 
 | 251 | 	else | 
 | 252 | 		nwname = 0; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 253 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 254 | 	tc = v9fs_create_twalk(fid, newfid, nwname, &name); | 
 | 255 | 	if (!IS_ERR(tc)) { | 
 | 256 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); | 
 | 257 | 		kfree(tc); | 
 | 258 | 	} else | 
 | 259 | 		ret = PTR_ERR(tc); | 
 | 260 |  | 
 | 261 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 262 | } | 
 | 263 |  | 
 | 264 | /** | 
 | 265 |  * v9fs_t_open - open a file | 
 | 266 |  * | 
 | 267 |  * @v9ses - 9P2000 session information | 
 | 268 |  * @fid - fid to open | 
 | 269 |  * @mode - mode to open file (R, RW, etc) | 
 | 270 |  * @fcall - pointer to response fcall | 
 | 271 |  * | 
 | 272 |  */ | 
 | 273 |  | 
 | 274 | int | 
 | 275 | v9fs_t_open(struct v9fs_session_info *v9ses, u32 fid, u8 mode, | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 276 | 	    struct v9fs_fcall **rcp) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 277 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 278 | 	int ret; | 
 | 279 | 	struct v9fs_fcall *tc; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 280 |  | 
 | 281 | 	dprintk(DEBUG_9P, "fid %d mode %d\n", fid, mode); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 282 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 283 | 	tc = v9fs_create_topen(fid, mode); | 
 | 284 | 	if (!IS_ERR(tc)) { | 
 | 285 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); | 
 | 286 | 		kfree(tc); | 
 | 287 | 	} else | 
 | 288 | 		ret = PTR_ERR(tc); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 289 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 290 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 291 | } | 
 | 292 |  | 
 | 293 | /** | 
 | 294 |  * v9fs_t_remove - remove a file or directory | 
 | 295 |  * @v9ses: 9P2000 session information | 
 | 296 |  * @fid: fid to remove | 
 | 297 |  * @fcall: pointer to response fcall | 
 | 298 |  * | 
 | 299 |  */ | 
 | 300 |  | 
 | 301 | int | 
 | 302 | v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid, | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 303 | 	      struct v9fs_fcall **rcp) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 304 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 305 | 	int ret; | 
 | 306 | 	struct v9fs_fcall *tc; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 307 |  | 
 | 308 | 	dprintk(DEBUG_9P, "fid %d\n", fid); | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 309 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 310 | 	tc = v9fs_create_tremove(fid); | 
 | 311 | 	if (!IS_ERR(tc)) { | 
 | 312 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); | 
 | 313 | 		kfree(tc); | 
 | 314 | 	} else | 
 | 315 | 		ret = PTR_ERR(tc); | 
 | 316 |  | 
 | 317 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 318 | } | 
 | 319 |  | 
 | 320 | /** | 
 | 321 |  * v9fs_t_create - create a file or directory | 
 | 322 |  * @v9ses: 9P2000 session information | 
 | 323 |  * @fid: fid to create | 
 | 324 |  * @name: name of the file or directory to create | 
 | 325 |  * @perm: permissions to create with | 
 | 326 |  * @mode: mode to open file (R, RW, etc) | 
 | 327 |  * @fcall: pointer to response fcall | 
 | 328 |  * | 
 | 329 |  */ | 
 | 330 |  | 
 | 331 | int | 
| Latchesar Ionkov | 16cce6d | 2006-03-25 03:07:26 -0800 | [diff] [blame] | 332 | v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, u32 perm, | 
 | 333 | 	u8 mode, char *extension, struct v9fs_fcall **rcp) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 334 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 335 | 	int ret; | 
 | 336 | 	struct v9fs_fcall *tc; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 337 |  | 
 | 338 | 	dprintk(DEBUG_9P, "fid %d name '%s' perm %x mode %d\n", | 
 | 339 | 		fid, name, perm, mode); | 
 | 340 |  | 
| Latchesar Ionkov | 16cce6d | 2006-03-25 03:07:26 -0800 | [diff] [blame] | 341 | 	tc = v9fs_create_tcreate(fid, name, perm, mode, extension, | 
 | 342 | 		v9ses->extended); | 
 | 343 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 344 | 	if (!IS_ERR(tc)) { | 
 | 345 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, rcp); | 
 | 346 | 		kfree(tc); | 
 | 347 | 	} else | 
 | 348 | 		ret = PTR_ERR(tc); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 349 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 350 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 351 | } | 
 | 352 |  | 
 | 353 | /** | 
 | 354 |  * v9fs_t_read - read data | 
 | 355 |  * @v9ses: 9P2000 session information | 
 | 356 |  * @fid: fid to read from | 
 | 357 |  * @offset: offset to start read at | 
 | 358 |  * @count: how many bytes to read | 
 | 359 |  * @fcall: pointer to response fcall (with data) | 
 | 360 |  * | 
 | 361 |  */ | 
 | 362 |  | 
 | 363 | int | 
 | 364 | v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid, u64 offset, | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 365 | 	    u32 count, struct v9fs_fcall **rcp) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 366 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 367 | 	int ret; | 
 | 368 | 	struct v9fs_fcall *tc, *rc; | 
| 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 | 	dprintk(DEBUG_9P, "fid %d offset 0x%llux count 0x%x\n", fid, | 
 | 371 | 		(long long unsigned) offset, count); | 
| 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 | 	tc = v9fs_create_tread(fid, offset, count); | 
 | 374 | 	if (!IS_ERR(tc)) { | 
 | 375 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, &rc); | 
 | 376 | 		if (!ret) | 
 | 377 | 			ret = rc->params.rread.count; | 
 | 378 | 		if (rcp) | 
 | 379 | 			*rcp = rc; | 
 | 380 | 		else | 
 | 381 | 			kfree(rc); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 382 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 383 | 		kfree(tc); | 
 | 384 | 	} else | 
 | 385 | 		ret = PTR_ERR(tc); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 386 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 387 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 388 | } | 
 | 389 |  | 
 | 390 | /** | 
 | 391 |  * v9fs_t_write - write data | 
 | 392 |  * @v9ses: 9P2000 session information | 
 | 393 |  * @fid: fid to write to | 
 | 394 |  * @offset: offset to start write at | 
 | 395 |  * @count: how many bytes to write | 
 | 396 |  * @fcall: pointer to response fcall | 
 | 397 |  * | 
 | 398 |  */ | 
 | 399 |  | 
 | 400 | int | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 401 | v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, u64 offset, u32 count, | 
 | 402 | 	const char __user *data, struct v9fs_fcall **rcp) | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 403 | { | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 404 | 	int ret; | 
 | 405 | 	struct v9fs_fcall *tc, *rc; | 
| 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 | 	dprintk(DEBUG_9P, "fid %d offset 0x%llux count 0x%x\n", fid, | 
 | 408 | 		(long long unsigned) offset, count); | 
| 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 | 	tc = v9fs_create_twrite(fid, offset, count, data); | 
 | 411 | 	if (!IS_ERR(tc)) { | 
 | 412 | 		ret = v9fs_mux_rpc(v9ses->mux, tc, &rc); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 413 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 414 | 		if (!ret) | 
 | 415 | 			ret = rc->params.rwrite.count; | 
 | 416 | 		if (rcp) | 
 | 417 | 			*rcp = rc; | 
 | 418 | 		else | 
 | 419 | 			kfree(rc); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 420 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 421 | 		kfree(tc); | 
 | 422 | 	} else | 
 | 423 | 		ret = PTR_ERR(tc); | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 424 |  | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 425 | 	return ret; | 
| Eric Van Hensbergen | b8cf945 | 2005-09-09 13:04:21 -0700 | [diff] [blame] | 426 | } | 
| Latchesar Ionkov | 531b109 | 2006-01-08 01:05:00 -0800 | [diff] [blame] | 427 |  |