ReactOS 0.4.16-dev-178-g8ba6102
chkdsk.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: File Management IFS Utility functions
4 * FILE: reactos/dll/win32/fmifs/chkdsk.c
5 * PURPOSE: Disk Checker
6 *
7 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10#include "precomp.h"
11#include <ntstrsafe.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* FMIFS.1 */
17VOID
20 IN PWCHAR DriveRoot,
22 IN BOOLEAN CorrectErrors,
24 IN BOOLEAN CheckOnlyIfDirty,
25 IN BOOLEAN ScanDrive,
26 IN PVOID Unused2,
27 IN PVOID Unused3,
29{
31 UNICODE_STRING usDriveRoot;
34 WCHAR DriveName[MAX_PATH];
36
38 if (!Provider)
39 {
40 /* Unknown file system */
41 goto Quit;
42 }
43
44 if (!NT_SUCCESS(RtlStringCchCopyW(DriveName, ARRAYSIZE(DriveName), DriveRoot)))
45 goto Quit;
46
47 if (DriveName[wcslen(DriveName) - 1] != L'\\')
48 {
49 /* Append the trailing backslash for GetVolumeNameForVolumeMountPointW */
50 if (!NT_SUCCESS(RtlStringCchCatW(DriveName, ARRAYSIZE(DriveName), L"\\")))
51 goto Quit;
52 }
53
55 {
56 /* Couldn't get a volume GUID path, try checking using a parameter provided path */
57 DPRINT1("Couldn't get a volume GUID path for drive %S\n", DriveName);
58 wcscpy(VolumeName, DriveName);
59 }
60
62 goto Quit;
63
64 /* Trim the trailing backslash since we will work with a device object */
65 usDriveRoot.Length -= sizeof(WCHAR);
66
67 DPRINT("Chkdsk() - %S\n", Format);
69 Success = Provider->Chkdsk(&usDriveRoot,
71 CorrectErrors,
72 Verbose,
73 CheckOnlyIfDirty,
74 ScanDrive,
75 NULL,
76 NULL,
77 NULL,
78 NULL,
79 (PULONG)&Status);
80 if (!Success)
81 DPRINT1("Chkdsk() failed with Status 0x%lx\n", Status);
82
83 RtlFreeUnicodeString(&usDriveRoot);
84
85Quit:
86 /* Report result */
87 Callback(DONE, 0, &Success);
88}
89
90/* EOF */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
BOOL Verbose
Definition: chkdsk.c:72
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_PATH
Definition: compat.h:34
VOID NTAPI Chkdsk(IN PWCHAR DriveRoot, IN PWCHAR Format, IN BOOLEAN CorrectErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID Unused2, IN PVOID Unused3, IN PFMIFSCALLBACK Callback)
Definition: chkdsk.c:19
@ Success
Definition: eventcreate.c:712
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
BOOLEAN(NTAPI * PFMIFSCALLBACK)(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: fmifs.h:103
return pInstance GetProvider() -> GetHandle()
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL WINAPI GetVolumeNameForVolumeMountPointW(IN LPCWSTR VolumeMountPoint, OUT LPWSTR VolumeName, IN DWORD VolumeNameLength)
Definition: mntpoint.c:496
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
NTSTRSAFEAPI RtlStringCchCatW(_Inout_updates_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:601
#define L(x)
Definition: ntvdm.h:50
#define DONE
Definition: rnr20lib.h:14
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
__wchar_t WCHAR
Definition: xmlstorage.h:180