1 /* 2 * PROJECT: ReactOS Setup Library 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: Filesystem Format and ChkDsk support functions 5 * COPYRIGHT: Copyright 2003-2019 Casper S. Hornstrup <chorns@users.sourceforge.net> 6 * Copyright 2017-2024 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> 7 */ 8 9 #pragma once 10 11 #include <fmifs/fmifs.h> 12 13 /** QueryAvailableFileSystemFormat() **/ 14 BOOLEAN 15 GetRegisteredFileSystems( 16 IN ULONG Index, 17 OUT PCWSTR* FileSystemName); 18 19 20 /** ChkdskEx() **/ 21 NTSTATUS 22 ChkdskFileSystem_UStr( 23 _In_ PUNICODE_STRING DriveRoot, 24 _In_ PCWSTR FileSystemName, 25 _In_ BOOLEAN FixErrors, 26 _In_ BOOLEAN Verbose, 27 _In_ BOOLEAN CheckOnlyIfDirty, 28 _In_ BOOLEAN ScanDrive, 29 _In_opt_ PFMIFSCALLBACK Callback); 30 31 NTSTATUS 32 ChkdskFileSystem( 33 _In_ PCWSTR DriveRoot, 34 _In_ PCWSTR FileSystemName, 35 _In_ BOOLEAN FixErrors, 36 _In_ BOOLEAN Verbose, 37 _In_ BOOLEAN CheckOnlyIfDirty, 38 _In_ BOOLEAN ScanDrive, 39 _In_opt_ PFMIFSCALLBACK Callback); 40 41 42 /** FormatEx() **/ 43 NTSTATUS 44 FormatFileSystem_UStr( 45 _In_ PUNICODE_STRING DriveRoot, 46 _In_ PCWSTR FileSystemName, 47 _In_ FMIFS_MEDIA_FLAG MediaFlag, 48 _In_opt_ PUNICODE_STRING Label, 49 _In_ BOOLEAN QuickFormat, 50 _In_ ULONG ClusterSize, 51 _In_opt_ PFMIFSCALLBACK Callback); 52 53 NTSTATUS 54 FormatFileSystem( 55 _In_ PCWSTR DriveRoot, 56 _In_ PCWSTR FileSystemName, 57 _In_ FMIFS_MEDIA_FLAG MediaFlag, 58 _In_opt_ PCWSTR Label, 59 _In_ BOOLEAN QuickFormat, 60 _In_ ULONG ClusterSize, 61 _In_opt_ PFMIFSCALLBACK Callback); 62 63 64 // 65 // Bootsector routines 66 // 67 68 #define FAT_BOOTSECTOR_SIZE (1 * SECTORSIZE) 69 #define FAT32_BOOTSECTOR_SIZE (1 * SECTORSIZE) // Counts only the primary sector. 70 #define BTRFS_BOOTSECTOR_SIZE (3 * SECTORSIZE) 71 #define NTFS_BOOTSECTOR_SIZE (16 * SECTORSIZE) 72 73 typedef NTSTATUS 74 (/*NTAPI*/ *PFS_INSTALL_BOOTCODE)( 75 IN PCWSTR SrcPath, // Bootsector source file (on the installation medium) 76 IN HANDLE DstPath, // Where to save the bootsector built from the source + partition information 77 IN HANDLE RootPartition); // Partition holding the (old) bootsector data information 78 79 NTSTATUS 80 InstallFatBootCode( 81 IN PCWSTR SrcPath, 82 IN HANDLE DstPath, 83 IN HANDLE RootPartition); 84 85 #define InstallFat12BootCode InstallFatBootCode 86 #define InstallFat16BootCode InstallFatBootCode 87 88 NTSTATUS 89 InstallFat32BootCode( 90 IN PCWSTR SrcPath, 91 IN HANDLE DstPath, 92 IN HANDLE RootPartition); 93 94 NTSTATUS 95 InstallBtrfsBootCode( 96 IN PCWSTR SrcPath, 97 IN HANDLE DstPath, 98 IN HANDLE RootPartition); 99 100 NTSTATUS 101 InstallNtfsBootCode( 102 IN PCWSTR SrcPath, 103 IN HANDLE DstPath, 104 IN HANDLE RootPartition); 105 106 107 // 108 // Formatting routines 109 // 110 111 NTSTATUS 112 ChkdskPartition( 113 _In_ PPARTENTRY PartEntry, 114 _In_ BOOLEAN FixErrors, 115 _In_ BOOLEAN Verbose, 116 _In_ BOOLEAN CheckOnlyIfDirty, 117 _In_ BOOLEAN ScanDrive, 118 _In_opt_ PFMIFSCALLBACK Callback); 119 120 NTSTATUS 121 FormatPartition( 122 _In_ PPARTENTRY PartEntry, 123 _In_ PCWSTR FileSystemName, 124 _In_ FMIFS_MEDIA_FLAG MediaFlag, 125 _In_opt_ PCWSTR Label, 126 _In_ BOOLEAN QuickFormat, 127 _In_ ULONG ClusterSize, 128 _In_opt_ PFMIFSCALLBACK Callback); 129 130 131 // 132 // FileSystem Volume Operations Queue 133 // 134 135 typedef enum _FSVOLNOTIFY 136 { 137 FSVOLNOTIFY_STARTQUEUE = 0, 138 FSVOLNOTIFY_ENDQUEUE, 139 FSVOLNOTIFY_STARTSUBQUEUE, 140 FSVOLNOTIFY_ENDSUBQUEUE, 141 // FSVOLNOTIFY_STARTPARTITION, FSVOLNOTIFY_ENDPARTITION, 142 FSVOLNOTIFY_PARTITIONERROR, 143 FSVOLNOTIFY_STARTFORMAT, 144 FSVOLNOTIFY_ENDFORMAT, 145 FSVOLNOTIFY_FORMATERROR, 146 FSVOLNOTIFY_STARTCHECK, 147 FSVOLNOTIFY_ENDCHECK, 148 FSVOLNOTIFY_CHECKERROR, 149 /**/ChangeSystemPartition/**/ // FIXME: Deprecate! 150 } FSVOLNOTIFY; 151 152 typedef enum _FSVOL_OP 153 { 154 /* Operations ****/ 155 FSVOL_FORMAT = 0, 156 FSVOL_CHECK, 157 /* Response actions ****/ 158 FSVOL_ABORT = 0, 159 FSVOL_DOIT, 160 FSVOL_RETRY = FSVOL_DOIT, 161 FSVOL_SKIP, 162 } FSVOL_OP; 163 164 typedef struct _FORMAT_VOLUME_INFO 165 { 166 PVOLENTRY Volume; 167 // PCWSTR NtPathPartition; 168 NTSTATUS ErrorStatus; 169 170 /* Input information given by the 'FSVOLNOTIFY_STARTFORMAT' step ****/ 171 PCWSTR FileSystemName; 172 FMIFS_MEDIA_FLAG MediaFlag; 173 PCWSTR Label; 174 BOOLEAN QuickFormat; 175 ULONG ClusterSize; 176 PFMIFSCALLBACK Callback; 177 178 } FORMAT_VOLUME_INFO, *PFORMAT_VOLUME_INFO; 179 180 typedef struct _CHECK_VOLUME_INFO 181 { 182 PVOLENTRY Volume; 183 // PCWSTR NtPathPartition; 184 NTSTATUS ErrorStatus; 185 186 /* Input information given by the 'FSVOLNOTIFY_STARTCHECK' step ****/ 187 BOOLEAN FixErrors; 188 BOOLEAN Verbose; 189 BOOLEAN CheckOnlyIfDirty; 190 BOOLEAN ScanDrive; 191 PFMIFSCALLBACK Callback; 192 193 } CHECK_VOLUME_INFO, *PCHECK_VOLUME_INFO; 194 195 typedef FSVOL_OP 196 (CALLBACK *PFSVOL_CALLBACK)( 197 _In_opt_ PVOID Context, 198 _In_ FSVOLNOTIFY FormatStatus, 199 _In_ ULONG_PTR Param1, 200 _In_ ULONG_PTR Param2); 201 202 BOOLEAN 203 FsVolCommitOpsQueue( 204 _In_ PPARTLIST PartitionList, 205 _In_ PVOLENTRY SystemVolume, 206 _In_ PVOLENTRY InstallVolume, 207 _In_opt_ PFSVOL_CALLBACK FsVolCallback, 208 _In_opt_ PVOID Context); 209 210 /* EOF */ 211