ReactOS 0.4.16-dev-2104-gb84fa49
detail.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS DiskPart
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/diskpart/detail.c
5 * PURPOSE: Manages all the partitions of the OS in an interactive way.
6 * PROGRAMMERS: Lee Schroeder
7 */
8
9#include "diskpart.h"
10
11#define NDEBUG
12#include <debug.h>
13
14/* FUNCTIONS ******************************************************************/
15
16static
17BOOL
19 _In_ PVOLENTRY VolumeEntry,
20 _In_ PDISKENTRY DiskEntry)
21{
22 ULONG i;
23
24 if ((VolumeEntry == NULL) ||
25 (VolumeEntry->pExtents == NULL) ||
26 (DiskEntry == NULL))
27 return FALSE;
28
29 for (i = 0; i < VolumeEntry->pExtents->NumberOfDiskExtents; i++)
30 {
31 if (VolumeEntry->pExtents->Extents[i].DiskNumber == DiskEntry->DiskNumber)
32 return TRUE;
33 }
34
35 return FALSE;
36}
37
38
39static
40BOOL
42 _In_ PVOLENTRY VolumeEntry,
43 _In_ PPARTENTRY PartEntry)
44{
45 ULONG i;
46
47 if ((VolumeEntry == NULL) ||
48 (VolumeEntry->pExtents == NULL) ||
49 (PartEntry == NULL) ||
50 (PartEntry->DiskEntry == NULL))
51 return FALSE;
52
53 for (i = 0; i < VolumeEntry->pExtents->NumberOfDiskExtents; i++)
54 {
55 if (VolumeEntry->pExtents->Extents[i].DiskNumber == PartEntry->DiskEntry->DiskNumber)
56 {
57 if ((VolumeEntry->pExtents->Extents[i].StartingOffset.QuadPart == PartEntry->StartSector.QuadPart * PartEntry->DiskEntry->BytesPerSector) &&
58 (VolumeEntry->pExtents->Extents[i].ExtentLength.QuadPart == PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector))
59 return TRUE;
60 }
61 }
62
63 return FALSE;
64}
65
66
71{
73 PVOLENTRY VolumeEntry;
74 BOOL bPrintHeader = TRUE;
75 WCHAR szBuffer[40];
76
77 DPRINT("DetailDisk()\n");
78
79 if (argc > 2)
80 {
82 return EXIT_SUCCESS;
83 }
84
85 if (CurrentDisk == NULL)
86 {
88 return EXIT_SUCCESS;
89 }
90
91 /* TODO: Print more disk details */
92 ConPuts(StdOut, L"\n");
94 if (CurrentDisk->LayoutBuffer->PartitionStyle == PARTITION_STYLE_GPT)
95 PrintGUID(szBuffer, &CurrentDisk->LayoutBuffer->Gpt.DiskId);
96 else if (CurrentDisk->LayoutBuffer->PartitionStyle == PARTITION_STYLE_MBR)
97 swprintf(szBuffer, L"%08lx", CurrentDisk->LayoutBuffer->Mbr.Signature);
98 else
99 wcscpy(szBuffer, L"00000000");
101 PrintBusType(szBuffer, ARRAYSIZE(szBuffer), CurrentDisk->BusType);
107
109 while (Entry != &VolumeListHead)
110 {
111 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
112
113 if (IsDiskInVolume(VolumeEntry, CurrentDisk))
114 {
115 if (bPrintHeader)
116 {
117 ConPuts(StdOut, L"\n");
120 bPrintHeader = FALSE;
121 }
122
123 PrintVolume(VolumeEntry);
124 }
125
126 Entry = Entry->Flink;
127 }
128
129 ConPuts(StdOut, L"\n");
130
131 return EXIT_SUCCESS;
132}
133
134
137 _In_ INT argc,
138 _In_ PWSTR *argv)
139{
140 PPARTENTRY PartEntry;
141 ULONGLONG PartOffset;
143 PVOLENTRY VolumeEntry;
144 BOOL bVolumeFound = FALSE, bPrintHeader = TRUE;
145 WCHAR szBuffer[40];
146
147 DPRINT("DetailPartition()\n");
148
149 if (argc > 2)
150 {
152 return EXIT_SUCCESS;
153 }
154
155 if (CurrentDisk == NULL)
156 {
158 return EXIT_SUCCESS;
159 }
160
161 if (CurrentPartition == NULL)
162 {
164 return EXIT_SUCCESS;
165 }
166
167 PartEntry = CurrentPartition;
168 PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
169
170 /* TODO: Print more partition details */
171 ConPuts(StdOut, L"\n");
174 {
175 PrintGUID(szBuffer, &PartEntry->Gpt.PartitionType);
177 ConResPrintf(StdOut, IDS_DETAIL_PARTITION_HIDDEN, (PartEntry->Gpt.Attributes & GPT_BASIC_DATA_ATTRIBUTE_HIDDEN) ? L"Yes" : L"No");
178 ConResPrintf(StdOut, IDS_DETAIL_PARTITION_REQUIRED, (PartEntry->Gpt.Attributes & GPT_ATTRIBUTE_PLATFORM_REQUIRED) ? L"Yes" : L"No");
180 }
182 {
183 swprintf(szBuffer, L"%02x", PartEntry->Mbr.PartitionType);
187 }
189
191 while (Entry != &VolumeListHead)
192 {
193 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
194
195 if (IsPartitionInVolume(VolumeEntry, CurrentPartition))
196 {
197 if (bPrintHeader)
198 {
199 ConPuts(StdOut, L"\n");
202 bPrintHeader = FALSE;
203 }
204
205 PrintVolume(VolumeEntry);
206 bVolumeFound = TRUE;
207 }
208
209 Entry = Entry->Flink;
210 }
211
212 if (bVolumeFound == FALSE)
214
215 ConPuts(StdOut, L"\n");
216
217 return EXIT_SUCCESS;
218}
219
220
223 _In_ INT argc,
224 _In_ PWSTR *argv)
225{
226 PDISKENTRY DiskEntry;
228 BOOL bDiskFound = FALSE, bPrintHeader = TRUE;
229
230 DPRINT("DetailVolume()\n");
231
232 if (argc > 2)
233 {
235 return EXIT_SUCCESS;
236 }
237
238 if (CurrentVolume == NULL)
239 {
241 return EXIT_SUCCESS;
242 }
243
244
246 while (Entry != &DiskListHead)
247 {
248 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
249
250 if (IsDiskInVolume(CurrentVolume, DiskEntry))
251 {
252 if (bPrintHeader)
253 {
254 ConPuts(StdOut, L"\n");
257 bPrintHeader = FALSE;
258 }
259
260 PrintDisk(DiskEntry);
261 bDiskFound = TRUE;
262 }
263
264 Entry = Entry->Flink;
265 }
266
267 if (bDiskFound == FALSE)
269
270 /* TODO: Print more volume details */
271
272 ConPuts(StdOut, L"\n");
273
274 return EXIT_SUCCESS;
275}
static int argc
Definition: ServiceArgs.c:12
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define StdOut
Definition: fc.c:14
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define StdErr
Definition: fc.c:15
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define IDS_LIST_DISK_LINE
Definition: resource.h:102
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:130
#define IDS_DETAIL_DISK_STATUS
Definition: resource.h:57
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:126
#define IDS_LIST_DISK_HEAD
Definition: resource.h:101
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:110
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:109
#define IDS_DETAIL_PARTITION_HIDDEN
Definition: resource.h:72
#define IDS_DETAIL_PARTITION_ACTIVE
Definition: resource.h:73
#define IDS_DETAIL_PARTITION_TYPE
Definition: resource.h:71
#define IDS_DETAIL_PARTITION_ATTRIBUTE
Definition: resource.h:76
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:229
#define IDS_DETAIL_PARTITION_REQUIRED
Definition: resource.h:75
#define IDS_DETAIL_INFO_LUN_ID
Definition: resource.h:60
#define IDS_DETAIL_NO_DISKS
Definition: resource.h:77
#define IDS_DETAIL_NO_VOLUME
Definition: resource.h:78
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:128
#define IDS_DETAIL_INFO_TARGET
Definition: resource.h:59
#define IDS_SELECT_NO_DISK
Definition: resource.h:121
#define IDS_DETAIL_PARTITION_OFFSET
Definition: resource.h:74
#define IDS_DETAIL_INFO_PATH
Definition: resource.h:58
#define IDS_DETAIL_PARTITION_NUMBER
Definition: resource.h:70
#define IDS_DETAIL_DISK_DESCRIPTION
Definition: resource.h:54
#define IDS_DETAIL_DISK_ID
Definition: resource.h:55
#define IDS_DETAIL_DISK_TYPE
Definition: resource.h:56
EXIT_CODE DetailDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:68
static BOOL IsDiskInVolume(_In_ PVOLENTRY VolumeEntry, _In_ PDISKENTRY DiskEntry)
Definition: detail.c:18
EXIT_CODE DetailVolume(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:222
static BOOL IsPartitionInVolume(_In_ PVOLENTRY VolumeEntry, _In_ PPARTENTRY PartEntry)
Definition: detail.c:41
EXIT_CODE DetailPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:136
LIST_ENTRY VolumeListHead
Definition: partlist.c:73
enum _EXIT_CODE EXIT_CODE
VOID PrintGUID(_Out_ PWSTR pszBuffer, _In_ GUID *pGuid)
Definition: misc.c:187
PDISKENTRY CurrentDisk
Definition: partlist.c:75
LIST_ENTRY DiskListHead
Definition: partlist.c:71
PVOLENTRY CurrentVolume
Definition: partlist.c:77
VOID PrintDisk(_In_ PDISKENTRY DiskEntry)
Definition: list.c:83
VOID PrintBusType(_Out_ PWSTR pszBuffer, _In_ INT cchBufferMax, _In_ STORAGE_BUS_TYPE Bustype)
Definition: misc.c:295
VOID PrintVolume(_In_ PVOLENTRY VolumeEntry)
Definition: list.c:471
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
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
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
#define argv
Definition: mplay32.c:18
#define _In_
Definition: no_sal2.h:158
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
wcscpy
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
STORAGE_BUS_TYPE BusType
Definition: diskpart.h:190
USHORT TargetId
Definition: diskpart.h:212
ULONG BytesPerSector
Definition: partlist.h:113
USHORT PathId
Definition: diskpart.h:211
USHORT Lun
Definition: diskpart.h:213
DWORD PartitionStyle
Definition: diskpart.h:219
PWSTR Description
Definition: diskpart.h:188
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:143
DWORD64 Attributes
Definition: diskpart.h:127
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
BOOLEAN BootIndicator
Definition: diskpart.h:119
MBR_PARTITION_DATA Mbr
Definition: diskpart.h:141
GPT_PARTITION_DATA Gpt
Definition: diskpart.h:142
ULONG PartitionNumber
Definition: partlist.h:75
ULARGE_INTEGER StartSector
Definition: partlist.h:69
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
static PPARTENTRY CurrentPartition
Definition: usetup.c:78
__wchar_t WCHAR
Definition: xmlstorage.h:180