btrfslib.c (cdaa5d5f) btrfslib.c (8d3e80e4)
1/* Copyright (c) Mark Harmstone 2016-17
2 *
3 * This file is part of WinBtrfs.
4 *
5 * WinBtrfs is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public Licence as published by
7 * the Free Software Foundation, either version 3 of the Licence, or
8 * (at your option) any later version.

--- 167 unchanged lines hidden (view full) ---

176 ((key1.offset > key2.offset) ? 1 :\
177 0))))))
178
179HMODULE module;
180ULONG def_sector_size = 0, def_node_size = 0;
181uint64_t def_incompat_flags = BTRFS_INCOMPAT_FLAGS_EXTENDED_IREF | BTRFS_INCOMPAT_FLAGS_SKINNY_METADATA;
182uint16_t def_csum_type = CSUM_TYPE_CRC32C;
183
1/* Copyright (c) Mark Harmstone 2016-17
2 *
3 * This file is part of WinBtrfs.
4 *
5 * WinBtrfs is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public Licence as published by
7 * the Free Software Foundation, either version 3 of the Licence, or
8 * (at your option) any later version.

--- 167 unchanged lines hidden (view full) ---

176 ((key1.offset > key2.offset) ? 1 :\
177 0))))))
178
179HMODULE module;
180ULONG def_sector_size = 0, def_node_size = 0;
181uint64_t def_incompat_flags = BTRFS_INCOMPAT_FLAGS_EXTENDED_IREF | BTRFS_INCOMPAT_FLAGS_SKINNY_METADATA;
182uint16_t def_csum_type = CSUM_TYPE_CRC32C;
183
184#ifndef __REACTOS__
184// the following definitions come from fmifs.h in ReactOS
185
186typedef struct {
187 ULONG Lines;
188 PCHAR Output;
189} TEXTOUTPUT, *PTEXTOUTPUT;
190
191typedef enum {

--- 40 unchanged lines hidden (view full) ---

232 UNKNOWND,
233 OUTPUT,
234 STRUCTUREPROGRESS,
235 CLUSTERSIZETOOSMALL,
236} CALLBACKCOMMAND;
237
238typedef BOOLEAN (NTAPI* PFMIFSCALLBACK)(CALLBACKCOMMAND Command, ULONG SubAction, PVOID ActionInfo);
239
185// the following definitions come from fmifs.h in ReactOS
186
187typedef struct {
188 ULONG Lines;
189 PCHAR Output;
190} TEXTOUTPUT, *PTEXTOUTPUT;
191
192typedef enum {

--- 40 unchanged lines hidden (view full) ---

233 UNKNOWND,
234 OUTPUT,
235 STRUCTUREPROGRESS,
236 CLUSTERSIZETOOSMALL,
237} CALLBACKCOMMAND;
238
239typedef BOOLEAN (NTAPI* PFMIFSCALLBACK)(CALLBACKCOMMAND Command, ULONG SubAction, PVOID ActionInfo);
240
241#else
242
243#include <fmifs/fmifs.h>
244
245#endif // __REACTOS__
246
240#ifndef __REACTOS__
241NTSTATUS WINAPI ChkdskEx(PUNICODE_STRING DriveRoot, BOOLEAN FixErrors, BOOLEAN Verbose, BOOLEAN CheckOnlyIfDirty,
247#ifndef __REACTOS__
248NTSTATUS WINAPI ChkdskEx(PUNICODE_STRING DriveRoot, BOOLEAN FixErrors, BOOLEAN Verbose, BOOLEAN CheckOnlyIfDirty,
249 BOOLEAN ScanDrive, PFMIFSCALLBACK Callback) {
242#else
250#else
243NTSTATUS NTAPI BtrfsChkdskEx(PUNICODE_STRING DriveRoot, BOOLEAN FixErrors, BOOLEAN Verbose, BOOLEAN CheckOnlyIfDirty,
251BOOLEAN
252NTAPI
253BtrfsChkdsk(
254 IN PUNICODE_STRING DriveRoot,
255 IN PFMIFSCALLBACK Callback,
256 IN BOOLEAN FixErrors,
257 IN BOOLEAN Verbose,
258 IN BOOLEAN CheckOnlyIfDirty,
259 IN BOOLEAN ScanDrive,
260 IN PVOID pUnknown1,
261 IN PVOID pUnknown2,
262 IN PVOID pUnknown3,
263 IN PVOID pUnknown4,
264 IN PULONG ExitStatus)
265{
244#endif
266#endif
245 BOOLEAN ScanDrive, PFMIFSCALLBACK Callback) {
246 // STUB
247
248 if (Callback) {
249 TEXTOUTPUT TextOut;
250
251 TextOut.Lines = 1;
252 TextOut.Output = "stub, not implemented";
253
254 Callback(OUTPUT, 0, &TextOut);
255 }
256
267 // STUB
268
269 if (Callback) {
270 TEXTOUTPUT TextOut;
271
272 TextOut.Lines = 1;
273 TextOut.Output = "stub, not implemented";
274
275 Callback(OUTPUT, 0, &TextOut);
276 }
277
278#ifndef __REACTOS__
257 return STATUS_SUCCESS;
279 return STATUS_SUCCESS;
280#else
281 *ExitStatus = (ULONG)STATUS_SUCCESS;
282 return TRUE;
283#endif
258}
259
260static btrfs_root* add_root(LIST_ENTRY* roots, uint64_t id) {
261 btrfs_root* root;
262
263 root = malloc(sizeof(btrfs_root));
264
265 root->id = id;

--- 1045 unchanged lines hidden (view full) ---

1311 have_sse42 = cpuInfo[2] & (1 << 20);
1312#endif
1313
1314 if (have_sse42)
1315 calc_crc32c = calc_crc32c_hw;
1316}
1317#endif
1318
284}
285
286static btrfs_root* add_root(LIST_ENTRY* roots, uint64_t id) {
287 btrfs_root* root;
288
289 root = malloc(sizeof(btrfs_root));
290
291 root->id = id;

--- 1045 unchanged lines hidden (view full) ---

1337 have_sse42 = cpuInfo[2] & (1 << 20);
1338#endif
1339
1340 if (have_sse42)
1341 calc_crc32c = calc_crc32c_hw;
1342}
1343#endif
1344
1319#ifndef __REACTOS__
1320static NTSTATUS NTAPI FormatEx2(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFlag, PUNICODE_STRING Label,
1345static NTSTATUS NTAPI FormatEx2(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFlag, PUNICODE_STRING Label,
1321#else
1322NTSTATUS NTAPI BtrfsFormatEx(PUNICODE_STRING DriveRoot, FMIFS_MEDIA_FLAG MediaFlag, PUNICODE_STRING Label,
1323#endif // __REACTOS__
1324 BOOLEAN QuickFormat, ULONG ClusterSize, PFMIFSCALLBACK Callback)
1325{
1326 NTSTATUS Status;
1327 HANDLE h, btrfsh;
1328 OBJECT_ATTRIBUTES attr;
1329 IO_STATUS_BLOCK iosb;
1330 GET_LENGTH_INFORMATION gli;
1331 DISK_GEOMETRY dg;

--- 142 unchanged lines hidden (view full) ---

1474 free(mdn);
1475
1476 NtClose(btrfsh);
1477 }
1478
1479 Status = STATUS_SUCCESS;
1480 }
1481
1346 BOOLEAN QuickFormat, ULONG ClusterSize, PFMIFSCALLBACK Callback)
1347{
1348 NTSTATUS Status;
1349 HANDLE h, btrfsh;
1350 OBJECT_ATTRIBUTES attr;
1351 IO_STATUS_BLOCK iosb;
1352 GET_LENGTH_INFORMATION gli;
1353 DISK_GEOMETRY dg;

--- 142 unchanged lines hidden (view full) ---

1496 free(mdn);
1497
1498 NtClose(btrfsh);
1499 }
1500
1501 Status = STATUS_SUCCESS;
1502 }
1503
1504#ifndef __REACTOS__
1482 if (Callback) {
1483 bool success = NT_SUCCESS(Status);
1484 Callback(DONE, 0, (PVOID)&success);
1485 }
1505 if (Callback) {
1506 bool success = NT_SUCCESS(Status);
1507 Callback(DONE, 0, (PVOID)&success);
1508 }
1509#endif
1486
1487 return Status;
1488}
1489
1510
1511 return Status;
1512}
1513
1514#ifdef __REACTOS__
1515
1516BOOLEAN
1517NTAPI
1518BtrfsFormat(
1519 IN PUNICODE_STRING DriveRoot,
1520 IN PFMIFSCALLBACK Callback,
1521 IN BOOLEAN QuickFormat,
1522 IN BOOLEAN BackwardCompatible,
1523 IN MEDIA_TYPE MediaType,
1524 IN PUNICODE_STRING Label,
1525 IN ULONG ClusterSize)
1526{
1527 NTSTATUS Status;
1528
1529 if (BackwardCompatible)
1530 {
1531 // DPRINT1("BackwardCompatible == TRUE is unsupported!\n");
1532 return FALSE;
1533 }
1534
1535 Status = FormatEx2(DriveRoot, (FMIFS_MEDIA_FLAG)MediaType, Label, QuickFormat, ClusterSize, Callback);
1536
1537 return NT_SUCCESS(Status);
1538}
1539
1540#else
1541
1490BOOL __stdcall FormatEx(DSTRING* root, STREAM_MESSAGE* message, options* opts, uint32_t unk1) {
1491 UNICODE_STRING DriveRoot, Label;
1492 NTSTATUS Status;
1493
1494 if (!root || !root->string)
1495 return false;
1496
1497 DriveRoot.Length = DriveRoot.MaximumLength = (USHORT)(wcslen(root->string) * sizeof(WCHAR));
1498 DriveRoot.Buffer = root->string;
1499
1500 if (opts && opts->label && opts->label->string) {
1501 Label.Length = Label.MaximumLength = (USHORT)(wcslen(opts->label->string) * sizeof(WCHAR));
1502 Label.Buffer = opts->label->string;
1503 } else {
1504 Label.Length = Label.MaximumLength = 0;
1505 Label.Buffer = NULL;
1506 }
1507
1542BOOL __stdcall FormatEx(DSTRING* root, STREAM_MESSAGE* message, options* opts, uint32_t unk1) {
1543 UNICODE_STRING DriveRoot, Label;
1544 NTSTATUS Status;
1545
1546 if (!root || !root->string)
1547 return false;
1548
1549 DriveRoot.Length = DriveRoot.MaximumLength = (USHORT)(wcslen(root->string) * sizeof(WCHAR));
1550 DriveRoot.Buffer = root->string;
1551
1552 if (opts && opts->label && opts->label->string) {
1553 Label.Length = Label.MaximumLength = (USHORT)(wcslen(opts->label->string) * sizeof(WCHAR));
1554 Label.Buffer = opts->label->string;
1555 } else {
1556 Label.Length = Label.MaximumLength = 0;
1557 Label.Buffer = NULL;
1558 }
1559
1508#ifndef __REACTOS__
1509 Status = FormatEx2(&DriveRoot, FMIFS_HARDDISK, &Label, opts && opts->flags & FORMAT_FLAG_QUICK_FORMAT, 0, NULL);
1560 Status = FormatEx2(&DriveRoot, FMIFS_HARDDISK, &Label, opts && opts->flags & FORMAT_FLAG_QUICK_FORMAT, 0, NULL);
1510#else
1511 Status = BtrfsFormatEx(&DriveRoot, FMIFS_HARDDISK, &Label, opts && opts->flags & FORMAT_FLAG_QUICK_FORMAT, 0, NULL);
1512#endif
1513
1514 return NT_SUCCESS(Status);
1515}
1516
1561
1562 return NT_SUCCESS(Status);
1563}
1564
1565#endif // __REACTOS__
1566
1517void __stdcall SetSizes(ULONG sector, ULONG node) {
1518 if (sector != 0)
1519 def_sector_size = sector;
1520
1521 if (node != 0)
1522 def_node_size = node;
1523}
1524

--- 22 unchanged lines hidden ---
1567void __stdcall SetSizes(ULONG sector, ULONG node) {
1568 if (sector != 0)
1569 def_sector_size = sector;
1570
1571 if (node != 0)
1572 def_node_size = node;
1573}
1574

--- 22 unchanged lines hidden ---