Commits

Anonymous committed 9690087

Clean remainings of the old style

Comments (0)

Files changed (7)

 	}\
 }while(0)
 
-struct o9fsqid {
+struct o9qid {
 	uint8_t		type;
 	uint32_t	vers;
 	uint64_t	path;
 };
 
-struct o9fsstat {
+struct o9stat {
 	uint16_t	type;			/* server type */
 	uint32_t	dev;			/* server subtype */
-	struct		o9fsqid qid;	/* unique id from server */
+	struct		o9qid qid;	/* unique id from server */
 	uint32_t	mode;			/* permissions */
 	uint32_t	atime;			/* last read time */
 	uint32_t	mtime;			/* last write time */
 	int32_t		fid;
 	int8_t		mode;			/* open mode */
 	uint32_t	iounit;
-	struct		o9fsqid	qid;
+	struct		o9qid	qid;
 	uint64_t	offset;
 
 	struct		o9fid *parent;
 	TAILQ_ENTRY(o9fid) next;
 };
 
-#define VTO9(vp) ((struct o9fsfid *)(vp)->v_data)
-#define VTO92(vp) ((struct o9fid *)(vp)->v_data)
+#define VTO9(vp) ((struct o9fid *)(vp)->v_data)
 #define VFSTOO9FS(mp) ((struct o9fs *)((mp)->mnt_data))
 
-
-#define	O9FS_VERSION9P	"9P2000"
-#define	O9FS_MAXWELEM	16
-
 enum {
 	Offtype	= 4,
 	Offtag	= 5,
 #define O9FS_OEXEC	3		/* execute, == read but check execute permission */
 #define O9FS_OTRUNC	16		/* or'ed in (except for exec), truncate file first */
 
-#define O9FS_DIRMAX		(sizeof(struct o9fsstat)+65535U)	/* max length of o9fsstat structure */
+#define O9FS_DIRMAX		(sizeof(struct o9stat)+65535U)	/* max length of o9fsstat structure */
 
 /* hack */
 #define M_O9FS M_TEMP
 	long n;
 	u_char *p;
 	int nwname, nwqid;
-	struct o9fsqid *nqid;
+	struct o9qid *nqid;
 	DIN();
 
 	if (fid == NULL) {
 
 	if (newfid == NULL) {
 		DBG("cloning fid %d\n", fid->fid);
-		newfid = o9fs_xgetfid(fs);
+		newfid = o9fs_getfid(fs);
 		newfid->mode = fid->mode;
 		newfid->qid = fid->qid;
 		newfid->offset = fid->offset;
 	}
 
 	if (name != NULL) {
-		p = putstring(fs->outbuf + Minhd + 4 + 4 + 2, name);
+		p = o9fs_putstr(fs->outbuf + Minhd + 4 + 4 + 2, name);
 		nwname = 1;
 	}
 
 	O9FS_PBIT32(fs->outbuf, n);
 	n = o9fs_mio(fs, n);
 	if (n <= 0) {
-		o9fs_xputfid(fs, newfid);
+		o9fs_putfid(fs, newfid);
 		DRET();
 		return NULL;
 	}
 	return newfid;
 }
 
-struct o9fsstat *
+struct o9stat *
 o9fs_stat(struct o9fs *fs, struct o9fid *fid)
 {
 	long n, nstat;
-	struct o9fsstat *stat;
+	struct o9stat *stat;
 	DIN();
 
 	if (fid == NULL) {
 }
 	
 uint32_t
-o9fs_rdwr2(struct o9fs *fs, struct o9fid *f, uint8_t type, uint32_t len, uint64_t off)
+o9fs_rdwr(struct o9fs *fs, struct o9fid *f, uint8_t type, uint32_t len, uint64_t off)
 {
 	u_char *p;
 	long n;
  * Both mode and perm are in Plan 9 convention.
  */
 int
-o9fs_opencreate2(struct o9fs *fs, struct o9fid *fid, uint8_t type, uint8_t mode, uint32_t perm, char *name)
+o9fs_opencreate(struct o9fs *fs, struct o9fid *fid, uint8_t type, uint8_t mode, uint32_t perm, char *name)
 {
 	long n;
 	u_char *p;
 			DRET();
 			return -1;
 		}
-		p = putstring(p, name);
+		p = o9fs_putstr(p, name);
 		O9FS_PBIT32(p, perm);
 		p += 4;
 	}
+/* TODO: this whole file should be removed */
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
 static char nullstring[] = "";
 
 u_int
-o9fs_convM2D(u_char *buf, u_int nbuf, struct o9fsstat *d, char *strs)
+o9fs_convM2D(u_char *buf, u_int nbuf, struct o9stat *d, char *strs)
 {
 	u_char *p, *ebuf;
 	char *sv[5];
 /* o9fs_subr.c */
 void	o9fs_dump(u_char *, long);
-char	*putstring(char *, char *);
-char	*getstring(char *);
+char	*o9fs_putstr(char *, char *);
+char	*o9fs_getstr(char *);
 int		o9fs_allocvp(struct mount *, struct o9fid *, struct vnode **, u_long);
-struct	o9fid *o9fs_xgetfid(struct o9fs *);
-void	o9fs_xputfid(struct o9fs *, struct o9fid *);
+struct	o9fid *o9fs_getfid(struct o9fs *);
+void	o9fs_putfid(struct o9fs *, struct o9fid *);
 int		o9fs_ptoumode(int);
 int		o9fs_utopmode(int);
 int		o9fs_uflags2omode(int);
 uint16_t	o9fs_tag(void);
 
 /* o9fs_9p.c */
-uint32_t	o9fs_rdwr2(struct o9fs *, struct o9fid *, uint8_t, uint32_t, uint64_t);
-int		o9fs_opencreate2(struct o9fs *, struct o9fid *, uint8_t, uint8_t, uint32_t, char *);
+uint32_t	o9fs_rdwr(struct o9fs *, struct o9fid *, uint8_t, uint32_t, uint64_t);
+int		o9fs_opencreate(struct o9fs *, struct o9fid *, uint8_t, uint8_t, uint32_t, char *);
 struct	o9fid *o9fs_walk(struct o9fs *, struct o9fid *, struct o9fid *, char *);
 void	o9fs_clunkremove(struct o9fs *, struct o9fid *, uint8_t);
-struct	o9fsstat *o9fs_stat(struct o9fs *, struct o9fid *);
+struct	o9stat *o9fs_stat(struct o9fs *, struct o9fid *);
 
 /* o9fs_convM2D.c */
 int		o9fs_statcheck(u_char *, u_int);
-u_int	o9fs_convM2D(u_char *, u_int, struct o9fsstat *, char *);
+u_int	o9fs_convM2D(u_char *, u_int, struct o9stat *, char *);
 
 extern uint8_t verbose;
 extern struct vops o9fs_vops;
 }
 
 struct o9fid *
-o9fs_xgetfid(struct o9fs *fs)
+o9fs_getfid(struct o9fs *fs)
 {
 	struct o9fid *f;
 
 }
 
 void
-o9fs_xputfid(struct o9fs *fs, struct o9fid *f)
+o9fs_putfid(struct o9fs *fs, struct o9fid *f)
 {
 	if (f == NULL)
-		panic("o9fs_xputfid: cannot put a nil fid");
+		panic("o9fs_putfid: cannot put a nil fid");
 
 	TAILQ_REMOVE(&fs->activeq, f, next);
 	TAILQ_INSERT_TAIL(&fs->freeq, f, next);
 }
 
 char *
-putstring(char *buf, char *s)
+o9fs_putstr(char *buf, char *s)
 {
 	long n;
 
 }
 
 char *
-getstring(char *buf)
+o9fs_getstr(char *buf)
 {
 	long n;
 	char *s;
 {
 	struct o9fid *f;
 
-	f = VTO92(vp);
+	f = VTO9(vp);
 	if (vp == NULL || f == NULL) {
 		printf("vp %p fid %p\n",  vp, f);
 		return;
 	O9FS_PBIT8(p + Offtype, O9FS_TVERSION);
 	O9FS_PBIT16(p + Offtag, O9FS_NOTAG);
 	O9FS_PBIT32(p + Minhd, msize);
-	putstring(p + Minhd + 4, "9P2000");
+	o9fs_putstr(p + Minhd + 4, "9P2000");
 
 	n = o9fs_mio(fs, 19);
 	if (n <= 0)
 	O9FS_PBIT8(p + Offtype, O9FS_TAUTH);
 	O9FS_PBIT16(p + Offtag, o9fs_tag());
 
-	f = o9fs_xgetfid(fs);
+	f = o9fs_getfid(fs);
 	O9FS_PBIT32(p + Minhd, f->fid);
-	p = putstring(p + Minhd + 4, user);
-	p = putstring(p, aname);
+	p = o9fs_putstr(p + Minhd + 4, user);
+	p = o9fs_putstr(p, aname);
 	n = p - fs->outbuf;
 	O9FS_PBIT32(fs->outbuf, n);
 
 	n = o9fs_mio(fs, n);
 	if (n <= 0) {
-		o9fs_xputfid(fs, f);
+		o9fs_putfid(fs, f);
 		return NULL;
 	}
 	return f;
 	O9FS_PBIT8(p + Offtype, O9FS_TATTACH);
 	O9FS_PBIT16(p + Offtag, o9fs_tag());
 	
-	f = o9fs_xgetfid(fs);
+	f = o9fs_getfid(fs);
 	O9FS_PBIT32(p + Minhd, f->fid);
 	O9FS_PBIT32(p + Minhd + 4, afid ? afid->fid : -1);
-	p = putstring(p + Minhd + 4 + 4, user);
-	p = putstring(p, aname);
+	p = o9fs_putstr(p + Minhd + 4 + 4, user);
+	p = o9fs_putstr(p, aname);
 	
 	n = p - fs->outbuf;
 	O9FS_PBIT32(fs->outbuf, n);
 	n = o9fs_mio(fs, n);
 	if (n <= 0) {
-		o9fs_xputfid(fs, f);
+		o9fs_putfid(fs, f);
 		return NULL;
 	}
 
 	DIN();
 
 	fs = VFSTOO9FS(mp);
-	f = o9fs_walk(fs, VTO92(fs->vroot), NULL, NULL);
+	f = o9fs_walk(fs, VTO9(fs->vroot), NULL, NULL);
 	if (f == NULL) {
 		DRET();
 		return -1;
 	fs = VFSTOO9FS(mp);
 	fp = fs->servfp;
 	vp = fs->vroot;
-	f = VTO92(vp);
+	f = VTO9(vp);
 
 	if (mntflags & MNT_FORCE)
 		flags |= FORCECLOSE;
 	vp = ap->a_vp;
 	p = ap->a_p;
 	fs = VFSTOO9FS(vp->v_mount);
-	f = VTO92(vp);
+	f = VTO9(vp);
 
 	printvp(vp);
 
 		return -1;
 	}
 
-	if (o9fs_opencreate2(fs, nf, O9FS_TOPEN, ap->a_mode, 0, 0) < 0) {
+	if (o9fs_opencreate(fs, nf, O9FS_TOPEN, ap->a_mode, 0, 0) < 0) {
 		DBG("failed open\n");
-		o9fs_xputfid(fs, nf);
+		o9fs_putfid(fs, nf);
 		DRET();
 		return -1;
 	}
 	vap = ap->a_vap;
 	vpp = ap->a_vpp;
 
-	f = VTO92(dvp);
+	f = VTO9(dvp);
 	*vpp = NULL;
 
 	fs = VFSTOO9FS(dvp->v_mount);
 	/* BUG: old fid leakage */
 	nf = o9fs_walk(fs, f, NULL, NULL);
 	if (nf == NULL) {
-		o9fs_xputfid(fs, nf);
+		o9fs_putfid(fs, nf);
 		DRET();
 		return -1;
 	}
 
-	if (o9fs_opencreate2(fs, nf, O9FS_TCREATE, 0, o9fs_utopmode(vap->va_mode), cnp->cn_nameptr) < 0) {
-		o9fs_xputfid(fs, nf);
+	if (o9fs_opencreate(fs, nf, O9FS_TCREATE, 0, o9fs_utopmode(vap->va_mode), cnp->cn_nameptr) < 0) {
+		o9fs_putfid(fs, nf);
 		DRET();
 		return -1;
 	}
 	/* walk from parent dir to get an unopened fid, break create+open atomicity of 9P */
 	nf = o9fs_walk(fs, f, NULL, cnp->cn_nameptr);
 	if (nf == NULL) {
-		o9fs_xputfid(fs, nf);
+		o9fs_putfid(fs, nf);
 		DRET();
 		return -1;
 	}
 	ap = v;
 	vp = ap->a_vp;
 	uio = ap->a_uio;
-	f = VTO92(vp);
+	f = VTO9(vp);
 	fs = VFSTOO9FS(vp->v_mount);
 
 	if (uio->uio_offset < 0)
 	if (uio->uio_resid == 0)
 		return 0;
 
-	n = o9fs_rdwr2(fs, f, O9FS_TREAD, uio->uio_resid, uio->uio_offset);
+	n = o9fs_rdwr(fs, f, O9FS_TREAD, uio->uio_resid, uio->uio_offset);
 	if (n > 0)
 		return uiomove(fs->inbuf + Minhd + 4, n, uio);
 	return n;
 }
 
 static long
-dirpackage(u_char *buf, long ts, struct o9fsstat **d)
+dirpackage(u_char *buf, long ts, struct o9stat **d)
 {
 	char *s;
 	long ss, i, n, nn, m;
 	if (i != ts)
 		return -1;
 
-	*d = malloc(n * sizeof(struct o9fsstat) + ss, M_O9FS, M_WAITOK);
+	*d = malloc(n * sizeof(struct o9stat) + ss, M_O9FS, M_WAITOK);
 
 	/*
 	 * then convert all buffers
 	 */
-	s = (char*)*d + n * sizeof(struct o9fsstat);
+	s = (char*)*d + n * sizeof(struct o9stat);
 	nn = 0;
 	for (i = 0; i < ts; i += m) {
 		m = O9FS_BIT16SZ + O9FS_GBIT16((u_char*)&buf[i]);
 	struct uio *uio;
 	struct o9fid *f;
 	struct o9fs *fs;
-	struct o9fsstat *stat;
+	struct o9stat *stat;
 	struct dirent d;
 	u_char *buf, *nbuf;
 	uint32_t n, ts;
 	vp = ap->a_vp;
 	uio = ap->a_uio;
 	fs = VFSTOO9FS(vp->v_mount);
-	f = VTO92(vp);
+	f = VTO9(vp);
 	error = 0;
 
 	if (vp->v_type != VDIR) {
 	for (;;) {
 		nbuf = o9fsrealloc(buf, ts+O9FS_DIRMAX-n, ts+O9FS_DIRMAX);
 		buf = nbuf;
-		n = o9fs_rdwr2(fs, f, O9FS_TREAD, len, f->offset);
+		n = o9fs_rdwr(fs, f, O9FS_TREAD, len, f->offset);
 		if (n <= 0)
 			break;
 		memcpy(buf + ts, fs->inbuf + Minhd + 4, n);
 	ap = v;
 	vp = ap->a_vp;
 
-	o9fs_clunkremove(VFSTOO9FS(vp->v_mount), VTO92(vp), O9FS_TREMOVE);
+	o9fs_clunkremove(VFSTOO9FS(vp->v_mount), VTO9(vp), O9FS_TREMOVE);
 	DRET();
 	return 0;
 }
 	vp = ap->a_vp;
 	uio = ap->a_uio;
 	ioflag = ap->a_ioflag;
-	f = VTO92(vp);
+	f = VTO9(vp);
 	fs = VFSTOO9FS(vp->v_mount);
 	error = n = 0;
 
 
 	len = uio->uio_resid;
 	error = uiomove(fs->outbuf + Minhd + 4 + 8 + 4, len, uio);
-	n = o9fs_rdwr2(fs, f, O9FS_TWRITE, len, offset);
+	n = o9fs_rdwr(fs, f, O9FS_TWRITE, len, offset);
 	if (n < 0) {
 		DRET();
 		return -1;
 	islast = flags & ISLASTCN;
 
 	fs = VFSTOO9FS(dvp->v_mount);
-	parf = VTO92(dvp);			/* parent fid */
+	parf = VTO9(dvp);			/* parent fid */
 	error = 0;
 	*vpp = NULL;
 	path = NULL;
 	else {
 		path = malloc(cnp->cn_namelen, M_O9FS, M_WAITOK);
 		strlcpy(path, cnp->cn_nameptr, cnp->cn_namelen+1);
-		nf = o9fs_xgetfid(fs);
+		nf = o9fs_getfid(fs);
 	}
 	printvp(dvp);
 
 	struct vnode *vp;
 	struct vattr *vap;
 	struct o9fid *f;
-	struct o9fsstat *stat;
+	struct o9stat *stat;
 	struct o9fs *fs;
 	DIN();
 
 	ap = v;
 	vp = ap->a_vp;
 	vap = ap->a_vap;
-	f = VTO92(vp);
+	f = VTO9(vp);
 	fs = VFSTOO9FS(vp->v_mount);
 
 	if (f == NULL) {
 
 	ap = v;
 	vp = ap->a_vp;
-	f = VTO92(vp);
+	f = VTO9(vp);
 	if(!(vp->v_flag & VXLOCK))
 		vgone(vp);
 	DRET();
 	
 	ap = v;
 	vp = ap->a_vp;
-	f = VTO92(vp);
+	f = VTO9(vp);
 	printvp(vp);
 
 	/* TODO: Removed fids should not be clunked again */
 	o9fs_clunkremove(VFSTOO9FS(vp->v_mount), f, O9FS_TCLUNK);
-//	o9fs_xputfid(VFSTOO9FS(vp->v_mount), f);
+//	o9fs_putfid(VFSTOO9FS(vp->v_mount), f);
 	vp->v_data = NULL;
 	DRET();
 	return 0;