Author: fsu
Date: Sun May 17 14:03:13 2020
New Revision: 361134
URL: https://svnweb.freebsd.org/changeset/base/361134

Log:
  Fix incorrect inode link count check in case of rename.
  
  The check was incorrect because the directory inode link count have
  min value 2 after dir_nlink extfs feature introduction.

Modified:
  head/sys/fs/ext2fs/ext2_vnops.c

Modified: head/sys/fs/ext2fs/ext2_vnops.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_vnops.c     Sun May 17 14:00:54 2020        
(r361133)
+++ head/sys/fs/ext2fs/ext2_vnops.c     Sun May 17 14:03:13 2020        
(r361134)
@@ -1018,10 +1018,11 @@ abortit:
                 */
                ext2_dec_nlink(xp);
                if (doingdirectory) {
-                       if (--xp->i_nlink != 0)
+                       if (xp->i_nlink > 2)
                                panic("ext2_rename: linked directory");
                        error = ext2_truncate(tvp, (off_t)0, IO_SYNC,
                            tcnp->cn_cred, tcnp->cn_thread);
+                       xp->i_nlink = 0;
                }
                xp->i_flag |= IN_CHANGE;
                vput(tvp);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to