ReactOS  0.4.15-dev-5462-g4d0d22a
list.c File Reference
#include "diskpart.h"
#include <debug.h>
Include dependency graph for list.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID PrintDisk (_In_ PDISKENTRY DiskEntry)
 
BOOL ListDisk (INT argc, PWSTR *argv)
 
BOOL ListPartition (INT argc, PWSTR *argv)
 
VOID PrintVolume (_In_ PVOLENTRY VolumeEntry)
 
BOOL ListVolume (INT argc, PWSTR *argv)
 
BOOL ListVirtualDisk (INT argc, PWSTR *argv)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file list.c.

Function Documentation

◆ ListDisk()

BOOL ListDisk ( INT  argc,
PWSTR argv 
)

Definition at line 59 of file list.c.

62 {
64  PDISKENTRY DiskEntry;
65 
66  /* Header labels */
67  ConPuts(StdOut, L"\n");
70 
72  while (Entry != &DiskListHead)
73  {
74  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
75 
76  PrintDisk(DiskEntry);
77 
78  Entry = Entry->Flink;
79  }
80 
81  ConPuts(StdOut, L"\n\n");
82 
83  return TRUE;
84 }
#define IDS_LIST_DISK_LINE
Definition: resource.h:72
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define IDS_LIST_DISK_HEAD
Definition: resource.h:71
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
Definition: typedefs.h:119
VOID PrintDisk(_In_ PDISKENTRY DiskEntry)
Definition: list.c:17
#define StdOut
Definition: fc.c:14
base of all file and directory entries
Definition: entries.h:82

◆ ListPartition()

BOOL ListPartition ( INT  argc,
PWSTR argv 
)

Definition at line 88 of file list.c.

91 {
93  PPARTENTRY PartEntry;
94  ULONGLONG PartSize;
95  ULONGLONG PartOffset;
96  LPWSTR lpSizeUnit;
97  LPWSTR lpOffsetUnit;
98  ULONG PartNumber = 1;
99 
100  if (CurrentDisk == NULL)
101  {
103  return TRUE;
104  }
105 
106  /* Header labels */
107  ConPuts(StdOut, L"\n");
110 
113  {
114  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
115 
116  if (PartEntry->PartitionType != 0)
117  {
118  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
119 
120  if (PartSize >= 10737418240) /* 10 GB */
121  {
122  PartSize = RoundingDivide(PartSize, 1073741824);
123  lpSizeUnit = L"GB";
124  }
125  else if (PartSize >= 10485760) /* 10 MB */
126  {
127  PartSize = RoundingDivide(PartSize, 1048576);
128  lpSizeUnit = L"MB";
129  }
130  else
131  {
132  PartSize = RoundingDivide(PartSize, 1024);
133  lpSizeUnit = L"KB";
134  }
135 
136  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
137 
138  if (PartOffset >= 10737418240) /* 10 GB */
139  {
140  PartOffset = RoundingDivide(PartOffset, 1073741824);
141  lpOffsetUnit = L"GB";
142  }
143  else if (PartOffset >= 10485760) /* 10 MB */
144  {
145  PartOffset = RoundingDivide(PartOffset, 1048576);
146  lpOffsetUnit = L"MB";
147  }
148  else
149  {
150  PartOffset = RoundingDivide(PartOffset, 1024);
151  lpOffsetUnit = L"KB";
152  }
153 
155  (CurrentPartition == PartEntry) ? L'*' : L' ',
156  PartNumber++,
157  IsContainerPartition(PartEntry->PartitionType) ? L"Extended" : L"Primary",
158  PartSize,
159  lpSizeUnit,
160  PartOffset,
161  lpOffsetUnit);
162  }
163 
164  Entry = Entry->Flink;
165  }
166 
169  {
170  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
171 
172  if (PartEntry->PartitionType != 0)
173  {
174  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
175 
176  if (PartSize >= 10737418240) /* 10 GB */
177  {
178  PartSize = RoundingDivide(PartSize, 1073741824);
179  lpSizeUnit = L"GB";
180  }
181  else if (PartSize >= 10485760) /* 10 MB */
182  {
183  PartSize = RoundingDivide(PartSize, 1048576);
184  lpSizeUnit = L"MB";
185  }
186  else
187  {
188  PartSize = RoundingDivide(PartSize, 1024);
189  lpSizeUnit = L"KB";
190  }
191 
192  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
193 
194  if (PartOffset >= 10737418240) /* 10 GB */
195  {
196  PartOffset = RoundingDivide(PartOffset, 1073741824);
197  lpOffsetUnit = L"GB";
198  }
199  else if (PartOffset >= 10485760) /* 10 MB */
200  {
201  PartOffset = RoundingDivide(PartOffset, 1048576);
202  lpOffsetUnit = L"MB";
203  }
204  else
205  {
206  PartOffset = RoundingDivide(PartOffset, 1024);
207  lpOffsetUnit = L"KB";
208  }
209 
211  (CurrentPartition == PartEntry) ? L'*' : L' ',
212  PartNumber++,
213  L"Logical",
214  PartSize,
215  lpSizeUnit,
216  PartOffset,
217  lpOffsetUnit);
218  }
219 
220  Entry = Entry->Flink;
221  }
222 
223  ConPuts(StdOut, L"\n");
224 
225  return TRUE;
226 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
ULARGE_INTEGER StartSector
Definition: partlist.h:49
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
ULARGE_INTEGER SectorCount
Definition: partlist.h:50
#define IDS_LIST_PARTITION_LINE
Definition: resource.h:75
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:74
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
#define IDS_LIST_PARTITION_FORMAT
Definition: resource.h:76
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
UCHAR PartitionType
Definition: partlist.h:53
ULONG BytesPerSector
Definition: partlist.h:95
uint64_t ULONGLONG
Definition: typedefs.h:67
Definition: typedefs.h:119
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define IDS_LIST_PARTITION_NO_DISK
Definition: resource.h:77
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
#define IDS_LIST_PARTITION_HEAD
Definition: resource.h:74
#define StdOut
Definition: fc.c:14
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82

◆ ListVirtualDisk()

BOOL ListVirtualDisk ( INT  argc,
PWSTR argv 
)

Definition at line 310 of file list.c.

313 {
314  ConPuts(StdOut, L"ListVirtualDisk()!\n");
315  return TRUE;
316 }
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define StdOut
Definition: fc.c:14

◆ ListVolume()

BOOL ListVolume ( INT  argc,
PWSTR argv 
)

Definition at line 282 of file list.c.

285 {
287  PVOLENTRY VolumeEntry;
288 
289  ConPuts(StdOut, L"\n");
292 
294  while (Entry != &VolumeListHead)
295  {
296  VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
297 
298  PrintVolume(VolumeEntry);
299 
300  Entry = Entry->Flink;
301  }
302 
303  ConPuts(StdOut, L"\n");
304 
305  return TRUE;
306 }
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
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
VOID PrintVolume(_In_ PVOLENTRY VolumeEntry)
Definition: list.c:230
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:79
Definition: typedefs.h:119
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:78
#define StdOut
Definition: fc.c:14
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
base of all file and directory entries
Definition: entries.h:82

◆ PrintDisk()

VOID PrintDisk ( _In_ PDISKENTRY  DiskEntry)

Definition at line 17 of file list.c.

19 {
20  ULONGLONG DiskSize;
21  ULONGLONG FreeSize;
22  LPWSTR lpSizeUnit;
23  LPWSTR lpFreeUnit;
24 
25  DiskSize = DiskEntry->SectorCount.QuadPart *
26  (ULONGLONG)DiskEntry->BytesPerSector;
27 
28  if (DiskSize >= 10737418240) /* 10 GB */
29  {
30  DiskSize = RoundingDivide(DiskSize, 1073741824);
31  lpSizeUnit = L"GB";
32  }
33  else
34  {
35  DiskSize = RoundingDivide(DiskSize, 1048576);
36  if (DiskSize == 0)
37  DiskSize = 1;
38  lpSizeUnit = L"MB";
39  }
40 
41  /* FIXME */
42  FreeSize = 0;
43  lpFreeUnit = L"B";
44 
46  (CurrentDisk == DiskEntry) ? L'*' : L' ',
47  DiskEntry->DiskNumber,
48  L"Online",
49  DiskSize,
50  lpSizeUnit,
51  FreeSize,
52  lpFreeUnit,
53  L" ",
54  L" ");
55 }
PDISKENTRY CurrentDisk
Definition: partlist.c:74
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define L(x)
Definition: ntvdm.h:50
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define StdOut
Definition: fc.c:14
#define IDS_LIST_DISK_FORMAT
Definition: resource.h:73
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DetailVolume(), and ListDisk().

◆ PrintVolume()

VOID PrintVolume ( _In_ PVOLENTRY  VolumeEntry)

Definition at line 230 of file list.c.

232 {
233  ULONGLONG VolumeSize;
234  PWSTR pszSizeUnit;
235  PWSTR pszVolumeType;
236 
237  VolumeSize = VolumeEntry->Size.QuadPart;
238  if (VolumeSize >= 10737418240) /* 10 GB */
239  {
240  VolumeSize = RoundingDivide(VolumeSize, 1073741824);
241  pszSizeUnit = L"GB";
242  }
243  else if (VolumeSize >= 10485760) /* 10 MB */
244  {
245  VolumeSize = RoundingDivide(VolumeSize, 1048576);
246  pszSizeUnit = L"MB";
247  }
248  else
249  {
250  VolumeSize = RoundingDivide(VolumeSize, 1024);
251  pszSizeUnit = L"KB";
252  }
253  switch (VolumeEntry->VolumeType)
254  {
255  case VOLUME_TYPE_CDROM:
256  pszVolumeType = L"DVD";
257  break;
259  pszVolumeType = L"Partition";
260  break;
262  pszVolumeType = L"Removable";
263  break;
264  case VOLUME_TYPE_UNKNOWN:
265  default:
266  pszVolumeType = L"Unknown";
267  break;
268  }
269 
271  (CurrentVolume == VolumeEntry) ? L'*' : L' ',
272  VolumeEntry->VolumeNumber,
273  VolumeEntry->DriveLetter,
274  (VolumeEntry->pszLabel) ? VolumeEntry->pszLabel : L"",
275  (VolumeEntry->pszFilesystem) ? VolumeEntry->pszFilesystem : L"",
276  pszVolumeType,
277  VolumeSize, pszSizeUnit);
278 }
uint16_t * PWSTR
Definition: typedefs.h:56
#define L(x)
Definition: ntvdm.h:50
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define IDS_LIST_VOLUME_FORMAT
Definition: resource.h:80
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define StdOut
Definition: fc.c:14
PVOLENTRY CurrentVolume
Definition: partlist.c:76

Referenced by DetailDisk(), DetailPartition(), and ListVolume().