Commits

iru  committed c652e14

Fix qid parsing in o9fs_opencreate2

  • Participants
  • Parent commits 335fd9d

Comments (0)

Files changed (5)

 #define DIN() DBG(">>>\n")
 #define DRET() DBG("<<<\n")
 
+#define printvp(x) do{\
+	printf("%s: ", __FUNCTION__);\
+	_printvp((x));\
+}while(0)
+
 #define nelem(a) (sizeof(a) / sizeof(*a))
 
 struct o9fsqid {
 		DRET();
 		return -1;
 	}
-	
-	fid->qid.type = O9FS_GBIT8(fs->inbuf + Minhd + 2);
-	fid->qid.vers = O9FS_GBIT32(fs->inbuf + Minhd + 2 + 1);
-	fid->qid.path = O9FS_GBIT64(fs->inbuf + Minhd + 2 + 1 + 4);
+
+	fid->qid.type = O9FS_GBIT8(fs->inbuf + Minhd);
+	fid->qid.vers = O9FS_GBIT32(fs->inbuf + Minhd + 1);
+	fid->qid.path = O9FS_GBIT64(fs->inbuf + Minhd + 1 + 4);
 	fid->mode = omode;
 	return 0;
 }

File o9fs_extern.h

 int		o9fs_uflags2omode(int);
 void	o9fs_freefcall(struct o9fsfcall *);
 void	o9fs_freestat(struct o9fsstat *);
-void	printvp(struct vnode *);
+void	_printvp(struct vnode *);
 
 /* o9fs_9p.c */
 struct	o9fsstat *o9fs_fstat(struct o9fs *, struct o9fsfid *);
 }
 
 void
-printvp(struct vnode *vp)
+_printvp(struct vnode *vp)
 {
 	struct o9fid *f;
 
 	if (vp == NULL || VTO92(vp) == NULL)
 		return;
 	f = VTO92(vp);
-	printf("[%p] %p fid %d ref %d qid (%.16llx %lu %d) mode %d\n", vp, f, f->fid, f->ref, f->qid.path, f->qid.vers, f->qid.type);
+	printf("[%p] %p fid %d ref %d qid (%.16llx %lu %d) mode %d\n", vp, f, f->fid, f->ref, f->qid.path, f->qid.vers, f->qid.type, mode);
 }

File o9fs_vnops.c

 	fs = VFSTOO9FS(vp->v_mount);
 	f = VTO92(vp);
 
+	printvp(vp);
 	if (o9fs_opencreate2(fs, f, O9FS_TOPEN, ap->a_mode, 0, 0) < 0) {
 		DBG("failed\n");
 		DRET();
 	long n, ts;
 	int error, *eofflag, i, msize;
 	int64_t len;
+	DIN();
 
-	DBG("readdir: enter\n");
 	ap = v;
 	vp = ap->a_vp;
 	uio = ap->a_uio;
 	eofflag = ap->a_eofflag;
 	fs = VFSTOO9FS(vp->v_mount);
-	f = VTO9(vp);
+	f = VTO92(vp);
 	error = i = n = 0;
 
-	if (uio->uio_resid == 0)
+	if (uio->uio_resid == 0) {
+		DRET();
 		return 0;
+	}
 
 	len = uio->uio_resid;
 	msize = fs->msize - O9FS_IOHDRSZ;
 	free(buf, M_O9FS);
 
 	if (ts == 0 && n < 0) {
-		DBG("readdir: return\n");
+		DRET();
 		return -1;
 	}
 	for (i = 0; i < ts; i++) {
 		d.d_reclen = DIRENT_SIZE(&d);
 		error = uiomove(&d, d.d_reclen, uio);
 		if (error) {
-			printf("readdir: uiomove error\n");
-			DBG("readdir: return\n");
+			DBG("uiomove error\n");
+			DRET():
 			return -1;
 		}
 	}
-	DBG("readdir: return\n");
+	DRET();
 	return 0;
 }