7f10962dfd9feb5cef193733c65a70087a241b31
[reactos.git] / reactos / dll / win32 / fmifs / format.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: File Management IFS Utility functions
4 * FILE: reactos/dll/win32/fmifs/format.c
5 * PURPOSE: Volume format
6 *
7 * PROGRAMMERS: Emanuele Aliberti
8 * Hervé Poussineau (hpoussin@reactos.org)
9 */
10
11 #include "precomp.h"
12
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FMIFS.6 */
17 VOID
18 NTAPI
19 Format(VOID)
20 {
21 }
22
23 /* FMIFS.7 */
24 VOID
25 NTAPI
26 FormatEx(
27 IN PWCHAR DriveRoot,
28 IN FMIFS_MEDIA_FLAG MediaFlag,
29 IN PWCHAR Format,
30 IN PWCHAR Label,
31 IN BOOLEAN QuickFormat,
32 IN ULONG ClusterSize,
33 IN PFMIFSCALLBACK Callback)
34 {
35 PIFS_PROVIDER Provider;
36 UNICODE_STRING usDriveRoot;
37 UNICODE_STRING usLabel;
38 BOOLEAN Argument = FALSE;
39 WCHAR VolumeName[MAX_PATH];
40 //CURDIR CurDir;
41
42 Provider = GetProvider(Format);
43 if (!Provider)
44 {
45 /* Unknown file system */
46 Callback(DONE, /* Command */
47 0, /* DWORD Modifier */
48 &Argument); /* Argument */
49 return;
50 }
51
52 #if 1
53 DPRINT1("Warning: use GetVolumeNameForVolumeMountPointW() instead!\n");
54 swprintf(VolumeName, L"\\??\\%c:", towupper(DriveRoot[0]));
55 RtlCreateUnicodeString(&usDriveRoot, VolumeName);
56 /* Code disabled as long as our storage stack doesn't understand IOCTL_MOUNTDEV_QUERY_DEVICE_NAME */
57 #else
58 if (!GetVolumeNameForVolumeMountPointW(DriveRoot, VolumeName, MAX_PATH) ||
59 !RtlDosPathNameToNtPathName_U(VolumeName, &usDriveRoot, NULL, &CurDir))
60 {
61 /* Report an error. */
62 Callback(DONE, /* Command */
63 0, /* DWORD Modifier */
64 &Argument); /* Argument */
65 return;
66 }
67 #endif
68
69 RtlInitUnicodeString(&usLabel, Label);
70
71 DPRINT("FormatEx - %S\n", Format);
72 Provider->FormatEx(&usDriveRoot,
73 MediaFlag,
74 &usLabel,
75 QuickFormat,
76 ClusterSize,
77 Callback);
78
79 RtlFreeUnicodeString(&usDriveRoot);
80 }
81
82 /* EOF */