mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 20:55:16 +00:00
- Plugin the filesystem checker into vfatlib, however leave its invocation #if0-ed out until all problems are solved.
svn path=/trunk/; revision=35180
This commit is contained in:
parent
7f639dac8f
commit
18dcfea9ac
|
@ -12,6 +12,11 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
PFMIFSCALLBACK ChkdskCallback = NULL;
|
||||
PVOID FsCheckMemQueue;
|
||||
ULONG FsCheckFlags;
|
||||
ULONG FsCheckTotalFiles;
|
||||
|
||||
NTSTATUS NTAPI
|
||||
VfatFormat (PUNICODE_STRING DriveRoot,
|
||||
FMIFS_MEDIA_FLAG MediaFlag,
|
||||
|
@ -50,7 +55,7 @@ VfatFormat (PUNICODE_STRING DriveRoot,
|
|||
FILE_SYNCHRONOUS_IO_ALERT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("NtOpenFile() failed with status 0x%.08x\n", Status);
|
||||
DPRINT1("NtOpenFile() failed with status 0x%.08x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -203,6 +208,25 @@ UpdateProgress (PFORMAT_CONTEXT Context,
|
|||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
VfatPrint(PCHAR Format, ...)
|
||||
{
|
||||
TEXTOUTPUT TextOut;
|
||||
CHAR TextBuf[512];
|
||||
va_list valist;
|
||||
|
||||
va_start(valist, Format);
|
||||
_vsnprintf(TextBuf, sizeof(TextBuf), Format, valist);
|
||||
va_end(valist);
|
||||
|
||||
/* Prepare parameters */
|
||||
TextOut.Lines = 1;
|
||||
TextOut.Output = TextBuf;
|
||||
|
||||
/* Do the callback */
|
||||
if (ChkdskCallback) ChkdskCallback(OUTPUT, 0, &TextOut);
|
||||
}
|
||||
|
||||
NTSTATUS WINAPI
|
||||
VfatChkdsk(
|
||||
IN PUNICODE_STRING DriveRoot,
|
||||
|
@ -212,8 +236,74 @@ VfatChkdsk(
|
|||
IN BOOLEAN ScanDrive,
|
||||
IN PFMIFSCALLBACK Callback)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return STATUS_SUCCESS;
|
||||
BOOLEAN verify, salvage_files;
|
||||
//ULONG free_clusters;
|
||||
//DOS_FS fs;
|
||||
|
||||
/* Store callback pointer */
|
||||
ChkdskCallback = Callback;
|
||||
FsCheckMemQueue = NULL;
|
||||
|
||||
/* Set parameters */
|
||||
FsCheckFlags = 0;
|
||||
if (Verbose) FsCheckFlags |= FSCHECK_VERBOSE;
|
||||
|
||||
FsCheckTotalFiles = 0;
|
||||
|
||||
verify = TRUE;
|
||||
salvage_files = TRUE;
|
||||
#if 0
|
||||
/* Open filesystem */
|
||||
fs_open(DriveRoot,FixErrors);
|
||||
|
||||
if (CheckOnlyIfDirty && !fs_isdirty(DriveRoot))
|
||||
{
|
||||
/* No need to check FS */
|
||||
return fs_close(FALSE);
|
||||
}
|
||||
|
||||
read_boot(&fs);
|
||||
if (verify) VfatPrint("Starting check/repair pass.\n");
|
||||
while (read_fat(&fs), scan_root(&fs)) qfree(&FsCheckMemQueue);
|
||||
if (ScanDrive) fix_bad(&fs);
|
||||
if (salvage_files)
|
||||
reclaim_file(&fs);
|
||||
else
|
||||
reclaim_free(&fs);
|
||||
free_clusters = update_free(&fs);
|
||||
file_unused();
|
||||
qfree(&FsCheckMemQueue);
|
||||
if (verify)
|
||||
{
|
||||
VfatPrint("Starting verification pass.\n");
|
||||
read_fat(&fs);
|
||||
scan_root(&fs);
|
||||
reclaim_free(&fs);
|
||||
qfree(&FsCheckMemQueue);
|
||||
}
|
||||
|
||||
if (fs_changed())
|
||||
{
|
||||
if (FixErrors)
|
||||
{
|
||||
if (FsCheckFlags & FSCHECK_INTERACTIVE)
|
||||
FixErrors = get_key("yn","Perform changes ? (y/n)") == 'y';
|
||||
else
|
||||
VfatPrint("Performing changes.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
VfatPrint("Leaving file system unchanged.\n");
|
||||
}
|
||||
}
|
||||
|
||||
VfatPrint("%wZ: %u files, %lu/%lu clusters\n", DriveRoot,
|
||||
FsCheckTotalFiles, fs.clusters - free_clusters, fs.clusters );
|
||||
|
||||
return fs_close(FixErrors) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
|
||||
#else
|
||||
return STATUS_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -10,6 +10,15 @@
|
|||
#include <ndk/ntndk.h>
|
||||
#include <fmifs/fmifs.h>
|
||||
|
||||
#include "check/dosfsck.h"
|
||||
#include "check/common.h"
|
||||
#include "check/io.h"
|
||||
#include "check/lfn.h"
|
||||
#include "check/boot.h"
|
||||
#include "check/fat.h"
|
||||
#include "check/file.h"
|
||||
#include "check/check.h"
|
||||
|
||||
#define SECTORSIZE 512
|
||||
|
||||
#include <pshpack1.h>
|
||||
|
@ -130,4 +139,7 @@ VOID
|
|||
UpdateProgress (PFORMAT_CONTEXT Context,
|
||||
ULONG Increment);
|
||||
|
||||
VOID
|
||||
VfatPrint(PCHAR Format, ...);
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -7,4 +7,14 @@
|
|||
<file>fat16.c</file>
|
||||
<file>fat32.c</file>
|
||||
<file>vfatlib.c</file>
|
||||
|
||||
<directory name="check">
|
||||
<file>boot.c</file>
|
||||
<file>check.c</file>
|
||||
<file>common.c</file>
|
||||
<file>fat.c</file>
|
||||
<file>file.c</file>
|
||||
<file>io.c</file>
|
||||
<file>lfn.c</file>
|
||||
</directory>
|
||||
</module>
|
||||
|
|
Loading…
Reference in a new issue