From 86e2d48bf9e2c729b4b9425320af0e8abc0d9b4c Mon Sep 17 00:00:00 2001 From: Fedor Uporov Date: Sun, 17 May 2020 14:03:13 +0000 Subject: [PATCH] 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. --- sys/fs/ext2fs/ext2_vnops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index 0e719a4a542..99d2043f498 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -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);