• Konstantin Komarov's avatar
    fs/ntfs3: Taking DOS names into account during link counting · 110b24eb
    Konstantin Komarov authored
    When counting and checking hard links in an ntfs file record,
    
      struct MFT_REC {
        struct NTFS_RECORD_HEADER rhdr; // 'FILE'
        __le16 seq;		    // 0x10: Sequence number for this record.
    >>  __le16 hard_links;	// 0x12: The number of hard links to record.
        __le16 attr_off;	// 0x14: Offset to attributes.
      ...
    
    the ntfs3 driver ignored short names (DOS names), causing the link count
    to be reduced by 1 and messages to be output to dmesg.
    
    For Windows, such a situation is a minor error, meaning chkdsk does not report
    errors on such a volume, and in the case of using the /f switch, it silently
    corrects them, reporting that no errors were found. This does not affect
    the consistency of the file system.
    
    Nevertheless, the behavior in the ntfs3 driver is incorrect and
    changes the content of the file system. This patch should fix that.
    
    PS: most likely, there has been a confusion of concepts
    MFT_REC::hard_links and inode::__i_nlink.
    
    Fixes: 82cae269 ("fs/ntfs3: Add initialization of super block")
    Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
    Cc: stable@vger.kernel.org
    110b24eb
record.c 13.2 KB