[FORMATTING]

Fix indentation. No code changes.

svn path=/trunk/; revision=47764
This commit is contained in:
Eric Kohl 2010-06-12 10:25:18 +00:00
parent 78b0fb4a21
commit 0c8457631d
9 changed files with 1644 additions and 1617 deletions

View file

@ -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,

View file

@ -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;

View file

@ -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;
} }
@ -62,7 +64,7 @@ Fat12WriteBootSector (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);
@ -87,7 +89,7 @@ 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 */
@ -95,7 +97,7 @@ Fat12WriteBootSector (IN HANDLE FileHandle,
UpdateProgress(Context, 1); UpdateProgress(Context, 1);
return(Status); return Status;
} }
@ -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,7 +145,7 @@ 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);
@ -176,7 +178,7 @@ 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);
@ -185,7 +187,7 @@ Fat12WriteFAT (IN HANDLE FileHandle,
/* Free the buffer */ /* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
return(Status); return Status;
} }
@ -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) +

View file

@ -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;
} }
@ -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);
@ -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,7 +147,7 @@ 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);
@ -178,7 +180,7 @@ 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);
@ -187,7 +189,7 @@ Fat16WriteFAT (IN HANDLE FileHandle,
/* Free the buffer */ /* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
return(Status); return Status;
} }
@ -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,7 +254,7 @@ 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);
@ -261,18 +263,18 @@ Fat16WriteRootDirectory (IN HANDLE FileHandle,
/* 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);

View file

@ -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;
} }
@ -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);
@ -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,7 +165,7 @@ 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);
@ -171,7 +173,7 @@ Fat32WriteFsInfo (IN HANDLE FileHandle,
/* Free the new sector buffer */ /* Free the new sector buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, FsInfo); RtlFreeHeap(RtlGetProcessHeap(), 0, FsInfo);
return(Status); return Status;
} }
@ -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,7 +233,7 @@ 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);
@ -262,7 +266,7 @@ 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);
@ -271,7 +275,7 @@ Fat32WriteFAT (IN HANDLE FileHandle,
/* Free the buffer */ /* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
return(Status); return Status;
} }
@ -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,7 +331,7 @@ 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);
@ -335,18 +339,18 @@ Fat32WriteRootDirectory (IN HANDLE FileHandle,
/* 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) +

View file

@ -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;
@ -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);

View file

@ -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;
} }
@ -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));
@ -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,7 +143,7 @@ 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);
@ -173,7 +175,7 @@ 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);
@ -182,7 +184,7 @@ Fatx16WriteFAT (IN HANDLE FileHandle,
/* Free the buffer */ /* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
return(Status); return Status;
} }
static NTSTATUS static NTSTATUS
@ -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,7 +237,7 @@ 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);
@ -267,7 +270,7 @@ 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);
@ -276,7 +279,7 @@ Fatx32WriteFAT (IN HANDLE FileHandle,
/* Free the buffer */ /* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
return(Status); return Status;
} }
static NTSTATUS static NTSTATUS
@ -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 */
@ -404,6 +406,7 @@ FatxFormat (HANDLE FileHandle,
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);

View file

@ -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;
@ -157,14 +157,13 @@ 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)