fs/ntfs3: Correct hard links updating when dealing with DOS names

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
Konstantin Komarov 2023-11-24 11:26:31 +03:00
parent 6a799c928b
commit 1918c10e13
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6
1 changed files with 14 additions and 2 deletions

View File

@ -535,8 +535,20 @@ bool mi_remove_attr(struct ntfs_inode *ni, struct mft_inode *mi,
return false;
if (ni && is_attr_indexed(attr)) {
le16_add_cpu(&ni->mi.mrec->hard_links, -1);
ni->mi.dirty = true;
u16 links = le16_to_cpu(ni->mi.mrec->hard_links);
struct ATTR_FILE_NAME *fname =
attr->type != ATTR_NAME ?
NULL :
resident_data_ex(attr,
SIZEOF_ATTRIBUTE_FILENAME);
if (fname && fname->type == FILE_NAME_DOS) {
/* Do not decrease links count deleting DOS name. */
} else if (!links) {
/* minor error. Not critical. */
} else {
ni->mi.mrec->hard_links = cpu_to_le16(links - 1);
ni->mi.dirty = true;
}
}
used -= asize;