Reactos
at master 104 lines 2.7 kB view raw
1/* 2 * PROJECT: ReactOS DiskPart 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/system/diskpart/filesystems.c 5 * PURPOSE: Manages all the partitions of the OS in an interactive way. 6 * PROGRAMMERS: Lee Schroeder 7 */ 8 9#include "diskpart.h" 10 11#define NDEBUG 12#include <debug.h> 13 14static 15VOID 16ShowFileSystemInfo( 17 _In_ PVOLENTRY VolumeEntry) 18{ 19 WCHAR szBuffer[32]; 20 PWSTR pszSizeUnit = L""; 21 ULONG ulClusterSize; 22 23 ConResPuts(StdOut, IDS_FILESYSTEMS_CURRENT); 24 ConPuts(StdOut, L"\n"); 25 26 ConResPrintf(StdOut, IDS_FILESYSTEMS_TYPE, VolumeEntry->pszFilesystem); 27 28 ulClusterSize = VolumeEntry->SectorsPerAllocationUnit * VolumeEntry->BytesPerSector; 29 if (ulClusterSize >= SIZE_10MB) /* 10 MB */ 30 { 31 ulClusterSize = RoundingDivide(ulClusterSize, SIZE_1MB); 32 pszSizeUnit = L"MB"; 33 } 34 else if (ulClusterSize >= SIZE_10KB) /* 10 KB */ 35 { 36 ulClusterSize = RoundingDivide(ulClusterSize, SIZE_1KB); 37 pszSizeUnit = L"KB"; 38 } 39 40 wsprintf(szBuffer, L"%lu %s", ulClusterSize, pszSizeUnit); 41 ConResPrintf(StdOut, IDS_FILESYSTEMS_CLUSTERSIZE, szBuffer); 42 ConResPrintf(StdOut, IDS_FILESYSTEMS_SERIAL_NUMBER, VolumeEntry->SerialNumber); 43 ConPuts(StdOut, L"\n"); 44} 45 46 47static 48VOID 49ShowInstalledFileSystems( 50 _In_ PVOLENTRY VolumeEntry) 51{ 52 WCHAR szBuffer[256]; 53 WCHAR szDefault[32]; 54 BOOLEAN ret; 55 DWORD dwIndex; 56 UCHAR uMajor, uMinor; 57 BOOLEAN bLatest; 58 59 LoadStringW(GetModuleHandle(NULL), 60 IDS_FILESYSTEMS_DEFAULT, 61 szDefault, ARRAYSIZE(szDefault)); 62 63 ConResPuts(StdOut, IDS_FILESYSTEMS_FORMATTING); 64 ConPuts(StdOut, L"\n"); 65 66 for (dwIndex = 0; ; dwIndex++) 67 { 68 ret = QueryAvailableFileSystemFormat(dwIndex, 69 szBuffer, 70 &uMajor, 71 &uMinor, 72 &bLatest); 73 if (ret == FALSE) 74 break; 75 76 if (wcscmp(szBuffer, L"FAT") == 0) 77 wcscat(szBuffer, szDefault); 78 79 ConResPrintf(StdOut, IDS_FILESYSTEMS_TYPE, szBuffer); 80 wcscpy(szBuffer, L"-"); 81 ConResPrintf(StdOut, IDS_FILESYSTEMS_CLUSTERSIZE, szBuffer); 82 ConPuts(StdOut, L"\n"); 83 } 84} 85 86 87EXIT_CODE 88filesystems_main( 89 _In_ INT argc, 90 _In_ PWSTR *argv) 91{ 92 if (CurrentVolume == NULL) 93 { 94 ConResPuts(StdOut, IDS_SELECT_NO_VOLUME); 95 return EXIT_SUCCESS; 96 } 97 98 ConPuts(StdOut, L"\n"); 99 100 ShowFileSystemInfo(CurrentVolume); 101 ShowInstalledFileSystems(CurrentVolume); 102 103 return EXIT_SUCCESS; 104}