summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorHyunchul Lee <hyc.lee@gmail.com>2026-04-28 10:34:10 +0900
committerNamjae Jeon <linkinjeon@kernel.org>2026-04-30 07:05:46 +0900
commit4ebcf3f94924d54706de0d2492c80944d85410fd (patch)
tree4d9ce367804bba1d987eee9d968f783b9a7c2579 /fs
parentd986ba0329dcca102e227995371135c9bbcefb6b (diff)
ntfs: drop nlink once for WIN32/DOS aliases
NTFS could store a filename as paired WIN32 and DOS $FILE_NAME attributes for directories. But ntfs_delete() deleted both attributes for unlinking a directory, but it also called drop_nlink() for each attributes. This could trigger warnings when unlinking directories. Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ntfs/namei.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 10894de519c3..96c450e62efc 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -945,7 +945,8 @@ search:
ni_mrec = actx->base_mrec ? actx->base_mrec : actx->mrec;
ni_mrec->link_count = cpu_to_le16(le16_to_cpu(ni_mrec->link_count) - 1);
- drop_nlink(VFS_I(ni));
+ if (!S_ISDIR(VFS_I(ni)->i_mode))
+ drop_nlink(VFS_I(ni));
mark_mft_record_dirty(ni);
if (looking_for_dos_name) {
@@ -956,6 +957,13 @@ search:
}
/*
+ * For directories, Drop VFS nlink only when mft record link count
+ * becomes zero. Because we fixes VFS nlink to 1 for directories.
+ */
+ if (S_ISDIR(VFS_I(ni)->i_mode) && !le16_to_cpu(ni_mrec->link_count))
+ drop_nlink(VFS_I(ni));
+
+ /*
* If hard link count is not equal to zero then we are done. In other
* case there are no reference to this inode left, so we should free all
* non-resident attributes and mark all MFT record as not in use.
@@ -1221,7 +1229,8 @@ static int __ntfs_link(struct ntfs_inode *ni, struct ntfs_inode *dir_ni,
}
/* Increment hard links count. */
ni_mrec->link_count = cpu_to_le16(le16_to_cpu(ni_mrec->link_count) + 1);
- inc_nlink(VFS_I(ni));
+ if (!S_ISDIR(vi->i_mode))
+ inc_nlink(VFS_I(ni));
/* Done! */
mark_mft_record_dirty(ni);