2 * PROJECT: ReactOS DiskPart
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/diskpart/list.c
5 * PURPOSE: Manages all the partitions of the OS in an interactive way.
6 * PROGRAMMERS: Lee Schroeder
14 /* FUNCTIONS ******************************************************************/
19 IN ULONGLONG Dividend
,
22 return (Dividend
+ Divisor
/ 2) / Divisor
;
38 ConResPuts(StdOut
, IDS_LIST_DISK_HEAD
);
39 ConResPuts(StdOut
, IDS_LIST_DISK_LINE
);
41 Entry
= DiskListHead
.Flink
;
42 while (Entry
!= &DiskListHead
)
44 DiskEntry
= CONTAINING_RECORD(Entry
, DISKENTRY
, ListEntry
);
46 DiskSize
= DiskEntry
->SectorCount
.QuadPart
*
47 (ULONGLONG
)DiskEntry
->BytesPerSector
;
49 if (DiskSize
>= 10737418240) /* 10 GB */
51 DiskSize
= RoundingDivide(DiskSize
, 1073741824);
56 DiskSize
= RoundingDivide(DiskSize
, 1048576);
66 ConResPrintf(StdOut
, IDS_LIST_DISK_FORMAT
,
67 (CurrentDisk
== DiskEntry
) ? L
'*': ' ',
68 DiskEntry
->DiskNumber
,
80 ConPuts(StdOut
, L
"\n\n");
95 if (CurrentDisk
== NULL
)
97 ConResPuts(StdOut
, IDS_LIST_PARTITION_NO_DISK
);
102 ConResPuts(StdOut
, IDS_LIST_PARTITION_HEAD
);
103 ConResPuts(StdOut
, IDS_LIST_PARTITION_LINE
);
105 Entry
= CurrentDisk
->PrimaryPartListHead
.Flink
;
106 while (Entry
!= &CurrentDisk
->PrimaryPartListHead
)
108 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
110 if (PartEntry
->PartitionType
!= 0)
112 PartSize
= PartEntry
->SectorCount
.QuadPart
* CurrentDisk
->BytesPerSector
;
114 if (PartSize
>= 10737418240) /* 10 GB */
116 PartSize
= RoundingDivide(PartSize
, 1073741824);
119 else if (PartSize
>= 10485760) /* 10 MB */
121 PartSize
= RoundingDivide(PartSize
, 1048576);
126 PartSize
= RoundingDivide(PartSize
, 1024);
130 PartOffset
= PartEntry
->StartSector
.QuadPart
* CurrentDisk
->BytesPerSector
;
132 if (PartOffset
>= 10737418240) /* 10 GB */
134 PartOffset
= RoundingDivide(PartOffset
, 1073741824);
135 lpOffsetUnit
= L
"GB";
137 else if (PartOffset
>= 10485760) /* 10 MB */
139 PartOffset
= RoundingDivide(PartOffset
, 1048576);
140 lpOffsetUnit
= L
"MB";
144 PartOffset
= RoundingDivide(PartOffset
, 1024);
145 lpOffsetUnit
= L
"KB";
148 ConResPrintf(StdOut
, IDS_LIST_PARTITION_FORMAT
,
149 (CurrentPartition
== PartEntry
) ? L
'*': ' ',
151 IsContainerPartition(PartEntry
->PartitionType
) ? L
"Extended" : L
"Primary",
158 Entry
= Entry
->Flink
;
161 Entry
= CurrentDisk
->LogicalPartListHead
.Flink
;
162 while (Entry
!= &CurrentDisk
->LogicalPartListHead
)
164 PartEntry
= CONTAINING_RECORD(Entry
, PARTENTRY
, ListEntry
);
166 if (PartEntry
->PartitionType
!= 0)
168 PartSize
= PartEntry
->SectorCount
.QuadPart
* CurrentDisk
->BytesPerSector
;
170 if (PartSize
>= 10737418240) /* 10 GB */
172 PartSize
= RoundingDivide(PartSize
, 1073741824);
175 else if (PartSize
>= 10485760) /* 10 MB */
177 PartSize
= RoundingDivide(PartSize
, 1048576);
182 PartSize
= RoundingDivide(PartSize
, 1024);
186 PartOffset
= PartEntry
->StartSector
.QuadPart
* CurrentDisk
->BytesPerSector
;
188 if (PartOffset
>= 10737418240) /* 10 GB */
190 PartOffset
= RoundingDivide(PartOffset
, 1073741824);
191 lpOffsetUnit
= L
"GB";
193 else if (PartOffset
>= 10485760) /* 10 MB */
195 PartOffset
= RoundingDivide(PartOffset
, 1048576);
196 lpOffsetUnit
= L
"MB";
200 PartOffset
= RoundingDivide(PartOffset
, 1024);
201 lpOffsetUnit
= L
"KB";
204 ConResPrintf(StdOut
, IDS_LIST_PARTITION_FORMAT
,
205 (CurrentPartition
== PartEntry
) ? L
'*': ' ',
214 Entry
= Entry
->Flink
;
217 ConPuts(StdOut
, L
"\n");
224 ConResPuts(StdOut
, IDS_LIST_VOLUME_HEAD
);
231 ConPuts(StdOut
, L
"List VDisk!!\n");
239 /* gets the first word from the string */
242 ConResPuts(StdOut
, IDS_HELP_CMD_LIST
);
246 /* determines which to list (disk, partition, etc.) */
247 if (!wcsicmp(argv
[1], L
"disk"))
249 else if (!wcsicmp(argv
[1], L
"partition"))
251 else if (!wcsicmp(argv
[1], L
"volume"))
253 else if (!wcsicmp(argv
[1], L
"vdisk"))
256 ConResPuts(StdOut
, IDS_HELP_CMD_LIST
);