Commits

Anonymous committed 74f3aac

Fix lookup to open fid.

  • Participants
  • Parent commits 7f7d716

Comments (0)

Files changed (3)

 	struct		o9fsqid	qid;
 	uint64_t	offset;
 
+	struct		o9fid *parent;
 	int			ref;
 	TAILQ_ENTRY(o9fid) next;
 };
 		TAILQ_REMOVE(&fs->freeq, f, next);
 	}
 
-	f->ref = 0;
+	f->ref = 1;
+	f->parent = NULL;
 	f->offset = 0;
 	f->mode = -1;
 	f->iounit = 0;

File o9fs_vnops.c

 		DRET();
 		return -1;
 	}
-	free(f, M_O9FS);
 
 	if (o9fs_opencreate2(fs, nf, O9FS_TOPEN, ap->a_mode, 0, 0) < 0) {
+		o9fs_xputfid(fs, nf);
 		DRET();
 		return -1;
 	}
 
+	nf->parent = f;
 	vp->v_data = nf; /* walk has set other properties */
 
 out:
 	vp = ap->a_vp;
 	f = VTO92(vp);
 
+	printvp(vp);
 	if (f == NULL) {
 		DRET();
 		return 0;
 	}
 
 	fs = VFSTOO9FS(vp->v_mount);
-//	o9fs_clunk(fs, f);
+	o9fs_clunk(fs, f);
+	f->ref = 0;
 	DRET();
 	return 0;
 }
 
 	path = NULL;
 	DBG("name %s\n", cnp->cn_nameptr);
-	if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
-		DBG("dot\n");
-		vref(dvp);
-		*vpp = dvp;
-		DRET();
-		return 0;
+
+	if (parf->mode != -1) {
+		DBG("fid %d already opened! parent %d\n", parf->fid, parf->parent->fid);
+		f = parf;
+		parf = parf->parent;
+	}
+
+	/* On dot, clone */
+	if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.')
 		nf = NULL;
-	} else {
+	else {
 		path = malloc(cnp->cn_namelen, M_O9FS, M_WAITOK);
 		strlcpy(path, cnp->cn_nameptr, cnp->cn_namelen+1);
 		nf = o9fs_xgetfid(fs);
 		VOP_UNLOCK(dvp, 0, p);
 		flags |= PDIRUNLOCK;
 	}
-	
+
 	if(f->qid.type == O9FS_QTDIR)
 		(*vpp)->v_type = VDIR;
 	else
 	return 0;
 }
 
-
-
 int
 o9fs_getattr(void *v)
 {
 o9fs_inactive(void *v)
 {
 	struct vop_inactive_args *ap;
-	struct o9fid *f;
+	struct vnode *vp;
 	DIN();
-
-	ap = v;
-	VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
-	f = VTO92(ap->a_vp);
-	f->ref--;
-	printvp(ap->a_vp);
-
-	/* TODO: is this an appropriate approach? */
-	if (f->ref == 0)
-		o9fs_clunk(VFSTOO9FS(ap->a_vp->v_mount), f);
-	
 	DRET();
 	return 0;
 }
 {
 	struct vop_reclaim_args *ap;
 	struct vnode *vp;
+	struct o9fid *f;
 	DIN();
 	
 	ap = v;
 	vp = ap->a_vp;
-
+	f = VTO92(vp);
+	printvp(vp);
+	vp->v_data = NULL;
 	DRET();
 	return 0;
 }