ReactOS 0.4.15-dev-7654-g6bc40d3
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
76 DPRINT("DetailDisk()\n");
77
78 if (argc > 2)
79 {
81 return TRUE;
82 }
83
84 if (CurrentDisk == NULL)
85 {
87 return TRUE;
88 }
89
90 /* TODO: Print more disk details */
91 ConPuts(StdOut, L"\n");
96
98 while (Entry != &VolumeListHead)
99 {
100 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
101
102 if (IsDiskInVolume(VolumeEntry, CurrentDisk))
103 {
104 if (bPrintHeader)
105 {
106 ConPuts(StdOut, L"\n");
109 bPrintHeader = FALSE;
110 }
111
112 PrintVolume(VolumeEntry);
113 }
114
115 Entry = Entry->Flink;
116 }
117
118 ConPuts(StdOut, L"\n");
119
120 return TRUE;
121}
122
123
124BOOL
126 _In_ INT argc,
127 _In_ PWSTR *argv)
128{
129 PPARTENTRY PartEntry;
130 ULONGLONG PartOffset;
132 PVOLENTRY VolumeEntry;
133 BOOL bVolumeFound = FALSE, bPrintHeader = TRUE;
134
135 DPRINT("DetailPartition()\n");
136
137 if (argc > 2)
138 {
140 return TRUE;
141 }
142
143 if (CurrentDisk == NULL)
144 {
146 return TRUE;
147 }
148
149 if (CurrentPartition == NULL)
150 {
152 return TRUE;
153 }
154
155 PartEntry = CurrentPartition;
156 PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
157
158 /* TODO: Print more partition details */
159 ConPuts(StdOut, L"\n");
165
167 while (Entry != &VolumeListHead)
168 {
169 VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
170
171 if (IsPartitionInVolume(VolumeEntry, CurrentPartition))
172 {
173 if (bPrintHeader)
174 {
175 ConPuts(StdOut, L"\n");
178 bPrintHeader = FALSE;
179 }
180
181 PrintVolume(VolumeEntry);
182 bVolumeFound = TRUE;
183 }
184
185 Entry = Entry->Flink;
186 }
187
188 if (bVolumeFound == FALSE)
190
191 ConPuts(StdOut, L"\n");
192
193 return TRUE;
194}
195
196
197BOOL
199 _In_ INT argc,
200 _In_ PWSTR *argv)
201{
202 PDISKENTRY DiskEntry;
204 BOOL bDiskFound = FALSE, bPrintHeader = TRUE;
205
206 DPRINT("DetailVolume()\n");
207
208 if (argc > 2)
209 {
211 return TRUE;
212 }
213
214 if (CurrentVolume == NULL)
215 {
217 return TRUE;
218 }
219
220
222 while (Entry != &DiskListHead)
223 {
224 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
225
226 if (IsDiskInVolume(CurrentVolume, DiskEntry))
227 {
228 if (bPrintHeader)
229 {
230 ConPuts(StdOut, L"\n");
233 bPrintHeader = FALSE;
234 }
235
236 PrintDisk(DiskEntry);
237 bDiskFound = TRUE;
238 }
239
240 Entry = Entry->Flink;
241 }
242
243 if (bDiskFound == FALSE)
245
246 /* TODO: Print more volume details */
247
248 ConPuts(StdOut, L"\n");
249
250 return TRUE;
251}
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:35
#define IDS_LIST_DISK_LINE
Definition: resource.h:72
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:92
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:88
#define IDS_LIST_DISK_HEAD
Definition: resource.h:71
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:79
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:78
#define IDS_DETAIL_PARTITION_HIDDEN
Definition: resource.h:52
#define IDS_DETAIL_PARTITION_ACTIVE
Definition: resource.h:53
#define IDS_DETAIL_PARTITION_TYPE
Definition: resource.h:51
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
#define IDS_DETAIL_INFO_LUN_ID
Definition: resource.h:40
#define IDS_DETAIL_NO_DISKS
Definition: resource.h:56
#define IDS_DETAIL_NO_VOLUME
Definition: resource.h:57
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:90
#define IDS_DETAIL_INFO_TARGET
Definition: resource.h:39
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
#define IDS_DETAIL_PARTITION_OFFSET
Definition: resource.h:54
#define IDS_DETAIL_INFO_PATH
Definition: resource.h:38
#define IDS_DETAIL_PARTITION_NUMBER
Definition: resource.h:50
BOOL DetailPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:125
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:198
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
PDISKENTRY CurrentDisk
Definition: partlist.c:74
LIST_ENTRY DiskListHead
Definition: partlist.c:70
PVOLENTRY CurrentVolume
Definition: partlist.c:76
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
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
#define argv
Definition: mplay32.c:18
#define _In_
Definition: ms_sal.h:308
#define L(x)
Definition: ntvdm.h:50
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:83
USHORT TargetId
Definition: diskpart.h:167
ULONG BytesPerSector
Definition: partlist.h:95
USHORT PathId
Definition: diskpart.h:166
USHORT Lun
Definition: diskpart.h:168
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:125
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR PartitionType
Definition: partlist.h:53
BOOLEAN BootIndicator
Definition: partlist.h:52
ULONG PartitionNumber
Definition: partlist.h:55
ULARGE_INTEGER StartSector
Definition: partlist.h:49
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:76