xref: /reactos/base/system/diskpart/diskpart.h (revision 50cf16b3)
1 /*
2  * PROJECT:         ReactOS DiskPart
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * FILE:            base/system/diskpart/diskpart.h
5  * PURPOSE:         Manages all the partitions of the OS in an interactive way.
6  * PROGRAMMERS:     Lee Schroeder
7  */
8 
9 #ifndef DISKPART_H
10 #define DISKPART_H
11 
12 /* INCLUDES ******************************************************************/
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 
17 #define WIN32_NO_STATUS
18 #include <windef.h>
19 #include <winbase.h>
20 #include <winreg.h>
21 #include <wincon.h>
22 
23 #include <conutils.h>
24 
25 /*
26 #define NTOS_MODE_USER
27 #include <ndk/exfuncs.h>
28 #include <ndk/iofuncs.h>
29 #include <ndk/obfuncs.h>
30 #include <ndk/psfuncs.h>
31 #include <ndk/rtlfuncs.h>
32 #include <ndk/umfuncs.h>
33 */
34 
35 #define NTOS_MODE_USER
36 #include <ndk/cmfuncs.h>
37 #include <ndk/exfuncs.h>
38 #include <ndk/iofuncs.h>
39 #include <ndk/kefuncs.h>
40 #include <ndk/mmfuncs.h>
41 #include <ndk/obfuncs.h>
42 #include <ndk/psfuncs.h>
43 #include <ndk/rtlfuncs.h>
44 #include <ndk/setypes.h>
45 #include <ndk/umfuncs.h>
46 
47 #include "resource.h"
48 
49 /* DEFINES *******************************************************************/
50 
51 typedef struct _COMMAND
52 {
53     LPWSTR name;
54     BOOL (*func)(INT, WCHAR**);
55     INT help;
56     INT help_desc;
57 } COMMAND, *PCOMMAND;
58 
59 extern COMMAND cmds[];
60 
61 /* NOERR codes for the program */
62 //#define ERROR_NONE      0
63 //#define ERROR_FATAL     1
64 //#define ERROR_CMD_ARG   2
65 //#define ERROR_FILE      3
66 //#define ERROR_SERVICE   4
67 //#define ERROR_SYNTAX    5
68 
69 #define MAX_STRING_SIZE 1024
70 #define MAX_ARGS_COUNT 256
71 
72 
73 typedef enum _FORMATSTATE
74 {
75     Unformatted,
76     UnformattedOrDamaged,
77     UnknownFormat,
78     Preformatted,
79     Formatted
80 } FORMATSTATE, *PFORMATSTATE;
81 
82 typedef struct _PARTENTRY
83 {
84     LIST_ENTRY ListEntry;
85 
86     struct _DISKENTRY *DiskEntry;
87 
88     ULARGE_INTEGER StartSector;
89     ULARGE_INTEGER SectorCount;
90 
91     BOOLEAN BootIndicator;
92     UCHAR PartitionType;
93     ULONG HiddenSectors;
94     ULONG PartitionNumber;
95     ULONG PartitionIndex;
96 
97     CHAR DriveLetter;
98     CHAR VolumeLabel[17];
99     CHAR FileSystemName[9];
100 
101     BOOLEAN LogicalPartition;
102 
103     /* Partition is partitioned disk space */
104     BOOLEAN IsPartitioned;
105 
106     /* Partition is new. Table does not exist on disk yet */
107     BOOLEAN New;
108 
109     /* Partition was created automatically. */
110     BOOLEAN AutoCreate;
111 
112     FORMATSTATE FormatState;
113 
114     /* Partition must be checked */
115     BOOLEAN NeedsCheck;
116 
117     struct _FILE_SYSTEM_ITEM *FileSystem;
118 } PARTENTRY, *PPARTENTRY;
119 
120 
121 typedef struct _BIOSDISKENTRY
122 {
123     LIST_ENTRY ListEntry;
124     ULONG DiskNumber;
125     ULONG Signature;
126     ULONG Checksum;
127     BOOLEAN Recognized;
128     CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
129     CM_INT13_DRIVE_PARAMETER Int13DiskData;
130 } BIOSDISKENTRY, *PBIOSDISKENTRY;
131 
132 
133 typedef struct _DISKENTRY
134 {
135     LIST_ENTRY ListEntry;
136 
137     ULONGLONG Cylinders;
138     ULONG TracksPerCylinder;
139     ULONG SectorsPerTrack;
140     ULONG BytesPerSector;
141 
142     ULARGE_INTEGER SectorCount;
143     ULONG SectorAlignment;
144     ULONG CylinderAlignment;
145 
146     BOOLEAN BiosFound;
147     ULONG BiosDiskNumber;
148 //    ULONG Signature;
149 //    ULONG Checksum;
150 
151     ULONG DiskNumber;
152     USHORT Port;
153     USHORT Bus;
154     USHORT Id;
155 
156     /* Has the partition list been modified? */
157     BOOLEAN Dirty;
158 
159     BOOLEAN NewDisk;
160     BOOLEAN NoMbr; /* MBR is absent */
161 
162     UNICODE_STRING DriverName;
163 
164     PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
165 
166     PPARTENTRY ExtendedPartition;
167 
168     LIST_ENTRY PrimaryPartListHead;
169     LIST_ENTRY LogicalPartListHead;
170 
171 } DISKENTRY, *PDISKENTRY;
172 
173 
174 /* GLOBAL VARIABLES ***********************************************************/
175 
176 extern LIST_ENTRY DiskListHead;
177 extern LIST_ENTRY BiosDiskListHead;
178 
179 extern PDISKENTRY CurrentDisk;
180 extern PPARTENTRY CurrentPartition;
181 
182 /* PROTOTYPES *****************************************************************/
183 
184 /* active.c */
185 BOOL active_main(INT argc, LPWSTR *argv);
186 
187 /* add.c */
188 BOOL add_main(INT argc, LPWSTR *argv);
189 
190 /* assign.c */
191 BOOL assign_main(INT argc, LPWSTR *argv);
192 
193 /* attach.c */
194 BOOL attach_main(INT argc, LPWSTR *argv);
195 
196 /* attributes.h */
197 BOOL attributes_main(INT argc, LPWSTR *argv);
198 
199 /* automount.c */
200 BOOL automount_main(INT argc, LPWSTR *argv);
201 
202 /* break.c */
203 BOOL break_main(INT argc, LPWSTR *argv);
204 
205 /* clean.c */
206 BOOL clean_main(INT argc, LPWSTR *argv);
207 
208 /* compact.c */
209 BOOL compact_main(INT argc, LPWSTR *argv);
210 
211 /* convert.c */
212 BOOL convert_main(INT argc, LPWSTR *argv);
213 
214 /* create.c */
215 BOOL create_main(INT argc, LPWSTR *argv);
216 
217 /* delete.c */
218 BOOL delete_main(INT argc, LPWSTR *argv);
219 
220 /* detach.c */
221 BOOL detach_main(INT argc, LPWSTR *argv);
222 
223 /* detail.c */
224 BOOL detail_main(INT argc, LPWSTR *argv);
225 
226 /* diskpart.c */
227 
228 /* expand.c */
229 BOOL expand_main(INT argc, LPWSTR *argv);
230 
231 /* extend.c */
232 BOOL extend_main(INT argc, LPWSTR *argv);
233 
234 /* filesystem.c */
235 BOOL filesystems_main(INT argc, LPWSTR *argv);
236 
237 /* format.c */
238 BOOL format_main(INT argc, LPWSTR *argv);
239 
240 /* gpt.c */
241 BOOL gpt_main(INT argc, LPWSTR *argv);
242 
243 /* help.c */
244 BOOL help_main(INT argc, LPWSTR *argv);
245 VOID help_cmdlist(VOID);
246 
247 /* import. c */
248 BOOL import_main(INT argc, LPWSTR *argv);
249 
250 /* inactive.c */
251 BOOL inactive_main(INT argc, LPWSTR *argv);
252 
253 /* interpreter.c */
254 BOOL InterpretScript(LPWSTR line);
255 BOOL InterpretCmd(INT argc, LPWSTR *argv);
256 VOID InterpretMain(VOID);
257 
258 /* list.c */
259 BOOL list_main(INT argc, LPWSTR *argv);
260 
261 /* merge.c */
262 BOOL merge_main(INT argc, LPWSTR *argv);
263 
264 /* offline.c */
265 BOOL offline_main(INT argc, LPWSTR *argv);
266 
267 /* online.c */
268 BOOL online_main(INT argc, LPWSTR *argv);
269 
270 /* partlist.c */
271 NTSTATUS
272 CreatePartitionList(VOID);
273 
274 VOID
275 DestroyPartitionList(VOID);
276 
277 /* recover.c */
278 BOOL recover_main(INT argc, LPWSTR *argv);
279 
280 /* remove.c */
281 BOOL remove_main(INT argc, LPWSTR *argv);
282 
283 /* repair.c */
284 BOOL repair_main(INT argc, LPWSTR *argv);
285 
286 /* rescan.c */
287 BOOL rescan_main(INT argc, LPWSTR *argv);
288 
289 /* retain.c */
290 BOOL retain_main(INT argc, LPWSTR *argv);
291 
292 /* san.c */
293 BOOL san_main(INT argc, LPWSTR *argv);
294 
295 /* select.c */
296 BOOL select_main(INT argc, LPWSTR *argv);
297 
298 /* setid.c */
299 BOOL setid_main(INT argc, LPWSTR *argv);
300 
301 /* shrink.c */
302 BOOL shrink_main(INT argc, LPWSTR *argv);
303 
304 /* uniqueid.c */
305 BOOL uniqueid_main(INT argc, LPWSTR *argv);
306 
307 #endif /* DISKPART_H */
308