[BACK]Return to ufs_rename.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / ufs / ufs

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/ufs/ufs/ufs_rename.c between version 1.5 and 1.5.2.4

version 1.5, 2012/06/04 20:13:47 version 1.5.2.4, 2017/12/03 11:39:22
Line 39  __KERNEL_RCSID(0, "$NetBSD$");
Line 39  __KERNEL_RCSID(0, "$NetBSD$");
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/buf.h>  #include <sys/buf.h>
 #include <sys/errno.h>  #include <sys/errno.h>
 #include <sys/fstrans.h>  
 #include <sys/kauth.h>  #include <sys/kauth.h>
 #include <sys/mount.h>  #include <sys/mount.h>
 #include <sys/namei.h>  #include <sys/namei.h>
Line 271  ufs_gro_remove_check_permitted(struct mo
Line 270  ufs_gro_remove_check_permitted(struct mo
  * XXX Copypasta from ufs_vnops.c.  Kill!   * XXX Copypasta from ufs_vnops.c.  Kill!
  */   */
 static const struct dirtemplate mastertemplate = {  static const struct dirtemplate mastertemplate = {
         0,      12,             DT_DIR, 1,      ".",          0,      12,                     DT_DIR, 1,      ".",
         0,      DIRBLKSIZ - 12, DT_DIR, 2,      ".."          0,      UFS_DIRBLKSIZ - 12,     DT_DIR, 2,      ".."
 };  };
   
 /*  /*
Line 334  ufs_gro_rename(struct mount *mp, kauth_c
Line 333  ufs_gro_rename(struct mount *mp, kauth_c
          * Commence hacking of the data on disk.           * Commence hacking of the data on disk.
          */           */
   
         fstrans_start(mp, FSTRANS_SHARED);  
         error = UFS_WAPBL_BEGIN(mp);          error = UFS_WAPBL_BEGIN(mp);
         if (error)          if (error)
                 goto ihateyou;                  goto ihateyou;
Line 471  ufs_gro_rename(struct mount *mp, kauth_c
Line 469  ufs_gro_rename(struct mount *mp, kauth_c
                                     "hard-linked directory");                                      "hard-linked directory");
                         VTOI(tvp)->i_nlink = 0;                          VTOI(tvp)->i_nlink = 0;
                         DIP_ASSIGN(VTOI(tvp), nlink, 0);                          DIP_ASSIGN(VTOI(tvp), nlink, 0);
                         error = UFS_TRUNCATE(tvp, (off_t)0, IO_SYNC, cred);                          (void) UFS_TRUNCATE(tvp, (off_t)0, IO_SYNC, cred);
                         if (error)  
                                 goto whymustithurtsomuch;  
                 }                  }
         }          }
   
Line 555  arghmybrainhurts:
Line 551  arghmybrainhurts:
         UFS_WAPBL_END(mp);          UFS_WAPBL_END(mp);
   
 ihateyou:  ihateyou:
         fstrans_done(mp);  
         return error;          return error;
 }  }
   
Line 586  ufs_rename_ulr_overlap_p(const struct uf
Line 581  ufs_rename_ulr_overlap_p(const struct uf
          * of the free space for an entry that we are about to fill.           * of the free space for an entry that we are about to fill.
          */           */
         to_start = tulr->ulr_offset;          to_start = tulr->ulr_offset;
         KASSERT(tulr->ulr_count < (MAXDIRSIZE - to_start));          KASSERT(tulr->ulr_count < (UFS_MAXDIRSIZE - to_start));
         to_end = (to_start + tulr->ulr_count);          to_end = (to_start + tulr->ulr_count);
   
         return          return
Line 644  ufs_rename_recalculate_fulr(struct vnode
Line 639  ufs_rename_recalculate_fulr(struct vnode
   
         /* Find the bounds of the search.  */          /* Find the bounds of the search.  */
         search_start = tulr->ulr_offset;          search_start = tulr->ulr_offset;
         KASSERT(fulr->ulr_reclen < (MAXDIRSIZE - fulr->ulr_offset));          KASSERT(fulr->ulr_reclen < (UFS_MAXDIRSIZE - fulr->ulr_offset));
         search_end = (fulr->ulr_offset + fulr->ulr_reclen);          search_end = (fulr->ulr_offset + fulr->ulr_reclen);
   
         /* Compaction must happen only within a directory block. (*)  */          /* Compaction must happen only within a directory block. (*)  */
Line 688  ufs_rename_recalculate_fulr(struct vnode
Line 683  ufs_rename_recalculate_fulr(struct vnode
                 if (ep->d_ino == 0)                  if (ep->d_ino == 0)
                         goto next;      /* Entry is unused.  */                          goto next;      /* Entry is unused.  */
   
                 if (ufs_rw32(ep->d_ino, needswap) == WINO)                  if (ufs_rw32(ep->d_ino, needswap) == UFS_WINO)
                         goto next;      /* Entry is whiteout.  */                          goto next;      /* Entry is whiteout.  */
   
                 if (fcnp->cn_namelen != ufs_direct_namlen(ep, dvp))                  if (fcnp->cn_namelen != ufs_direct_namlen(ep, dvp))
Line 786  ufs_gro_remove(struct mount *mp, kauth_c
Line 781  ufs_gro_remove(struct mount *mp, kauth_c
         KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);          KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
         KASSERT(cnp->cn_nameiop == DELETE);          KASSERT(cnp->cn_nameiop == DELETE);
   
         fstrans_start(mp, FSTRANS_SHARED);  
         error = UFS_WAPBL_BEGIN(mp);          error = UFS_WAPBL_BEGIN(mp);
         if (error)          if (error)
                 goto out0;                  goto out0;
Line 800  ufs_gro_remove(struct mount *mp, kauth_c
Line 794  ufs_gro_remove(struct mount *mp, kauth_c
         VN_KNOTE(vp, (VTOI(vp)->i_nlink? NOTE_LINK : NOTE_DELETE));          VN_KNOTE(vp, (VTOI(vp)->i_nlink? NOTE_LINK : NOTE_DELETE));
   
 out1:   UFS_WAPBL_END(mp);  out1:   UFS_WAPBL_END(mp);
 out0:   fstrans_done(mp);  out0:
         return error;          return error;
 }  }
   
Line 878  ufs_read_dotdot(struct vnode *vp, kauth_
Line 872  ufs_read_dotdot(struct vnode *vp, kauth_
         KASSERT(ino_ret != NULL);          KASSERT(ino_ret != NULL);
         KASSERT(vp->v_type == VDIR);          KASSERT(vp->v_type == VDIR);
   
         error = vn_rdwr(UIO_READ, vp, &dirbuf, sizeof dirbuf, (off_t)0,          error = ufs_bufio(UIO_READ, vp, &dirbuf, sizeof dirbuf, (off_t)0,
             UIO_SYSSPACE, IO_NODELOCKED, cred, NULL, NULL);              IO_NODELOCKED, cred, NULL, NULL);
         if (error)          if (error)
                 return error;                  return error;
   
Line 930  ufs_gro_genealogy(struct mount *mp, kaut
Line 924  ufs_gro_genealogy(struct mount *mp, kaut
     struct vnode **intermediate_node_ret)      struct vnode **intermediate_node_ret)
 {  {
         struct vnode *vp, *dvp;          struct vnode *vp, *dvp;
         ino_t dotdot_ino;          ino_t dotdot_ino = 0;   /* XXX: gcc */
         int error;          int error;
   
         KASSERT(mp != NULL);          KASSERT(mp != NULL);
Line 962  ufs_gro_genealogy(struct mount *mp, kaut
Line 956  ufs_gro_genealogy(struct mount *mp, kaut
                 KASSERT(!ufs_rmdired_p(vp));                  KASSERT(!ufs_rmdired_p(vp));
   
                 /* Did we hit the root without finding fdvp?  */                  /* Did we hit the root without finding fdvp?  */
                 if (VTOI(vp)->i_number == ROOTINO) {                  if (VTOI(vp)->i_number == UFS_ROOTINO) {
                         vput(vp);                          vput(vp);
                         *intermediate_node_ret = NULL;                          *intermediate_node_ret = NULL;
                         return 0;                          return 0;
Line 983  ufs_gro_genealogy(struct mount *mp, kaut
Line 977  ufs_gro_genealogy(struct mount *mp, kaut
                 }                  }
   
                 /* Neither -- keep ascending the family tree.  */                  /* Neither -- keep ascending the family tree.  */
                   error = vcache_get(mp, &dotdot_ino, sizeof(dotdot_ino), &dvp);
                 /*                  vput(vp);
                  * Unlock vp so that we can lock the parent, but keep  
                  * vp referenced until after we have found the parent,  
                  * so that dotdot_ino will not be recycled.  
                  *  
                  * XXX This guarantees that vp's inode number will not  
                  * be recycled, but why can't dotdot_ino be recycled?  
                  */  
                 VOP_UNLOCK(vp);  
                 error = VFS_VGET(mp, dotdot_ino, &dvp);  
                 vrele(vp);  
                 if (error)                  if (error)
                         return error;                          return error;
                   error = vn_lock(dvp, LK_EXCLUSIVE);
                   if (error) {
                           vrele(dvp);
                           return error;
                   }
   
                 KASSERT(dvp != NULL);                  KASSERT(dvp != NULL);
                 KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);                  KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.5.2.4

CVSweb <webmaster@jp.NetBSD.org>