Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/ufs/ufs/ufs_rename.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/ufs/ufs/ufs_rename.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.2.2.4 retrieving revision 1.3 diff -u -p -r1.2.2.4 -r1.3 --- src/sys/ufs/ufs/ufs_rename.c 2013/01/23 00:06:35 1.2.2.4 +++ src/sys/ufs/ufs/ufs_rename.c 2012/06/04 19:37:36 1.3 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_rename.c,v 1.2.2.4 2013/01/23 00:06:35 yamt Exp $ */ +/* $NetBSD: ufs_rename.c,v 1.3 2012/06/04 19:37:36 riastradh Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_rename.c,v 1.2.2.4 2013/01/23 00:06:35 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_rename.c,v 1.3 2012/06/04 19:37:36 riastradh Exp $"); #include #include @@ -321,11 +321,24 @@ ufs_gro_rename(struct mount *mp, kauth_c if ((nlink_t)VTOI(fvp)->i_nlink >= LINK_MAX) return EMLINK; + /* + * XXX There is a pile of logic here to handle a voodoo flag + * IN_RENAME. I think this is a vestige of days when the file + * system hackers didn't understand concurrency or race + * conditions; I believe it serves no useful function + * whatsoever. + */ + directory_p = (fvp->v_type == VDIR); KASSERT(directory_p == ((VTOI(fvp)->i_mode & IFMT) == IFDIR)); KASSERT((tvp == NULL) || (directory_p == (tvp->v_type == VDIR))); KASSERT((tvp == NULL) || (directory_p == ((VTOI(tvp)->i_mode & IFMT) == IFDIR))); + if (directory_p) { + if (VTOI(fvp)->i_flag & IN_RENAME) + return EINVAL; + VTOI(fvp)->i_flag |= IN_RENAME; + } reparent_p = (fdvp != tdvp); KASSERT(reparent_p == (VTOI(fdvp)->i_number != VTOI(tdvp)->i_number)); @@ -549,6 +562,8 @@ whymustithurtsomuch: VTOI(fvp)->i_nlink--; DIP_ASSIGN(VTOI(fvp), nlink, VTOI(fvp)->i_nlink); VTOI(fvp)->i_flag |= IN_CHANGE; + if (directory_p) + VTOI(fvp)->i_flag &=~ IN_RENAME; UFS_WAPBL_UPDATE(fvp, NULL, NULL, 0); arghmybrainhurts: @@ -556,6 +571,9 @@ arghmybrainhurts: ihateyou: fstrans_done(mp); + /* XXX UFS kludge -- get rid of me with IN_RENAME! */ + if (directory_p) + VTOI(fvp)->i_flag &=~ IN_RENAME; return error; } @@ -662,7 +680,7 @@ ufs_rename_recalculate_fulr(struct vnode /* * Guarantee we sha'n't go past the end of the buffer we got. * dirbuf is bp->b_data + (search_start & (iosize - 1)), and - * the valid range is [bp->b_data, bp->b_data + bp->b_bcount). + * the valid range is [bp->b_data, bp->b_data + bp->b_count). */ KASSERT((search_end - search_start) <= (bp->b_bcount - (search_start & (mp->mnt_stat.f_iosize - 1)))); @@ -688,7 +706,7 @@ ufs_rename_recalculate_fulr(struct vnode if (ep->d_ino == 0) goto next; /* Entry is unused. */ - if (ufs_rw32(ep->d_ino, needswap) == UFS_WINO) + if (ufs_rw32(ep->d_ino, needswap) == WINO) goto next; /* Entry is whiteout. */ if (fcnp->cn_namelen != ufs_direct_namlen(ep, dvp)) @@ -962,7 +980,7 @@ ufs_gro_genealogy(struct mount *mp, kaut KASSERT(!ufs_rmdired_p(vp)); /* Did we hit the root without finding fdvp? */ - if (VTOI(vp)->i_number == UFS_ROOTINO) { + if (VTOI(vp)->i_number == ROOTINO) { vput(vp); *intermediate_node_ret = NULL; return 0;