/*
* 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
/* FIXME: MFTContext is never freed. */
PNTFS_ATTR_CONTEXT MFTContext;
ULONG DeviceId;
+ PUCHAR TemporarySector;
} NTFS_VOLUME_INFO;
PNTFS_VOLUME_INFO NtfsVolumes[MAX_FDS];
ret = ArcSeek(Volume->DeviceId, &Position, SeekAbsolute);
if (ret != ESUCCESS)
return FALSE;
- ReadLength = min(Length, Volume->BootSector.BytesPerSector - (Offset % Volume->BootSector.BytesPerSector));
- ret = ArcRead(Volume->DeviceId, Buffer, ReadLength, &Count);
- if (ret != ESUCCESS || Count != ReadLength)
+ 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));
+
+ //
+ // Copy interesting data
+ //
+ RtlCopyMemory(Buffer,
+ &Volume->TemporarySector[Offset % Volume->BootSector.BytesPerSector],
+ ReadLength);
//
// Move to unfilled buffer part
return ENOENT;
}
+ FsSetDeviceSpecific(*FileId, FileHandle);
return ESUCCESS;
}
return NULL;
}
+ //
+ // 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
//