Index: nfs/nfs_serv.c
===================================================================
RCS file: /cvs/src/sys/nfs/nfs_serv.c,v
retrieving revision 1.56
diff -u -p -r1.56 nfs_serv.c
--- nfs/nfs_serv.c 14 Jun 2008 22:44:07 -0000 1.56
+++ nfs/nfs_serv.c 15 Jun 2008 04:36:23 -0000
@@ -2222,7 +2211,7 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
int v3 = (nfsd->nd_flag & ND_NFSV3);
char *cp2;
struct mbuf *mb, *mreq;
- struct vnode *vp, *dirp = (struct vnode *)0;
+ struct vnode *vp, *dirp = NULL;
struct vattr dirfor, diraft;
nfsfh_t nfh;
fhandle_t *fhp;
@@ -2241,7 +2230,7 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
procp);
else {
vrele(dirp);
- dirp = (struct vnode *)0;
+ dirp = NULL;
}
}
if (error) {
@@ -2255,31 +2244,35 @@ nfsrv_rmdir(nfsd, slp, procp, mrq)
vp = nd.ni_vp;
if (vp->v_type != VDIR) {
error = ENOTDIR;
- goto out;
+ goto abort;
}
/*
* No rmdir "." please.
*/
if (nd.ni_dvp == vp) {
error = EINVAL;
- goto out;
+ goto abort;
}
/*
* The root of a mounted filesystem cannot be deleted.
*/
- if (vp->v_flag & VROOT)
+ if (vp->v_flag & VROOT) {
error = EBUSY;
-out:
- if (!error) {
- error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
- } else {
- VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vput(vp);
+ goto abort;
}
+
+ error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
+ goto out;
+
+abort:
+ /* the following code is only reached via error cases above */
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ vput(vp);
+out:
if (dirp) {
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
vrele(dirp);