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