[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: fcall interface



Here are the Inferno defs:

enum
{
	Tnop,		/*  0 */
	Rnop,		/*  1 */
	Terror,		/*  2, illegal */
	Rerror,		/*  3 */
	Tflush,		/*  4 */
	Rflush,		/*  5 */
	Tclone,		/*  6 */
	Rclone,		/*  7 */
	Twalk,		/*  8 */
	Rwalk,		/*  9 */
	Topen,		/* 10 */
	Ropen,		/* 11 */
	Tcreate,	/* 12 */
	Rcreate,	/* 13 */
	Tread,		/* 14 */
	Rread,		/* 15 */
	Twrite,		/* 16 */
	Rwrite,		/* 17 */
	Tclunk,		/* 18 */
	Rclunk,		/* 19 */
	Tremove,	/* 20 */
	Rremove,	/* 21 */
	Tstat,		/* 22 */
	Rstat,		/* 23 */
	Twstat,		/* 24 */
	Rwstat,		/* 25 */
	Tsession,	/* 26 */
	Rsession,	/* 27 */
	Tattach,	/* 28 */
	Rattach,	/* 29 */
	Tmax
};

here are the conv routines:

int
convM2S(char *ap, Fcall *f, int n)
{

	uchar *p;

	p = (uchar*)ap;
	if(n < 3)
		return 0;

	GCHAR(type);
	GSHORT(tag);

	if(n < msglen[f->type])
		return 0;

	switch(f->type) {
	default:
		return -1;

	case Tnop:
		break;
	case Tflush:
		GSHORT(oldtag);
		break;
	case Tattach:
		GSHORT(fid);
		GSTRING(uname, sizeof(f->uname));
		GSTRING(aname, sizeof(f->aname));
		break;
	case Tclone:
		GSHORT(fid);
		GSHORT(newfid);
		break;
	case Twalk:
		GSHORT(fid);
		GSTRING(name, sizeof(f->name));
		break;
	case Topen:
		GSHORT(fid);
		GCHAR(mode);
		break;
	case Tcreate:
		GSHORT(fid);
		GSTRING(name, sizeof(f->name));
		GLONG(perm);
		GCHAR(mode);
		break;
	case Tread:
		GSHORT(fid);
		GVLONG(offset);
		GSHORT(count);
		break;
	case Twrite:
		GSHORT(fid);
		GVLONG(offset);
		GSHORT(count);
		if(n < msglen[f->type]+f->count)
			return 0;
		p++;	/* pad(1) */
		f->data = (char*)p; p += f->count;
		break;
	case Tclunk:
		GSHORT(fid);
		break;
	case Tremove:
		GSHORT(fid);
		break;
	case Tstat:
		GSHORT(fid);
		break;
	case Twstat:
		GSHORT(fid);
		GSTRING(stat, sizeof(f->stat));
		break;

	case Rnop:
		break;
	case Rerror:
		GSTRING(ename, sizeof(f->ename));
		break;
	case Rflush:
		break;
	case Rattach:
		GSHORT(fid);
		GLONG(qid.path);
		GLONG(qid.vers);
		break;
	case Rclone:
		GSHORT(fid);
		break;
	case Rwalk:
		GSHORT(fid);
		GLONG(qid.path);
		GLONG(qid.vers);
		break;
	case Ropen:
		GSHORT(fid);
		GLONG(qid.path);
		GLONG(qid.vers);
		break;
	case Rcreate:
		GSHORT(fid);
		GLONG(qid.path);
		GLONG(qid.vers);
		break;
	case Rread:
		GSHORT(fid);
		GSHORT(count);
		if(n < msglen[f->type]+f->count)
			return 0;
		p++;			/* pad(1) */
		f->data = (char*)p;
		p += f->count;
		break;
	case Rwrite:
		GSHORT(fid);
		GSHORT(count);
		break;
	case Rclunk:
		GSHORT(fid);
		break;
	case Rremove:
		GSHORT(fid);
		break;
	case Rstat:
		GSHORT(fid);
		GSTRING(stat, sizeof(f->stat));
		break;
	case Rwstat:
		GSHORT(fid);
		break;
	}
	return (char*)p - ap;
}

I will make sure all the include files go out in
the next binary distribution.
-------------------------------------
philw