Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293/* * PROJECT: ReactOS DiskPart * LICENSE: GPL - See COPYING in the top level directory * FILE: base/system/diskpart/detail.c * PURPOSE: Manages all the partitions of the OS in an interactive way. * PROGRAMMERS: Lee Schroeder */
#include "diskpart.h"
#define NDEBUG#include <debug.h>
/* FUNCTIONS ******************************************************************/
staticBOOLIsDiskInVolume( _In_ PVOLENTRY VolumeEntry, _In_ PDISKENTRY DiskEntry){ ULONG i;
if ((VolumeEntry == NULL) || (VolumeEntry->pExtents == NULL) || (DiskEntry == NULL)) return FALSE;
for (i = 0; i < VolumeEntry->pExtents->NumberOfDiskExtents; i++) { if (VolumeEntry->pExtents->Extents[i].DiskNumber == DiskEntry->DiskNumber) return TRUE; }
return FALSE;}
staticBOOLIsPartitionInVolume( _In_ PVOLENTRY VolumeEntry, _In_ PPARTENTRY PartEntry){ ULONG i;
if ((VolumeEntry == NULL) || (VolumeEntry->pExtents == NULL) || (PartEntry == NULL) || (PartEntry->DiskEntry == NULL)) return FALSE;
for (i = 0; i < VolumeEntry->pExtents->NumberOfDiskExtents; i++) { if (VolumeEntry->pExtents->Extents[i].DiskNumber == PartEntry->DiskEntry->DiskNumber) { if ((VolumeEntry->pExtents->Extents[i].StartingOffset.QuadPart == PartEntry->StartSector.QuadPart * PartEntry->DiskEntry->BytesPerSector) && (VolumeEntry->pExtents->Extents[i].ExtentLength.QuadPart == PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector)) return TRUE; } }
return FALSE;}
EXIT_CODEDetailDisk( _In_ INT argc, _In_ PWSTR *argv){ PLIST_ENTRY Entry; PVOLENTRY VolumeEntry; BOOL bPrintHeader = TRUE; WCHAR szBuffer[40];
DPRINT("DetailDisk()\n");
if (argc > 2) { ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); return EXIT_SUCCESS; }
if (CurrentDisk == NULL) { ConResPuts(StdOut, IDS_SELECT_NO_DISK); return EXIT_SUCCESS; }
/* TODO: Print more disk details */ ConPuts(StdOut, L"\n"); ConResPrintf(StdOut, IDS_DETAIL_DISK_DESCRIPTION, CurrentDisk->Description); if (CurrentDisk->LayoutBuffer->PartitionStyle == PARTITION_STYLE_GPT) PrintGUID(szBuffer, &CurrentDisk->LayoutBuffer->Gpt.DiskId); else if (CurrentDisk->LayoutBuffer->PartitionStyle == PARTITION_STYLE_MBR) swprintf(szBuffer, L"%08lx", CurrentDisk->LayoutBuffer->Mbr.Signature); else wcscpy(szBuffer, L"00000000"); ConResPrintf(StdOut, IDS_DETAIL_DISK_ID, szBuffer); PrintBusType(szBuffer, ARRAYSIZE(szBuffer), CurrentDisk->BusType); ConResPrintf(StdOut, IDS_DETAIL_DISK_TYPE, szBuffer); LoadStringW(GetModuleHandle(NULL), IDS_STATUS_ONLINE, szBuffer, ARRAYSIZE(szBuffer)); ConResPrintf(StdOut, IDS_DETAIL_DISK_STATUS, szBuffer); ConResPrintf(StdOut, IDS_DETAIL_INFO_PATH, CurrentDisk->PathId); ConResPrintf(StdOut, IDS_DETAIL_INFO_TARGET, CurrentDisk->TargetId); ConResPrintf(StdOut, IDS_DETAIL_INFO_LUN_ID, CurrentDisk->Lun);
LoadStringW(GetModuleHandle(NULL), CurrentDisk->IsBoot ? IDS_STATUS_YES : IDS_STATUS_YES, szBuffer, ARRAYSIZE(szBuffer)); ConResPrintf(StdOut, IDS_DETAIL_INFO_BOOT_DSK, szBuffer);
Entry = VolumeListHead.Flink; while (Entry != &VolumeListHead) { VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
if (IsDiskInVolume(VolumeEntry, CurrentDisk)) { if (bPrintHeader) { ConPuts(StdOut, L"\n"); ConResPuts(StdOut, IDS_LIST_VOLUME_HEAD); ConResPuts(StdOut, IDS_LIST_VOLUME_LINE); bPrintHeader = FALSE; }
PrintVolume(VolumeEntry); }
Entry = Entry->Flink; }
ConPuts(StdOut, L"\n");
return EXIT_SUCCESS;}
EXIT_CODEDetailPartition( _In_ INT argc, _In_ PWSTR *argv){ PPARTENTRY PartEntry; ULONGLONG PartOffset; PLIST_ENTRY Entry; PVOLENTRY VolumeEntry; BOOL bVolumeFound = FALSE, bPrintHeader = TRUE; WCHAR szBuffer[40];
DPRINT("DetailPartition()\n");
if (argc > 2) { ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); return EXIT_SUCCESS; }
if (CurrentDisk == NULL) { ConResPuts(StdOut, IDS_SELECT_PARTITION_NO_DISK); return EXIT_SUCCESS; }
if (CurrentPartition == NULL) { ConResPuts(StdOut, IDS_SELECT_NO_PARTITION); return EXIT_SUCCESS; }
PartEntry = CurrentPartition; PartOffset = PartEntry->StartSector.QuadPart * CurrentDisk->BytesPerSector;
/* TODO: Print more partition details */ ConPuts(StdOut, L"\n"); ConResPrintf(StdOut, IDS_DETAIL_PARTITION_NUMBER, PartEntry->PartitionNumber); if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT) { PrintGUID(szBuffer, &PartEntry->Gpt.PartitionType); ConResPrintf(StdOut, IDS_DETAIL_PARTITION_TYPE, szBuffer); LoadStringW(GetModuleHandle(NULL), (PartEntry->Gpt.Attributes & GPT_BASIC_DATA_ATTRIBUTE_HIDDEN) ? IDS_STATUS_YES : IDS_STATUS_NO, szBuffer, ARRAYSIZE(szBuffer)); ConResPrintf(StdOut, IDS_DETAIL_PARTITION_HIDDEN, szBuffer); LoadStringW(GetModuleHandle(NULL), (PartEntry->Gpt.Attributes & GPT_ATTRIBUTE_PLATFORM_REQUIRED) ? IDS_STATUS_YES : IDS_STATUS_NO, szBuffer, ARRAYSIZE(szBuffer)); ConResPrintf(StdOut, IDS_DETAIL_PARTITION_REQUIRED, szBuffer); ConResPrintf(StdOut, IDS_DETAIL_PARTITION_ATTRIBUTE, PartEntry->Gpt.Attributes); } else if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR) { swprintf(szBuffer, L"%02x", PartEntry->Mbr.PartitionType); ConResPrintf(StdOut, IDS_DETAIL_PARTITION_TYPE, szBuffer); ConResPrintf(StdOut, IDS_DETAIL_PARTITION_HIDDEN, ""); LoadStringW(GetModuleHandle(NULL), PartEntry->Mbr.BootIndicator ? IDS_STATUS_YES : IDS_STATUS_NO, szBuffer, ARRAYSIZE(szBuffer)); ConResPrintf(StdOut, IDS_DETAIL_PARTITION_ACTIVE, szBuffer); } ConResPrintf(StdOut, IDS_DETAIL_PARTITION_OFFSET, PartOffset);
Entry = VolumeListHead.Flink; while (Entry != &VolumeListHead) { VolumeEntry = CONTAINING_RECORD(Entry, VOLENTRY, ListEntry);
if (IsPartitionInVolume(VolumeEntry, CurrentPartition)) { if (bPrintHeader) { ConPuts(StdOut, L"\n"); ConResPuts(StdOut, IDS_LIST_VOLUME_HEAD); ConResPuts(StdOut, IDS_LIST_VOLUME_LINE); bPrintHeader = FALSE; }
PrintVolume(VolumeEntry); bVolumeFound = TRUE; }
Entry = Entry->Flink; }
if (bVolumeFound == FALSE) ConResPuts(StdOut, IDS_DETAIL_NO_VOLUME);
ConPuts(StdOut, L"\n");
return EXIT_SUCCESS;}
EXIT_CODEDetailVolume( _In_ INT argc, _In_ PWSTR *argv){ PDISKENTRY DiskEntry; PLIST_ENTRY Entry; BOOL bDiskFound = FALSE, bPrintHeader = TRUE;
DPRINT("DetailVolume()\n");
if (argc > 2) { ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS); return EXIT_SUCCESS; }
if (CurrentVolume == NULL) { ConResPuts(StdOut, IDS_SELECT_NO_VOLUME); return EXIT_SUCCESS; }
Entry = DiskListHead.Flink; while (Entry != &DiskListHead) { DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
if (IsDiskInVolume(CurrentVolume, DiskEntry)) { if (bPrintHeader) { ConPuts(StdOut, L"\n"); ConResPuts(StdOut, IDS_LIST_DISK_HEAD); ConResPuts(StdOut, IDS_LIST_DISK_LINE); bPrintHeader = FALSE; }
PrintDisk(DiskEntry); bDiskFound = TRUE; }
Entry = Entry->Flink; }
if (bDiskFound == FALSE) ConResPuts(StdOut, IDS_DETAIL_NO_DISKS);
/* TODO: Print more volume details */
ConPuts(StdOut, L"\n");
return EXIT_SUCCESS;}