ReactOS 0.4.15-dev-7942-gd23573b
dirty.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS FS utility tool
4 * FILE: base/applications/cmdutils/dirty.c
5 * PURPOSE: FSutil dirty bit handling
6 * PROGRAMMERS: Pierre Schweitzer <pierre@reactos.org>
7 */
8
9#include "fsutil.h"
10#include <winioctl.h>
11
12/* Add handlers here for subcommands */
16{
17 /* Proc, name, help */
18 { QueryMain, _T("query"), _T("Show the dirty bit") },
19 { SetMain, _T("set"), _T("Set the dirty bit") },
20};
21
22static int
23QueryMain(int argc, const TCHAR *argv[])
24{
26 ULONG VolumeStatus, BytesRead;
27
28 /* We need a volume (letter or GUID) */
29 if (argc < 2)
30 {
31 _ftprintf(stderr, _T("Usage: fsutil dirty query <volume>\n"));
32 _ftprintf(stderr, _T("\tFor example: fsutil dirty query c:\n"));
33 return 1;
34 }
35
36 /* Get a handle for the volume */
39 {
40 return 1;
41 }
42
43 /* And query the dirty status */
44 if (DeviceIoControl(Volume, FSCTL_IS_VOLUME_DIRTY, NULL, 0, &VolumeStatus,
45 sizeof(ULONG), &BytesRead, NULL) == FALSE)
46 {
49 return 1;
50 }
51
53
54 /* Print the status */
55 _ftprintf(stdout, _T("The %s volume is %s\n"), argv[1], ((VolumeStatus & VOLUME_IS_DIRTY) ? _T("dirty") : _T("clean")));
56
57 return 0;
58}
59
60static int
61SetMain(int argc, const TCHAR *argv[])
62{
65
66 /* We need a volume (letter or GUID) */
67 if (argc < 2)
68 {
69 _ftprintf(stderr, _T("Usage: fsutil dirty set <volume>\n"));
70 _ftprintf(stderr, _T("\tFor example: fsutil dirty set c:\n"));
71 return 1;
72 }
73
74 /* Get a handle for the volume */
77 {
78 return 1;
79 }
80
81 /* And set the dirty bit */
83 {
86 return 1;
87 }
88
90
91 /* Print the status */
92 _ftprintf(stdout, _T("The %s volume is now marked as dirty\n"), argv[1]);
93
94 return 0;
95}
96
97static void
99{
101 (sizeof(HandlersList) / sizeof(HandlersList[0])));
102}
103
104int
105DirtyMain(int argc, const TCHAR *argv[])
106{
108 (sizeof(HandlersList) / sizeof(HandlersList[0])),
109 PrintUsage);
110}
static int argc
Definition: ServiceArgs.c:12
HandlerProc DirtyMain
Definition: fsutil.c:12
int() HandlerProc(int argc, const TCHAR *argv[])
Definition: fsutil.h:8
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
HANDLE OpenVolume(const TCHAR *Volume, BOOLEAN AllowRemote, BOOLEAN NtfsOnly)
Definition: common.c:49
void PrintDefaultUsage(const TCHAR *Command, const TCHAR *SubCommand, HandlerItem *HandlersList, int HandlerListCount)
Definition: common.c:102
int FindHandler(int argc, const TCHAR *argv[], HandlerItem *HandlersList, int HandlerListCount, void(*UsageHelper)(const TCHAR *))
Definition: common.c:11
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
static HandlerProc QueryMain
Definition: dirty.c:13
static HandlerProc SetMain
Definition: dirty.c:14
static HandlerItem HandlersList[]
Definition: dirty.c:15
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
unsigned long DWORD
Definition: ntddk_ex.h:95
#define stdout
Definition: stdio.h:99
#define stderr
Definition: stdio.h:100
#define _ftprintf
Definition: tchar.h:518
UNICODE_STRING Volume
Definition: fltkernel.h:1172
#define argv
Definition: mplay32.c:18
void PrintUsage()
Definition: nslookup.c:68
#define FSCTL_MARK_VOLUME_DIRTY
Definition: nt_native.h:838
#define VOLUME_IS_DIRTY
Definition: ntifs_ex.h:330
#define FSCTL_IS_VOLUME_DIRTY
Definition: winioctl.h:714
Definition: shell.h:41
uint32_t ULONG
Definition: typedefs.h:59
#define _T(x)
Definition: vfdio.h:22
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
char TCHAR
Definition: xmlstorage.h:189