Commits

Anonymous committed 6de602b

Remove unused files and routines

Comments (0)

Files changed (7)

 NOMAN=
 LKM=\
 	o9fs_9p\
-	o9fs_convS2M\
-	o9fs_convM2S\
 	o9fs_convM2D\
 	o9fs_lkm\
-	o9fs_rpc\
 	o9fs_subr\
 	o9fs_vfsops\
 	o9fs_vnops
 	return stat;
 }
 	
-
-struct o9fsstat *
-o9fs_fstat(struct o9fs *fs, struct o9fsfid *fid)
-{
-	struct o9fsstat *stat;
-	struct o9fsfcall tx, rx;
-
-	tx.type = O9FS_TSTAT;
-	tx.fid = fid->fid;
-	if ((o9fs_rpc(fs, &tx, &rx)) == -1)
-		return NULL;
-
-	stat = malloc(sizeof(struct o9fsstat) + rx.nstat,	M_O9FS, M_WAITOK);
-	if (!o9fs_convM2D(rx.stat, rx.nstat, stat, (char*)rx.stat))
-		return NULL;
-
-	return stat;
-}
-
-long
-o9fs_rdwr(struct o9fs *fs, int type, struct o9fsfid *f, void *buf, 
-		u_long n, int64_t offset)
-{
-	char *uba;
-	u_long nr;
-	
-	uba = buf;
-	fs->request.type = type;
-	fs->request.fid = f->fid;
-
-	if (offset == -1)
-		fs->request.offset= f->offset;
-	else
-		fs->request.offset = offset;
-
-	if (type == O9FS_TWRITE)
-		fs->request.data = uba;
-
-	nr = n;
-	if (nr > fs->msize)
-		nr = fs->msize;
-	fs->request.count = nr;
-
-	if ((o9fs_rpc(fs, &fs->request, &fs->reply)) < 0)
-		return -1;
-
-	nr = fs->reply.count;
-	if (nr <= 0)
-		return nr;
-
-	if (type == O9FS_TREAD)
-		memcpy((u_char *)uba, fs->reply.data, nr);
-
-	if (offset == -1)
-		f->offset += fs->reply.count;
-	return nr;
-}
-
 uint32_t
 o9fs_rdwr2(struct o9fs *fs, struct o9fid *f, uint8_t type, uint32_t len, uint64_t off)
 {

o9fs_convM2S.c

-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-
-#include "o9fs.h"
-#include "o9fs_extern.h"
-
-enum{
-	Debug = 0,
-};
-
-u_char*
-gstring(u_char *p, u_char *ep, char **s)
-{
-	u_int n;
-
-	if (p + O9FS_BIT16SZ > ep)
-		return NULL;
-	n = O9FS_GBIT16(p);
-	p += O9FS_BIT16SZ - 1;
-	if (p+n+1 > ep)
-		return NULL;
-	/* move it down, on top of count, to make room for '\0' */
-	memcpy(p, p+1, n);
-	p[n] = '\0';
-	*s = (char*)p;
-	p += n+1;
-	return p;
-}
-
-u_char*
-gqid(u_char *p, u_char *ep, struct o9fsqid *q)
-{
-	if (p + O9FS_QIDSZ > ep)
-		return NULL;
-	q->type = O9FS_GBIT8(p);
-	p += O9FS_BIT8SZ;
-	q->vers = O9FS_GBIT32(p);
-	p += O9FS_BIT32SZ;
-	q->path = O9FS_GBIT64(p);
-	p += O9FS_BIT64SZ;
-	return p;
-}
-
-/*
- * no syntactic checks.
- * three causes for error:
- *  1. message size field is incorrect
- *  2. input buffer too short for its own data (counts too long, etc.)
- *  3. too many names or qids
- * gqid() and gstring() return NULL if they would reach beyond buffer.
- * main switch statement checks range and also can fall through
- * to test at end of routine.
- */
-u_int
-o9fs_convM2S(u_char *ap, u_int nap, struct o9fsfcall *f)
-{
-	u_char *p, *ep;
-	u_int i, size;
-
-	p = ap;
-	ep = p + nap;
-
-	if (p + O9FS_BIT32SZ + O9FS_BIT8SZ + O9FS_BIT16SZ > ep)
-		return 0;
-	size = O9FS_GBIT32(p);
-	p += O9FS_BIT32SZ;
-
-	if (size > nap)
-		return 0;
-	if (size < O9FS_BIT32SZ + O9FS_BIT8SZ + O9FS_BIT16SZ)
-		return 0;
-
-	f->type = O9FS_GBIT8(p);
-	p += O9FS_BIT8SZ;
-	f->tag = O9FS_GBIT16(p);
-	p += O9FS_BIT16SZ;
-
-	switch(f->type)
-	{
-	default:
-		return 0;
-
-	case O9FS_TVERSION:
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->msize = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		p = gstring(p, ep, &f->version);
-		break;
-
-	case O9FS_TFLUSH:
-		if (p+O9FS_BIT16SZ > ep)
-			return 0;
-		f->oldtag = O9FS_GBIT16(p);
-		p += O9FS_BIT16SZ;
-		break;
-
-	case O9FS_TAUTH:
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->afid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		p = gstring(p, ep, &f->uname);
-		if (p == NULL)
-			break;
-		p = gstring(p, ep, &f->aname);
-		if (p == NULL)
-			break;
-		break;
-
-	case O9FS_TATTACH:
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->afid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		p = gstring(p, ep, &f->uname);
-		if (p == NULL)
-			break;
-		p = gstring(p, ep, &f->aname);
-		if (p == NULL)
-			break;
-		break;
-
-	case O9FS_TWALK:
-		if (p + O9FS_BIT32SZ + O9FS_BIT32SZ + O9FS_BIT16SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		f->newfid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		f->nwname = O9FS_GBIT16(p);
-		p += O9FS_BIT16SZ;
-		if (f->nwname > O9FS_MAXWELEM)
-			return 0;
-		for (i = 0; i < f->nwname; i++) {
-			p = gstring(p, ep, &f->wname[i]);
-			if (p == NULL)
-				break;
-		}
-		break;
-
-	case O9FS_TOPEN:
-		if (p + O9FS_BIT32SZ + O9FS_BIT8SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		f->mode = O9FS_GBIT8(p);
-		p += O9FS_BIT8SZ;
-		break;
-
-	case O9FS_TCREATE:
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		p = gstring(p, ep, &f->name);
-		if (p == NULL)
-			break;
-		if (p + O9FS_BIT32SZ + O9FS_BIT8SZ > ep)
-			return 0;
-		f->perm = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		f->mode = O9FS_GBIT8(p);
-		p += O9FS_BIT8SZ;
-		break;
-
-	case O9FS_TREAD:
-		if (p + O9FS_BIT32SZ + O9FS_BIT64SZ + O9FS_BIT32SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		f->offset = O9FS_GBIT64(p);
-		p += O9FS_BIT64SZ;
-		f->count = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TWRITE:
-		if (p + O9FS_BIT32SZ + O9FS_BIT64SZ + O9FS_BIT32SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		f->offset = O9FS_GBIT64(p);
-		p += O9FS_BIT64SZ;
-
-		p += O9FS_BIT32SZ;
-		if (p + f->count > ep)
-			return 0;
-		f->data = (char*)p;
-		p += f->count;
-		break;
-
-	case O9FS_TCLUNK:
-	case O9FS_TREMOVE:
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TSTAT:
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TWSTAT:
-		if (p + O9FS_BIT32SZ + O9FS_BIT16SZ > ep)
-			return 0;
-		f->fid = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		f->nstat = O9FS_GBIT16(p);
-		p += O9FS_BIT16SZ;
-		if (p + f->nstat > ep)
-			return 0;
-		f->stat = p;
-		p += f->nstat;
-		break;
-
-/*
- */
-	case O9FS_RVERSION:
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->msize = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		p = gstring(p, ep, &f->version);
-		break;
-
-	case O9FS_RERROR:
-		p = gstring(p, ep, &f->ename);
-		break;
-
-	case O9FS_RFLUSH:
-		break;
-
-	case O9FS_RAUTH:
-		p = gqid(p, ep, &f->aqid);
-		if (p == NULL)
-			break;
-		break;
-
-	case O9FS_RATTACH:
-		p = gqid(p, ep, &f->qid);
-		if (p == NULL)
-			break;
-		break;
-
-	case O9FS_RWALK:
-		if (p + O9FS_BIT16SZ > ep)
-			return 0;
-		f->nwqid = O9FS_GBIT16(p);
-		p += O9FS_BIT16SZ;
-		if (f->nwqid > O9FS_MAXWELEM)
-			return 0;
-		for (i = 0; i < f->nwqid; i++){
-			p = gqid(p, ep, &f->wqid[i]);
-			if (p == NULL)
-				break;
-		}
-		break;
-
-	case O9FS_ROPEN:
-	case O9FS_RCREATE:
-		p = gqid(p, ep, &f->qid);
-		if (p == NULL)
-			break;
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->iounit = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_RREAD:
-		if (p + O9FS_BIT32SZ > ep)
-			return 0;
-		f->count = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		if (p + f->count > ep)
-			return 0;
-		f->data = (char*)p;
-		p += f->count;
-		break;
-
-	case O9FS_RWRITE:
-		if (p + O9FS_BIT32SZ > ep)
-			return (0);
-		f->count = O9FS_GBIT32(p);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_RCLUNK:
-	case O9FS_RREMOVE:
-		break;
-
-	case O9FS_RSTAT:
-		if (p + O9FS_BIT16SZ > ep)
-			return 0;
-		f->nstat = O9FS_GBIT16(p);
-		p += O9FS_BIT16SZ;
-		if (p + f->nstat > ep)
-			return 0;
-		f->stat = p;
-		p += f->nstat;
-		break;
-
-	case O9FS_RWSTAT:
-		break;
-	}
-
-	if (p == NULL || p > ep)
-		return 0;
-	if (ap + size == p)
-		return size;
-	return 0;
-}
-

o9fs_convS2M.c

-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-
-#include "o9fs.h"
-#include "o9fs_extern.h"
-
-enum{
-	Debug = 0,
-};
-
-u_char*
-pstring(u_char *p, char *s)
-{
-	u_int n;
-
-	if (s == NULL) {
-		O9FS_PBIT16(p, 0);
-		p += O9FS_BIT16SZ;
-		return p;
-	}
-
-	n = strlen(s);
-	O9FS_PBIT16(p, n);
-	p += O9FS_BIT16SZ;
-	memcpy(p, s, n);
-	p += n;
-	return p;
-}
-
-u_char*
-pqid(u_char *p, struct o9fsqid *q)
-{
-	O9FS_PBIT8(p, q->type);
-	p += O9FS_BIT8SZ;
-	O9FS_PBIT32(p, q->vers);
-	p += O9FS_BIT32SZ;
-	O9FS_PBIT64(p, q->path);
-	p += O9FS_BIT64SZ;
-	return p;
-}
-
-u_int
-stringsz(char *s)
-{
-	return O9FS_BIT16SZ + strlen(s);
-}
-
-u_int
-o9fs_sizeS2M(struct o9fsfcall *f)
-{
-	u_int n;
-	int i;
-
-	n = 0;
-	n += O9FS_BIT32SZ;	/* size */
-	n += O9FS_BIT8SZ;	/* type */
-	n += O9FS_BIT16SZ;	/* tag */
-
-	switch(f->type)
-	{
-	default:
-		return 0;
-
-	case O9FS_TVERSION:
-		n += O9FS_BIT32SZ;
-		n += stringsz(f->version);
-		break;
-
-	case O9FS_TFLUSH:
-		n += O9FS_BIT16SZ;
-		break;
-
-	case O9FS_TAUTH:
-		n += O9FS_BIT32SZ;
-		n += stringsz(f->uname);
-		n += stringsz(f->aname);
-		break;
-
-	case O9FS_TATTACH:
-		n += O9FS_BIT32SZ;
-		n += O9FS_BIT32SZ;
-		n += stringsz(f->uname);
-		n += stringsz(f->aname);
-		break;
-
-	case O9FS_TWALK:
-		n += O9FS_BIT32SZ;
-		n += O9FS_BIT32SZ;
-		n += O9FS_BIT16SZ;
-		for (i = 0; i < f->nwname; i++)
-			n += stringsz(f->wname[i]);
-		break;
-
-	case O9FS_TOPEN:
-		n += O9FS_BIT32SZ;
-		n += O9FS_BIT8SZ;
-		break;
-
-	case O9FS_TCREATE:
-		n += O9FS_BIT32SZ;
-		n += stringsz(f->name);
-		n += O9FS_BIT32SZ;
-		n += O9FS_BIT8SZ;
-		break;
-
-	case O9FS_TREAD:
-		n += O9FS_BIT32SZ;
-		n += O9FS_BIT64SZ;
-		n += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TWRITE:
-		n += O9FS_BIT32SZ;
-		n += O9FS_BIT64SZ;
-		n += O9FS_BIT32SZ;
-		n += f->count;
-		break;
-
-	case O9FS_TCLUNK:
-	case O9FS_TREMOVE:
-		n += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TSTAT:
-		n += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TWSTAT:
-		n += O9FS_BIT32SZ;
-		n += O9FS_BIT16SZ;
-		n += f->nstat;
-		break;
-/*
- */
-
-	case O9FS_RVERSION:
-		n += O9FS_BIT32SZ;
-		n += stringsz(f->version);
-		break;
-
-	case O9FS_RERROR:
-		n += stringsz(f->ename);
-		break;
-
-	case O9FS_RFLUSH:
-		break;
-
-	case O9FS_RAUTH:
-		n += O9FS_QIDSZ;
-		break;
-
-	case O9FS_RATTACH:
-		n += O9FS_QIDSZ;
-		break;
-
-	case O9FS_RWALK:
-		n += O9FS_BIT16SZ;
-		n += f->nwqid * O9FS_QIDSZ;
-		break;
-
-	case O9FS_ROPEN:
-	case O9FS_RCREATE:
-		n += O9FS_QIDSZ;
-		n += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_RREAD:
-		n += O9FS_BIT32SZ;
-		n += f->count;
-		break;
-
-	case O9FS_RWRITE:
-		n += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_RCLUNK:
-		break;
-
-	case O9FS_RREMOVE:
-		break;
-
-	case O9FS_RSTAT:
-		n += O9FS_BIT16SZ;
-		n += f->nstat;
-		break;
-
-	case O9FS_RWSTAT:
-		break;
-	}
-	return n;
-}
-
-u_int
-o9fs_convS2M(struct o9fsfcall *f, u_char *ap, u_int nap)
-{
-	u_char *p;
-	u_int i, size;
-
-	size = o9fs_sizeS2M(f);
-	if (size == 0)
-		return 0;
-	if (size > nap)
-		return 0;
-
-	p = (u_char*)ap;
-
-	O9FS_PBIT32(p, size);
-	p += O9FS_BIT32SZ;
-	O9FS_PBIT8(p, f->type);
-	p += O9FS_BIT8SZ;
-	O9FS_PBIT16(p, f->tag);
-	p += O9FS_BIT16SZ;
-
-	switch (f->type)
-	{
-	default:
-		return 0;
-
-	case O9FS_TVERSION:
-		O9FS_PBIT32(p, f->msize);
-		p += O9FS_BIT32SZ;
-		p = pstring(p, f->version);
-		break;
-
-	case O9FS_TFLUSH:
-		O9FS_PBIT16(p, f->oldtag);
-		p += O9FS_BIT16SZ;
-		break;
-
-	case O9FS_TAUTH:
-		O9FS_PBIT32(p, f->afid);
-		p += O9FS_BIT32SZ;
-		p  = pstring(p, f->uname);
-		p  = pstring(p, f->aname);
-		break;
-
-	case O9FS_TATTACH:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		O9FS_PBIT32(p, f->afid);
-		p += O9FS_BIT32SZ;
-		p  = pstring(p, f->uname);
-		p  = pstring(p, f->aname);
-		break;
-
-	case O9FS_TWALK:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		O9FS_PBIT32(p, f->newfid);
-		p += O9FS_BIT32SZ;
-		O9FS_PBIT16(p, f->nwname);
-		p += O9FS_BIT16SZ;
-		if (f->nwname > O9FS_MAXWELEM)
-			return 0;
-		for (i = 0; i < f->nwname; i++)
-			p = pstring(p, f->wname[i]);
-		break;
-
-	case O9FS_TOPEN:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		O9FS_PBIT8(p, f->mode);
-		p += O9FS_BIT8SZ;
-		break;
-
-	case O9FS_TCREATE:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		p = pstring(p, f->name);
-		O9FS_PBIT32(p, f->perm);
-		p += O9FS_BIT32SZ;
-		O9FS_PBIT8(p, f->mode);
-		p += O9FS_BIT8SZ;
-		break;
-
-	case O9FS_TREAD:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		O9FS_PBIT64(p, f->offset);
-		p += O9FS_BIT64SZ;
-		O9FS_PBIT32(p, f->count);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TWRITE:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		O9FS_PBIT64(p, f->offset);
-		p += O9FS_BIT64SZ;
-		O9FS_PBIT32(p, f->count);
-		p += O9FS_BIT32SZ;
-		memcpy(p, f->data, f->count);
-		p += f->count;
-		break;
-
-	case O9FS_TCLUNK:
-	case O9FS_TREMOVE:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TSTAT:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_TWSTAT:
-		O9FS_PBIT32(p, f->fid);
-		p += O9FS_BIT32SZ;
-		O9FS_PBIT16(p, f->nstat);
-		p += O9FS_BIT16SZ;
-		memcpy(p, f->stat, f->nstat);
-		p += f->nstat;
-		break;
-/*
- */
-
-	case O9FS_RVERSION:
-		O9FS_PBIT32(p, f->msize);
-		p += O9FS_BIT32SZ;
-		p = pstring(p, f->version);
-		break;
-
-	case O9FS_RERROR:
-		p = pstring(p, f->ename);
-		break;
-
-	case O9FS_RFLUSH:
-		break;
-
-	case O9FS_RAUTH:
-		p = pqid(p, &f->aqid);
-		break;
-
-	case O9FS_RATTACH:
-		p = pqid(p, &f->qid);
-		break;
-
-	case O9FS_RWALK:
-		O9FS_PBIT16(p, f->nwqid);
-		p += O9FS_BIT16SZ;
-		if (f->nwqid > O9FS_MAXWELEM)
-			return 0;
-		for (i = 0; i < f->nwqid; i++)
-			p = pqid(p, &f->wqid[i]);
-		break;
-
-	case O9FS_ROPEN:
-	case O9FS_RCREATE: 
-		p = pqid(p, &f->qid);
-		O9FS_PBIT32(p, f->iounit);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_RREAD:
-		O9FS_PBIT32(p, f->count);
-		p += O9FS_BIT32SZ;
-		memcpy(p, f->data, f->count);
-		printf("rread: %s\n", p);
-		p += f->count;
-		break;
-
-	case O9FS_RWRITE:
-		O9FS_PBIT32(p, f->count);
-		p += O9FS_BIT32SZ;
-		break;
-
-	case O9FS_RCLUNK:
-		break;
-
-	case O9FS_RREMOVE:
-		break;
-
-	case O9FS_RSTAT:
-		O9FS_PBIT16(p, f->nstat);
-		p += O9FS_BIT16SZ;
-		memcpy(p, f->stat, f->nstat);
-		p += f->nstat;
-		break;
-
-	case O9FS_RWSTAT:
-		break;
-	}
-	if(size != p-ap)
-		return 0;
-	return size;
-}
 int		o9fs_ptoumode(int);
 int		o9fs_utopmode(int);
 int		o9fs_uflags2omode(int);
-void	o9fs_freefcall(struct o9fsfcall *);
-void	o9fs_freestat(struct o9fsstat *);
 void	*o9fsrealloc(void *, size_t, size_t);
 void	_printvp(struct vnode *);
+long	o9fs_mio(struct o9fs *, u_long);
 
 /* o9fs_9p.c */
-struct	o9fsstat *o9fs_fstat(struct o9fs *, struct o9fsfid *);
-long	o9fs_rdwr(struct o9fs *, int, struct o9fsfid *, void *, u_long, int64_t);
 uint32_t	o9fs_rdwr2(struct o9fs *, struct o9fid *, uint8_t, uint32_t, uint64_t);
 void	o9fs_fidclunk(struct o9fs *, struct o9fsfid *);
 struct	o9fsfid *o9fs_twalk(struct o9fs *, struct o9fsfid *, struct o9fsfid *, char *);
 void	o9fs_clunk(struct o9fs *, struct o9fid *);
 struct	o9fsstat *o9fs_stat(struct o9fs *, struct o9fid *);
 
-/* o9fs_conv* */
-u_char	*pstring(u_char *, char *);
-u_char	*pqid(u_char *, struct o9fsqid *);
-u_int	stringsz(char *);
-u_int	o9fs_sizeS2M(struct o9fsfcall *);
-uint	o9fs_convS2M(struct o9fsfcall *, u_char *, u_int);
-
-u_char	*gstring(u_char *, u_char *, char **);
-u_char	*gqid(u_char *, u_char *, struct o9fsqid *);
-u_int	o9fs_convM2S(u_char *, u_int, struct o9fsfcall *);
-
+/* o9fs_convM2D.c */
 int		o9fs_statcheck(u_char *, u_int);
 u_int	o9fs_convM2D(u_char *, u_int, struct o9fsstat *, char *);
 
 
-/* o9fs_rpc.c */
-int		o9fs_rpc(struct o9fs *, struct o9fsfcall *, struct o9fsfcall *);
-long	o9fs_mio(struct o9fs *, u_long);
-
 extern struct vops o9fs_vops;

o9fs_rpc.c

-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-#include <sys/namei.h>
-#include <sys/filedesc.h>
-#include <sys/file.h>
-
-#include "o9fs.h"
-#include "o9fs_extern.h"
-
-enum{
-	Debug = 0,
-};
-
-static long
-rdwr(struct o9fs *fs, void *buf, long count, off_t *offset, int write)
-{
-	struct file *fp;
-	struct uio auio;
-	struct iovec aiov;
-	long cnt;
-	int error;
-
-	error = 0;
-	fp = fs->servfp;
-	aiov.iov_base = buf;
-	cnt = aiov.iov_len = auio.uio_resid = count;
-	auio.uio_iov = &aiov;
-	auio.uio_segflg = UIO_SYSSPACE;
-	auio.uio_procp = curproc;
-
-	if (write) {
-		auio.uio_rw = UIO_WRITE;
-		error = (*fp->f_ops->fo_write)(fp, offset, &auio, fp->f_cred);
-		cnt -= auio.uio_resid;
-
-		fp->f_wxfer++;
-		fp->f_wbytes += cnt;
-	} else {
-		auio.uio_rw = UIO_READ;
-		error = (*fp->f_ops->fo_read)(fp, offset, &auio, fp->f_cred);
-		cnt -= auio.uio_resid;
-
-		fp->f_rxfer++;
-		fp->f_rbytes += cnt;
-	}
-	if (error)
-		return -error;
-	return cnt;
-}
-
-long
-o9fs_mio(struct o9fs *fs, u_long len)
-{
-	long n;
-
-	n = rdwr(fs, fs->outbuf, len, &fs->servfp->f_offset, 1);
-	if (n <= 0)
-		return n;
-
-	n = rdwr(fs, fs->inbuf, 4, &fs->servfp->f_offset, 0);
-	if (n <= 0) {
-		printf("o9fs_mio: Error reading message size\n");
-		return n;
-	}
-	
-	len = O9FS_GBIT32(fs->inbuf);
-	if (len <= 4) {
-		printf("R-message with length < 4\n");
-		return -1;
-	}
-
-	n = rdwr(fs, fs->inbuf + Offtype, len - Offtype, &fs->servfp->f_offset, 0);
-	if (n <= 0)
-		return n;
-
-	if (O9FS_GBIT8(fs->inbuf + Offtype) == O9FS_RERROR) {
-		printf("%.*s\n", O9FS_GBIT16(fs->inbuf + Minhd), fs->inbuf + Minhd + 2);
-		return -1;
-	}
-
-	return len;
-}
-
-int
-o9fs_rpc(struct o9fs *fs, struct o9fsfcall *tx, struct o9fsfcall *rx)
-{
-	int n, nn, error;
-	u_char buf[4];
-	struct proc *p;
-	struct file *fp;
-	
-	p = curproc;
-	error = 0;
-	fp = fs->servfp;
-
-	/* calculate the size and allocate a new fcall */
-	n = o9fs_sizeS2M(tx);
-	nn = o9fs_convS2M(tx, fs->rpc, n);
-	if (nn != n) {
-		printf("size mismatch\n");
-		return EIO;
-	}
-
-	n = rdwr(fs, fs->rpc, nn, &fp->f_offset, 1);
-	if (n < 0)
-		return -1;
-	if (n == 0)
-		return 0;
-
-	o9fs_freefcall(tx);
-//	bzero(fs->rpc, 8192); /* xxx */
-	n = rdwr(fs, buf, O9FS_BIT32SZ, &fp->f_offset, 0);
-	if (n < 0)
-		return -1;
-	if (n == 0)
-		return 0;
-
-	n = O9FS_GBIT32(buf);
-	if (n <= O9FS_BIT32SZ) {
-		printf("bogus message\n");
-		return -1;
-	}
-
-	/* read the rest of the msg */
-	O9FS_PBIT32(fs->rpc, n);
-
-	n = rdwr(fs, fs->rpc + O9FS_BIT32SZ, n - O9FS_BIT32SZ, &fp->f_offset, 0);
-	if (n < 0)
-		return -1;
-	if (n == 0)
-		return 0;
-	
-	n = O9FS_GBIT32((u_char *) fs->rpc);
-	nn = o9fs_convM2S(fs->rpc, n, rx);
-	if (nn != n) {
-		printf("size mismatch\n");
-		return EIO;
-	}
-
-	if (rx->type == O9FS_RERROR) {
-		DBG("%s\n", rx->ename);
-		return -1;
-	}
-	return error;
-}
 	return s;
 }	
 
-void
-o9fs_freestat(struct o9fsstat *s)
-{
-	/* let'em leak! */
-/*	if(s->name != NULL)
-		free(s->name, M_O9FS);
-	if(s->uid != NULL)
-		free(s->uid, M_O9FS);
-	if(s->gid != NULL)
-		free(s->gid, M_O9FS);
-	if(s->muid)
-		free(s->muid, M_O9FS); */
-	s->name = s->uid = s->gid = s->muid = NULL;
-}
-
-void
-o9fs_freefcall(struct o9fsfcall *fcall)
-{
-	void *p;
-
-	switch(fcall->type) {
-	case O9FS_RSTAT:
-		p = fcall->stat;
-		break;
-	case O9FS_RREAD:
-		p = fcall->data;
-		break;
-	case O9FS_RVERSION:
-		p = fcall->version;
-		break;
-	case O9FS_RERROR:
-		p = fcall->ename;
-		break;
-	default:
-		return;
-	}
-	
-	free(p, M_O9FS);
-	p = NULL;
-}
-
 int
 o9fs_allocvp(struct mount *mp, struct o9fid *f, struct vnode **vpp, u_long flag)
 {
 	}
 	printf("[%p] %p fid %d ref %d qid (%.16llx %lu %d) mode %d iounit %ld\n", vp, f, f->fid, f->ref, f->qid.path, f->qid.vers, f->qid.type, f->mode, f->iounit);
 }
+
+static long
+rdwr(struct o9fs *fs, void *buf, long count, off_t *offset, int write)
+{
+	struct file *fp;
+	struct uio auio;
+	struct iovec aiov;
+	long cnt;
+	int error;
+
+	error = 0;
+	fp = fs->servfp;
+	aiov.iov_base = buf;
+	cnt = aiov.iov_len = auio.uio_resid = count;
+	auio.uio_iov = &aiov;
+	auio.uio_segflg = UIO_SYSSPACE;
+	auio.uio_procp = curproc;
+
+	if (write) {
+		auio.uio_rw = UIO_WRITE;
+		error = (*fp->f_ops->fo_write)(fp, offset, &auio, fp->f_cred);
+		cnt -= auio.uio_resid;
+
+		fp->f_wxfer++;
+		fp->f_wbytes += cnt;
+	} else {
+		auio.uio_rw = UIO_READ;
+		error = (*fp->f_ops->fo_read)(fp, offset, &auio, fp->f_cred);
+		cnt -= auio.uio_resid;
+
+		fp->f_rxfer++;
+		fp->f_rbytes += cnt;
+	}
+	if (error)
+		return -error;
+	return cnt;
+}
+
+long
+o9fs_mio(struct o9fs *fs, u_long len)
+{
+	long n;
+
+	n = rdwr(fs, fs->outbuf, len, &fs->servfp->f_offset, 1);
+	if (n <= 0)
+		return n;
+
+	n = rdwr(fs, fs->inbuf, 4, &fs->servfp->f_offset, 0);
+	if (n <= 0) {
+		printf("o9fs_mio: Error reading message size\n");
+		return n;
+	}
+	
+	len = O9FS_GBIT32(fs->inbuf);
+	if (len <= 4) {
+		printf("R-message with length < 4\n");
+		return -1;
+	}
+
+	n = rdwr(fs, fs->inbuf + Offtype, len - Offtype, &fs->servfp->f_offset, 0);
+	if (n <= 0)
+		return n;
+
+	if (O9FS_GBIT8(fs->inbuf + Offtype) == O9FS_RERROR) {
+		printf("%.*s\n", O9FS_GBIT16(fs->inbuf + Minhd), fs->inbuf + Minhd + 2);
+		return -1;
+	}
+
+	return len;
+}