Skip to content

Commit 1918c10

Browse files
fs/ntfs3: Correct hard links updating when dealing with DOS names
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent 6a799c9 commit 1918c10

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

fs/ntfs3/record.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,20 @@ bool mi_remove_attr(struct ntfs_inode *ni, struct mft_inode *mi,
535535
return false;
536536

537537
if (ni && is_attr_indexed(attr)) {
538-
le16_add_cpu(&ni->mi.mrec->hard_links, -1);
539-
ni->mi.dirty = true;
538+
u16 links = le16_to_cpu(ni->mi.mrec->hard_links);
539+
struct ATTR_FILE_NAME *fname =
540+
attr->type != ATTR_NAME ?
541+
NULL :
542+
resident_data_ex(attr,
543+
SIZEOF_ATTRIBUTE_FILENAME);
544+
if (fname && fname->type == FILE_NAME_DOS) {
545+
/* Do not decrease links count deleting DOS name. */
546+
} else if (!links) {
547+
/* minor error. Not critical. */
548+
} else {
549+
ni->mi.mrec->hard_links = cpu_to_le16(links - 1);
550+
ni->mi.dirty = true;
551+
}
540552
}
541553

542554
used -= asize;

0 commit comments

Comments
 (0)