9aed4196c26d8c6e9af58b93772db361a2974a78
[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 NTAPI
18 Format(
19 IN PWCHAR DriveRoot,
20 IN FMIFS_MEDIA_FLAG MediaFlag,
21 IN PWCHAR Format,
22 IN PWCHAR Label,
23 IN BOOLEAN QuickFormat,
24 IN PFMIFSCALLBACK Callback)
25 {
26 FormatEx(DriveRoot,
27 MediaFlag,
28 Format,
29 Label,
30 QuickFormat,
31 0,
32 Callback);
33 }
34
35 /* FMIFS.7 */
36 VOID
37 NTAPI
38 FormatEx(
39 IN PWCHAR DriveRoot,
40 IN FMIFS_MEDIA_FLAG MediaFlag,
41 IN PWCHAR Format,
42 IN PWCHAR Label,
43 IN BOOLEAN QuickFormat,
44 IN ULONG ClusterSize,
45 IN PFMIFSCALLBACK Callback)
46 {
47 PIFS_PROVIDER Provider;
48 UNICODE_STRING usDriveRoot;
49 UNICODE_STRING usLabel;
50 BOOLEAN Argument = FALSE;
51 WCHAR VolumeName[MAX_PATH];
52 //CURDIR CurDir;
53
54 Provider = GetProvider(Format);
55 if (!Provider)
56 {
57 /* Unknown file system */
58 Callback(DONE, /* Command */
59 0, /* DWORD Modifier */
60 &Argument); /* Argument */
61 return;
62 }
63
64 #if 1
65 DPRINT1("Warning: use GetVolumeNameForVolumeMountPointW() instead!\n");
66 swprintf(VolumeName, L"\\??\\%c:", towupper(DriveRoot[0]));
67 RtlCreateUnicodeString(&usDriveRoot, VolumeName);
68 /* Code disabled as long as our storage stack doesn't understand IOCTL_MOUNTDEV_QUERY_DEVICE_NAME */
69 #else
70 if (!GetVolumeNameForVolumeMountPointW(DriveRoot, VolumeName, MAX_PATH) ||
71 !RtlDosPathNameToNtPathName_U(VolumeName, &usDriveRoot, NULL, &CurDir))
72 {
73 /* Report an error. */
74 Callback(DONE, /* Command */
75 0, /* DWORD Modifier */
76 &Argument); /* Argument */
77 return;
78 }
79 #endif
80
81 RtlInitUnicodeString(&usLabel, Label);
82
83 DPRINT("FormatEx - %S\n", Format);
84 Provider->FormatEx(&usDriveRoot,
85 MediaFlag,
86 &usLabel,
87 QuickFormat,
88 ClusterSize,
89 Callback);
90
91 RtlFreeUnicodeString(&usDriveRoot);
92 }
93
94 /* EOF */