static int plan9_create(struct session_struct *sp, struct p9_client **cp) { struct p9_nbd_device *nbd = sp->nbd; struct p9_client *clnt = NULL; int err; dprintk(DBG_PLAN9, "%s: p9_client_create %s %s\n", nbd->disk->disk_name, nbd->p9_addr, nbd->p9_opts); session_busy(sp); clnt = p9_client_create(nbd->p9_addr, nbd->p9_opts); if (IS_ERR(clnt)) return PTR_ERR(clnt); if (clnt->msize - P9_IOHDRSZ < nbd->blksize) { err = -EINVAL; goto error; } if (clnt->proto_version != p9_proto_2000L) { err = -EINVAL; goto error; } if (session_idle(sp) < 0) { err = -ETIMEDOUT; goto error; } *cp = clnt; return 0; error: if (clnt) p9_client_destroy(clnt); return err; }
struct p9_client *p9_client_create(const char *dev_name, char *options) { int err; struct p9_client *clnt; err = 0; clnt = kmalloc(sizeof(struct p9_client), GFP_KERNEL); if (!clnt) return ERR_PTR(-ENOMEM); clnt->trans_mod = NULL; clnt->trans = NULL; spin_lock_init(&clnt->lock); INIT_LIST_HEAD(&clnt->fidlist); clnt->fidpool = p9_idpool_create(); if (IS_ERR(clnt->fidpool)) { err = PTR_ERR(clnt->fidpool); clnt->fidpool = NULL; goto error; } p9_tag_init(clnt); err = parse_opts(options, clnt); if (err < 0) goto error; if (!clnt->trans_mod) clnt->trans_mod = v9fs_get_default_trans(); if (clnt->trans_mod == NULL) { err = -EPROTONOSUPPORT; P9_DPRINTK(P9_DEBUG_ERROR, "No transport defined or default transport\n"); goto error; } P9_DPRINTK(P9_DEBUG_MUX, "clnt %p trans %p msize %d dotu %d\n", clnt, clnt->trans_mod, clnt->msize, clnt->dotu); err = clnt->trans_mod->create(clnt, dev_name, options); if (err) goto error; if ((clnt->msize+P9_IOHDRSZ) > clnt->trans_mod->maxsize) clnt->msize = clnt->trans_mod->maxsize-P9_IOHDRSZ; err = p9_client_version(clnt); if (err) goto error; return clnt; error: p9_client_destroy(clnt); return ERR_PTR(err); }
void v9fs_session_close(struct v9fs_session_info *v9ses) { if (v9ses->clnt) { p9_client_destroy(v9ses->clnt); v9ses->clnt = NULL; } __putname(v9ses->name); __putname(v9ses->remotename); }
void v9fs_session_close(struct v9fs_session_info *v9ses) { if (v9ses->clnt) { p9_client_destroy(v9ses->clnt); v9ses->clnt = NULL; } __putname(v9ses->uname); __putname(v9ses->aname); kfree(v9ses->options); }
struct p9_client *p9_client_create(struct p9_trans *trans, int msize, int dotu) { int err, n; struct p9_client *clnt; struct p9_fcall *tc, *rc; struct p9_str *version; err = 0; tc = NULL; rc = NULL; clnt = kmalloc(sizeof(struct p9_client), GFP_KERNEL); if (!clnt) return ERR_PTR(-ENOMEM); P9_DPRINTK(P9_DEBUG_9P, "clnt %p trans %p msize %d dotu %d\n", clnt, trans, msize, dotu); spin_lock_init(&clnt->lock); clnt->trans = trans; clnt->msize = msize; clnt->dotu = dotu; INIT_LIST_HEAD(&clnt->fidlist); clnt->fidpool = p9_idpool_create(); if (!clnt->fidpool) { err = PTR_ERR(clnt->fidpool); clnt->fidpool = NULL; goto error; } clnt->conn = p9_conn_create(clnt->trans, clnt->msize, &clnt->dotu); if (IS_ERR(clnt->conn)) { err = PTR_ERR(clnt->conn); clnt->conn = NULL; goto error; } tc = p9_create_tversion(clnt->msize, clnt->dotu?"9P2000.u":"9P2000"); if (IS_ERR(tc)) { err = PTR_ERR(tc); tc = NULL; goto error; } err = p9_conn_rpc(clnt->conn, tc, &rc); if (err) goto error; version = &rc->params.rversion.version; if (version->len == 8 && !memcmp(version->str, "9P2000.u", 8)) clnt->dotu = 1; else if (version->len == 6 && !memcmp(version->str, "9P2000", 6)) clnt->dotu = 0; else { err = -EREMOTEIO; goto error; } n = rc->params.rversion.msize; if (n < clnt->msize) clnt->msize = n; kfree(tc); kfree(rc); return clnt; error: kfree(tc); kfree(rc); p9_client_destroy(clnt); return ERR_PTR(err); }