Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Hyunchul Lee and committed by
Namjae Jeon
4ebcf3f9 d986ba03

+11 -2
+11 -2
fs/ntfs/namei.c
··· 945 945 946 946 ni_mrec = actx->base_mrec ? actx->base_mrec : actx->mrec; 947 947 ni_mrec->link_count = cpu_to_le16(le16_to_cpu(ni_mrec->link_count) - 1); 948 - drop_nlink(VFS_I(ni)); 948 + if (!S_ISDIR(VFS_I(ni)->i_mode)) 949 + drop_nlink(VFS_I(ni)); 949 950 950 951 mark_mft_record_dirty(ni); 951 952 if (looking_for_dos_name) { ··· 955 954 ntfs_attr_reinit_search_ctx(actx); 956 955 goto search; 957 956 } 957 + 958 + /* 959 + * For directories, Drop VFS nlink only when mft record link count 960 + * becomes zero. Because we fixes VFS nlink to 1 for directories. 961 + */ 962 + if (S_ISDIR(VFS_I(ni)->i_mode) && !le16_to_cpu(ni_mrec->link_count)) 963 + drop_nlink(VFS_I(ni)); 958 964 959 965 /* 960 966 * If hard link count is not equal to zero then we are done. In other ··· 1229 1221 } 1230 1222 /* Increment hard links count. */ 1231 1223 ni_mrec->link_count = cpu_to_le16(le16_to_cpu(ni_mrec->link_count) + 1); 1232 - inc_nlink(VFS_I(ni)); 1224 + if (!S_ISDIR(vi->i_mode)) 1225 + inc_nlink(VFS_I(ni)); 1233 1226 1234 1227 /* Done! */ 1235 1228 mark_mft_record_dirty(ni);