https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c70f5033ec01c8a9bed5b…
commit c70f5033ec01c8a9bed5b71f12b184db135daf95
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Jun 5 10:30:55 2022 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Jun 5 10:30:55 2022 +0200
[DISKPART] Implement the OVERRIDE option for the DELETE PARTITION command
---
base/system/diskpart/delete.c | 46 +++++++++++++++++++++++++++++++++++++++++
base/system/diskpart/diskpart.h | 1 +
2 files changed, 47 insertions(+)
diff --git a/base/system/diskpart/delete.c b/base/system/diskpart/delete.c
index 6841b3d9a27..feb66e58c9a 100644
--- a/base/system/diskpart/delete.c
+++ b/base/system/diskpart/delete.c
@@ -11,6 +11,19 @@
#define NDEBUG
#include <debug.h>
+static
+BOOL
+IsKnownPartition(
+ _In_ PPARTENTRY PartEntry)
+{
+ if (IsRecognizedPartition(PartEntry->PartitionType) ||
+ IsContainerPartition(PartEntry->PartitionType))
+ return TRUE;
+
+ return FALSE;
+}
+
+
BOOL
DeleteDisk(
_In_ INT argc,
@@ -29,6 +42,8 @@ DeletePartition(
PPARTENTRY NextPartEntry;
PPARTENTRY LogicalPartEntry;
PLIST_ENTRY Entry;
+ INT i;
+ BOOL bOverride = FALSE;
NTSTATUS Status;
DPRINT("DeletePartition()\n");
@@ -47,6 +62,31 @@ DeletePartition(
ASSERT(CurrentPartition->PartitionType != PARTITION_ENTRY_UNUSED);
+ for (i = 2; i < argc; i++)
+ {
+ if (_wcsicmp(argv[i], L"noerr") == 0)
+ {
+ /* noerr */
+ DPRINT("NOERR\n");
+ ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
+#if 0
+ bNoErr = TRUE;
+#endif
+ }
+ else if (_wcsicmp(argv[i], L"override") == 0)
+ {
+ /* noerr */
+ DPRINT("OVERRIDE\n");
+ bOverride = TRUE;
+ }
+ else
+ {
+ ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
+ return TRUE;
+ }
+ }
+
+
/* Clear the system partition if it is being deleted */
#if 0
if (List->SystemPartition == PartEntry)
@@ -56,6 +96,12 @@ DeletePartition(
}
#endif
+ if ((bOverride == FALSE) && (IsKnownPartition(CurrentPartition) == FALSE))
+ {
+ ConResPuts(StdOut, IDS_DELETE_PARTITION_FAIL);
+ return FALSE;
+ }
+
/* Check which type of partition (primary/logical or extended) is being deleted */
if (CurrentDisk->ExtendedPartition == CurrentPartition)
{
diff --git a/base/system/diskpart/diskpart.h b/base/system/diskpart/diskpart.h
index 755dc7b44c4..fbf63bc7dc4 100644
--- a/base/system/diskpart/diskpart.h
+++ b/base/system/diskpart/diskpart.h
@@ -19,6 +19,7 @@
#include <winbase.h>
#include <winreg.h>
#include <wincon.h>
+#include <winioctl.h>
#include <errno.h>