cec651ea311442844deb85ba99b3fb272e299c68
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 int QueryMain(int argc
, const TCHAR
*argv
[]);
14 static int SetMain(int argc
, const TCHAR
*argv
[]);
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 TCHAR VolumeID
[PATH_MAX
];
27 ULONG VolumeStatus
, BytesRead
;
29 /* We need a volume (letter or GUID) */
32 _ftprintf(stderr
, _T("Usage: fsutil dirty query <volume>\n"));
33 _ftprintf(stderr
, _T("\tFor example: fsutil dirty query c:\n"));
37 /* Create full name */
38 _stprintf(VolumeID
, _T("\\\\.\\%s"), argv
[1]);
41 Volume
= CreateFile(VolumeID
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
,
42 NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
43 if (Volume
== INVALID_HANDLE_VALUE
)
45 _ftprintf(stderr
, _T("Error: %d\n"), GetLastError());
49 /* And query the dirty status */
50 if (DeviceIoControl(Volume
, FSCTL_IS_VOLUME_DIRTY
, NULL
, 0, &VolumeStatus
,
51 sizeof(ULONG
), &BytesRead
, NULL
) == FALSE
)
53 _ftprintf(stderr
, _T("Error: %d\n"), GetLastError());
60 /* Print the status */
61 _ftprintf(stdout
, _T("The %s volume is %s\n"), argv
[1], (VolumeStatus
& VOLUME_IS_DIRTY
? _T("dirty") : _T("clean")));
67 SetMain(int argc
, const TCHAR
*argv
[])
70 _ftprintf(stderr
, _T("Not implemented\n"));
75 PrintUsage(const TCHAR
* Command
)
79 /* If we were given a command, print it's not supported */
82 _ftprintf(stderr
, _T("Unhandled DIRTY command: %s\n"), Command
);
85 /* And dump any available command */
86 _ftprintf(stderr
, _T("---- Handled DIRTY commands ----\n\n"));
87 for (i
= 0; i
< (sizeof(HandlersList
) / sizeof(HandlersList
[0])); ++i
)
89 _ftprintf(stderr
, _T("%s\t%s\n"), HandlersList
[i
].Command
, HandlersList
[i
].Desc
);
94 DirtyMain(int argc
, const TCHAR
*argv
[])
96 return FindHandler(argc
, argv
, (HandlerItem
*)&HandlersList
,
97 (sizeof(HandlersList
) / sizeof(HandlersList
[0])),