Author: fireball
Date: Fri Aug 8 04:53:13 2008
New Revision: 35180
URL:
http://svn.reactos.org/svn/reactos?rev=35180&view=rev
Log:
- Plugin the filesystem checker into vfatlib, however leave its invocation #if0-ed out
until all problems are solved.
Modified:
trunk/reactos/lib/fslib/vfatlib/vfatlib.c
trunk/reactos/lib/fslib/vfatlib/vfatlib.h
trunk/reactos/lib/fslib/vfatlib/vfatlib.rbuild
Modified: trunk/reactos/lib/fslib/vfatlib/vfatlib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/vfatlib.…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/vfatlib.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/vfatlib.c [iso-8859-1] Fri Aug 8 04:53:13 2008
@@ -11,6 +11,11 @@
#define NDEBUG
#include <debug.h>
+
+PFMIFSCALLBACK ChkdskCallback = NULL;
+PVOID FsCheckMemQueue;
+ULONG FsCheckFlags;
+ULONG FsCheckTotalFiles;
NTSTATUS NTAPI
VfatFormat (PUNICODE_STRING DriveRoot,
@@ -50,7 +55,7 @@
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 @@
}
}
+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 @@
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 */
Modified: trunk/reactos/lib/fslib/vfatlib/vfatlib.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/vfatlib.…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/vfatlib.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/vfatlib.h [iso-8859-1] Fri Aug 8 04:53:13 2008
@@ -9,6 +9,15 @@
#define NTOS_MODE_USER
#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
@@ -130,4 +139,7 @@
UpdateProgress (PFORMAT_CONTEXT Context,
ULONG Increment);
+VOID
+VfatPrint(PCHAR Format, ...);
+
/* EOF */
Modified: trunk/reactos/lib/fslib/vfatlib/vfatlib.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/vfatlib.…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/vfatlib.rbuild [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/vfatlib.rbuild [iso-8859-1] Fri Aug 8 04:53:13 2008
@@ -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>