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