Skip to content

Commit 22d077f

Browse files
authored
[FREELDR] Make the NTFS filename comparison conforming to NTLDR/BOOTMGR (reactos#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).
1 parent 2ab01e7 commit 22d077f

File tree

1 file changed

+9
-11
lines changed
  • boot/freeldr/freeldr/lib/fs

1 file changed

+9
-11
lines changed

boot/freeldr/freeldr/lib/fs/ntfs.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -525,18 +525,16 @@ static BOOLEAN NtfsCompareFileName(PCHAR FileName, PNTFS_INDEX_ENTRY IndexEntry)
525525
if (strlen(FileName) != EntryFileNameLength)
526526
return FALSE;
527527

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++)
536535
{
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;
540538
}
541539

542540
return TRUE;

0 commit comments

Comments
 (0)