Author: ekohl
Date: Sat Jun 12 11:20:58 2010
New Revision: 47765
URL:
http://svn.reactos.org/svn/reactos?rev=47765&view=rev
Log:
[VFATLIB]
- Get rid of the hard-coded sector size as large sector (4KB) harddisks are already
available.
- When a partition is formatted, choose the FAT type according to the partition type. The
size of the partition does not matter here as it is up to the caller to set the right
partition type according to its size.
Modified:
trunk/reactos/lib/fslib/vfatlib/fat12.c
trunk/reactos/lib/fslib/vfatlib/fat16.c
trunk/reactos/lib/fslib/vfatlib/fat32.c
trunk/reactos/lib/fslib/vfatlib/vfatlib.c
trunk/reactos/lib/fslib/vfatlib/vfatlib.h
Modified: trunk/reactos/lib/fslib/vfatlib/fat12.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/fat12.c?…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/fat12.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/fat12.c [iso-8859-1] Sat Jun 12 11:20:58 2010
@@ -62,12 +62,12 @@
/* Allocate buffer for new bootsector */
NewBootSector = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap (),
0,
- SECTORSIZE);
+ BootSector->BytesPerSector);
if (NewBootSector == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the new bootsector */
- memset(NewBootSector, 0, SECTORSIZE);
+ memset(NewBootSector, 0, BootSector->BytesPerSector);
/* Copy FAT16 BPB to new bootsector */
memcpy((NewBootSector + 3),
@@ -82,7 +82,7 @@
NULL,
&IoStatusBlock,
NewBootSector,
- SECTORSIZE,
+ BootSector->BytesPerSector,
&FileOffset,
NULL);
if (!NT_SUCCESS(Status))
Modified: trunk/reactos/lib/fslib/vfatlib/fat16.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/fat16.c?…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/fat16.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/fat16.c [iso-8859-1] Sat Jun 12 11:20:58 2010
@@ -62,12 +62,12 @@
/* Allocate buffer for new bootsector */
NewBootSector = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
0,
- SECTORSIZE);
+ BootSector->BytesPerSector);
if (NewBootSector == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the new bootsector */
- memset(NewBootSector, 0, SECTORSIZE);
+ memset(NewBootSector, 0, BootSector->BytesPerSector);
/* Copy FAT16 BPB to new bootsector */
memcpy((NewBootSector + 3),
@@ -82,7 +82,7 @@
NULL,
&IoStatusBlock,
NewBootSector,
- SECTORSIZE,
+ BootSector->BytesPerSector,
&FileOffset,
NULL);
if (!NT_SUCCESS(Status))
Modified: trunk/reactos/lib/fslib/vfatlib/fat32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/fat32.c?…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/fat32.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/fat32.c [iso-8859-1] Sat Jun 12 11:20:58 2010
@@ -62,12 +62,12 @@
/* Allocate buffer for new bootsector */
NewBootSector = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
0,
- SECTORSIZE);
+ BootSector->BytesPerSector);
if (NewBootSector == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
/* Zero the new bootsector */
- memset(NewBootSector, 0, SECTORSIZE);
+ memset(NewBootSector, 0, BootSector->BytesPerSector);
/* Copy FAT32 BPB to new bootsector */
memcpy((NewBootSector + 3),
@@ -82,7 +82,7 @@
NULL,
&IoStatusBlock,
NewBootSector,
- SECTORSIZE,
+ BootSector->BytesPerSector,
&FileOffset,
NULL);
if (!NT_SUCCESS(Status))
@@ -97,14 +97,14 @@
/* Write backup boot sector */
if (BootSector->BootBackup != 0x0000)
{
- FileOffset.QuadPart = (ULONGLONG)((ULONG) BootSector->BootBackup *
SECTORSIZE);
+ FileOffset.QuadPart = (ULONGLONG)((ULONG)BootSector->BootBackup *
BootSector->BytesPerSector);
Status = NtWriteFile(FileHandle,
NULL,
NULL,
NULL,
&IoStatusBlock,
NewBootSector,
- SECTORSIZE,
+ BootSector->BytesPerSector,
&FileOffset,
NULL);
if (!NT_SUCCESS(Status))
Modified: trunk/reactos/lib/fslib/vfatlib/vfatlib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/vfatlib.…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/vfatlib.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/vfatlib.c [iso-8859-1] Sat Jun 12 11:20:58 2010
@@ -143,9 +143,9 @@
Callback (PROGRESS, 0, (PVOID)&Context.Percent);
}
- if (PartitionInfo.PartitionLength.QuadPart < (4200LL * 1024LL))
- {
- /* FAT12 (volume is smaller than 4.1MB) */
+ if (PartitionInfo.PartitionType == PARTITION_FAT_12)
+ {
+ /* FAT12 */
Status = Fat12Format(FileHandle,
&PartitionInfo,
&DiskGeometry,
@@ -154,9 +154,11 @@
ClusterSize,
&Context);
}
- else if (PartitionInfo.PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
- {
- /* FAT16 (volume is smaller than 512MB) */
+ else if (PartitionInfo.PartitionType == PARTITION_FAT_16 ||
+ PartitionInfo.PartitionType == PARTITION_HUGE ||
+ PartitionInfo.PartitionType == PARTITION_XINT13)
+ {
+ /* FAT16 */
Status = Fat16Format(FileHandle,
&PartitionInfo,
&DiskGeometry,
@@ -165,9 +167,10 @@
ClusterSize,
&Context);
}
- else
- {
- /* FAT32 (volume is 512MB or larger) */
+ else if (PartitionInfo.PartitionType == PARTITION_FAT32 ||
+ PartitionInfo.PartitionType == PARTITION_FAT32_XINT13)
+ {
+ /* FAT32 */
Status = Fat32Format(FileHandle,
&PartitionInfo,
&DiskGeometry,
@@ -175,6 +178,10 @@
QuickFormat,
ClusterSize,
&Context);
+ }
+ else
+ {
+ Status = STATUS_INVALID_PARAMETER;
}
NtClose(FileHandle);
Modified: trunk/reactos/lib/fslib/vfatlib/vfatlib.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/vfatlib.…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/vfatlib.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/vfatlib.h [iso-8859-1] Sat Jun 12 11:20:58 2010
@@ -18,8 +18,6 @@
#include "check/fat.h"
#include "check/file.h"
#include "check/check.h"
-
-#define SECTORSIZE 512
#include <pshpack1.h>
typedef struct _FAT16_BOOT_SECTOR