ReactOS  0.4.14-dev-999-g61c8d34
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

static ULONGLONG RoundingDivide (IN ULONGLONG Dividend, IN ULONGLONG Divisor)
 
static VOID ListDisk (VOID)
 
static VOID ListPartition (VOID)
 
static VOID ListVolume (VOID)
 
static VOID ListVdisk (VOID)
 
BOOL list_main (INT argc, LPWSTR *argv)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file list.c.

Function Documentation

◆ list_main()

BOOL list_main ( INT  argc,
LPWSTR argv 
)

Definition at line 235 of file list.c.

238 {
239  /* gets the first word from the string */
240  if (argc == 1)
241  {
243  return TRUE;
244  }
245 
246  /* determines which to list (disk, partition, etc.) */
247  if (!wcsicmp(argv[1], L"disk"))
248  ListDisk();
249  else if (!wcsicmp(argv[1], L"partition"))
250  ListPartition();
251  else if (!wcsicmp(argv[1], L"volume"))
252  ListVolume();
253  else if (!wcsicmp(argv[1], L"vdisk"))
254  ListVdisk();
255  else
257 
258  return TRUE;
259 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define argv
Definition: mplay32.c:18
static VOID ListPartition(VOID)
Definition: list.c:85
#define IDS_HELP_CMD_LIST
Definition: resource.h:132
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1250
#define wcsicmp
Definition: string.h:1152
static VOID ListVdisk(VOID)
Definition: list.c:229
static VOID ListVolume(VOID)
Definition: list.c:222
#define StdOut
Definition: stream.h:76
static VOID ListDisk(VOID)
Definition: list.c:28

◆ ListDisk()

static VOID ListDisk ( VOID  )
static

Definition at line 28 of file list.c.

29 {
31  PDISKENTRY DiskEntry;
32  ULONGLONG DiskSize;
33  ULONGLONG FreeSize;
34  LPWSTR lpSizeUnit;
35  LPWSTR lpFreeUnit;
36 
37  /* Header labels */
40 
42  while (Entry != &DiskListHead)
43  {
44  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
45 
46  DiskSize = DiskEntry->SectorCount.QuadPart *
47  (ULONGLONG)DiskEntry->BytesPerSector;
48 
49  if (DiskSize >= 10737418240) /* 10 GB */
50  {
51  DiskSize = RoundingDivide(DiskSize, 1073741824);
52  lpSizeUnit = L"GB";
53  }
54  else
55  {
56  DiskSize = RoundingDivide(DiskSize, 1048576);
57  if (DiskSize == 0)
58  DiskSize = 1;
59  lpSizeUnit = L"MB";
60  }
61 
62  /* FIXME */
63  FreeSize = 0;
64  lpFreeUnit = L"B";
65 
67  (CurrentDisk == DiskEntry) ? L'*': ' ',
68  DiskEntry->DiskNumber,
69  L"Online",
70  DiskSize,
71  lpSizeUnit,
72  FreeSize,
73  lpFreeUnit,
74  L" ",
75  L" ");
76 
77  Entry = Entry->Flink;
78  }
79 
80  ConPuts(StdOut, L"\n\n");
81 }
#define IDS_LIST_DISK_LINE
Definition: resource.h:36
struct _Entry Entry
Definition: kefuncs.h:627
ULONG DiskNumber
Definition: partlist.h:104
PDISKENTRY CurrentDisk
Definition: partlist.c:73
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define IDS_LIST_DISK_HEAD
Definition: resource.h:35
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:90
LIST_ENTRY DiskListHead
Definition: partlist.c:70
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
ULONG BytesPerSector
Definition: partlist.h:88
if(!(yy_init))
Definition: macro.lex.yy.c:714
uint64_t ULONGLONG
Definition: typedefs.h:66
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: list.c:18
static const WCHAR L[]
Definition: oid.c:1250
Definition: typedefs.h:118
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define StdOut
Definition: stream.h:76
#define IDS_LIST_DISK_FORMAT
Definition: resource.h:37
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82

Referenced by list_main().

◆ ListPartition()

static VOID ListPartition ( VOID  )
static

Definition at line 85 of file list.c.

86 {
88  PPARTENTRY PartEntry;
89  ULONGLONG PartSize;
90  ULONGLONG PartOffset;
91  LPWSTR lpSizeUnit;
92  LPWSTR lpOffsetUnit;
93  ULONG PartNumber = 1;
94 
95  if (CurrentDisk == NULL)
96  {
98  return;
99  }
100 
101  /* Header labels */
104 
107  {
108  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
109 
110  if (PartEntry->PartitionType != 0)
111  {
112  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
113 
114  if (PartSize >= 10737418240) /* 10 GB */
115  {
116  PartSize = RoundingDivide(PartSize, 1073741824);
117  lpSizeUnit = L"GB";
118  }
119  else if (PartSize >= 10485760) /* 10 MB */
120  {
121  PartSize = RoundingDivide(PartSize, 1048576);
122  lpSizeUnit = L"MB";
123  }
124  else
125  {
126  PartSize = RoundingDivide(PartSize, 1024);
127  lpSizeUnit = L"KB";
128  }
129 
130  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
131 
132  if (PartOffset >= 10737418240) /* 10 GB */
133  {
134  PartOffset = RoundingDivide(PartOffset, 1073741824);
135  lpOffsetUnit = L"GB";
136  }
137  else if (PartOffset >= 10485760) /* 10 MB */
138  {
139  PartOffset = RoundingDivide(PartOffset, 1048576);
140  lpOffsetUnit = L"MB";
141  }
142  else
143  {
144  PartOffset = RoundingDivide(PartOffset, 1024);
145  lpOffsetUnit = L"KB";
146  }
147 
149  (CurrentPartition == PartEntry) ? L'*': ' ',
150  PartNumber++,
151  IsContainerPartition(PartEntry->PartitionType) ? L"Extended" : L"Primary",
152  PartSize,
153  lpSizeUnit,
154  PartOffset,
155  lpOffsetUnit);
156  }
157 
158  Entry = Entry->Flink;
159  }
160 
163  {
164  PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
165 
166  if (PartEntry->PartitionType != 0)
167  {
168  PartSize = PartEntry->SectorCount.QuadPart * CurrentDisk->BytesPerSector;
169 
170  if (PartSize >= 10737418240) /* 10 GB */
171  {
172  PartSize = RoundingDivide(PartSize, 1073741824);
173  lpSizeUnit = L"GB";
174  }
175  else if (PartSize >= 10485760) /* 10 MB */
176  {
177  PartSize = RoundingDivide(PartSize, 1048576);
178  lpSizeUnit = L"MB";
179  }
180  else
181  {
182  PartSize = RoundingDivide(PartSize, 1024);
183  lpSizeUnit = L"KB";
184  }
185 
186  PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
187 
188  if (PartOffset >= 10737418240) /* 10 GB */
189  {
190  PartOffset = RoundingDivide(PartOffset, 1073741824);
191  lpOffsetUnit = L"GB";
192  }
193  else if (PartOffset >= 10485760) /* 10 MB */
194  {
195  PartOffset = RoundingDivide(PartOffset, 1048576);
196  lpOffsetUnit = L"MB";
197  }
198  else
199  {
200  PartOffset = RoundingDivide(PartOffset, 1024);
201  lpOffsetUnit = L"KB";
202  }
203 
205  (CurrentPartition == PartEntry) ? L'*': ' ',
206  PartNumber++,
207  L"Logical",
208  PartSize,
209  lpSizeUnit,
210  PartOffset,
211  lpOffsetUnit);
212  }
213 
214  Entry = Entry->Flink;
215  }
216 
217  ConPuts(StdOut, L"\n");
218 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:124
ULARGE_INTEGER StartSector
Definition: partlist.h:42
struct _Entry Entry
Definition: kefuncs.h:627
ULARGE_INTEGER SectorCount
Definition: partlist.h:43
#define IDS_LIST_PARTITION_LINE
Definition: resource.h:39
static PPARTENTRY CurrentPartition
Definition: usetup.c:76
PDISKENTRY CurrentDisk
Definition: partlist.c:73
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:250
#define IDS_LIST_PARTITION_FORMAT
Definition: resource.h:40
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
smooth NULL
Definition: ftsmooth.c:416
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
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
UCHAR PartitionType
Definition: partlist.h:46
ULONG BytesPerSector
Definition: partlist.h:88
uint64_t ULONGLONG
Definition: typedefs.h:66
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: list.c:18
static const WCHAR L[]
Definition: oid.c:1250
Definition: typedefs.h:118
#define IDS_LIST_PARTITION_NO_DISK
Definition: resource.h:41
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:125
#define IDS_LIST_PARTITION_HEAD
Definition: resource.h:38
#define StdOut
Definition: stream.h:76
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
base of all file and directory entries
Definition: entries.h:82

Referenced by list_main().

◆ ListVdisk()

static VOID ListVdisk ( VOID  )
static

Definition at line 229 of file list.c.

230 {
231  ConPuts(StdOut, L"List VDisk!!\n");
232 }
static const WCHAR L[]
Definition: oid.c:1250
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define StdOut
Definition: stream.h:76

Referenced by list_main().

◆ ListVolume()

static VOID ListVolume ( VOID  )
static

Definition at line 222 of file list.c.

223 {
225 }
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
#define IDS_LIST_VOLUME_HEAD
Definition: resource.h:42
#define StdOut
Definition: stream.h:76

Referenced by list_main().

◆ RoundingDivide()

static ULONGLONG RoundingDivide ( IN ULONGLONG  Dividend,
IN ULONGLONG  Divisor 
)
static

Definition at line 18 of file list.c.

21 {
22  return (Dividend + Divisor / 2) / Divisor;
23 }
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3046

Referenced by ListDisk(), and ListPartition().