diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2013-06-05 18:26:07 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2013-06-05 18:26:07 +0000 |
commit | 532e3b6a0c874e594e7947bf17134e61193750e6 (patch) | |
tree | 8968ae2c549aa285c0344cc126911068a7310204 /sys/miscfs/fuse | |
parent | 09e0efda189ed3bb0be7e760712b56d8e4e99f4d (diff) |
rename should be working now, from Sylvestre Gallon
Diffstat (limited to 'sys/miscfs/fuse')
-rw-r--r-- | sys/miscfs/fuse/fuse_lookup.c | 13 | ||||
-rw-r--r-- | sys/miscfs/fuse/fuse_vnops.c | 67 |
2 files changed, 27 insertions, 53 deletions
diff --git a/sys/miscfs/fuse/fuse_lookup.c b/sys/miscfs/fuse/fuse_lookup.c index d3eaacea075..6060bc40d59 100644 --- a/sys/miscfs/fuse/fuse_lookup.c +++ b/sys/miscfs/fuse/fuse_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_lookup.c,v 1.1 2013/06/03 15:50:56 tedu Exp $ */ +/* $OpenBSD: fuse_lookup.c,v 1.2 2013/06/05 18:26:06 tedu Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -50,6 +50,7 @@ fusefs_lookup(void *v) struct ucred *cred = cnp->cn_cred; int flags; int nameiop = cnp->cn_nameiop; + int wantparent; int error = 0; uint64_t nid; @@ -59,6 +60,7 @@ fusefs_lookup(void *v) dp = VTOI(vdp); fmp = (struct fusefs_mnt *)dp->ufs_ino.i_ump; lockparent = flags & LOCKPARENT; + wantparent = flags & (LOCKPARENT | WANTPARENT); DPRINTF("lookup path %s\n", cnp->cn_pnbuf); DPRINTF("lookup file %s\n", cnp->cn_nameptr); @@ -132,7 +134,7 @@ fusefs_lookup(void *v) cnp->cn_flags |= SAVENAME; } - if (nameiop == RENAME && (flags & ISLASTCN)) { + if (nameiop == RENAME && wantparent && (flags & ISLASTCN)) { /* * Write access to directory required to delete files. */ @@ -144,6 +146,13 @@ fusefs_lookup(void *v) goto out; } + error = VFS_VGET(fmp->mp, nid, &tdp); + if (error) + goto out; + + tdp->v_type = IFTOVT(fbuf->fb_vattr.va_mode); + VTOI(tdp)->vtype = tdp->v_type; + *vpp = tdp; cnp->cn_flags |= SAVENAME; goto out; diff --git a/sys/miscfs/fuse/fuse_vnops.c b/sys/miscfs/fuse/fuse_vnops.c index 7a6d0313167..2f92d80e8db 100644 --- a/sys/miscfs/fuse/fuse_vnops.c +++ b/sys/miscfs/fuse/fuse_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_vnops.c,v 1.1 2013/06/03 15:50:56 tedu Exp $ */ +/* $OpenBSD: fuse_vnops.c,v 1.2 2013/06/05 18:26:06 tedu Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -1018,44 +1018,15 @@ abortit: * If source and dest are the same, do nothing. */ if (tvp == fvp) { - if (fvp->v_type == VDIR) { - error = EINVAL; - goto abortit; - } - - DPRINTF("THE SAME!!!\n"); - /* Release destination completely. */ - VOP_ABORTOP(tdvp, tcnp); - vput(tdvp); - vput(tvp); - - /* Delete source. */ - vrele(fdvp); - vrele(fvp); - fcnp->cn_flags &= ~MODMASK; - fcnp->cn_flags |= LOCKPARENT | LOCKLEAF; - if ((fcnp->cn_flags & SAVESTART) == 0) - panic("fusefs_rename: lost from startdir"); - fcnp->cn_nameiop = DELETE; - vfs_relookup(fdvp, &fvp, fcnp); - return (VOP_REMOVE(fdvp, fvp, fcnp)); + error = 0; + goto abortit; } - /* */ if ((error = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, p)) != 0) goto abortit; dp = VTOI(fdvp); ip = VTOI(fvp); - fmp = (struct fusefs_mnt *)ip->ufs_ino.i_ump; - /* - *If fuse connection down RENAME undef - */ - if (!fmp->sess_init || (fmp->undef_op & UNDEF_RMDIR)) { - VOP_UNLOCK(fvp, 0, p); - error = ENOSYS; - goto abortit; - } /* * Be sure we are not renaming ".", "..", or an alias of ".". This @@ -1064,15 +1035,6 @@ abortit: * doesn't work if the ".." entry is missing. */ if (ip->vtype == VDIR) { - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc); - if (!error && tvp) - error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred, - tcnp->cn_proc); - if (error) { - VOP_UNLOCK(fvp, 0, p); - error = EACCES; - goto abortit; - } /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ @@ -1085,14 +1047,13 @@ abortit: goto abortit; } } - vrele(fdvp); VN_KNOTE(fdvp, NOTE_WRITE); /* XXX right place? */ - /* - * When the target exists, both the directory - * and target vnodes are returned locked. - */ - dp = VTOI(tdvp); + if (!fmp->sess_init || (fmp->undef_op & UNDEF_RENAME)) { + error = ENOSYS; + VOP_UNLOCK(fvp, 0, p); + goto abortit; + } fbuf = fb_setup(FUSEFDSIZE + fcnp->cn_namelen + tcnp->cn_namelen + 2, dp->ufs_ino.i_number, FBT_RENAME, p); @@ -1102,6 +1063,7 @@ abortit: memcpy(fbuf->fb_dat + fcnp->cn_namelen + 1, tcnp->cn_nameptr, tcnp->cn_namelen); fbuf->fb_dat[fcnp->cn_namelen + tcnp->cn_namelen + 1] = '\0'; + fbuf->fb_io_ino = VTOI(tdvp)->ufs_ino.i_number; error = fb_queue(fmp->dev, fbuf); @@ -1116,12 +1078,15 @@ abortit: } VN_KNOTE(fvp, NOTE_RENAME); - VOP_UNLOCK(fvp, 0, p); - if (dp) - vput(fdvp); + VOP_UNLOCK(fvp, 0, p); + if (tdvp == tvp) + vrele(tdvp); + else + vput(tdvp); + vrele(fdvp); + vrele(fvp); - vrele(ap->a_fvp); return (error); } |