ReactOS 0.4.16-dev-1972-gf20c09f
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
67BOOL
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 TRUE;
83 }
84
85 if (CurrentDisk == NULL)
86 {
88 return TRUE;
89 }
90
91 /* TODO: Print more disk details */
92 ConPuts(StdOut, L"\n");
93 if (CurrentDisk->LayoutBuffer->PartitionStyle == PARTITION_STYLE_GPT)
94 PrintGUID(szBuffer, &CurrentDisk->LayoutBuffer->Gpt.DiskId);
95 else if (CurrentDisk->LayoutBuffer->PartitionStyle == PARTITION_STYLE_MBR)
96 swprintf(szBuffer, L"%08lx", CurrentDisk->LayoutBuffer->Mbr.Signature);
97 else
98 wcscpy(szBuffer, L"00000000");
103
105 while (Entry != &VolumeListHead)
106 {
107 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
108
109 if (IsDiskInVolume(VolumeEntry, CurrentDisk))
110 {
111 if (bPrintHeader)
112 {
113 ConPuts(StdOut, L"\n");
116 bPrintHeader = FALSE;
117 }
118
119 PrintVolume(VolumeEntry);
120 }
121
122 Entry = Entry->Flink;
123 }
124
125 ConPuts(StdOut, L"\n");
126
127 return TRUE;
128}
129
130
131BOOL
133 _In_ INT argc,
134 _In_ PWSTR *argv)
135{
136 PPARTENTRY PartEntry;
137 ULONGLONG PartOffset;
139 PVOLENTRY VolumeEntry;
140 BOOL bVolumeFound = FALSE, bPrintHeader = TRUE;
141
142 DPRINT("DetailPartition()\n");
143
144 if (argc > 2)
145 {
147 return TRUE;
148 }
149
150 if (CurrentDisk == NULL)
151 {
153 return TRUE;
154 }
155
156 if (CurrentPartition == NULL)
157 {
159 return TRUE;
160 }
161
162 PartEntry = CurrentPartition;
163 PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
164
165 /* TODO: Print more partition details */
166 ConPuts(StdOut, L"\n");
172
174 while (Entry != &VolumeListHead)
175 {
176 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
177
178 if (IsPartitionInVolume(VolumeEntry, CurrentPartition))
179 {
180 if (bPrintHeader)
181 {
182 ConPuts(StdOut, L"\n");
185 bPrintHeader = FALSE;
186 }
187
188 PrintVolume(VolumeEntry);
189 bVolumeFound = TRUE;
190 }
191
192 Entry = Entry->Flink;
193 }
194
195 if (bVolumeFound == FALSE)
197
198 ConPuts(StdOut, L"\n");
199
200 return TRUE;
201}
202
203
204BOOL
206 _In_ INT argc,
207 _In_ PWSTR *argv)
208{
209 PDISKENTRY DiskEntry;
211 BOOL bDiskFound = FALSE, bPrintHeader = TRUE;
212
213 DPRINT("DetailVolume()\n");
214
215 if (argc > 2)
216 {
218 return TRUE;
219 }
220
221 if (CurrentVolume == NULL)
222 {
224 return TRUE;
225 }
226
227
229 while (Entry != &DiskListHead)
230 {
231 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
232
233 if (IsDiskInVolume(CurrentVolume, DiskEntry))
234 {
235 if (bPrintHeader)
236 {
237 ConPuts(StdOut, L"\n");
240 bPrintHeader = FALSE;
241 }
242
243 PrintDisk(DiskEntry);
244 bDiskFound = TRUE;
245 }
246
247 Entry = Entry->Flink;
248 }
249
250 if (bDiskFound == FALSE)
252
253 /* TODO: Print more volume details */
254
255 ConPuts(StdOut, L"\n");
256
257 return TRUE;
258}
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_DETAIL_INFO_DISK_ID
Definition: resource.h:44
#define IDS_LIST_DISK_LINE
Definition: resource.h:81
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:103
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:99
#define IDS_LIST_DISK_HEAD
Definition: resource.h:80
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:88
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:87
#define IDS_DETAIL_PARTITION_HIDDEN
Definition: resource.h:61
#define IDS_DETAIL_PARTITION_ACTIVE
Definition: resource.h:62
#define IDS_DETAIL_PARTITION_TYPE
Definition: resource.h:60
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:202
#define IDS_DETAIL_INFO_LUN_ID
Definition: resource.h:49
#define IDS_DETAIL_NO_DISKS
Definition: resource.h:65
#define IDS_DETAIL_NO_VOLUME
Definition: resource.h:66
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:101
#define IDS_DETAIL_INFO_TARGET
Definition: resource.h:48
#define IDS_SELECT_NO_DISK
Definition: resource.h:94
#define IDS_DETAIL_PARTITION_OFFSET
Definition: resource.h:63
#define IDS_DETAIL_INFO_PATH
Definition: resource.h:47
#define IDS_DETAIL_PARTITION_NUMBER
Definition: resource.h:59
wcscpy
BOOL DetailPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:132
BOOL DetailDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:68
static BOOL IsDiskInVolume(_In_ PVOLENTRY VolumeEntry, _In_ PDISKENTRY DiskEntry)
Definition: detail.c:18
static BOOL IsPartitionInVolume(_In_ PVOLENTRY VolumeEntry, _In_ PPARTENTRY PartEntry)
Definition: detail.c:41
BOOL DetailVolume(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:205
LIST_ENTRY VolumeListHead
Definition: partlist.c:74
VOID PrintGUID(_Out_ PWSTR pszBuffer, _In_ GUID *pGuid)
Definition: misc.c:187
PDISKENTRY CurrentDisk
Definition: partlist.c:76
LIST_ENTRY DiskListHead
Definition: partlist.c:72
PVOLENTRY CurrentVolume
Definition: partlist.c:78
VOID PrintDisk(_In_ PDISKENTRY DiskEntry)
Definition: list.c:17
VOID PrintVolume(_In_ PVOLENTRY VolumeEntry)
Definition: list.c:230
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#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 DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
USHORT TargetId
Definition: diskpart.h:172
ULONG BytesPerSector
Definition: partlist.h:113
USHORT PathId
Definition: diskpart.h:171
USHORT Lun
Definition: diskpart.h:173
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:143
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR PartitionType
Definition: partlist.h:73
BOOLEAN BootIndicator
Definition: partlist.h:72
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