svn commit: r362097 - stable/12/sys/fs/ext2fs

Fedor Uporov fsu at FreeBSD.org
Fri Jun 12 13:53:50 UTC 2020


Author: fsu
Date: Fri Jun 12 13:53:50 2020
New Revision: 362097
URL: https://svnweb.freebsd.org/changeset/base/362097

Log:
  MFC r361134:
  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:
  stable/12/sys/fs/ext2fs/ext2_vnops.c

Modified: stable/12/sys/fs/ext2fs/ext2_vnops.c
==============================================================================
--- stable/12/sys/fs/ext2fs/ext2_vnops.c	Fri Jun 12 13:52:11 2020	(r362096)
+++ stable/12/sys/fs/ext2fs/ext2_vnops.c	Fri Jun 12 13:53:50 2020	(r362097)
@@ -1016,10 +1016,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);


More information about the svn-src-stable mailing list