mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:23:05 +00:00
[FORMATTING]
Fix indentation. No code changes. svn path=/trunk/; revision=47764
This commit is contained in:
parent
78b0fb4a21
commit
0c8457631d
9 changed files with 1644 additions and 1617 deletions
|
@ -798,9 +798,9 @@ Ext2TotalBlocks(PEXT2_FILESYS Ext2Sys, ULONG DataBlocks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
Ext2Format(
|
NTAPI
|
||||||
IN PUNICODE_STRING DriveRoot,
|
Ext2Format(IN PUNICODE_STRING DriveRoot,
|
||||||
IN FMIFS_MEDIA_FLAG MediaFlag,
|
IN FMIFS_MEDIA_FLAG MediaFlag,
|
||||||
IN PUNICODE_STRING Label,
|
IN PUNICODE_STRING Label,
|
||||||
IN BOOLEAN QuickFormat,
|
IN BOOLEAN QuickFormat,
|
||||||
|
@ -1002,9 +1002,9 @@ clean_up:
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WINAPI
|
NTSTATUS
|
||||||
Ext2Chkdsk(
|
WINAPI
|
||||||
IN PUNICODE_STRING DriveRoot,
|
Ext2Chkdsk(IN PUNICODE_STRING DriveRoot,
|
||||||
IN BOOLEAN FixErrors,
|
IN BOOLEAN FixErrors,
|
||||||
IN BOOLEAN Verbose,
|
IN BOOLEAN Verbose,
|
||||||
IN BOOLEAN CheckOnlyIfDirty,
|
IN BOOLEAN CheckOnlyIfDirty,
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
NtfsFormat(PUNICODE_STRING DriveRoot,
|
NtfsFormat(IN PUNICODE_STRING DriveRoot,
|
||||||
FMIFS_MEDIA_FLAG MediaFlag,
|
IN FMIFS_MEDIA_FLAG MediaFlag,
|
||||||
PUNICODE_STRING Label,
|
IN PUNICODE_STRING Label,
|
||||||
BOOLEAN QuickFormat,
|
IN BOOLEAN QuickFormat,
|
||||||
ULONG ClusterSize,
|
IN ULONG ClusterSize,
|
||||||
PFMIFSCALLBACK Callback)
|
IN PFMIFSCALLBACK Callback)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
|
@ -14,14 +14,16 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static ULONG
|
static ULONG
|
||||||
GetShiftCount(ULONG Value)
|
GetShiftCount(IN ULONG Value)
|
||||||
{
|
{
|
||||||
ULONG i = 1;
|
ULONG i = 1;
|
||||||
|
|
||||||
while (Value > 0)
|
while (Value > 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
Value /= 2;
|
Value /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i - 2;
|
return i - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +36,8 @@ CalcVolumeSerialNumber(VOID)
|
||||||
ULONG Serial;
|
ULONG Serial;
|
||||||
PUCHAR Buffer;
|
PUCHAR Buffer;
|
||||||
|
|
||||||
NtQuerySystemTime (&SystemTime);
|
NtQuerySystemTime(&SystemTime);
|
||||||
RtlTimeToTimeFields (&SystemTime, &TimeFields);
|
RtlTimeToTimeFields(&SystemTime, &TimeFields);
|
||||||
|
|
||||||
Buffer = (PUCHAR)&Serial;
|
Buffer = (PUCHAR)&Serial;
|
||||||
Buffer[0] = (UCHAR)(TimeFields.Year & 0xFF) + (UCHAR)(TimeFields.Hour & 0xFF);
|
Buffer[0] = (UCHAR)(TimeFields.Year & 0xFF) + (UCHAR)(TimeFields.Hour & 0xFF);
|
||||||
|
@ -48,7 +50,7 @@ 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)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -58,11 +60,11 @@ 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;
|
||||||
|
|
||||||
/* Zero the new bootsector */
|
/* Zero the new bootsector */
|
||||||
memset(NewBootSector, 0, SECTORSIZE);
|
memset(NewBootSector, 0, SECTORSIZE);
|
||||||
|
@ -87,20 +89,20 @@ Fat12WriteBootSector (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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the new boot sector */
|
/* Free the new boot sector */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
|
|
||||||
UpdateProgress (Context, 1);
|
UpdateProgress(Context, 1);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat12WriteFAT (IN HANDLE FileHandle,
|
Fat12WriteFAT(IN HANDLE FileHandle,
|
||||||
IN ULONG SectorOffset,
|
IN ULONG SectorOffset,
|
||||||
IN PFAT16_BOOT_SECTOR BootSector,
|
IN PFAT16_BOOT_SECTOR BootSector,
|
||||||
IN OUT PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
|
@ -118,7 +120,7 @@ Fat12WriteFAT (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
32 * 1024);
|
32 * 1024);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0, 32 * 1024);
|
memset(Buffer, 0, 32 * 1024);
|
||||||
|
@ -143,10 +145,10 @@ Fat12WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, 1);
|
UpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Zero the begin of the buffer */
|
/* Zero the begin of the buffer */
|
||||||
memset(Buffer, 0, 3);
|
memset(Buffer, 0, 3);
|
||||||
|
@ -176,21 +178,21 @@ Fat12WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, Sectors);
|
UpdateProgress(Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -222,7 +224,7 @@ Fat12WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
32 * 1024);
|
32 * 1024);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0, 32 * 1024);
|
memset(Buffer, 0, 32 * 1024);
|
||||||
|
@ -237,6 +239,7 @@ Fat12WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
Sectors = RootDirSectors - i;
|
Sectors = RootDirSectors - i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size = Sectors * BootSector->BytesPerSector;
|
Size = Sectors * BootSector->BytesPerSector;
|
||||||
|
|
||||||
Status = NtWriteFile(FileHandle,
|
Status = NtWriteFile(FileHandle,
|
||||||
|
@ -252,26 +255,27 @@ Fat12WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
UpdateProgress (Context, Sectors);
|
|
||||||
|
UpdateProgress(Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
Fat12Format (HANDLE FileHandle,
|
Fat12Format(IN HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
IN PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
IN PDISK_GEOMETRY DiskGeometry,
|
||||||
PUNICODE_STRING Label,
|
IN PUNICODE_STRING Label,
|
||||||
BOOLEAN QuickFormat,
|
IN BOOLEAN QuickFormat,
|
||||||
ULONG ClusterSize,
|
IN ULONG ClusterSize,
|
||||||
PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
FAT16_BOOT_SECTOR BootSector;
|
FAT16_BOOT_SECTOR BootSector;
|
||||||
OEM_STRING VolumeLabel;
|
OEM_STRING VolumeLabel;
|
||||||
|
@ -323,6 +327,7 @@ Fat12Format (HANDLE FileHandle,
|
||||||
VolumeLabel.Length < 11 ? VolumeLabel.Length : 11);
|
VolumeLabel.Length < 11 ? VolumeLabel.Length : 11);
|
||||||
RtlFreeOemString(&VolumeLabel);
|
RtlFreeOemString(&VolumeLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&BootSector.SysType[0], "FAT12 ", 8);
|
memcpy(&BootSector.SysType[0], "FAT12 ", 8);
|
||||||
|
|
||||||
RootDirSectors = ((BootSector.RootEntries * 32) +
|
RootDirSectors = ((BootSector.RootEntries * 32) +
|
||||||
|
@ -341,7 +346,7 @@ Fat12Format (HANDLE FileHandle,
|
||||||
Context->TotalSectorCount =
|
Context->TotalSectorCount =
|
||||||
1 + (BootSector.FATSectors * 2) + RootDirSectors;
|
1 + (BootSector.FATSectors * 2) + RootDirSectors;
|
||||||
|
|
||||||
Status = Fat12WriteBootSector (FileHandle,
|
Status = Fat12WriteBootSector(FileHandle,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -351,7 +356,7 @@ Fat12Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write first FAT copy */
|
/* Write first FAT copy */
|
||||||
Status = Fat12WriteFAT (FileHandle,
|
Status = Fat12WriteFAT(FileHandle,
|
||||||
0,
|
0,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
|
@ -362,7 +367,7 @@ 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);
|
Context);
|
||||||
|
@ -372,7 +377,7 @@ Fat12Format (HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Fat12WriteRootDirectory (FileHandle,
|
Status = Fat12WriteRootDirectory(FileHandle,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -14,14 +14,16 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static ULONG
|
static ULONG
|
||||||
GetShiftCount(ULONG Value)
|
GetShiftCount(IN ULONG Value)
|
||||||
{
|
{
|
||||||
ULONG i = 1;
|
ULONG i = 1;
|
||||||
|
|
||||||
while (Value > 0)
|
while (Value > 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
Value /= 2;
|
Value /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i - 2;
|
return i - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +50,7 @@ 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)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +64,7 @@ Fat16WriteBootSector (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
SECTORSIZE);
|
SECTORSIZE);
|
||||||
if (NewBootSector == NULL)
|
if (NewBootSector == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the new bootsector */
|
/* Zero the new bootsector */
|
||||||
memset(NewBootSector, 0, SECTORSIZE);
|
memset(NewBootSector, 0, SECTORSIZE);
|
||||||
|
@ -90,7 +92,7 @@ Fat16WriteBootSector (IN HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, 1);
|
UpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Free the new boot sector */
|
/* Free the new boot sector */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
|
@ -100,7 +102,7 @@ Fat16WriteBootSector (IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat16WriteFAT (IN HANDLE FileHandle,
|
Fat16WriteFAT(IN HANDLE FileHandle,
|
||||||
IN ULONG SectorOffset,
|
IN ULONG SectorOffset,
|
||||||
IN PFAT16_BOOT_SECTOR BootSector,
|
IN PFAT16_BOOT_SECTOR BootSector,
|
||||||
IN OUT PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
|
@ -117,7 +119,7 @@ Fat16WriteFAT (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
32 * 1024);
|
32 * 1024);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0, 32 * 1024);
|
memset(Buffer, 0, 32 * 1024);
|
||||||
|
@ -145,10 +147,10 @@ Fat16WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, 1);
|
UpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Zero the begin of the buffer */
|
/* Zero the begin of the buffer */
|
||||||
memset(Buffer, 0, 4);
|
memset(Buffer, 0, 4);
|
||||||
|
@ -178,21 +180,21 @@ Fat16WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, Sectors);
|
UpdateProgress(Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -223,7 +225,7 @@ Fat16WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
32 * 1024);
|
32 * 1024);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0, 32 * 1024);
|
memset(Buffer, 0, 32 * 1024);
|
||||||
|
@ -252,27 +254,27 @@ Fat16WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, Sectors);
|
UpdateProgress(Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
Fat16Format (HANDLE FileHandle,
|
Fat16Format(IN HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
IN PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
IN PDISK_GEOMETRY DiskGeometry,
|
||||||
PUNICODE_STRING Label,
|
IN PUNICODE_STRING Label,
|
||||||
BOOLEAN QuickFormat,
|
IN BOOLEAN QuickFormat,
|
||||||
ULONG ClusterSize,
|
IN ULONG ClusterSize,
|
||||||
PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
FAT16_BOOT_SECTOR BootSector;
|
FAT16_BOOT_SECTOR BootSector;
|
||||||
OEM_STRING VolumeLabel;
|
OEM_STRING VolumeLabel;
|
||||||
|
@ -340,6 +342,7 @@ Fat16Format (HANDLE FileHandle,
|
||||||
VolumeLabel.Length < 11 ? VolumeLabel.Length : 11);
|
VolumeLabel.Length < 11 ? VolumeLabel.Length : 11);
|
||||||
RtlFreeOemString(&VolumeLabel);
|
RtlFreeOemString(&VolumeLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&BootSector.SysType[0], "FAT16 ", 8);
|
memcpy(&BootSector.SysType[0], "FAT16 ", 8);
|
||||||
|
|
||||||
DPRINT("BootSector.SectorsHuge = %lx\n", BootSector.SectorsHuge);
|
DPRINT("BootSector.SectorsHuge = %lx\n", BootSector.SectorsHuge);
|
||||||
|
@ -359,7 +362,7 @@ Fat16Format (HANDLE FileHandle,
|
||||||
Context->TotalSectorCount =
|
Context->TotalSectorCount =
|
||||||
1 + (BootSector.FATSectors * 2) + RootDirSectors;
|
1 + (BootSector.FATSectors * 2) + RootDirSectors;
|
||||||
|
|
||||||
Status = Fat16WriteBootSector (FileHandle,
|
Status = Fat16WriteBootSector(FileHandle,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -369,7 +372,7 @@ Fat16Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write first FAT copy */
|
/* Write first FAT copy */
|
||||||
Status = Fat16WriteFAT (FileHandle,
|
Status = Fat16WriteFAT(FileHandle,
|
||||||
0,
|
0,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
|
@ -380,7 +383,7 @@ 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);
|
Context);
|
||||||
|
@ -390,7 +393,7 @@ Fat16Format (HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Fat16WriteRootDirectory (FileHandle,
|
Status = Fat16WriteRootDirectory(FileHandle,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -14,14 +14,16 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static ULONG
|
static ULONG
|
||||||
GetShiftCount(ULONG Value)
|
GetShiftCount(IN ULONG Value)
|
||||||
{
|
{
|
||||||
ULONG i = 1;
|
ULONG i = 1;
|
||||||
|
|
||||||
while (Value > 0)
|
while (Value > 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
Value /= 2;
|
Value /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i - 2;
|
return i - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +50,7 @@ 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)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +64,7 @@ Fat32WriteBootSector (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
SECTORSIZE);
|
SECTORSIZE);
|
||||||
if (NewBootSector == NULL)
|
if (NewBootSector == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the new bootsector */
|
/* Zero the new bootsector */
|
||||||
memset(NewBootSector, 0, SECTORSIZE);
|
memset(NewBootSector, 0, SECTORSIZE);
|
||||||
|
@ -90,7 +92,7 @@ Fat32WriteBootSector (IN HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, 1);
|
UpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Write backup boot sector */
|
/* Write backup boot sector */
|
||||||
if (BootSector->BootBackup != 0x0000)
|
if (BootSector->BootBackup != 0x0000)
|
||||||
|
@ -112,7 +114,7 @@ Fat32WriteBootSector (IN HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, 1);
|
UpdateProgress(Context, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the new boot sector */
|
/* Free the new boot sector */
|
||||||
|
@ -123,7 +125,7 @@ Fat32WriteBootSector (IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
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)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -137,7 +139,7 @@ Fat32WriteFsInfo (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
BootSector->BytesPerSector);
|
BootSector->BytesPerSector);
|
||||||
if (FsInfo == NULL)
|
if (FsInfo == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the new sector */
|
/* Zero the new sector */
|
||||||
memset(FsInfo, 0, BootSector->BytesPerSector);
|
memset(FsInfo, 0, BootSector->BytesPerSector);
|
||||||
|
@ -163,20 +165,20 @@ Fat32WriteFsInfo (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FsInfo);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, FsInfo);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, 1);
|
UpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Free the new sector buffer */
|
/* Free the new sector buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FsInfo);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, FsInfo);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fat32WriteFAT (IN HANDLE FileHandle,
|
Fat32WriteFAT(IN HANDLE FileHandle,
|
||||||
IN ULONG SectorOffset,
|
IN ULONG SectorOffset,
|
||||||
IN PFAT32_BOOT_SECTOR BootSector,
|
IN PFAT32_BOOT_SECTOR BootSector,
|
||||||
IN OUT PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
|
@ -193,7 +195,7 @@ Fat32WriteFAT (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
64 * 1024);
|
64 * 1024);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0, 64 * 1024);
|
memset(Buffer, 0, 64 * 1024);
|
||||||
|
@ -203,11 +205,13 @@ Fat32WriteFAT (IN HANDLE FileHandle,
|
||||||
Buffer[1] = 0xff;
|
Buffer[1] = 0xff;
|
||||||
Buffer[2] = 0xff;
|
Buffer[2] = 0xff;
|
||||||
Buffer[3] = 0x0f;
|
Buffer[3] = 0x0f;
|
||||||
|
|
||||||
/* FAT cluster 1 */
|
/* FAT cluster 1 */
|
||||||
Buffer[4] = 0xff; /* Clean shutdown, no disk read/write errors, end-of-cluster (EOC) mark */
|
Buffer[4] = 0xff; /* Clean shutdown, no disk read/write errors, end-of-cluster (EOC) mark */
|
||||||
Buffer[5] = 0xff;
|
Buffer[5] = 0xff;
|
||||||
Buffer[6] = 0xff;
|
Buffer[6] = 0xff;
|
||||||
Buffer[7] = 0x0f;
|
Buffer[7] = 0x0f;
|
||||||
|
|
||||||
/* FAT cluster 2 */
|
/* FAT cluster 2 */
|
||||||
Buffer[8] = 0xff; /* End of root directory */
|
Buffer[8] = 0xff; /* End of root directory */
|
||||||
Buffer[9] = 0xff;
|
Buffer[9] = 0xff;
|
||||||
|
@ -229,10 +233,10 @@ Fat32WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, 1);
|
UpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Zero the begin of the buffer */
|
/* Zero the begin of the buffer */
|
||||||
memset(Buffer, 0, 12);
|
memset(Buffer, 0, 12);
|
||||||
|
@ -262,21 +266,21 @@ Fat32WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, Sectors);
|
UpdateProgress(Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -292,7 +296,7 @@ Fat32WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
BootSector->SectorsPerCluster * BootSector->BytesPerSector);
|
BootSector->SectorsPerCluster * BootSector->BytesPerSector);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0, BootSector->SectorsPerCluster * BootSector->BytesPerSector);
|
memset(Buffer, 0, BootSector->SectorsPerCluster * BootSector->BytesPerSector);
|
||||||
|
@ -327,26 +331,26 @@ Fat32WriteRootDirectory (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateProgress (Context, (ULONG)BootSector->SectorsPerCluster);
|
UpdateProgress(Context, (ULONG)BootSector->SectorsPerCluster);
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
Fat32Format (HANDLE FileHandle,
|
Fat32Format(IN HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
IN PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
IN PDISK_GEOMETRY DiskGeometry,
|
||||||
PUNICODE_STRING Label,
|
IN PUNICODE_STRING Label,
|
||||||
BOOLEAN QuickFormat,
|
IN BOOLEAN QuickFormat,
|
||||||
ULONG ClusterSize,
|
IN ULONG ClusterSize,
|
||||||
PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
FAT32_BOOT_SECTOR BootSector;
|
FAT32_BOOT_SECTOR BootSector;
|
||||||
OEM_STRING VolumeLabel;
|
OEM_STRING VolumeLabel;
|
||||||
|
@ -416,6 +420,7 @@ Fat32Format (HANDLE FileHandle,
|
||||||
VolumeLabel.Length < 11 ? VolumeLabel.Length : 11);
|
VolumeLabel.Length < 11 ? VolumeLabel.Length : 11);
|
||||||
RtlFreeOemString(&VolumeLabel);
|
RtlFreeOemString(&VolumeLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&BootSector.SysType[0], "FAT32 ", 8);
|
memcpy(&BootSector.SysType[0], "FAT32 ", 8);
|
||||||
|
|
||||||
RootDirSectors = ((BootSector.RootEntries * 32) +
|
RootDirSectors = ((BootSector.RootEntries * 32) +
|
||||||
|
@ -432,7 +437,7 @@ Fat32Format (HANDLE FileHandle,
|
||||||
Context->TotalSectorCount =
|
Context->TotalSectorCount =
|
||||||
2 + (BootSector.FATSectors32 * BootSector.FATCount) + BootSector.SectorsPerCluster;
|
2 + (BootSector.FATSectors32 * BootSector.FATCount) + BootSector.SectorsPerCluster;
|
||||||
|
|
||||||
Status = Fat32WriteBootSector (FileHandle,
|
Status = Fat32WriteBootSector(FileHandle,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -441,7 +446,7 @@ Fat32Format (HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Fat32WriteFsInfo (FileHandle,
|
Status = Fat32WriteFsInfo(FileHandle,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -451,7 +456,7 @@ Fat32Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write first FAT copy */
|
/* Write first FAT copy */
|
||||||
Status = Fat32WriteFAT (FileHandle,
|
Status = Fat32WriteFAT(FileHandle,
|
||||||
0,
|
0,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
|
@ -462,7 +467,7 @@ Fat32Format (HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write second FAT copy */
|
/* Write second FAT copy */
|
||||||
Status = Fat32WriteFAT (FileHandle,
|
Status = Fat32WriteFAT(FileHandle,
|
||||||
BootSector.FATSectors32,
|
BootSector.FATSectors32,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
|
@ -472,7 +477,7 @@ Fat32Format (HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Fat32WriteRootDirectory (FileHandle,
|
Status = Fat32WriteRootDirectory(FileHandle,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS VFAT filesystem library
|
* PROJECT: ReactOS VFAT filesystem library
|
||||||
* FILE: vfatlib.c
|
* FILE: lib\fslib\vfatlib\vfatlib.c
|
||||||
* PURPOSE: Main API
|
* PURPOSE: Main API
|
||||||
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||||
* REVISIONS:
|
* REVISIONS:
|
||||||
|
@ -17,13 +17,14 @@ PVOID FsCheckMemQueue;
|
||||||
ULONG FsCheckFlags;
|
ULONG FsCheckFlags;
|
||||||
ULONG FsCheckTotalFiles;
|
ULONG FsCheckTotalFiles;
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
VfatFormat (PUNICODE_STRING DriveRoot,
|
NTAPI
|
||||||
FMIFS_MEDIA_FLAG MediaFlag,
|
VfatFormat(IN PUNICODE_STRING DriveRoot,
|
||||||
PUNICODE_STRING Label,
|
IN FMIFS_MEDIA_FLAG MediaFlag,
|
||||||
BOOLEAN QuickFormat,
|
IN PUNICODE_STRING Label,
|
||||||
ULONG ClusterSize,
|
IN BOOLEAN QuickFormat,
|
||||||
PFMIFSCALLBACK Callback)
|
IN ULONG ClusterSize,
|
||||||
|
IN PFMIFSCALLBACK Callback)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
DISK_GEOMETRY DiskGeometry;
|
DISK_GEOMETRY DiskGeometry;
|
||||||
|
@ -145,7 +146,7 @@ VfatFormat (PUNICODE_STRING DriveRoot,
|
||||||
if (PartitionInfo.PartitionLength.QuadPart < (4200LL * 1024LL))
|
if (PartitionInfo.PartitionLength.QuadPart < (4200LL * 1024LL))
|
||||||
{
|
{
|
||||||
/* FAT12 (volume is smaller than 4.1MB) */
|
/* FAT12 (volume is smaller than 4.1MB) */
|
||||||
Status = Fat12Format (FileHandle,
|
Status = Fat12Format(FileHandle,
|
||||||
&PartitionInfo,
|
&PartitionInfo,
|
||||||
&DiskGeometry,
|
&DiskGeometry,
|
||||||
Label,
|
Label,
|
||||||
|
@ -156,7 +157,7 @@ VfatFormat (PUNICODE_STRING DriveRoot,
|
||||||
else if (PartitionInfo.PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
|
else if (PartitionInfo.PartitionLength.QuadPart < (512LL * 1024LL * 1024LL))
|
||||||
{
|
{
|
||||||
/* FAT16 (volume is smaller than 512MB) */
|
/* FAT16 (volume is smaller than 512MB) */
|
||||||
Status = Fat16Format (FileHandle,
|
Status = Fat16Format(FileHandle,
|
||||||
&PartitionInfo,
|
&PartitionInfo,
|
||||||
&DiskGeometry,
|
&DiskGeometry,
|
||||||
Label,
|
Label,
|
||||||
|
@ -167,7 +168,7 @@ VfatFormat (PUNICODE_STRING DriveRoot,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* FAT32 (volume is 512MB or larger) */
|
/* FAT32 (volume is 512MB or larger) */
|
||||||
Status = Fat32Format (FileHandle,
|
Status = Fat32Format(FileHandle,
|
||||||
&PartitionInfo,
|
&PartitionInfo,
|
||||||
&DiskGeometry,
|
&DiskGeometry,
|
||||||
Label,
|
Label,
|
||||||
|
@ -191,7 +192,7 @@ VfatFormat (PUNICODE_STRING DriveRoot,
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
UpdateProgress (PFORMAT_CONTEXT Context,
|
UpdateProgress(PFORMAT_CONTEXT Context,
|
||||||
ULONG Increment)
|
ULONG Increment)
|
||||||
{
|
{
|
||||||
ULONG NewPercent;
|
ULONG NewPercent;
|
||||||
|
@ -208,6 +209,7 @@ UpdateProgress (PFORMAT_CONTEXT Context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
VfatPrint(PCHAR Format, ...)
|
VfatPrint(PCHAR Format, ...)
|
||||||
{
|
{
|
||||||
|
@ -224,12 +226,14 @@ VfatPrint(PCHAR Format, ...)
|
||||||
TextOut.Output = TextBuf;
|
TextOut.Output = TextBuf;
|
||||||
|
|
||||||
/* Do the callback */
|
/* Do the callback */
|
||||||
if (ChkdskCallback) ChkdskCallback(OUTPUT, 0, &TextOut);
|
if (ChkdskCallback)
|
||||||
|
ChkdskCallback(OUTPUT, 0, &TextOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS WINAPI
|
|
||||||
VfatChkdsk(
|
NTSTATUS
|
||||||
IN PUNICODE_STRING DriveRoot,
|
WINAPI
|
||||||
|
VfatChkdsk(IN PUNICODE_STRING DriveRoot,
|
||||||
IN BOOLEAN FixErrors,
|
IN BOOLEAN FixErrors,
|
||||||
IN BOOLEAN Verbose,
|
IN BOOLEAN Verbose,
|
||||||
IN BOOLEAN CheckOnlyIfDirty,
|
IN BOOLEAN CheckOnlyIfDirty,
|
||||||
|
@ -246,7 +250,8 @@ VfatChkdsk(
|
||||||
|
|
||||||
/* Set parameters */
|
/* Set parameters */
|
||||||
FsCheckFlags = 0;
|
FsCheckFlags = 0;
|
||||||
if (Verbose) FsCheckFlags |= FSCHECK_VERBOSE;
|
if (Verbose)
|
||||||
|
FsCheckFlags |= FSCHECK_VERBOSE;
|
||||||
|
|
||||||
FsCheckTotalFiles = 0;
|
FsCheckTotalFiles = 0;
|
||||||
|
|
||||||
|
@ -263,13 +268,20 @@ VfatChkdsk(
|
||||||
}
|
}
|
||||||
|
|
||||||
read_boot(&fs);
|
read_boot(&fs);
|
||||||
if (verify) VfatPrint("Starting check/repair pass.\n");
|
if (verify)
|
||||||
while (read_fat(&fs), scan_root(&fs)) qfree(&FsCheckMemQueue);
|
VfatPrint("Starting check/repair pass.\n");
|
||||||
if (ScanDrive) fix_bad(&fs);
|
|
||||||
|
while (read_fat(&fs), scan_root(&fs))
|
||||||
|
qfree(&FsCheckMemQueue);
|
||||||
|
|
||||||
|
if (ScanDrive)
|
||||||
|
fix_bad(&fs);
|
||||||
|
|
||||||
if (salvage_files)
|
if (salvage_files)
|
||||||
reclaim_file(&fs);
|
reclaim_file(&fs);
|
||||||
else
|
else
|
||||||
reclaim_free(&fs);
|
reclaim_free(&fs);
|
||||||
|
|
||||||
free_clusters = update_free(&fs);
|
free_clusters = update_free(&fs);
|
||||||
file_unused();
|
file_unused();
|
||||||
qfree(&FsCheckMemQueue);
|
qfree(&FsCheckMemQueue);
|
||||||
|
|
|
@ -109,7 +109,7 @@ typedef struct _FORMAT_CONTEXT
|
||||||
|
|
||||||
|
|
||||||
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,
|
||||||
|
@ -118,7 +118,7 @@ Fat12Format (HANDLE FileHandle,
|
||||||
PFORMAT_CONTEXT Context);
|
PFORMAT_CONTEXT Context);
|
||||||
|
|
||||||
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,
|
||||||
|
@ -127,7 +127,7 @@ Fat16Format (HANDLE FileHandle,
|
||||||
PFORMAT_CONTEXT Context);
|
PFORMAT_CONTEXT Context);
|
||||||
|
|
||||||
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,
|
||||||
|
@ -136,7 +136,7 @@ Fat32Format (HANDLE FileHandle,
|
||||||
PFORMAT_CONTEXT Context);
|
PFORMAT_CONTEXT Context);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
UpdateProgress (PFORMAT_CONTEXT Context,
|
UpdateProgress(PFORMAT_CONTEXT Context,
|
||||||
ULONG Increment);
|
ULONG Increment);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
|
@ -12,14 +12,16 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static ULONG
|
static ULONG
|
||||||
GetShiftCount(ULONG Value)
|
GetShiftCount(IN ULONG Value)
|
||||||
{
|
{
|
||||||
ULONG i = 1;
|
ULONG i = 1;
|
||||||
|
|
||||||
while (Value > 0)
|
while (Value > 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
Value /= 2;
|
Value /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i - 2;
|
return i - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +48,7 @@ CalcVolumeSerialNumber(VOID)
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
FatxWriteBootSector (IN HANDLE FileHandle,
|
FatxWriteBootSector(IN HANDLE FileHandle,
|
||||||
IN PFATX_BOOT_SECTOR BootSector,
|
IN PFATX_BOOT_SECTOR BootSector,
|
||||||
IN OUT PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +62,7 @@ FatxWriteBootSector (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
sizeof(FATX_BOOT_SECTOR));
|
sizeof(FATX_BOOT_SECTOR));
|
||||||
if (NewBootSector == NULL)
|
if (NewBootSector == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the new bootsector */
|
/* Zero the new bootsector */
|
||||||
memset(NewBootSector, 0, sizeof(FATX_BOOT_SECTOR));
|
memset(NewBootSector, 0, sizeof(FATX_BOOT_SECTOR));
|
||||||
|
@ -86,7 +88,7 @@ FatxWriteBootSector (IN HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VfatxUpdateProgress (Context, 1);
|
VfatxUpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Free the new boot sector */
|
/* Free the new boot sector */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, NewBootSector);
|
||||||
|
@ -96,7 +98,7 @@ FatxWriteBootSector (IN HANDLE FileHandle,
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fatx16WriteFAT (IN HANDLE FileHandle,
|
Fatx16WriteFAT(IN HANDLE FileHandle,
|
||||||
IN ULONG SectorOffset,
|
IN ULONG SectorOffset,
|
||||||
IN ULONG FATSectors,
|
IN ULONG FATSectors,
|
||||||
IN OUT PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
|
@ -113,7 +115,7 @@ Fatx16WriteFAT (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
32 * 1024);
|
32 * 1024);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0, 32 * 1024);
|
memset(Buffer, 0, 32 * 1024);
|
||||||
|
@ -141,10 +143,10 @@ Fatx16WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VfatxUpdateProgress (Context, 1);
|
VfatxUpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Zero the begin of the buffer */
|
/* Zero the begin of the buffer */
|
||||||
memset(Buffer, 0, 4);
|
memset(Buffer, 0, 4);
|
||||||
|
@ -173,20 +175,20 @@ Fatx16WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VfatxUpdateProgress (Context, Sectors);
|
VfatxUpdateProgress(Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
Fatx32WriteFAT (IN HANDLE FileHandle,
|
Fatx32WriteFAT(IN HANDLE FileHandle,
|
||||||
IN ULONG SectorOffset,
|
IN ULONG SectorOffset,
|
||||||
IN ULONG FATSectors,
|
IN ULONG FATSectors,
|
||||||
IN OUT PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
|
@ -203,7 +205,7 @@ Fatx32WriteFAT (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
64 * 1024);
|
64 * 1024);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0, 64 * 1024);
|
memset(Buffer, 0, 64 * 1024);
|
||||||
|
@ -213,6 +215,7 @@ Fatx32WriteFAT (IN HANDLE FileHandle,
|
||||||
Buffer[1] = 0xff;
|
Buffer[1] = 0xff;
|
||||||
Buffer[2] = 0xff;
|
Buffer[2] = 0xff;
|
||||||
Buffer[3] = 0x0f;
|
Buffer[3] = 0x0f;
|
||||||
|
|
||||||
/* FAT cluster 1 */
|
/* FAT cluster 1 */
|
||||||
Buffer[4] = 0xff; /* Clean shutdown, no disk read/write errors, end-of-cluster (EOC) mark */
|
Buffer[4] = 0xff; /* Clean shutdown, no disk read/write errors, end-of-cluster (EOC) mark */
|
||||||
Buffer[5] = 0xff;
|
Buffer[5] = 0xff;
|
||||||
|
@ -234,10 +237,10 @@ Fatx32WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VfatxUpdateProgress (Context, 1);
|
VfatxUpdateProgress(Context, 1);
|
||||||
|
|
||||||
/* Zero the begin of the buffer */
|
/* Zero the begin of the buffer */
|
||||||
memset(Buffer, 0, 8);
|
memset(Buffer, 0, 8);
|
||||||
|
@ -267,20 +270,20 @@ Fatx32WriteFAT (IN HANDLE FileHandle,
|
||||||
{
|
{
|
||||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VfatxUpdateProgress (Context, Sectors);
|
VfatxUpdateProgress(Context, Sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
FatxWriteRootDirectory (IN HANDLE FileHandle,
|
FatxWriteRootDirectory(IN HANDLE FileHandle,
|
||||||
IN ULONG FATSectors,
|
IN ULONG FATSectors,
|
||||||
IN OUT PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
|
@ -303,7 +306,7 @@ FatxWriteRootDirectory (IN HANDLE FileHandle,
|
||||||
0,
|
0,
|
||||||
RootDirSectors * 512);
|
RootDirSectors * 512);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
/* Zero the buffer */
|
/* Zero the buffer */
|
||||||
memset(Buffer, 0xff, RootDirSectors * 512);
|
memset(Buffer, 0xff, RootDirSectors * 512);
|
||||||
|
@ -328,23 +331,22 @@ FatxWriteRootDirectory (IN HANDLE FileHandle,
|
||||||
/* Free the buffer */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
FatxFormat (HANDLE FileHandle,
|
FatxFormat(IN HANDLE FileHandle,
|
||||||
PPARTITION_INFORMATION PartitionInfo,
|
IN PPARTITION_INFORMATION PartitionInfo,
|
||||||
PDISK_GEOMETRY DiskGeometry,
|
IN PDISK_GEOMETRY DiskGeometry,
|
||||||
BOOLEAN QuickFormat,
|
IN BOOLEAN QuickFormat,
|
||||||
PFORMAT_CONTEXT Context)
|
IN OUT PFORMAT_CONTEXT Context)
|
||||||
{
|
{
|
||||||
FATX_BOOT_SECTOR BootSector;
|
FATX_BOOT_SECTOR BootSector;
|
||||||
ULONGLONG SectorCount;
|
ULONGLONG SectorCount;
|
||||||
ULONG ClusterCount;
|
ULONG ClusterCount;
|
||||||
ULONG RootDirSectors;
|
ULONG RootDirSectors;
|
||||||
ULONG FATSectors;
|
ULONG FATSectors;
|
||||||
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
SectorCount = PartitionInfo->PartitionLength.QuadPart >> GetShiftCount(512); /* Use shifting to avoid 64-bit division */
|
SectorCount = PartitionInfo->PartitionLength.QuadPart >> GetShiftCount(512); /* Use shifting to avoid 64-bit division */
|
||||||
|
@ -380,7 +382,7 @@ FatxFormat (HANDLE FileHandle,
|
||||||
Context->TotalSectorCount = SectorCount;
|
Context->TotalSectorCount = SectorCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FatxWriteBootSector (FileHandle,
|
Status = FatxWriteBootSector(FileHandle,
|
||||||
&BootSector,
|
&BootSector,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -392,25 +394,26 @@ FatxFormat (HANDLE FileHandle,
|
||||||
/* Write first FAT copy */
|
/* Write first FAT copy */
|
||||||
if (ClusterCount > 65525)
|
if (ClusterCount > 65525)
|
||||||
{
|
{
|
||||||
Status = Fatx32WriteFAT (FileHandle,
|
Status = Fatx32WriteFAT(FileHandle,
|
||||||
0,
|
0,
|
||||||
FATSectors,
|
FATSectors,
|
||||||
Context);
|
Context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Status = Fatx16WriteFAT (FileHandle,
|
Status = Fatx16WriteFAT(FileHandle,
|
||||||
0,
|
0,
|
||||||
FATSectors,
|
FATSectors,
|
||||||
Context);
|
Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("FatxWriteFAT() failed with status 0x%.08x\n", Status);
|
DPRINT("FatxWriteFAT() failed with status 0x%.08x\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FatxWriteRootDirectory (FileHandle,
|
Status = FatxWriteRootDirectory(FileHandle,
|
||||||
FATSectors,
|
FATSectors,
|
||||||
Context);
|
Context);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
VfatxFormat (PUNICODE_STRING DriveRoot,
|
VfatxFormat(IN PUNICODE_STRING DriveRoot,
|
||||||
FMIFS_MEDIA_FLAG MediaFlag,
|
IN FMIFS_MEDIA_FLAG MediaFlag,
|
||||||
PUNICODE_STRING Label,
|
IN PUNICODE_STRING Label,
|
||||||
BOOLEAN QuickFormat,
|
IN BOOLEAN QuickFormat,
|
||||||
ULONG ClusterSize,
|
IN ULONG ClusterSize,
|
||||||
PFMIFSCALLBACK Callback)
|
IN PFMIFSCALLBACK Callback)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
DISK_GEOMETRY DiskGeometry;
|
DISK_GEOMETRY DiskGeometry;
|
||||||
|
@ -134,10 +134,10 @@ VfatxFormat (PUNICODE_STRING DriveRoot,
|
||||||
if (Callback != NULL)
|
if (Callback != NULL)
|
||||||
{
|
{
|
||||||
Context.Percent = 0;
|
Context.Percent = 0;
|
||||||
Callback (PROGRESS, 0, (PVOID)&Context.Percent);
|
Callback(PROGRESS, 0, (PVOID)&Context.Percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FatxFormat (FileHandle,
|
Status = FatxFormat(FileHandle,
|
||||||
&PartitionInfo,
|
&PartitionInfo,
|
||||||
&DiskGeometry,
|
&DiskGeometry,
|
||||||
QuickFormat,
|
QuickFormat,
|
||||||
|
@ -147,7 +147,7 @@ VfatxFormat (PUNICODE_STRING DriveRoot,
|
||||||
if (Callback != NULL)
|
if (Callback != NULL)
|
||||||
{
|
{
|
||||||
Context.Success = (BOOLEAN)(NT_SUCCESS(Status));
|
Context.Success = (BOOLEAN)(NT_SUCCESS(Status));
|
||||||
Callback (DONE, 0, (PVOID)&Context.Success);
|
Callback(DONE, 0, (PVOID)&Context.Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("VfatxFormat() done. Status 0x%.08x\n", Status);
|
DPRINT("VfatxFormat() done. Status 0x%.08x\n", Status);
|
||||||
|
@ -157,20 +157,19 @@ VfatxFormat (PUNICODE_STRING DriveRoot,
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
VfatxUpdateProgress (PFORMAT_CONTEXT Context,
|
VfatxUpdateProgress(IN PFORMAT_CONTEXT Context,
|
||||||
ULONG Increment)
|
IN ULONG Increment)
|
||||||
{
|
{
|
||||||
ULONG NewPercent;
|
ULONG NewPercent;
|
||||||
|
|
||||||
Context->CurrentSectorCount += (ULONGLONG)Increment;
|
Context->CurrentSectorCount += (ULONGLONG)Increment;
|
||||||
|
|
||||||
|
|
||||||
NewPercent = (Context->CurrentSectorCount * 100ULL) / Context->TotalSectorCount;
|
NewPercent = (Context->CurrentSectorCount * 100ULL) / Context->TotalSectorCount;
|
||||||
|
|
||||||
if (NewPercent > Context->Percent)
|
if (NewPercent > Context->Percent)
|
||||||
{
|
{
|
||||||
Context->Percent = NewPercent;
|
Context->Percent = NewPercent;
|
||||||
Context->Callback (PROGRESS, 0, &Context->Percent);
|
Context->Callback(PROGRESS, 0, &Context->Percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue