ReactOS  0.4.12-dev-18-gf469aca
dirty.c File Reference
#include "fsutil.h"
#include <winioctl.h>
Include dependency graph for dirty.c:

Go to the source code of this file.

Functions

static int QueryMain (int argc, const TCHAR *argv[])
 
static int SetMain (int argc, const TCHAR *argv[])
 
static void PrintUsage (const TCHAR *Command)
 
int DirtyMain (int argc, const TCHAR *argv[])
 

Variables

static HandlerProc QueryMain
 
static HandlerProc SetMain
 
static HandlerItem HandlersList []
 

Function Documentation

◆ DirtyMain()

int DirtyMain ( int  argc,
const TCHAR argv[] 
)

Definition at line 105 of file dirty.c.

106 {
108  (sizeof(HandlersList) / sizeof(HandlersList[0])),
109  PrintUsage);
110 }
static int argc
Definition: ServiceArgs.c:12
static char ** argv
Definition: ServiceArgs.c:11
int FindHandler(int argc, const TCHAR *argv[], HandlerItem *HandlersList, int HandlerListCount, void(*UsageHelper)(const TCHAR *))
Definition: common.c:11
static HandlerItem HandlersList[]
Definition: dirty.c:15
static void PrintUsage(const TCHAR *Command)
Definition: dirty.c:98

◆ PrintUsage()

static void PrintUsage ( const TCHAR Command)
static

Definition at line 98 of file dirty.c.

Referenced by DirtyMain().

99 {
101  (sizeof(HandlersList) / sizeof(HandlersList[0])));
102 }
void PrintDefaultUsage(const TCHAR *Command, const TCHAR *SubCommand, HandlerItem *HandlersList, int HandlerListCount)
Definition: common.c:102
Definition: shell.h:41
static HandlerItem HandlersList[]
Definition: dirty.c:15
#define _T(x)
Definition: vfdio.h:22

◆ QueryMain()

static int QueryMain ( int  argc,
const TCHAR argv[] 
)
static

Definition at line 23 of file dirty.c.

24 {
25  HANDLE Volume;
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 */
37  Volume = OpenVolume(argv[1], FALSE, FALSE);
38  if (Volume == INVALID_HANDLE_VALUE)
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  {
48  CloseHandle(Volume);
49  return 1;
50  }
51 
52  CloseHandle(Volume);
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 }
static int argc
Definition: ServiceArgs.c:12
#define CloseHandle
Definition: compat.h:398
#define VOLUME_IS_DIRTY
Definition: ntifs_ex.h:330
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
smooth NULL
Definition: ftsmooth.c:416
HANDLE OpenVolume(const TCHAR *Volume, BOOLEAN AllowRemote, BOOLEAN NtfsOnly)
Definition: common.c:49
#define _ftprintf
Definition: tchar.h:518
#define _T(x)
Definition: vfdio.h:22
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
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
#define FSCTL_IS_VOLUME_DIRTY
Definition: winioctl.h:636
unsigned int ULONG
Definition: retypes.h:1
FILE * stderr
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

◆ SetMain()

static int SetMain ( int  argc,
const TCHAR argv[] 
)
static

Definition at line 61 of file dirty.c.

62 {
63  HANDLE Volume;
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 */
75  Volume = OpenVolume(argv[1], FALSE, FALSE);
76  if (Volume == INVALID_HANDLE_VALUE)
77  {
78  return 1;
79  }
80 
81  /* And set the dirty bit */
82  if (DeviceIoControl(Volume, FSCTL_MARK_VOLUME_DIRTY, NULL, 0, NULL, 0, &BytesRead, NULL) == FALSE)
83  {
85  CloseHandle(Volume);
86  return 1;
87  }
88 
89  CloseHandle(Volume);
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 }
static int argc
Definition: ServiceArgs.c:12
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FSCTL_MARK_VOLUME_DIRTY
Definition: nt_native.h:838
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
smooth NULL
Definition: ftsmooth.c:416
HANDLE OpenVolume(const TCHAR *Volume, BOOLEAN AllowRemote, BOOLEAN NtfsOnly)
Definition: common.c:49
#define _ftprintf
Definition: tchar.h:518
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
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
FILE * stderr
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

Variable Documentation

◆ HandlersList

HandlerItem HandlersList[]
static
Initial value:
=
{
{ QueryMain, _T("query"), _T("Show the dirty bit") },
{ SetMain, _T("set"), _T("Set the dirty bit") },
}
#define _T(x)
Definition: vfdio.h:22
static HandlerProc QueryMain
Definition: dirty.c:13
static HandlerProc SetMain
Definition: dirty.c:14

Definition at line 15 of file dirty.c.

◆ QueryMain

HandlerProc QueryMain
static

Definition at line 13 of file dirty.c.

◆ SetMain

HandlerProc SetMain
static

Definition at line 14 of file dirty.c.