ReactOS  0.4.15-dev-5446-g3f3714b
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 
16 static
17 BOOL
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 
39 static
40 BOOL
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 
67 BOOL
69  _In_ INT argc,
70  _In_ PWSTR *argv)
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 
124 BOOL
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");
163  ConResPrintf(StdOut, IDS_DETAIL_PARTITION_ACTIVE, PartEntry->BootIndicator ? L"Yes" : L"No");
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 
197 BOOL
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 }
USHORT TargetId
Definition: diskpart.h:167
#define IDS_SELECT_NO_PARTITION
Definition: resource.h:88
static int argc
Definition: ServiceArgs.c:12
#define IDS_DETAIL_PARTITION_ACTIVE
Definition: resource.h:53
ULONG PartitionNumber
Definition: partlist.h:55
#define IDS_LIST_DISK_LINE
Definition: resource.h:72
ULARGE_INTEGER StartSector
Definition: partlist.h:49
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define IDS_DETAIL_INFO_TARGET
Definition: resource.h:39
VOID PrintDisk(_In_ PDISKENTRY DiskEntry)
Definition: list.c:17
#define IDS_DETAIL_NO_VOLUME
Definition: resource.h:57
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define argv
Definition: mplay32.c:18
#define IDS_DETAIL_PARTITION_NUMBER
Definition: resource.h:50
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:92
int32_t INT
Definition: typedefs.h:58
#define IDS_DETAIL_INFO_DISK_ID
Definition: resource.h:35
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:187
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDS_LIST_DISK_HEAD
Definition: resource.h:71
#define _In_
Definition: ms_sal.h:308
#define IDS_DETAIL_PARTITION_TYPE
Definition: resource.h:51
static BOOL IsDiskInVolume(_In_ PVOLENTRY VolumeEntry, _In_ PDISKENTRY DiskEntry)
Definition: detail.c:18
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY DiskListHead
Definition: partlist.c:70
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
USHORT Lun
Definition: diskpart.h:168
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
UCHAR PartitionType
Definition: partlist.h:53
BOOL DetailDisk(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:68
ULONG BytesPerSector
Definition: partlist.h:95
#define IDS_DETAIL_PARTITION_OFFSET
Definition: resource.h:54
uint64_t ULONGLONG
Definition: typedefs.h:67
BOOL DetailPartition(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:125
#define IDS_SELECT_NO_DISK
Definition: resource.h:85
USHORT PathId
Definition: diskpart.h:166
static BOOL IsPartitionInVolume(_In_ PVOLENTRY VolumeEntry, _In_ PPARTENTRY PartEntry)
Definition: detail.c:41
#define IDS_SELECT_PARTITION_NO_DISK
Definition: resource.h:90
#define IDS_DETAIL_INFO_LUN_ID
Definition: resource.h:40
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:79
Definition: typedefs.h:119
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:78
BOOL DetailVolume(_In_ INT argc, _In_ PWSTR *argv)
Definition: detail.c:198
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 IDS_DETAIL_NO_DISKS
Definition: resource.h:56
#define NULL
Definition: types.h:112
BOOLEAN BootIndicator
Definition: partlist.h:52
#define StdOut
Definition: fc.c:14
#define IDS_DETAIL_INFO_PATH
Definition: resource.h:38
unsigned int ULONG
Definition: retypes.h:1
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
#define IDS_DETAIL_PARTITION_HIDDEN
Definition: resource.h:52
PVOLENTRY CurrentVolume
Definition: partlist.c:76
#define DPRINT
Definition: sndvol32.h:71
VOID PrintVolume(_In_ PVOLENTRY VolumeEntry)
Definition: list.c:230
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
Definition: partlist.h:125
base of all file and directory entries
Definition: entries.h:82
#define StdErr
Definition: fc.c:15