Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. FTMan
  5. File Name:
  6. RootVol.cpp
  7. Abstract:
  8. Implementation of the CRootVolumesData class. The class who stores the properties of the "fake" root of the
  9. volumes tree
  10. Author:
  11. Cristian Teodorescu October 22, 1998
  12. Notes:
  13. Revision History:
  14. --*/
  15. #include "stdafx.h"
  16. #include "DiskMap.h"
  17. #include "Global.h"
  18. #include "LogVol.h"
  19. #include "Resource.h"
  20. #include "RootVol.h"
  21. extern "C"
  22. {
  23. #include <FTAPI.h>
  24. }
  25. #include <winioctl.h>
  26. #include <basetyps.h>
  27. #include <mountmgr.h>
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. ///////////////////////////////////////////////////////////////////////////////////////////////////
  34. // CRootVolumesData
  35. // Constructor
  36. CRootVolumesData::CRootVolumesData() : CItemData( IT_RootVolumes, NULL, FALSE )
  37. {
  38. }
  39. ////////////////////////////////////////////////////////////////////////////////////////////////////
  40. // Public methods
  41. BOOL CRootVolumesData::ReadItemInfo( CString& strErrors )
  42. {
  43. MY_TRY
  44. m_bValid = TRUE;
  45. strErrors = _T("");
  46. m_ulNumMembers = 1; // Just to notify the tree that this item has children
  47. m_iImage = ComputeImageIndex();
  48. return m_bValid;
  49. MY_CATCH_AND_THROW
  50. }
  51. BOOL CRootVolumesData::ReadMembers( CObArray& arrMembersData, CString& strErrors )
  52. {
  53. MY_TRY
  54. BOOL bReturn = TRUE;
  55. arrMembersData.RemoveAll();
  56. strErrors = _T("");
  57. // 1. Read all root logical volumes
  58. FT_LOGICAL_DISK_ID diskId[100];
  59. if( FtEnumerateLogicalDisks( 100,
  60. diskId,
  61. &m_ulNumMembers ) )
  62. {
  63. for( ULONG i = 0; i < m_ulNumMembers; i++ )
  64. {
  65. // Create the logical volume item data
  66. CLogicalVolumeData* pData = new CLogicalVolumeData( diskId[i], this, TRUE );
  67. // Read logical volume info and collect errors ( if any )
  68. CString strMemberErrors;
  69. pData->ReadItemInfo( strMemberErrors );
  70. strErrors += strMemberErrors;
  71. // Add the structure to the members' data array
  72. arrMembersData.Add(pData);
  73. }
  74. }
  75. else
  76. {
  77. AddError( strErrors, IDS_ERR_ENUMERATE_ROOT_VOLS, TRUE );
  78. bReturn = FALSE;
  79. m_ulNumMembers = 0;
  80. }
  81. // 2. Read all physical partitions not promoted as logical volumes
  82. CDiskMap diskMap;
  83. for( DWORD dwDiskNumber = 0; ; dwDiskNumber++ )
  84. {
  85. CObArray arrPartitions;
  86. CString strDiskMapErrors;
  87. BOOL bMissingDisk;
  88. diskMap.SetDiskNumber(dwDiskNumber);
  89. BOOL bResult = diskMap.ReadPartitions( arrPartitions, strDiskMapErrors, bMissingDisk, this );
  90. strErrors += strDiskMapErrors;
  91. if( !bResult )
  92. {
  93. if( bMissingDisk ) // It's over. There are no more disks in the system
  94. break;
  95. else // Continue with the following disk
  96. {
  97. bReturn = FALSE;
  98. continue;
  99. }
  100. }
  101. arrMembersData.Append(arrPartitions);
  102. m_ulNumMembers += (ULONG)arrPartitions.GetSize();
  103. }
  104. // 3. Read all mount paths for every member
  105. QueryMountList( arrMembersData );
  106. return bReturn;
  107. MY_CATCH_AND_THROW
  108. }
  109. int CRootVolumesData::ComputeImageIndex() const
  110. {
  111. return II_Root;
  112. }
  113. BOOL CRootVolumesData::operator==(CItemData& rData) const
  114. {
  115. return(rData.GetItemType() == IT_RootVolumes );
  116. }
  117. void CRootVolumesData::GetDisplayName( CString& strDisplay ) const
  118. {
  119. MY_TRY
  120. strDisplay.LoadString(IDS_ROOT_VOLUMES_DISPLAY_NAME);
  121. MY_CATCH_AND_THROW
  122. }
  123. ////////////////////////////////////////////////////////////////////////////////////////////////////
  124. // Protected methods
  125.