ReactOS 0.4.16-dev-297-gc569aee
delete.c File Reference
#include "diskpart.h"
#include <debug.h>
Include dependency graph for delete.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static BOOL IsKnownPartition (_In_ PPARTENTRY PartEntry)
 
BOOL DeleteDisk (_In_ INT argc, _In_ PWSTR *argv)
 
BOOL DeletePartition (_In_ INT argc, _In_ PWSTR *argv)
 
BOOL DeleteVolume (_In_ INT argc, _In_ PWSTR *argv)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file delete.c.

Function Documentation

◆ DeleteDisk()

BOOL DeleteDisk ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 28 of file delete.c.

31{
32 return TRUE;
33}
#define TRUE
Definition: types.h:120

◆ DeletePartition()

BOOL DeletePartition ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 37 of file delete.c.

40{
41 PPARTENTRY PrevPartEntry;
42 PPARTENTRY NextPartEntry;
43 PPARTENTRY LogicalPartEntry;
45 INT i;
46 BOOL bOverride = FALSE;
48
49 DPRINT("DeletePartition()\n");
50
51 if (CurrentDisk == NULL)
52 {
54 return TRUE;
55 }
56
58 {
60 return TRUE;
61 }
62
64
65 for (i = 2; i < argc; i++)
66 {
67 if (_wcsicmp(argv[i], L"noerr") == 0)
68 {
69 /* noerr */
70 DPRINT("NOERR\n");
71 ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
72#if 0
73 bNoErr = TRUE;
74#endif
75 }
76 else if (_wcsicmp(argv[i], L"override") == 0)
77 {
78 /* noerr */
79 DPRINT("OVERRIDE\n");
80 bOverride = TRUE;
81 }
82 else
83 {
85 return TRUE;
86 }
87 }
88
89
90 /* Clear the system partition if it is being deleted */
91#if 0
92 if (List->SystemPartition == PartEntry)
93 {
94 ASSERT(List->SystemPartition);
95 List->SystemPartition = NULL;
96 }
97#endif
98
99 if ((bOverride == FALSE) && (IsKnownPartition(CurrentPartition) == FALSE))
100 {
102 return FALSE;
103 }
104
105 /* Check which type of partition (primary/logical or extended) is being deleted */
107 {
108 /* An extended partition is being deleted: delete all logical partition entries */
110 {
112 LogicalPartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
113
114 /* Dismount the logical partition */
115 DismountVolume(LogicalPartEntry);
116
117 /* Delete it */
118 RtlFreeHeap(RtlGetProcessHeap(), 0, LogicalPartEntry);
119 }
120
122 }
123 else
124 {
125 /* A primary partition is being deleted: dismount it */
127 }
128
129 /* Adjust the unpartitioned disk space entries */
130
131 /* Get pointer to previous and next unpartitioned entries */
134
135 if (PrevPartEntry != NULL && NextPartEntry != NULL)
136 {
137 /* Merge the previous, current and next unpartitioned entries */
138
139 /* Adjust the previous entry length */
140 PrevPartEntry->SectorCount.QuadPart += (CurrentPartition->SectorCount.QuadPart + NextPartEntry->SectorCount.QuadPart);
141
142 /* Remove the current and next entries */
144 RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentPartition);
145 RemoveEntryList(&NextPartEntry->ListEntry);
146 RtlFreeHeap(RtlGetProcessHeap(), 0, NextPartEntry);
147 }
148 else if (PrevPartEntry != NULL && NextPartEntry == NULL)
149 {
150 /* Merge the current and the previous unpartitioned entries */
151
152 /* Adjust the previous entry length */
154
155 /* Remove the current entry */
157 RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentPartition);
158 }
159 else if (PrevPartEntry == NULL && NextPartEntry != NULL)
160 {
161 /* Merge the current and the next unpartitioned entries */
162
163 /* Adjust the next entry offset and length */
166
167 /* Remove the current entry */
169 RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentPartition);
170 }
171 else
172 {
173 /* Nothing to merge but change the current entry */
177 // CurrentPartition->PartitionIndex = 0;
184 }
185
187
190 if (!NT_SUCCESS(Status))
191 {
193 return TRUE;
194 }
195
197
198 return TRUE;
199}
static int argc
Definition: ServiceArgs.c:12
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define StdOut
Definition: fc.c:14
#define StdErr
Definition: fc.c:15
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
LONG NTSTATUS
Definition: precomp.h:26
static BOOL IsKnownPartition(_In_ PPARTENTRY PartEntry)
Definition: delete.c:16
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:88
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
#define IDS_DELETE_PARTITION_SUCCESS
Definition: resource.h:33
#define IDS_DELETE_PARTITION_FAIL
Definition: resource.h:32
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:87
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
PPARTENTRY GetPrevUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1901
PDISKENTRY CurrentDisk
Definition: partlist.c:74
PPARTENTRY GetNextUnpartitionedEntry(_In_ PPARTENTRY PartEntry)
Definition: partlist.c:1930
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ Unformatted
Definition: partlist.h:34
#define ASSERT(a)
Definition: mode.c:44
#define argv
Definition: mplay32.c:18
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
Definition: partlist.c:2585
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
Definition: partlist.c:3582
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
PPARTENTRY ExtendedPartition
Definition: partlist.h:153
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:150
Definition: typedefs.h:120
BOOLEAN IsPartitioned
Definition: partlist.h:82
UCHAR PartitionType
Definition: partlist.h:73
ULARGE_INTEGER SectorCount
Definition: partlist.h:70
BOOLEAN BootIndicator
Definition: partlist.h:72
CHAR VolumeLabel[17]
Definition: diskpart.h:114
CHAR DriveLetter
Definition: diskpart.h:113
FORMATSTATE FormatState
Definition: diskpart.h:116
ULONG OnDiskPartitionNumber
Definition: partlist.h:74
LIST_ENTRY ListEntry
Definition: partlist.h:63
ULONG PartitionNumber
Definition: partlist.h:75
ULARGE_INTEGER StartSector
Definition: partlist.h:69
CHAR FileSystemName[9]
Definition: diskpart.h:115
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
int32_t INT
Definition: typedefs.h:58
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
static PPARTENTRY CurrentPartition
Definition: usetup.c:78
NTSTATUS DismountVolume(_Inout_ PVOLINFO Volume, _In_ BOOLEAN Force)
Attempts to dismount the designated volume.
Definition: volutil.c:152
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

◆ DeleteVolume()

BOOL DeleteVolume ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 203 of file delete.c.

206{
207 return TRUE;
208}

◆ IsKnownPartition()

static BOOL IsKnownPartition ( _In_ PPARTENTRY  PartEntry)
static

Definition at line 16 of file delete.c.

18{
19 if (IsRecognizedPartition(PartEntry->PartitionType) ||
20 IsContainerPartition(PartEntry->PartitionType))
21 return TRUE;
22
23 return FALSE;
24}
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:321
#define IsRecognizedPartition(PartitionType)
Definition: ntdddisk.h:342

Referenced by DeletePartition().