properly decrement reference count on directory
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 20 Oct 1990 07:26:43 +0000 (23:26 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Sat, 20 Oct 1990 07:26:43 +0000 (23:26 -0800)
SCCS-vsn: sys/ufs/ffs/ffs_vnops.c 7.46
SCCS-vsn: sys/ufs/ffs/ufs_vnops.c 7.46
SCCS-vsn: sys/ufs/lfs/lfs_vnops.c 7.46
SCCS-vsn: sys/ufs/ufs/ufs_vnops.c 7.46

usr/src/sys/ufs/ffs/ffs_vnops.c
usr/src/sys/ufs/ffs/ufs_vnops.c
usr/src/sys/ufs/lfs/lfs_vnops.c
usr/src/sys/ufs/ufs/ufs_vnops.c

index 30ee93c..638ce74 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ffs_vnops.c 7.45 (Berkeley) %G%
+ *     @(#)ffs_vnops.c 7.46 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1036,6 +1036,16 @@ ufs_rename(fndp, tndp)
                }
                if (error = dirrewrite(dp, ip, tndp))
                        goto bad;
                }
                if (error = dirrewrite(dp, ip, tndp))
                        goto bad;
+               /*
+                * If the target directory is in the same
+                * directory as the source directory,
+                * decrement the link count on the parent
+                * of the target directory.
+                */
+                if (doingdirectory && !newparent) {
+                       dp->i_nlink--;
+                       dp->i_flag |= ICHG;
+               }
                vput(ITOV(dp));
                /*
                 * Adjust the link count of the target to
                vput(ITOV(dp));
                /*
                 * Adjust the link count of the target to
index 89fb338..146a105 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_vnops.c 7.45 (Berkeley) %G%
+ *     @(#)ufs_vnops.c 7.46 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1036,6 +1036,16 @@ ufs_rename(fndp, tndp)
                }
                if (error = dirrewrite(dp, ip, tndp))
                        goto bad;
                }
                if (error = dirrewrite(dp, ip, tndp))
                        goto bad;
+               /*
+                * If the target directory is in the same
+                * directory as the source directory,
+                * decrement the link count on the parent
+                * of the target directory.
+                */
+                if (doingdirectory && !newparent) {
+                       dp->i_nlink--;
+                       dp->i_flag |= ICHG;
+               }
                vput(ITOV(dp));
                /*
                 * Adjust the link count of the target to
                vput(ITOV(dp));
                /*
                 * Adjust the link count of the target to
index 9e19cbc..9ed00fd 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)lfs_vnops.c 7.45 (Berkeley) %G%
+ *     @(#)lfs_vnops.c 7.46 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1036,6 +1036,16 @@ ufs_rename(fndp, tndp)
                }
                if (error = dirrewrite(dp, ip, tndp))
                        goto bad;
                }
                if (error = dirrewrite(dp, ip, tndp))
                        goto bad;
+               /*
+                * If the target directory is in the same
+                * directory as the source directory,
+                * decrement the link count on the parent
+                * of the target directory.
+                */
+                if (doingdirectory && !newparent) {
+                       dp->i_nlink--;
+                       dp->i_flag |= ICHG;
+               }
                vput(ITOV(dp));
                /*
                 * Adjust the link count of the target to
                vput(ITOV(dp));
                /*
                 * Adjust the link count of the target to
index 89fb338..146a105 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ufs_vnops.c 7.45 (Berkeley) %G%
+ *     @(#)ufs_vnops.c 7.46 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1036,6 +1036,16 @@ ufs_rename(fndp, tndp)
                }
                if (error = dirrewrite(dp, ip, tndp))
                        goto bad;
                }
                if (error = dirrewrite(dp, ip, tndp))
                        goto bad;
+               /*
+                * If the target directory is in the same
+                * directory as the source directory,
+                * decrement the link count on the parent
+                * of the target directory.
+                */
+                if (doingdirectory && !newparent) {
+                       dp->i_nlink--;
+                       dp->i_flag |= ICHG;
+               }
                vput(ITOV(dp));
                /*
                 * Adjust the link count of the target to
                vput(ITOV(dp));
                /*
                 * Adjust the link count of the target to