xref: /reactos/base/setup/lib/fsutil.h (revision 67559215)
1 /*
2  * PROJECT:     ReactOS Setup Library
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     Filesystem Format and ChkDsk support functions.
5  * COPYRIGHT:   Copyright 2003-2019 Casper S. Hornstrup (chorns@users.sourceforge.net)
6  *              Copyright 2017-2020 Hermes Belusca-Maito
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 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 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 PUNICODE_STRING Label,
49     IN BOOLEAN QuickFormat,
50     IN ULONG ClusterSize,
51     IN PFMIFSCALLBACK Callback);
52 
53 NTSTATUS
54 FormatFileSystem(
55     IN PCWSTR DriveRoot,
56     IN PCWSTR FileSystemName,
57     IN FMIFS_MEDIA_FLAG MediaFlag,
58     IN PCWSTR Label,
59     IN BOOLEAN QuickFormat,
60     IN ULONG ClusterSize,
61     IN 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 PFMIFSCALLBACK Callback);
119 
120 NTSTATUS
121 FormatPartition(
122     IN PPARTENTRY PartEntry,
123     IN PCWSTR FileSystemName,
124     IN FMIFS_MEDIA_FLAG MediaFlag,
125     IN PCWSTR Label,
126     IN BOOLEAN QuickFormat,
127     IN ULONG ClusterSize,
128     IN PFMIFSCALLBACK Callback);
129 
130 /* EOF */
131