e5fabb3ab3593163490792b9964f5a53cdd919b5
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>
12 /* Add handlers here for subcommands */
13 static HandlerProc QueryMain
;
14 static HandlerProc SetMain
;
15 static HandlerItem HandlersList
[] =
17 /* Proc, name, help */
18 { QueryMain
, _T("query"), _T("Show the dirty bit") },
19 { SetMain
, _T("set"), _T("Set the dirty bit") },
23 QueryMain(int argc
, const TCHAR
*argv
[])
26 ULONG VolumeStatus
, BytesRead
;
28 /* We need a volume (letter or GUID) */
31 _ftprintf(stderr
, _T("Usage: fsutil dirty query <volume>\n"));
32 _ftprintf(stderr
, _T("\tFor example: fsutil dirty query c:\n"));
36 /* Get a handle for the volume */
37 Volume
= OpenVolume(argv
[1], FALSE
);
38 if (Volume
== INVALID_HANDLE_VALUE
)
43 /* And query the dirty status */
44 if (DeviceIoControl(Volume
, FSCTL_IS_VOLUME_DIRTY
, NULL
, 0, &VolumeStatus
,
45 sizeof(ULONG
), &BytesRead
, NULL
) == FALSE
)
47 PrintErrorMessage(GetLastError());
54 /* Print the status */
55 _ftprintf(stdout
, _T("The %s volume is %s\n"), argv
[1], ((VolumeStatus
& VOLUME_IS_DIRTY
) ? _T("dirty") : _T("clean")));
61 SetMain(int argc
, const TCHAR
*argv
[])
66 /* We need a volume (letter or GUID) */
69 _ftprintf(stderr
, _T("Usage: fsutil dirty set <volume>\n"));
70 _ftprintf(stderr
, _T("\tFor example: fsutil dirty set c:\n"));
74 /* Get a handle for the volume */
75 Volume
= OpenVolume(argv
[1], FALSE
);
76 if (Volume
== INVALID_HANDLE_VALUE
)
81 /* And set the dirty bit */
82 if (DeviceIoControl(Volume
, FSCTL_MARK_VOLUME_DIRTY
, NULL
, 0, NULL
, 0, &BytesRead
, NULL
) == FALSE
)
84 PrintErrorMessage(GetLastError());
91 /* Print the status */
92 _ftprintf(stdout
, _T("The %s volume is now marked as dirty\n"), argv
[1]);
98 PrintUsage(const TCHAR
* Command
)
100 PrintDefaultUsage(_T(" DIRTY "), Command
, (HandlerItem
*)&HandlersList
,
101 (sizeof(HandlersList
) / sizeof(HandlersList
[0])));
105 DirtyMain(int argc
, const TCHAR
*argv
[])
107 return FindHandler(argc
, argv
, (HandlerItem
*)&HandlersList
,
108 (sizeof(HandlersList
) / sizeof(HandlersList
[0])),