ReactOS 0.4.16-dev-2208-g6350669
detail.c File Reference
#include "diskpart.h"
#include <debug.h>
Include dependency graph for detail.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static BOOL IsDiskInVolume (_In_ PVOLENTRY VolumeEntry, _In_ PDISKENTRY DiskEntry)
 
static BOOL IsPartitionInVolume (_In_ PVOLENTRY VolumeEntry, _In_ PPARTENTRY PartEntry)
 
EXIT_CODE DetailDisk (_In_ INT argc, _In_ PWSTR *argv)
 
EXIT_CODE DetailPartition (_In_ INT argc, _In_ PWSTR *argv)
 
EXIT_CODE DetailVolume (_In_ INT argc, _In_ PWSTR *argv)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file detail.c.

Function Documentation

◆ DetailDisk()

EXIT_CODE DetailDisk ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 68 of file detail.c.

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);
105 szBuffer, ARRAYSIZE(szBuffer));
110
113 szBuffer, ARRAYSIZE(szBuffer));
115
117 while (Entry != &VolumeListHead)
118 {
119 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
120
121 if (IsDiskInVolume(VolumeEntry, CurrentDisk))
122 {
123 if (bPrintHeader)
124 {
125 ConPuts(StdOut, L"\n");
128 bPrintHeader = FALSE;
129 }
130
131 PrintVolume(VolumeEntry);
132 }
133
134 Entry = Entry->Flink;
135 }
136
137 ConPuts(StdOut, L"\n");
138
139 return EXIT_SUCCESS;
140}
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_DISK_STATUS
Definition: resource.h:59
#define IDS_DETAIL_INFO_BOOT_DSK
Definition: resource.h:66
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:112
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:111
#define IDS_STATUS_ONLINE
Definition: resource.h:148
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:233
#define IDS_DETAIL_INFO_LUN_ID
Definition: resource.h:62
#define IDS_DETAIL_INFO_TARGET
Definition: resource.h:61
#define IDS_STATUS_YES
Definition: resource.h:143
#define IDS_SELECT_NO_DISK
Definition: resource.h:123
#define IDS_DETAIL_INFO_PATH
Definition: resource.h:60
#define IDS_DETAIL_DISK_DESCRIPTION
Definition: resource.h:56
#define IDS_DETAIL_DISK_ID
Definition: resource.h:57
#define IDS_DETAIL_DISK_TYPE
Definition: resource.h:58
static BOOL IsDiskInVolume(_In_ PVOLENTRY VolumeEntry, _In_ PDISKENTRY DiskEntry)
Definition: detail.c:18
LIST_ENTRY VolumeListHead
Definition: partlist.c:73
VOID PrintGUID(_Out_ PWSTR pszBuffer, _In_ GUID *pGuid)
Definition: misc.c:187
PDISKENTRY CurrentDisk
Definition: partlist.c:75
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:361
#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
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
#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
BOOL IsBoot
Definition: diskpart.h:234
STORAGE_BUS_TYPE BusType
Definition: diskpart.h:194
USHORT TargetId
Definition: diskpart.h:216
USHORT PathId
Definition: diskpart.h:215
USHORT Lun
Definition: diskpart.h:217
PWSTR Description
Definition: diskpart.h:192
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:143
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define GetModuleHandle
Definition: winbase.h:3576
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ DetailPartition()

EXIT_CODE DetailPartition ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 144 of file detail.c.

147{
148 PPARTENTRY PartEntry;
149 ULONGLONG PartOffset;
151 PVOLENTRY VolumeEntry;
152 BOOL bVolumeFound = FALSE, bPrintHeader = TRUE;
153 WCHAR szBuffer[40];
154
155 DPRINT("DetailPartition()\n");
156
157 if (argc > 2)
158 {
160 return EXIT_SUCCESS;
161 }
162
163 if (CurrentDisk == NULL)
164 {
166 return EXIT_SUCCESS;
167 }
168
169 if (CurrentPartition == NULL)
170 {
172 return EXIT_SUCCESS;
173 }
174
175 PartEntry = CurrentPartition;
176 PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
177
178 /* TODO: Print more partition details */
179 ConPuts(StdOut, L"\n");
182 {
183 PrintGUID(szBuffer, &PartEntry->Gpt.PartitionType);
186 (PartEntry->Gpt.Attributes & GPT_BASIC_DATA_ATTRIBUTE_HIDDEN) ? IDS_STATUS_YES : IDS_STATUS_NO,
187 szBuffer, ARRAYSIZE(szBuffer));
190 (PartEntry->Gpt.Attributes & GPT_ATTRIBUTE_PLATFORM_REQUIRED) ? IDS_STATUS_YES : IDS_STATUS_NO,
191 szBuffer, ARRAYSIZE(szBuffer));
194 }
196 {
197 swprintf(szBuffer, L"%02x", PartEntry->Mbr.PartitionType);
202 szBuffer, ARRAYSIZE(szBuffer));
204 }
206
208 while (Entry != &VolumeListHead)
209 {
210 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
211
212 if (IsPartitionInVolume(VolumeEntry, CurrentPartition))
213 {
214 if (bPrintHeader)
215 {
216 ConPuts(StdOut, L"\n");
219 bPrintHeader = FALSE;
220 }
221
222 PrintVolume(VolumeEntry);
223 bVolumeFound = TRUE;
224 }
225
226 Entry = Entry->Flink;
227 }
228
229 if (bVolumeFound == FALSE)
231
232 ConPuts(StdOut, L"\n");
233
234 return EXIT_SUCCESS;
235}
#define IDS_STATUS_NO
Definition: resource.h:144
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:128
#define IDS_DETAIL_PARTITION_HIDDEN
Definition: resource.h:74
#define IDS_DETAIL_PARTITION_ACTIVE
Definition: resource.h:75
#define IDS_DETAIL_PARTITION_TYPE
Definition: resource.h:73
#define IDS_DETAIL_PARTITION_ATTRIBUTE
Definition: resource.h:78
#define IDS_DETAIL_PARTITION_REQUIRED
Definition: resource.h:77
#define IDS_DETAIL_NO_VOLUME
Definition: resource.h:80
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:130
#define IDS_DETAIL_PARTITION_OFFSET
Definition: resource.h:76
#define IDS_DETAIL_PARTITION_NUMBER
Definition: resource.h:72
static BOOL IsPartitionInVolume(_In_ PVOLENTRY VolumeEntry, _In_ PPARTENTRY PartEntry)
Definition: detail.c:41
ULONG BytesPerSector
Definition: partlist.h:113
DWORD PartitionStyle
Definition: diskpart.h:223
DWORD64 Attributes
Definition: diskpart.h:127
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
uint64_t ULONGLONG
Definition: typedefs.h:67
static PPARTENTRY CurrentPartition
Definition: usetup.c:78

◆ DetailVolume()

EXIT_CODE DetailVolume ( _In_ INT  argc,
_In_ PWSTR argv 
)

Definition at line 239 of file detail.c.

242{
243 PDISKENTRY DiskEntry;
245 BOOL bDiskFound = FALSE, bPrintHeader = TRUE;
246
247 DPRINT("DetailVolume()\n");
248
249 if (argc > 2)
250 {
252 return EXIT_SUCCESS;
253 }
254
255 if (CurrentVolume == NULL)
256 {
258 return EXIT_SUCCESS;
259 }
260
261
263 while (Entry != &DiskListHead)
264 {
265 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
266
267 if (IsDiskInVolume(CurrentVolume, DiskEntry))
268 {
269 if (bPrintHeader)
270 {
271 ConPuts(StdOut, L"\n");
274 bPrintHeader = FALSE;
275 }
276
277 PrintDisk(DiskEntry);
278 bDiskFound = TRUE;
279 }
280
281 Entry = Entry->Flink;
282 }
283
284 if (bDiskFound == FALSE)
286
287 /* TODO: Print more volume details */
288
289 ConPuts(StdOut, L"\n");
290
291 return EXIT_SUCCESS;
292}
#define IDS_LIST_DISK_LINE
Definition: resource.h:104
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:132
#define IDS_LIST_DISK_HEAD
Definition: resource.h:103
#define IDS_DETAIL_NO_DISKS
Definition: resource.h:79
LIST_ENTRY DiskListHead
Definition: partlist.c:71
PVOLENTRY CurrentVolume
Definition: partlist.c:77
VOID PrintDisk(_In_ PDISKENTRY DiskEntry)
Definition: list.c:125

◆ IsDiskInVolume()

static BOOL IsDiskInVolume ( _In_ PVOLENTRY  VolumeEntry,
_In_ PDISKENTRY  DiskEntry 
)
static

Definition at line 18 of file detail.c.

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}
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
uint32_t ULONG
Definition: typedefs.h:59

Referenced by DetailDisk(), and DetailVolume().

◆ IsPartitionInVolume()

static BOOL IsPartitionInVolume ( _In_ PVOLENTRY  VolumeEntry,
_In_ PPARTENTRY  PartEntry 
)
static

Definition at line 41 of file detail.c.

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}

Referenced by DetailPartition().