aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p/client.c
diff options
context:
space:
mode:
authorLatchesar Ionkov <lucho@ionkov.net>2009-04-05 17:22:16 -0400
committerEric Van Hensbergen <ericvh@vTrogdor.(none)>2009-04-05 17:54:52 -0400
commit453ed90d1395a5281a8f1a0de5d8aabc66202e34 (patch)
treedca5c43212ec89988a9367dec12f4d43bc45c5c9 /net/9p/client.c
parentb4348f32dae3cb6eb4bc21c7ed8f76c0b11e9d6a (diff)
net/9p: set correct stat size when sending Twstat messages
The 9P2000 Twstat message requires the size of the stat structure to be specified. Currently the 9p code writes zero instead of the actual size. This behavior confuses some of the file servers that check if the size is correct. This patch adds a new function that calculcates the stat size and puts the value in the appropriate place in the 9P message. Signed-off-by: Latchesar Ionkov <lucho@ionkov.net> Reviewed-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p/client.c')
-rw-r--r--net/9p/client.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/net/9p/client.c b/net/9p/client.c
index 1eb580c38fbb..93f442aaa119 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -1251,12 +1251,42 @@ error:
1251} 1251}
1252EXPORT_SYMBOL(p9_client_stat); 1252EXPORT_SYMBOL(p9_client_stat);
1253 1253
1254static int p9_client_statsize(struct p9_wstat *wst, int optional)
1255{
1256 int ret;
1257
1258 /* size[2] type[2] dev[4] qid[13] */
1259 /* mode[4] atime[4] mtime[4] length[8]*/
1260 /* name[s] uid[s] gid[s] muid[s] */
1261 ret = 2+2+4+13+4+4+4+8+2+2+2+2;
1262
1263 if (wst->name)
1264 ret += strlen(wst->name);
1265 if (wst->uid)
1266 ret += strlen(wst->uid);
1267 if (wst->gid)
1268 ret += strlen(wst->gid);
1269 if (wst->muid)
1270 ret += strlen(wst->muid);
1271
1272 if (optional) {
1273 ret += 2+4+4+4; /* extension[s] n_uid[4] n_gid[4] n_muid[4] */
1274 if (wst->extension)
1275 ret += strlen(wst->extension);
1276 }
1277
1278 return ret;
1279}
1280
1254int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst) 1281int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst)
1255{ 1282{
1256 int err; 1283 int err;
1257 struct p9_req_t *req; 1284 struct p9_req_t *req;
1258 struct p9_client *clnt; 1285 struct p9_client *clnt;
1259 1286
1287 err = 0;
1288 clnt = fid->clnt;
1289 wst->size = p9_client_statsize(wst, clnt->dotu);
1260 P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid); 1290 P9_DPRINTK(P9_DEBUG_9P, ">>> TWSTAT fid %d\n", fid->fid);
1261 P9_DPRINTK(P9_DEBUG_9P, 1291 P9_DPRINTK(P9_DEBUG_9P,
1262 " sz=%x type=%x dev=%x qid=%x.%llx.%x\n" 1292 " sz=%x type=%x dev=%x qid=%x.%llx.%x\n"
@@ -1268,10 +1298,8 @@ int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst)
1268 wst->atime, wst->mtime, (unsigned long long)wst->length, 1298 wst->atime, wst->mtime, (unsigned long long)wst->length,
1269 wst->name, wst->uid, wst->gid, wst->muid, wst->extension, 1299 wst->name, wst->uid, wst->gid, wst->muid, wst->extension,
1270 wst->n_uid, wst->n_gid, wst->n_muid); 1300 wst->n_uid, wst->n_gid, wst->n_muid);
1271 err = 0;
1272 clnt = fid->clnt;
1273 1301
1274 req = p9_client_rpc(clnt, P9_TWSTAT, "dwS", fid->fid, 0, wst); 1302 req = p9_client_rpc(clnt, P9_TWSTAT, "dwS", fid->fid, wst->size, wst);
1275 if (IS_ERR(req)) { 1303 if (IS_ERR(req)) {
1276 err = PTR_ERR(req); 1304 err = PTR_ERR(req);
1277 goto error; 1305 goto error;