format.c (c2c66aff) | format.c (8d3e80e4) |
---|---|
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) --- 33 unchanged lines hidden (view full) --- 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; | 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) --- 33 unchanged lines hidden (view full) --- 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; | 50 BOOLEAN Success = FALSE; 51 BOOLEAN BackwardCompatible = FALSE; // Default to latest FS versions. 52 MEDIA_TYPE MediaType; |
51 WCHAR VolumeName[MAX_PATH]; 52 //CURDIR CurDir; 53 | 53 WCHAR VolumeName[MAX_PATH]; 54 //CURDIR CurDir; 55 |
56// 57// TODO: Convert filesystem Format into ULIB format string. 58// 59 |
|
54 Provider = GetProvider(Format); 55 if (!Provider) 56 { 57 /* Unknown file system */ | 60 Provider = GetProvider(Format); 61 if (!Provider) 62 { 63 /* Unknown file system */ |
58 Callback(DONE, 0, &Argument); | 64 Callback(DONE, 0, &Success); |
59 return; 60 } 61 62#if 1 63 DPRINT1("Warning: use GetVolumeNameForVolumeMountPointW() instead!\n"); 64 swprintf(VolumeName, L"\\??\\%c:", towupper(DriveRoot[0])); 65 RtlCreateUnicodeString(&usDriveRoot, VolumeName); 66 /* Code disabled as long as our storage stack doesn't understand IOCTL_MOUNTDEV_QUERY_DEVICE_NAME */ 67#else | 65 return; 66 } 67 68#if 1 69 DPRINT1("Warning: use GetVolumeNameForVolumeMountPointW() instead!\n"); 70 swprintf(VolumeName, L"\\??\\%c:", towupper(DriveRoot[0])); 71 RtlCreateUnicodeString(&usDriveRoot, VolumeName); 72 /* Code disabled as long as our storage stack doesn't understand IOCTL_MOUNTDEV_QUERY_DEVICE_NAME */ 73#else |
68 if (!GetVolumeNameForVolumeMountPointW(DriveRoot, VolumeName, MAX_PATH) || | 74 if (!GetVolumeNameForVolumeMountPointW(DriveRoot, VolumeName, RTL_NUMBER_OF(VolumeName)) || |
69 !RtlDosPathNameToNtPathName_U(VolumeName, &usDriveRoot, NULL, &CurDir)) 70 { | 75 !RtlDosPathNameToNtPathName_U(VolumeName, &usDriveRoot, NULL, &CurDir)) 76 { |
71 /* Report an error. */ 72 Callback(DONE, 0, &Argument); | 77 /* Report an error */ 78 Callback(DONE, 0, &Success); |
73 return; 74 } 75#endif 76 77 RtlInitUnicodeString(&usLabel, Label); 78 | 79 return; 80 } 81#endif 82 83 RtlInitUnicodeString(&usLabel, Label); 84 |
79 DPRINT("FormatEx - %S\n", Format); 80 Provider->FormatEx(&usDriveRoot, 81 MediaFlag, 82 &usLabel, 83 QuickFormat, 84 ClusterSize, 85 Callback); | 85 /* Set the BackwardCompatible flag in case we format with older FAT12/16 */ 86 if (wcsicmp(Format, L"FAT") == 0) 87 BackwardCompatible = TRUE; 88 // else if (wcsicmp(Format, L"FAT32") == 0) 89 // BackwardCompatible = FALSE; |
86 | 90 |
91 /* Convert the FMIFS MediaFlag to a NT MediaType */ 92 // FIXME: Actually covert all the possible flags. 93 switch (MediaFlag) 94 { 95 case FMIFS_FLOPPY: 96 MediaType = F5_320_1024; // FIXME: This is hardfixed! 97 break; 98 case FMIFS_REMOVABLE: 99 MediaType = RemovableMedia; 100 break; 101 case FMIFS_HARDDISK: 102 MediaType = FixedMedia; 103 break; 104 default: 105 DPRINT1("Unknown FMIFS MediaFlag %d, converting 1-to-1 to NT MediaType\n", 106 MediaFlag); 107 MediaType = (MEDIA_TYPE)MediaFlag; 108 break; 109 } 110 111 DPRINT("Format() - %S\n", Format); 112 Success = Provider->Format(&usDriveRoot, 113 Callback, 114 QuickFormat, 115 BackwardCompatible, 116 MediaType, 117 &usLabel, 118 ClusterSize); 119 if (!Success) 120 DPRINT1("Format() failed\n"); 121 122 /* Report success */ 123 Callback(DONE, 0, &Success); 124 |
|
87 RtlFreeUnicodeString(&usDriveRoot); 88} 89 90/* EOF */ | 125 RtlFreeUnicodeString(&usDriveRoot); 126} 127 128/* EOF */ |