mirror of
https://github.com/reactos/reactos.git
synced 2025-07-05 22:31:22 +00:00
* lib/fmifs
* lib/fslib/fvatlib Convert Win32 types to native Add PROGRESS and DONE callbacks. svn path=/trunk/; revision=8330
This commit is contained in:
parent
2b197a92e6
commit
574b42db31
5 changed files with 290 additions and 138 deletions
|
@ -52,8 +52,9 @@ CalcVolumeSerialNumber(VOID)
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat12WriteBootSector(IN HANDLE FileHandle,
|
Fat12WriteBootSector (IN HANDLE FileHandle,
|
||||||
IN PFAT16_BOOT_SECTOR BootSector)
|
IN PFAT16_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -61,9 +62,9 @@ Fat12WriteBootSector(IN HANDLE FileHandle,
|
||||||
LARGE_INTEGER FileOffset;
|
LARGE_INTEGER FileOffset;
|
||||||
|
|
||||||
/* Allocate buffer for new bootsector */
|
/* Allocate buffer for new bootsector */
|
||||||
NewBootSector = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
|
NewBootSector = (PUCHAR)RtlAllocateHeap (RtlGetProcessHeap (),
|
||||||
0,
|
0,
|
||||||
SECTORSIZE);
|
SECTORSIZE);
|
||||||
if (NewBootSector == NULL)
|
if (NewBootSector == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
|
|
||||||
|
@ -96,14 +97,17 @@ Fat12WriteBootSector(IN HANDLE FileHandle,
|
||||||
/* Free the new boot sector */
|
/* Free the new boot sector */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
|
|
||||||
|
UpdateProgress (Context, 1);
|
||||||
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat12WriteFAT(IN HANDLE FileHandle,
|
Fat12WriteFAT (IN HANDLE FileHandle,
|
||||||
ULONG SectorOffset,
|
IN ULONG SectorOffset,
|
||||||
IN PFAT16_BOOT_SECTOR BootSector)
|
IN PFAT16_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -146,6 +150,8 @@ Fat12WriteFAT(IN HANDLE FileHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, 1);
|
||||||
|
|
||||||
/* Zero the begin of the buffer */
|
/* Zero the begin of the buffer */
|
||||||
memset(Buffer, 0, 3);
|
memset(Buffer, 0, 3);
|
||||||
|
|
||||||
|
@ -155,12 +161,12 @@ Fat12WriteFAT(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
/* Zero some sectors of the FAT */
|
/* Zero some sectors of the FAT */
|
||||||
FileOffset.QuadPart = (SectorOffset + BootSector->ReservedSectors + i) * BootSector->BytesPerSector;
|
FileOffset.QuadPart = (SectorOffset + BootSector->ReservedSectors + i) * BootSector->BytesPerSector;
|
||||||
Size = (ULONG)BootSector->FATSectors - i;
|
if (((ULONG)BootSector->FATSectors - i) <= Sectors)
|
||||||
if (Size > Sectors)
|
|
||||||
{
|
{
|
||||||
Size = Sectors;
|
Sectors = (ULONG)BootSector->FATSectors - i;
|
||||||
}
|
}
|
||||||
Size *= BootSector->BytesPerSector;
|
|
||||||
|
Size = Sectors * BootSector->BytesPerSector;
|
||||||
Status = NtWriteFile(FileHandle,
|
Status = NtWriteFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -176,6 +182,8 @@ Fat12WriteFAT(IN HANDLE FileHandle,
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
|
@ -186,8 +194,9 @@ Fat12WriteFAT(IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat12WriteRootDirectory(IN HANDLE FileHandle,
|
Fat12WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
IN PFAT16_BOOT_SECTOR BootSector)
|
IN PFAT16_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -227,12 +236,12 @@ Fat12WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
/* Zero some sectors of the root directory */
|
/* Zero some sectors of the root directory */
|
||||||
FileOffset.QuadPart = (FirstRootDirSector + i) * BootSector->BytesPerSector;
|
FileOffset.QuadPart = (FirstRootDirSector + i) * BootSector->BytesPerSector;
|
||||||
Size = RootDirSectors - i;
|
|
||||||
if (Size > Sectors)
|
if ((RootDirSectors - i) <= Sectors)
|
||||||
{
|
{
|
||||||
Size = Sectors;
|
Sectors = RootDirSectors - i;
|
||||||
}
|
}
|
||||||
Size *= BootSector->BytesPerSector;
|
Size = Sectors * BootSector->BytesPerSector;
|
||||||
|
|
||||||
Status = NtWriteFile(FileHandle,
|
Status = NtWriteFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -249,6 +258,7 @@ Fat12WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
UpdateProgress (Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
|
@ -259,13 +269,13 @@ Fat12WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
Fat12Format (HANDLE FileHandle,
|
Fat12Format (HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
PDISK_GEOMETRY DiskGeometry,
|
||||||
PUNICODE_STRING Label,
|
PUNICODE_STRING Label,
|
||||||
BOOL QuickFormat,
|
BOOLEAN QuickFormat,
|
||||||
DWORD ClusterSize,
|
ULONG ClusterSize,
|
||||||
PFMIFSCALLBACK Callback)
|
PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
FAT16_BOOT_SECTOR BootSector;
|
FAT16_BOOT_SECTOR BootSector;
|
||||||
OEM_STRING VolumeLabel;
|
OEM_STRING VolumeLabel;
|
||||||
|
@ -331,8 +341,20 @@ Fat12Format (HANDLE FileHandle,
|
||||||
|
|
||||||
DPRINT("BootSector.FATSectors = %hx\n", BootSector.FATSectors);
|
DPRINT("BootSector.FATSectors = %hx\n", BootSector.FATSectors);
|
||||||
|
|
||||||
Status = Fat12WriteBootSector(FileHandle,
|
/* Init context data */
|
||||||
&BootSector);
|
if (QuickFormat)
|
||||||
|
{
|
||||||
|
Context->TotalSectorCount =
|
||||||
|
1 + (BootSector.FATSectors * 2) + RootDirSectors;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Context->TotalSectorCount = SectorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = Fat12WriteBootSector (FileHandle,
|
||||||
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat12WriteBootSector() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat12WriteBootSector() failed with status 0x%.08x\n", Status);
|
||||||
|
@ -340,9 +362,10 @@ Fat12Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write first FAT copy */
|
/* Write first FAT copy */
|
||||||
Status = Fat12WriteFAT(FileHandle,
|
Status = Fat12WriteFAT (FileHandle,
|
||||||
0,
|
0,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat12WriteFAT() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat12WriteFAT() failed with status 0x%.08x\n", Status);
|
||||||
|
@ -350,21 +373,28 @@ Fat12Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write second FAT copy */
|
/* Write second FAT copy */
|
||||||
Status = Fat12WriteFAT(FileHandle,
|
Status = Fat12WriteFAT (FileHandle,
|
||||||
(ULONG)BootSector.FATSectors,
|
(ULONG)BootSector.FATSectors,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat12WriteFAT() failed with status 0x%.08x.\n", Status);
|
DPRINT("Fat12WriteFAT() failed with status 0x%.08x.\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Fat12WriteRootDirectory(FileHandle,
|
Status = Fat12WriteRootDirectory (FileHandle,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat12WriteRootDirectory() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat12WriteRootDirectory() failed with status 0x%.08x\n", Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!QuickFormat)
|
||||||
|
{
|
||||||
|
/* FIXME: Fill remaining sectors */
|
||||||
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,9 @@ CalcVolumeSerialNumber(VOID)
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat16WriteBootSector(IN HANDLE FileHandle,
|
Fat16WriteBootSector (IN HANDLE FileHandle,
|
||||||
IN PFAT16_BOOT_SECTOR BootSector)
|
IN PFAT16_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -90,27 +91,29 @@ Fat16WriteBootSector(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, 1);
|
||||||
|
|
||||||
/* Free the new boot sector */
|
/* Free the new boot sector */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat16WriteFAT(IN HANDLE FileHandle,
|
Fat16WriteFAT (IN HANDLE FileHandle,
|
||||||
ULONG SectorOffset,
|
IN ULONG SectorOffset,
|
||||||
IN PFAT16_BOOT_SECTOR BootSector)
|
IN PFAT16_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PUCHAR Buffer;
|
PUCHAR Buffer;
|
||||||
LARGE_INTEGER FileOffset;
|
LARGE_INTEGER FileOffset;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG Size;
|
|
||||||
ULONG Sectors;
|
ULONG Sectors;
|
||||||
|
|
||||||
/* Allocate buffer */
|
/* Allocate buffer */
|
||||||
|
@ -149,6 +152,8 @@ Fat16WriteFAT(IN HANDLE FileHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, 1);
|
||||||
|
|
||||||
/* Zero the begin of the buffer */
|
/* Zero the begin of the buffer */
|
||||||
memset(Buffer, 0, 4);
|
memset(Buffer, 0, 4);
|
||||||
|
|
||||||
|
@ -158,19 +163,19 @@ Fat16WriteFAT(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
/* Zero some sectors of the FAT */
|
/* Zero some sectors of the FAT */
|
||||||
FileOffset.QuadPart = (SectorOffset + BootSector->ReservedSectors + i) * BootSector->BytesPerSector;
|
FileOffset.QuadPart = (SectorOffset + BootSector->ReservedSectors + i) * BootSector->BytesPerSector;
|
||||||
Size = (ULONG)BootSector->FATSectors - i;
|
|
||||||
if (Size > Sectors)
|
if (((ULONG)BootSector->FATSectors - i) <= Sectors)
|
||||||
{
|
{
|
||||||
Size = Sectors;
|
Sectors = (ULONG)BootSector->FATSectors - i;
|
||||||
}
|
}
|
||||||
Size *= BootSector->BytesPerSector;
|
|
||||||
Status = NtWriteFile(FileHandle,
|
Status = NtWriteFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
Buffer,
|
Buffer,
|
||||||
Size,
|
Sectors * BootSector->BytesPerSector,
|
||||||
&FileOffset,
|
&FileOffset,
|
||||||
NULL);
|
NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -179,6 +184,8 @@ Fat16WriteFAT(IN HANDLE FileHandle,
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
|
@ -189,8 +196,9 @@ Fat16WriteFAT(IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat16WriteRootDirectory(IN HANDLE FileHandle,
|
Fat16WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
IN PFAT16_BOOT_SECTOR BootSector)
|
IN PFAT16_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -199,7 +207,6 @@ Fat16WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
ULONG FirstRootDirSector;
|
ULONG FirstRootDirSector;
|
||||||
ULONG RootDirSectors;
|
ULONG RootDirSectors;
|
||||||
ULONG Sectors;
|
ULONG Sectors;
|
||||||
ULONG Size;
|
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
DPRINT("BootSector->ReservedSectors = %hu\n", BootSector->ReservedSectors);
|
DPRINT("BootSector->ReservedSectors = %hu\n", BootSector->ReservedSectors);
|
||||||
|
@ -230,12 +237,11 @@ Fat16WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
/* Zero some sectors of the root directory */
|
/* Zero some sectors of the root directory */
|
||||||
FileOffset.QuadPart = (FirstRootDirSector + i) * BootSector->BytesPerSector;
|
FileOffset.QuadPart = (FirstRootDirSector + i) * BootSector->BytesPerSector;
|
||||||
Size = RootDirSectors - i;
|
|
||||||
if (Size > Sectors)
|
if ((RootDirSectors - i) <= Sectors)
|
||||||
{
|
{
|
||||||
Size = Sectors;
|
Sectors = RootDirSectors - i;
|
||||||
}
|
}
|
||||||
Size *= BootSector->BytesPerSector;
|
|
||||||
|
|
||||||
Status = NtWriteFile(FileHandle,
|
Status = NtWriteFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -243,7 +249,7 @@ Fat16WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
Buffer,
|
Buffer,
|
||||||
Size,
|
Sectors * BootSector->BytesPerSector,
|
||||||
&FileOffset,
|
&FileOffset,
|
||||||
NULL);
|
NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -252,6 +258,8 @@ Fat16WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
|
@ -262,13 +270,13 @@ Fat16WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
Fat16Format (HANDLE FileHandle,
|
Fat16Format (HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
PDISK_GEOMETRY DiskGeometry,
|
||||||
PUNICODE_STRING Label,
|
PUNICODE_STRING Label,
|
||||||
BOOL QuickFormat,
|
BOOLEAN QuickFormat,
|
||||||
DWORD ClusterSize,
|
ULONG ClusterSize,
|
||||||
PFMIFSCALLBACK Callback)
|
PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
FAT16_BOOT_SECTOR BootSector;
|
FAT16_BOOT_SECTOR BootSector;
|
||||||
OEM_STRING VolumeLabel;
|
OEM_STRING VolumeLabel;
|
||||||
|
@ -351,8 +359,20 @@ Fat16Format (HANDLE FileHandle,
|
||||||
BootSector.FATSectors = (unsigned short)(TmpVal3 & 0xffff);
|
BootSector.FATSectors = (unsigned short)(TmpVal3 & 0xffff);
|
||||||
DPRINT("BootSector.FATSectors = %hu\n", BootSector.FATSectors);
|
DPRINT("BootSector.FATSectors = %hu\n", BootSector.FATSectors);
|
||||||
|
|
||||||
Status = Fat16WriteBootSector(FileHandle,
|
/* Init context data */
|
||||||
&BootSector);
|
if (QuickFormat)
|
||||||
|
{
|
||||||
|
Context->TotalSectorCount =
|
||||||
|
1 + (BootSector.FATSectors * 2) + RootDirSectors;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Context->TotalSectorCount = SectorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = Fat16WriteBootSector (FileHandle,
|
||||||
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat16WriteBootSector() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat16WriteBootSector() failed with status 0x%.08x\n", Status);
|
||||||
|
@ -360,9 +380,10 @@ Fat16Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write first FAT copy */
|
/* Write first FAT copy */
|
||||||
Status = Fat16WriteFAT(FileHandle,
|
Status = Fat16WriteFAT (FileHandle,
|
||||||
0,
|
0,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat16WriteFAT() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat16WriteFAT() failed with status 0x%.08x\n", Status);
|
||||||
|
@ -370,21 +391,28 @@ Fat16Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write second FAT copy */
|
/* Write second FAT copy */
|
||||||
Status = Fat16WriteFAT(FileHandle,
|
Status = Fat16WriteFAT (FileHandle,
|
||||||
(ULONG)BootSector.FATSectors,
|
(ULONG)BootSector.FATSectors,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat16WriteFAT() failed with status 0x%.08x.\n", Status);
|
DPRINT("Fat16WriteFAT() failed with status 0x%.08x.\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Fat16WriteRootDirectory(FileHandle,
|
Status = Fat16WriteRootDirectory (FileHandle,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat16WriteRootDirectory() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat16WriteRootDirectory() failed with status 0x%.08x\n", Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!QuickFormat)
|
||||||
|
{
|
||||||
|
/* FIXME: Fill remaining sectors */
|
||||||
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,9 @@ CalcVolumeSerialNumber(VOID)
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat32WriteBootSector(IN HANDLE FileHandle,
|
Fat32WriteBootSector (IN HANDLE FileHandle,
|
||||||
IN PFAT32_BOOT_SECTOR BootSector)
|
IN PFAT32_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -90,9 +91,11 @@ Fat32WriteBootSector(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, 1);
|
||||||
|
|
||||||
/* Write backup boot sector */
|
/* Write backup boot sector */
|
||||||
if (BootSector->BootBackup != 0x0000)
|
if (BootSector->BootBackup != 0x0000)
|
||||||
{
|
{
|
||||||
|
@ -110,20 +113,23 @@ Fat32WriteBootSector(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the new boot sector */
|
/* Free the new boot sector */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat32WriteFsInfo(IN HANDLE FileHandle,
|
Fat32WriteFsInfo (IN HANDLE FileHandle,
|
||||||
IN PFAT32_BOOT_SECTOR BootSector)
|
IN PFAT32_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -164,6 +170,8 @@ Fat32WriteFsInfo(IN HANDLE FileHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, 1);
|
||||||
|
|
||||||
/* Free the new sector buffer */
|
/* Free the new sector buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FsInfo);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, FsInfo);
|
||||||
|
|
||||||
|
@ -172,16 +180,16 @@ Fat32WriteFsInfo(IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat32WriteFAT(IN HANDLE FileHandle,
|
Fat32WriteFAT (IN HANDLE FileHandle,
|
||||||
ULONG SectorOffset,
|
IN ULONG SectorOffset,
|
||||||
IN PFAT32_BOOT_SECTOR BootSector)
|
IN PFAT32_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PUCHAR Buffer;
|
PUCHAR Buffer;
|
||||||
LARGE_INTEGER FileOffset;
|
LARGE_INTEGER FileOffset;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG Size;
|
|
||||||
ULONG Sectors;
|
ULONG Sectors;
|
||||||
|
|
||||||
/* Allocate buffer */
|
/* Allocate buffer */
|
||||||
|
@ -228,6 +236,8 @@ Fat32WriteFAT(IN HANDLE FileHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, 1);
|
||||||
|
|
||||||
/* Zero the begin of the buffer */
|
/* Zero the begin of the buffer */
|
||||||
memset(Buffer, 0, 12);
|
memset(Buffer, 0, 12);
|
||||||
|
|
||||||
|
@ -237,19 +247,19 @@ Fat32WriteFAT(IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
/* Zero some sectors of the FAT */
|
/* Zero some sectors of the FAT */
|
||||||
FileOffset.QuadPart = (SectorOffset + BootSector->ReservedSectors + i) * BootSector->BytesPerSector;
|
FileOffset.QuadPart = (SectorOffset + BootSector->ReservedSectors + i) * BootSector->BytesPerSector;
|
||||||
Size = BootSector->FATSectors32 - i;
|
|
||||||
if (Size > Sectors)
|
if ((BootSector->FATSectors32 - i) <= Sectors)
|
||||||
{
|
{
|
||||||
Size = Sectors;
|
Sectors = BootSector->FATSectors32 - i;
|
||||||
}
|
}
|
||||||
Size *= BootSector->BytesPerSector;
|
|
||||||
Status = NtWriteFile(FileHandle,
|
Status = NtWriteFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
Buffer,
|
Buffer,
|
||||||
Size,
|
Sectors * BootSector->BytesPerSector,
|
||||||
&FileOffset,
|
&FileOffset,
|
||||||
NULL);
|
NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -258,6 +268,8 @@ Fat32WriteFAT(IN HANDLE FileHandle,
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
|
@ -268,8 +280,9 @@ Fat32WriteFAT(IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat32WriteRootDirectory(IN HANDLE FileHandle,
|
Fat32WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
IN PFAT32_BOOT_SECTOR BootSector)
|
IN PFAT32_BOOT_SECTOR BootSector,
|
||||||
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -321,6 +334,8 @@ Fat32WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateProgress (Context, (ULONG)BootSector->SectorsPerCluster);
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
|
@ -329,13 +344,13 @@ Fat32WriteRootDirectory(IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
Fat32Format (HANDLE FileHandle,
|
Fat32Format (HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
PDISK_GEOMETRY DiskGeometry,
|
||||||
PUNICODE_STRING Label,
|
PUNICODE_STRING Label,
|
||||||
BOOL QuickFormat,
|
BOOLEAN QuickFormat,
|
||||||
DWORD ClusterSize,
|
ULONG ClusterSize,
|
||||||
PFMIFSCALLBACK Callback)
|
PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
FAT32_BOOT_SECTOR BootSector;
|
FAT32_BOOT_SECTOR BootSector;
|
||||||
OEM_STRING VolumeLabel;
|
OEM_STRING VolumeLabel;
|
||||||
|
@ -417,16 +432,29 @@ Fat32Format (HANDLE FileHandle,
|
||||||
BootSector.FATSectors32 = (TmpVal1 + (TmpVal2 - 1)) / TmpVal2;
|
BootSector.FATSectors32 = (TmpVal1 + (TmpVal2 - 1)) / TmpVal2;
|
||||||
DPRINT("FATSectors32 = %lu\n", BootSector.FATSectors32);
|
DPRINT("FATSectors32 = %lu\n", BootSector.FATSectors32);
|
||||||
|
|
||||||
Status = Fat32WriteBootSector(FileHandle,
|
/* Init context data */
|
||||||
&BootSector);
|
if (QuickFormat)
|
||||||
|
{
|
||||||
|
Context->TotalSectorCount =
|
||||||
|
2 + (BootSector.FATSectors32 * BootSector.FATCount) + BootSector.SectorsPerCluster;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Context->TotalSectorCount = BootSector.SectorsHuge;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = Fat32WriteBootSector (FileHandle,
|
||||||
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat32WriteBootSector() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat32WriteBootSector() failed with status 0x%.08x\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Fat32WriteFsInfo(FileHandle,
|
Status = Fat32WriteFsInfo (FileHandle,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat32WriteFsInfo() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat32WriteFsInfo() failed with status 0x%.08x\n", Status);
|
||||||
|
@ -434,9 +462,10 @@ Fat32Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write first FAT copy */
|
/* Write first FAT copy */
|
||||||
Status = Fat32WriteFAT(FileHandle,
|
Status = Fat32WriteFAT (FileHandle,
|
||||||
0,
|
0,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat32WriteFAT() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat32WriteFAT() failed with status 0x%.08x\n", Status);
|
||||||
|
@ -444,21 +473,30 @@ Fat32Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write second FAT copy */
|
/* Write second FAT copy */
|
||||||
Status = Fat32WriteFAT(FileHandle,
|
Status = Fat32WriteFAT (FileHandle,
|
||||||
BootSector.FATSectors32,
|
BootSector.FATSectors32,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat32WriteFAT() failed with status 0x%.08x.\n", Status);
|
DPRINT("Fat32WriteFAT() failed with status 0x%.08x.\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Fat32WriteRootDirectory(FileHandle,
|
Status = Fat32WriteRootDirectory (FileHandle,
|
||||||
&BootSector);
|
&BootSector,
|
||||||
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Fat32WriteRootDirectory() failed with status 0x%.08x\n", Status);
|
DPRINT("Fat32WriteRootDirectory() failed with status 0x%.08x\n", Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!QuickFormat)
|
||||||
|
{
|
||||||
|
/* FIXME: Fill remaining sectors */
|
||||||
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
|
@ -7,14 +7,15 @@
|
||||||
* REVISIONS:
|
* REVISIONS:
|
||||||
* CSH 05/04-2003 Created
|
* CSH 05/04-2003 Created
|
||||||
*/
|
*/
|
||||||
#define NDEBUG
|
|
||||||
#include <debug.h>
|
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
#include <ddk/ntddscsi.h>
|
#include <ddk/ntddscsi.h>
|
||||||
#include <fslib/vfatlib.h>
|
#include <fslib/vfatlib.h>
|
||||||
#include "vfatlib.h"
|
#include "vfatlib.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VfatInitialize(VOID)
|
VfatInitialize(VOID)
|
||||||
|
@ -26,23 +27,29 @@ VfatInitialize(VOID)
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VfatFormat(
|
VfatFormat (PUNICODE_STRING DriveRoot,
|
||||||
PUNICODE_STRING DriveRoot,
|
ULONG MediaFlag,
|
||||||
DWORD MediaFlag,
|
PUNICODE_STRING Label,
|
||||||
PUNICODE_STRING Label,
|
BOOLEAN QuickFormat,
|
||||||
BOOL QuickFormat,
|
ULONG ClusterSize,
|
||||||
DWORD ClusterSize,
|
PFMIFSCALLBACK Callback)
|
||||||
PFMIFSCALLBACK Callback)
|
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
DISK_GEOMETRY DiskGeometry;
|
DISK_GEOMETRY DiskGeometry;
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
PARTITION_INFORMATION PartitionInfo;
|
PARTITION_INFORMATION PartitionInfo;
|
||||||
|
FORMAT_CONTEXT Context;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("VfatFormat(DriveRoot '%wZ')\n", DriveRoot);
|
DPRINT("VfatFormat(DriveRoot '%wZ')\n", DriveRoot);
|
||||||
|
|
||||||
|
Context.TotalSectorCount = 0;
|
||||||
|
Context.CurrentSectorCount = 0;
|
||||||
|
Context.Callback = Callback;
|
||||||
|
Context.Success = FALSE;
|
||||||
|
Context.Percent = 0;
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
DriveRoot,
|
DriveRoot,
|
||||||
0,
|
0,
|
||||||
|
@ -138,6 +145,12 @@ VfatFormat(
|
||||||
DPRINT("RewritePartition %d\n", PartitionInfo.RewritePartition);
|
DPRINT("RewritePartition %d\n", PartitionInfo.RewritePartition);
|
||||||
DPRINT("RecognizedPartition %d\n", PartitionInfo.RecognizedPartition);
|
DPRINT("RecognizedPartition %d\n", PartitionInfo.RecognizedPartition);
|
||||||
|
|
||||||
|
if (Callback != NULL)
|
||||||
|
{
|
||||||
|
Context.Percent = 0;
|
||||||
|
Callback (PROGRESS, 0, (PVOID)&Context.Percent);
|
||||||
|
}
|
||||||
|
|
||||||
if (PartitionInfo.PartitionLength.QuadPart < (4200ULL * 1024ULL))
|
if (PartitionInfo.PartitionLength.QuadPart < (4200ULL * 1024ULL))
|
||||||
{
|
{
|
||||||
/* FAT12 (volume is smaller than 4.1MB) */
|
/* FAT12 (volume is smaller than 4.1MB) */
|
||||||
|
@ -147,7 +160,7 @@ VfatFormat(
|
||||||
Label,
|
Label,
|
||||||
QuickFormat,
|
QuickFormat,
|
||||||
ClusterSize,
|
ClusterSize,
|
||||||
Callback);
|
&Context);
|
||||||
}
|
}
|
||||||
else if (PartitionInfo.PartitionLength.QuadPart < (512ULL * 1024ULL * 1024ULL))
|
else if (PartitionInfo.PartitionLength.QuadPart < (512ULL * 1024ULL * 1024ULL))
|
||||||
{
|
{
|
||||||
|
@ -158,7 +171,7 @@ VfatFormat(
|
||||||
Label,
|
Label,
|
||||||
QuickFormat,
|
QuickFormat,
|
||||||
ClusterSize,
|
ClusterSize,
|
||||||
Callback);
|
&Context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -169,11 +182,17 @@ VfatFormat(
|
||||||
Label,
|
Label,
|
||||||
QuickFormat,
|
QuickFormat,
|
||||||
ClusterSize,
|
ClusterSize,
|
||||||
Callback);
|
&Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
NtClose(FileHandle);
|
NtClose(FileHandle);
|
||||||
|
|
||||||
|
if (Callback != NULL)
|
||||||
|
{
|
||||||
|
Context.Success = (BOOLEAN)(NT_SUCCESS(Status));
|
||||||
|
Callback (DONE, 0, (PVOID)&Context.Success);
|
||||||
|
}
|
||||||
|
|
||||||
DPRINT("VfatFormat() done. Status 0x%.08x\n", Status);
|
DPRINT("VfatFormat() done. Status 0x%.08x\n", Status);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -187,3 +206,24 @@ VfatCleanup(VOID)
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID
|
||||||
|
UpdateProgress (PFORMAT_CONTEXT Context,
|
||||||
|
ULONG Increment)
|
||||||
|
{
|
||||||
|
ULONG NewPercent;
|
||||||
|
|
||||||
|
Context->CurrentSectorCount += (ULONGLONG)Increment;
|
||||||
|
|
||||||
|
|
||||||
|
NewPercent = (Context->CurrentSectorCount * 100ULL) / Context->TotalSectorCount;
|
||||||
|
|
||||||
|
if (NewPercent > Context->Percent)
|
||||||
|
{
|
||||||
|
Context->Percent = NewPercent;
|
||||||
|
Context->Callback (PROGRESS, 0, &Context->Percent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
|
@ -87,29 +87,45 @@ typedef struct _FAT32_FSINFO
|
||||||
} __attribute__((packed)) FAT32_FSINFO, *PFAT32_FSINFO;
|
} __attribute__((packed)) FAT32_FSINFO, *PFAT32_FSINFO;
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
typedef struct _FORMAT_CONTEXT
|
||||||
Fat12Format (HANDLE FileHandle,
|
{
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
PFMIFSCALLBACK Callback;
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
ULONG TotalSectorCount;
|
||||||
PUNICODE_STRING Label,
|
ULONG CurrentSectorCount;
|
||||||
BOOL QuickFormat,
|
BOOLEAN Success;
|
||||||
DWORD ClusterSize,
|
ULONG Percent;
|
||||||
PFMIFSCALLBACK Callback);
|
} FORMAT_CONTEXT, *PFORMAT_CONTEXT;
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
Fat16Format (HANDLE FileHandle,
|
Fat12Format (HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
PDISK_GEOMETRY DiskGeometry,
|
||||||
PUNICODE_STRING Label,
|
PUNICODE_STRING Label,
|
||||||
BOOL QuickFormat,
|
BOOLEAN QuickFormat,
|
||||||
DWORD ClusterSize,
|
ULONG ClusterSize,
|
||||||
PFMIFSCALLBACK Callback);
|
PFORMAT_CONTEXT Context);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
Fat32Format (HANDLE FileHandle,
|
Fat16Format (HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
PDISK_GEOMETRY DiskGeometry,
|
||||||
PUNICODE_STRING Label,
|
PUNICODE_STRING Label,
|
||||||
BOOL QuickFormat,
|
BOOLEAN QuickFormat,
|
||||||
DWORD ClusterSize,
|
ULONG ClusterSize,
|
||||||
PFMIFSCALLBACK Callback);
|
PFORMAT_CONTEXT Context);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
Fat32Format (HANDLE FileHandle,
|
||||||
|
PPARTITION_INFORMATION PartitionInfo,
|
||||||
|
PDISK_GEOMETRY DiskGeometry,
|
||||||
|
PUNICODE_STRING Label,
|
||||||
|
BOOLEAN QuickFormat,
|
||||||
|
ULONG ClusterSize,
|
||||||
|
PFORMAT_CONTEXT Context);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
UpdateProgress (PFORMAT_CONTEXT Context,
|
||||||
|
ULONG Increment);
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue