Index: ufs/ufs/inode.h =================================================================== RCS file: /home/ncvs/src/sys/ufs/ufs/inode.h,v retrieving revision 1.51 diff -u -r1.51 inode.h --- ufs/ufs/inode.h 10 Oct 2006 09:20:54 -0000 1.51 +++ ufs/ufs/inode.h 13 Apr 2008 13:09:06 -0000 @@ -83,7 +83,6 @@ doff_t i_endoff; /* End of useful stuff in directory. */ doff_t i_diroff; /* Offset in dir, where we found last entry. */ doff_t i_offset; /* Offset of free space in directory. */ - ino_t i_ino; /* Inode number of found directory. */ u_int32_t i_reclen; /* Size of found directory entry. */ union { Index: ufs/ufs/ufs_lookup.c =================================================================== RCS file: /home/ncvs/src/sys/ufs/ufs/ufs_lookup.c,v retrieving revision 1.87 diff -u -r1.87 ufs_lookup.c --- ufs/ufs/ufs_lookup.c 11 Apr 2008 09:44:25 -0000 1.87 +++ ufs/ufs/ufs_lookup.c 13 Apr 2008 13:09:06 -0000 @@ -155,7 +155,7 @@ struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - ino_t saved_ino; + ino_t ino; int ltype; bp = NULL; @@ -176,6 +176,7 @@ * we watch for a place to put the new file in * case it doesn't already exist. */ + ino = 0; i_diroff = dp->i_diroff; slotstatus = FOUND; slotfreespace = slotsize = slotneeded = 0; @@ -358,7 +359,7 @@ numdirpasses--; goto notfound; } - dp->i_ino = ep->d_ino; + ino = ep->d_ino; dp->i_reclen = ep->d_reclen; goto found; } @@ -496,12 +497,12 @@ dp->i_count = 0; else dp->i_count = dp->i_offset - prevoff; - if (dp->i_number == dp->i_ino) { + if (dp->i_number == ino) { VREF(vdp); *vpp = vdp; return (0); } - if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, + if ((error = VFS_VGET(vdp->v_mount, ino, LK_EXCLUSIVE, &tdp)) != 0) return (error); /* @@ -527,15 +528,16 @@ * regular file, or empty directory. */ if (nameiop == RENAME && (flags & ISLASTCN)) { + ASSERT_VOP_ELOCKED(vdp, __FUNCTION__); if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread))) return (error); /* * Careful about locking second inode. * This can only occur if the target is ".". */ - if (dp->i_number == dp->i_ino) + if (dp->i_number == ino) return (EISDIR); - if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, + if ((error = VFS_VGET(vdp->v_mount, ino, LK_EXCLUSIVE, &tdp)) != 0) return (error); *vpp = tdp; @@ -565,15 +567,13 @@ pdp = vdp; if (flags & ISDOTDOT) { ltype = VOP_ISLOCKED(pdp); - saved_ino = dp->i_ino; VOP_UNLOCK(pdp, 0); /* race to get the inode */ - error = VFS_VGET(pdp->v_mount, saved_ino, - cnp->cn_lkflags, &tdp); + error = VFS_VGET(pdp->v_mount, ino, cnp->cn_lkflags, &tdp); vn_lock(pdp, ltype | LK_RETRY); if (error) return (error); *vpp = tdp; - } else if (dp->i_number == dp->i_ino) { + } else if (dp->i_number == ino) { VREF(vdp); /* we want ourself, ie "." */ /* * When we lookup "." we still can be asked to lock it @@ -588,8 +588,7 @@ } *vpp = vdp; } else { - error = VFS_VGET(pdp->v_mount, dp->i_ino, - cnp->cn_lkflags, &tdp); + error = VFS_VGET(pdp->v_mount, ino, cnp->cn_lkflags, &tdp); if (error) return (error); *vpp = tdp;