Reorganized NTFS driver header :

- Renamed Magic (bad !) to jump, and OemName to OEMID
- Created structures for BPB and EBPB and used them in BOOT_SECTOR one
- Added a field to BOOY_SECTOR structure
This is based on Technet doc and Alex Ionescu doc

svn path=/trunk/; revision=31483
This commit is contained in:
Pierre Schweitzer 2007-12-28 21:56:19 +00:00
parent 3a0687218d
commit df28dbd1ee
2 changed files with 49 additions and 37 deletions

View file

@ -20,7 +20,7 @@
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/fs/ntfs/fsctl.c
* FILE: drivers/filesystems/ntfs/fsctl.c
* PURPOSE: NTFS filesystem driver
* PROGRAMMER: Eric Kohl
* Updated by Valentin Verkhovsky 2003/09/12
@ -106,8 +106,8 @@ NtfsHasFileSystem(PDEVICE_OBJECT DeviceToMount)
TRUE);
if (NT_SUCCESS(Status))
{
DPRINT1("NTFS-identifier: [%.8s]\n", BootSector->OemName);
if (RtlCompareMemory(BootSector->OemName, "NTFS ", 8) != 8)
DPRINT1("NTFS-identifier: [%.8s]\n", BootSector->OEMID);
if (RtlCompareMemory(BootSector->OEMID, "NTFS ", 8) != 8)
{
Status = STATUS_UNRECOGNIZED_VOLUME;
}
@ -170,33 +170,33 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
}
/* Read data from the bootsector */
NtfsInfo->BytesPerSector = BootSector->BytesPerSector;
NtfsInfo->SectorsPerCluster = BootSector->SectorsPerCluster;
NtfsInfo->BytesPerCluster = BootSector->BytesPerSector * BootSector->SectorsPerCluster;
NtfsInfo->SectorCount = BootSector->SectorCount;
NtfsInfo->BytesPerSector = BootSector->BPB.BytesPerSector;
NtfsInfo->SectorsPerCluster = BootSector->BPB.SectorsPerCluster;
NtfsInfo->BytesPerCluster = BootSector->BPB.BytesPerSector * BootSector->BPB.SectorsPerCluster;
NtfsInfo->SectorCount = BootSector->EBPB.SectorCount;
NtfsInfo->MftStart.QuadPart = BootSector->MftLocation;
NtfsInfo->MftMirrStart.QuadPart = BootSector->MftMirrLocation;
NtfsInfo->SerialNumber = BootSector->SerialNumber;
if (BootSector->ClustersPerMftRecord > 0)
NtfsInfo->BytesPerFileRecord = BootSector->ClustersPerMftRecord * NtfsInfo->BytesPerCluster;
NtfsInfo->MftStart.QuadPart = BootSector->EBPB.MftLocation;
NtfsInfo->MftMirrStart.QuadPart = BootSector->EBPB.MftMirrLocation;
NtfsInfo->SerialNumber = BootSector->EBPB.SerialNumber;
if (BootSector->EBPB.ClustersPerMftRecord > 0)
NtfsInfo->BytesPerFileRecord = BootSector->EBPB.ClustersPerMftRecord * NtfsInfo->BytesPerCluster;
else
NtfsInfo->BytesPerFileRecord = 1 << (-BootSector->ClustersPerMftRecord);
NtfsInfo->BytesPerFileRecord = 1 << (-BootSector->EBPB.ClustersPerMftRecord);
//#ifndef NDEBUG
DbgPrint("Boot sector information:\n");
DbgPrint(" BytesPerSector: %hu\n", BootSector->BytesPerSector);
DbgPrint(" SectorsPerCluster: %hu\n", BootSector->SectorsPerCluster);
DbgPrint(" BytesPerSector: %hu\n", BootSector->BPB.BytesPerSector);
DbgPrint(" SectorsPerCluster: %hu\n", BootSector->BPB.SectorsPerCluster);
DbgPrint(" SectorCount: %I64u\n", BootSector->SectorCount);
DbgPrint(" SectorCount: %I64u\n", BootSector->EBPB.SectorCount);
DbgPrint(" MftStart: %I64u\n", BootSector->MftLocation);
DbgPrint(" MftMirrStart: %I64u\n", BootSector->MftMirrLocation);
DbgPrint(" MftStart: %I64u\n", BootSector->EBPB.MftLocation);
DbgPrint(" MftMirrStart: %I64u\n", BootSector->EBPB.MftMirrLocation);
DbgPrint(" ClustersPerMftRecord: %lx\n", BootSector->ClustersPerMftRecord);
DbgPrint(" ClustersPerIndexRecord: %lx\n", BootSector->ClustersPerIndexRecord);
DbgPrint(" ClustersPerMftRecord: %lx\n", BootSector->EBPB.ClustersPerMftRecord);
DbgPrint(" ClustersPerIndexRecord: %lx\n", BootSector->EBPB.ClustersPerIndexRecord);
DbgPrint(" SerialNumber: %I64x\n", BootSector->SerialNumber);
DbgPrint(" SerialNumber: %I64x\n", BootSector->EBPB.SerialNumber);
//#endif
ExFreePool(BootSector);

View file

@ -20,28 +20,40 @@
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
#include <pshpack1.h>
typedef struct _BOOT_SECTOR
typedef struct _BIOS_PARAMETERS_BLOCK
{
UCHAR Magic[3]; // 0x00
UCHAR OemName[8]; // 0x03
USHORT BytesPerSector; // 0x0B
UCHAR SectorsPerCluster; // 0x0D
UCHAR SectorsPerCluster; // 0x0D
UCHAR Unused0[7]; // 0x0E
UCHAR MediaId; // 0x15
UCHAR Unused1[2]; // 0x16
USHORT SectorsPerTrack;
USHORT Heads;
UCHAR Unused2[8];
UCHAR Unknown0[4]; /* always 80 00 80 00 */
ULONGLONG SectorCount;
ULONGLONG MftLocation;
ULONGLONG MftMirrLocation;
CHAR ClustersPerMftRecord;
UCHAR Unused3[3];
CHAR ClustersPerIndexRecord;
UCHAR Unused4[3];
USHORT SectorsPerTrack; // 0x18
USHORT Heads; // 0x1A
UCHAR Unused2[8]; // 0x1C
} BIOS_PARAMETERS_BLOCK, *PBIOS_PARAMETERS_BLOCK;
typedef struct _EXTENDED_BIOS_PARAMETERS_BLOCK
{
UCHAR Unknown[4]; // 0x24, always 80 00 80 00
ULONGLONG SectorCount; // 0x28
ULONGLONG MftLocation; // 0x30
ULONGLONG MftMirrLocation; // 0x38
CHAR ClustersPerMftRecord; // 0x40
UCHAR Unused3[3]; // 0x41
CHAR ClustersPerIndexRecord; // 0x44
UCHAR Unused4[3]; // 0x45
ULONGLONG SerialNumber; // 0x48
UCHAR BootCode[432]; // 0x50
UCHAR Checksum[4]; // 0x50
} EXTENDED_BIOS_PARAMETERS_BLOCK, *PEXTENDED_BIOS_PARAMETERS_BLOCK;
typedef struct _BOOT_SECTOR
{
UCHAR Jump[3]; // 0x00
UCHAR OEMID[8]; // 0x03
BIOS_PARAMETERS_BLOCK BPB;
EXTENDED_BIOS_PARAMETERS_BLOCK EBPB;
UCHAR BootStrap[426]; // 0x54
USHORT EndSector; // 0x1FE
} BOOT_SECTOR, *PBOOT_SECTOR;
#include <poppack.h>