Fix last commit that broke lookup for dot with op DELETE.

Reviewed by: David Holland <dholland@netbsd.org>
This commit is contained in:
hannken 2012-03-16 08:39:54 +00:00
parent e04c99d5d7
commit 88f39ca44e
2 changed files with 44 additions and 33 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_lookup.c,v 1.68 2012/03/13 18:41:03 elad Exp $ */
/* $NetBSD: ext2fs_lookup.c,v 1.69 2012/03/16 08:39:54 hannken Exp $ */
/*
* Modified for NetBSD 1.2E
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.68 2012/03/13 18:41:03 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.69 2012/03/16 08:39:54 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -586,18 +586,26 @@ found:
results->ulr_count = 0;
else
results->ulr_count = results->ulr_offset - prevoff;
if (flags & ISDOTDOT)
VOP_UNLOCK(vdp); /* race to get the inode */
error = VFS_VGET(vdp->v_mount, foundino, &tdp);
if (flags & ISDOTDOT)
vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
if (error)
return (error);
if (dp->i_number == foundino) {
vref(vdp);
tdp = vdp;
} else {
if (flags & ISDOTDOT)
VOP_UNLOCK(vdp); /* race to get the inode */
error = VFS_VGET(vdp->v_mount, foundino, &tdp);
if (flags & ISDOTDOT)
vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
if (error)
return (error);
}
/*
* Write access to directory required to delete files.
*/
if ((error = VOP_ACCESS(vdp, VWRITE, cred)) != 0) {
vput(tdp);
if (dp->i_number == foundino)
vrele(tdp);
else
vput(tdp);
return (error);
}
/*
@ -611,15 +619,13 @@ found:
tdp, vdp, genfs_can_sticky(cred, dp->i_uid,
VTOI(tdp)->i_uid));
if (error) {
vput(tdp);
if (dp->i_number == foundino)
vrele(tdp);
else
vput(tdp);
return (EPERM);
}
}
if (dp->i_number == foundino) {
vref(vdp);
*vpp = vdp;
return (0);
}
*vpp = tdp;
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_lookup.c,v 1.112 2012/03/13 18:41:14 elad Exp $ */
/* $NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.112 2012/03/13 18:41:14 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_ffs.h"
@ -532,19 +532,27 @@ found:
results->ulr_count = 0;
else
results->ulr_count = results->ulr_offset - prevoff;
if (flags & ISDOTDOT)
VOP_UNLOCK(vdp); /* race to get the inode */
error = VFS_VGET(vdp->v_mount, foundino, &tdp);
if (flags & ISDOTDOT)
vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
if (error)
goto out;
if (dp->i_number == foundino) {
vref(vdp);
tdp = vdp;
} else {
if (flags & ISDOTDOT)
VOP_UNLOCK(vdp); /* race to get the inode */
error = VFS_VGET(vdp->v_mount, foundino, &tdp);
if (flags & ISDOTDOT)
vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY);
if (error)
goto out;
}
/*
* Write access to directory required to delete files.
*/
error = VOP_ACCESS(vdp, VWRITE, cred);
if (error) {
vput(tdp);
if (dp->i_number == foundino)
vrele(tdp);
else
vput(tdp);
goto out;
}
/*
@ -558,17 +566,14 @@ found:
tdp, vdp, genfs_can_sticky(cred, dp->i_uid,
VTOI(tdp)->i_uid));
if (error) {
vput(tdp);
if (dp->i_number == foundino)
vrele(tdp);
else
vput(tdp);
error = EPERM;
goto out;
}
}
if (dp->i_number == foundino) {
vref(vdp);
*vpp = vdp;
error = 0;
goto out;
}
*vpp = tdp;
error = 0;
goto out;