Reactos

[FREELDR] Make the NTFS filename comparison conforming to NTLDR/BOOTMGR (#8021)

When an NTFS partition is created with Windows and modified with Linux
(see below), the NTLDR/BOOTMGR will compare the file names ignoring the
case of the files, while FreeLdr does not and the same hack is on Btrfs
file name comparison.

This PR is necessary because the case of the file names on registry, etc.
may not always be consistent!

How to reproduce:
- Try to install Windows with NTFS and install FreeLdr on it;
- Try to modify Windows partition on Linux like creating/copying some new files;
- Try to boot with FreeLdr (it will fail if the hive file path case is different
than the actual file path);
- Try to boot with NTLDR/BOOTMGR (it will work finally reaching the desktop).

authored by

Daniel Victor and committed by
GitHub
22d077f9 2ab01e73

+9 -11
+9 -11
boot/freeldr/freeldr/lib/fs/ntfs.c
··· 525 525 if (strlen(FileName) != EntryFileNameLength) 526 526 return FALSE; 527 527 528 - /* Do case-sensitive compares for Posix file names. */ 529 - if (IndexEntry->FileName.FileNameType == NTFS_FILE_NAME_POSIX) 530 - { 531 - for (i = 0; i < EntryFileNameLength; i++) 532 - if (EntryFileName[i] != FileName[i]) 533 - return FALSE; 534 - } 535 - else 528 + /* 529 + * Always perform case-insensitive comparison for file names. 530 + * This is necessary, because when modifying e.g. on Linux a Windows NTFS 531 + * partition formatted with Windows itself, the NTLDR/BOOTMGR will boot 532 + * normally ignoring the case of the paths. 533 + */ 534 + for (i = 0; i < EntryFileNameLength; i++) 536 535 { 537 - for (i = 0; i < EntryFileNameLength; i++) 538 - if (tolower(EntryFileName[i]) != tolower(FileName[i])) 539 - return FALSE; 536 + if (tolower(EntryFileName[i]) != tolower(FileName[i])) 537 + return FALSE; 540 538 } 541 539 542 540 return TRUE;