Commits

iru  committed 96e4d67

Improve on name resolution

  • Participants
  • Parent commits 2b6bf0e

Comments (0)

Files changed (4)

 {
 	struct o9fsfcall tx, rx;
 
-	DBG("fidclunk: enter\n");
+	DIN();
 	tx.type = O9FS_TCLUNK;
 	tx.fid = f->fid;
 	o9fs_rpc(fs, &tx, &rx);
 	f->opened = 0;
 	f->mode = -1;
 	o9fs_putfid(fs, f);
-	DBG("fidclunk: return\n");
+	DRET();
 }
 
 struct o9fid *
 {
 	long n;
 	u_char *p;
-	int nwname;
+	int nwname, nwqid;
+	struct o9fsqid *nqid;
 	DIN();
 
 	if (fid == NULL) {
 		newfid->offset = fid->offset;
 		nwname = 0;
 		p += Minhd + 4 + 4 + 2;		/* Advance after nwname, which will be filled later */
-	} else {
-		if (name == NULL) {
-			printf("o9fs_walk: cloning with empty name\n");
-			DRET();
-			return NULL;
-		}
-		p = putstring(p + Minhd + 4 + 4 + 2, name);
+	}
+
+	if (name != NULL) {
+		p = putstring(fs->outbuf + Minhd + 4 + 4 + 2, name);
 		nwname = 1;
 	}
+
 	O9FS_PBIT32(fs->outbuf + Minhd + 4, newfid->fid);
-	o9fs_dump(fs->outbuf, p - fs->outbuf);
 	O9FS_PBIT16(fs->outbuf + Minhd + 4 + 4, nwname);
 
 	n = p - fs->outbuf;
-	o9fs_dump(fs->outbuf, n);
 	O9FS_PBIT32(fs->outbuf, n);
 	n = o9fs_mio(fs, n);
 	if (n <= 0) {
 		DRET();
 		return NULL;
 	}
+
+	nwqid = O9FS_GBIT16(fs->inbuf + Minhd);
+	if (nwqid < nwname) {
+		printf("nwqid < nwname\n");
+		return NULL;
+	}
+
+	newfid->qid.type = O9FS_GBIT8(fs->inbuf + Minhd + 2);
+	newfid->qid.vers = O9FS_GBIT32(fs->inbuf + Minhd + 2 + 1);
+	newfid->qid.path = O9FS_GBIT64(fs->inbuf + Minhd + 2 + 1 + 4);
+
 	DRET();
-	return fid;
+	return newfid;
 }
 
 struct o9fsfid*
 		return error;
 	}
 
-	if (f->qid.type == O9FS_QTDIR){
-		DBG("o9fs_fid2vnode: isdir\n");
+	if (f->qid.type == O9FS_QTDIR)
 		vp->v_type = VDIR;
-	} else
+	else
 		vp->v_type = VREG;
 
 	vp->v_data = f;

File o9fs_vfsops.c

 
 	p = curproc;
 	fs = VFSTOO9FS(mp);
-	DBG("fs %p\n", fs);
-	DBG("fs->vroot %p %d\n", fs->vroot, VTO92(fs->vroot)->fid);
 
 	f = o9fs_walk(fs, VTO92(fs->vroot), NULL, NULL);
 	if (f == NULL) {
 		DRET();
 		return -1;
 	}
-	DBG("cloned root\n");
+	DBG("cloned root to %d\n", f->fid);
 
 	if (error = o9fs_allocvp(fs->mp, f, &vp, VROOT)) {
 		DRET();
 		return error;
 	}
+	vp->v_data = f;
 	vp->v_flag = VROOT;
 	vp->v_type = VDIR;
 	*vpp = vp; 

File o9fs_vnops.c

 	struct o9fs *fs;
 	struct o9fid *f, *parf;
 	int flags, op, islast, error;
+	long n;
+	char *path;
 	
 	DIN();
 	ap = v;
 	parf = VTO92(dvp);			/* parent fid */
 	error = 0;
 	*vpp = NULL;
+
+	DBG("parent (%p) fid %d\n", parf, parf->fid);
 	
 	if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
 		DBG("dot\n");
 		return 0;
 	}
 
-	DBG("name is %s\n", cnp->cn_nameptr);
+	path = malloc(cnp->cn_namelen, M_O9FS, M_WAITOK);
+	strlcpy(path, cnp->cn_nameptr, cnp->cn_namelen+1);
 
-	f = o9fs_walk(fs, parf, o9fs_xgetfid(fs), cnp->cn_nameptr);
+	/* todo: watch for fid leakage */
+	f = o9fs_walk(fs, parf, o9fs_xgetfid(fs), path);
 	if (f == NULL) {
 		DBG("%s not found\n", cnp->cn_nameptr);
 		if (islast && (op == CREATE || op == RENAME)) {
 o9fs_inactive(void *v)
 {
 	struct vop_inactive_args *ap;
-	DBG("inactive: enter\n");
-	DBG("inactive: return\n");
+	DIN();
+	DRET();
 	return 0;
 }