Author: hpoussin Date: Wed May 26 21:58:54 2010 New Revision: 47365
URL: http://svn.reactos.org/svn/reactos?rev=47365&view=rev Log: [freeldr] Repair NTFS driver. ReactOS is now able to boot (again) from NTFS partitions
Modified: trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c
Modified: trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/ntf... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/ntfs.c [iso-8859-1] Wed May 26 21:58:54 2010 @@ -1,6 +1,7 @@ /* * FreeLoader NTFS support * Copyright (C) 2004 Filip Navara xnavara@volny.cz + * Copyright (C) 2009-2010 Hervé Poussineau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,6 +38,7 @@ /* FIXME: MFTContext is never freed. */ PNTFS_ATTR_CONTEXT MFTContext; ULONG DeviceId; + PUCHAR TemporarySector; } NTFS_VOLUME_INFO;
PNTFS_VOLUME_INFO NtfsVolumes[MAX_FDS]; @@ -147,10 +149,17 @@ ret = ArcSeek(Volume->DeviceId, &Position, SeekAbsolute); if (ret != ESUCCESS) return FALSE; + ret = ArcRead(Volume->DeviceId, Volume->TemporarySector, Volume->BootSector.BytesPerSector, &Count); + if (ret != ESUCCESS || Count != Volume->BootSector.BytesPerSector) + return FALSE; ReadLength = min(Length, Volume->BootSector.BytesPerSector - (Offset % Volume->BootSector.BytesPerSector)); - ret = ArcRead(Volume->DeviceId, Buffer, ReadLength, &Count); - if (ret != ESUCCESS || Count != ReadLength) - return FALSE; + + // + // Copy interesting data + // + RtlCopyMemory(Buffer, + &Volume->TemporarySector[Offset % Volume->BootSector.BytesPerSector], + ReadLength);
// // Move to unfilled buffer part @@ -792,6 +801,7 @@ return ENOENT; }
+ FsSetDeviceSpecific(*FileId, FileHandle); return ESUCCESS; }
@@ -933,6 +943,18 @@ }
// + // Keep room to read partial sectors + // + Volume->TemporarySector = MmHeapAlloc(Volume->BootSector.BytesPerSector); + if (!Volume->TemporarySector) + { + FileSystemError("Failed to allocate memory."); + MmHeapFree(Volume->MasterFileTable); + MmHeapFree(Volume); + return NULL; + } + + // // Keep device id // Volume->DeviceId = DeviceId;