ReactOS  0.4.15-dev-4610-g11e0ed3
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

BOOL ListDisk (INT argc, PWSTR *argv)
 
BOOL ListPartition (INT argc, PWSTR *argv)
 
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 17 of file list.c.

20 {
22  PDISKENTRY DiskEntry;
23  ULONGLONG DiskSize;
24  ULONGLONG FreeSize;
25  LPWSTR lpSizeUnit;
26  LPWSTR lpFreeUnit;
27 
28  /* Header labels */
31 
33  while (Entry != &DiskListHead)
34  {
35  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
36 
37  DiskSize = DiskEntry->SectorCount.QuadPart *
38  (ULONGLONG)DiskEntry->BytesPerSector;
39 
40  if (DiskSize >= 10737418240) /* 10 GB */
41  {
42  DiskSize = RoundingDivide(DiskSize, 1073741824);
43  lpSizeUnit = L"GB";
44  }
45  else
46  {
47  DiskSize = RoundingDivide(DiskSize, 1048576);
48  if (DiskSize == 0)
49  DiskSize = 1;
50  lpSizeUnit = L"MB";
51  }
52 
53  /* FIXME */
54  FreeSize = 0;
55  lpFreeUnit = L"B";
56 
58  (CurrentDisk == DiskEntry) ? L'*': ' ',
59  DiskEntry->DiskNumber,
60  L"Online",
61  DiskSize,
62  lpSizeUnit,
63  FreeSize,
64  lpFreeUnit,
65  L" ",
66  L" ");
67 
68  Entry = Entry->Flink;
69  }
70 
71  ConPuts(StdOut, L"\n\n");
72 
73  return TRUE;
74 }
#define IDS_LIST_DISK_LINE
Definition: resource.h:44
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
ULONG DiskNumber
Definition: partlist.h:111
PDISKENTRY CurrentDisk
Definition: partlist.c:74
if(dx==0 &&dy==0)
Definition: linetemp.h:174
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define IDS_LIST_DISK_HEAD
Definition: resource.h:43
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
ULARGE_INTEGER SectorCount
Definition: partlist.h:97
LIST_ENTRY DiskListHead
Definition: partlist.c:70
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
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 StdOut
Definition: fc.c:14
#define IDS_LIST_DISK_FORMAT
Definition: resource.h:45
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82

◆ ListPartition()

BOOL ListPartition ( INT  argc,
PWSTR argv 
)

Definition at line 78 of file list.c.

81 {
83  PPARTENTRY PartEntry;
84  ULONGLONG PartSize;
85  ULONGLONG PartOffset;
86  LPWSTR lpSizeUnit;
87  LPWSTR lpOffsetUnit;
88  ULONG PartNumber = 1;
89 
90  if (CurrentDisk == NULL)
91  {
93  return TRUE;
94  }
95 
96  /* Header labels */
99 
102  {
103  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
104 
105  if (PartEntry->PartitionType != 0)
106  {
107  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
108 
109  if (PartSize >= 10737418240) /* 10 GB */
110  {
111  PartSize = RoundingDivide(PartSize, 1073741824);
112  lpSizeUnit = L"GB";
113  }
114  else if (PartSize >= 10485760) /* 10 MB */
115  {
116  PartSize = RoundingDivide(PartSize, 1048576);
117  lpSizeUnit = L"MB";
118  }
119  else
120  {
121  PartSize = RoundingDivide(PartSize, 1024);
122  lpSizeUnit = L"KB";
123  }
124 
125  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
126 
127  if (PartOffset >= 10737418240) /* 10 GB */
128  {
129  PartOffset = RoundingDivide(PartOffset, 1073741824);
130  lpOffsetUnit = L"GB";
131  }
132  else if (PartOffset >= 10485760) /* 10 MB */
133  {
134  PartOffset = RoundingDivide(PartOffset, 1048576);
135  lpOffsetUnit = L"MB";
136  }
137  else
138  {
139  PartOffset = RoundingDivide(PartOffset, 1024);
140  lpOffsetUnit = L"KB";
141  }
142 
144  (CurrentPartition == PartEntry) ? L'*': ' ',
145  PartNumber++,
146  IsContainerPartition(PartEntry->PartitionType) ? L"Extended" : L"Primary",
147  PartSize,
148  lpSizeUnit,
149  PartOffset,
150  lpOffsetUnit);
151  }
152 
153  Entry = Entry->Flink;
154  }
155 
158  {
159  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
160 
161  if (PartEntry->PartitionType != 0)
162  {
163  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
164 
165  if (PartSize >= 10737418240) /* 10 GB */
166  {
167  PartSize = RoundingDivide(PartSize, 1073741824);
168  lpSizeUnit = L"GB";
169  }
170  else if (PartSize >= 10485760) /* 10 MB */
171  {
172  PartSize = RoundingDivide(PartSize, 1048576);
173  lpSizeUnit = L"MB";
174  }
175  else
176  {
177  PartSize = RoundingDivide(PartSize, 1024);
178  lpSizeUnit = L"KB";
179  }
180 
181  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
182 
183  if (PartOffset >= 10737418240) /* 10 GB */
184  {
185  PartOffset = RoundingDivide(PartOffset, 1073741824);
186  lpOffsetUnit = L"GB";
187  }
188  else if (PartOffset >= 10485760) /* 10 MB */
189  {
190  PartOffset = RoundingDivide(PartOffset, 1048576);
191  lpOffsetUnit = L"MB";
192  }
193  else
194  {
195  PartOffset = RoundingDivide(PartOffset, 1024);
196  lpOffsetUnit = L"KB";
197  }
198 
200  (CurrentPartition == PartEntry) ? L'*': ' ',
201  PartNumber++,
202  L"Logical",
203  PartSize,
204  lpSizeUnit,
205  PartOffset,
206  lpOffsetUnit);
207  }
208 
209  Entry = Entry->Flink;
210  }
211 
212  ConPuts(StdOut, L"\n");
213 
214  return TRUE;
215 }
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:47
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:48
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:49
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
#define IDS_LIST_PARTITION_HEAD
Definition: resource.h:46
#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 271 of file list.c.

274 {
275  ConPuts(StdOut, L"ListVirtualDisk()!\n");
276  return TRUE;
277 }
#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 219 of file list.c.

222 {
224  PVOLENTRY VolumeEntry;
225  ULONGLONG VolumeSize;
226  LPWSTR lpSizeUnit;
227 
230 
232  while (Entry != &VolumeListHead)
233  {
234  VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
235 
236  VolumeSize = VolumeEntry->Size.QuadPart;
237  if (VolumeSize >= 10737418240) /* 10 GB */
238  {
239  VolumeSize = RoundingDivide(VolumeSize, 1073741824);
240  lpSizeUnit = L"GB";
241  }
242  else if (VolumeSize >= 10485760) /* 10 MB */
243  {
244  VolumeSize = RoundingDivide(VolumeSize, 1048576);
245  lpSizeUnit = L"MB";
246  }
247  else
248  {
249  VolumeSize = RoundingDivide(VolumeSize, 1024);
250  lpSizeUnit = L"KB";
251  }
252 
254  VolumeEntry->VolumeNumber,
255  VolumeEntry->DriveLetter,
256  (VolumeEntry->pszLabel) ? VolumeEntry->pszLabel : L"",
257  (VolumeEntry->pszFilesystem) ? VolumeEntry->pszFilesystem : L"",
258  VolumeEntry->DriveType,
259  VolumeSize, lpSizeUnit);
260 
261  Entry = Entry->Flink;
262  }
263 
264  ConPuts(StdOut, L"\n\n");
265 
266  return TRUE;
267 }
struct _Entry Entry
Definition: kefuncs.h:629
#define TRUE
Definition: types.h:120
ULARGE_INTEGER Size
Definition: diskpart.h:190
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
WCHAR DriveLetter
Definition: diskpart.h:185
PWSTR pszLabel
Definition: diskpart.h:187
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
#define IDS_LIST_VOLUME_FORMAT
Definition: resource.h:52
uint64_t ULONGLONG
Definition: typedefs.h:67
UINT DriveType
Definition: diskpart.h:189
#define IDS_LIST_VOLUME_LINE
Definition: resource.h:51
Definition: typedefs.h:119
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:50
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
ULONG VolumeNumber
Definition: diskpart.h:182
PWSTR pszFilesystem
Definition: diskpart.h:188
#define StdOut
Definition: fc.c:14
LIST_ENTRY VolumeListHead
Definition: partlist.c:72
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82