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.

1448 lines
32 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CResourcePhysicalDisk.cpp
  7. //
  8. // Description:
  9. // CResourcePhysicalDisk implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-AUG-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. //////////////////////////////////////////////////////////////////////////////
  16. // Include Files
  17. //////////////////////////////////////////////////////////////////////////////
  18. #include "pch.h"
  19. #include "CResourcePhysicalDisk.h"
  20. #include "CResourcePhysicalDiskPartition.h"
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Constant Definitions
  23. //////////////////////////////////////////////////////////////////////////////
  24. DEFINE_THISCLASS("CResourcePhysicalDisk")
  25. //////////////////////////////////////////////////////////////////////////////
  26. //++
  27. //
  28. // CResourcePhysicalDiskPartition::S_HrCreateInstance()
  29. //
  30. // Description:
  31. // Create a CResourcePhysicalDisk instance.
  32. //
  33. // Arguments:
  34. // ppunkOut
  35. //
  36. // Return Values:
  37. // S_OK
  38. // Success.
  39. //
  40. // E_POINTER
  41. // A passed in argument is NULL.
  42. //
  43. // E_OUTOFMEMORY
  44. // Out of memory.
  45. //
  46. // Other HRESULT error.
  47. //
  48. //--
  49. //////////////////////////////////////////////////////////////////////////////
  50. HRESULT
  51. CResourcePhysicalDisk::S_HrCreateInstance(
  52. IUnknown ** ppunkOut,
  53. IUnknown * punkOuterIn,
  54. HCLUSTER * phClusterIn,
  55. CLSID * pclsidMajorIn,
  56. LPCWSTR pcszNameIn
  57. )
  58. {
  59. TraceFunc( "" );
  60. HRESULT hr;
  61. CResourcePhysicalDisk * pcc = NULL;
  62. Assert( ppunkOut != NULL );
  63. if ( ppunkOut == NULL )
  64. goto InvalidArg;
  65. pcc = new CResourcePhysicalDisk;
  66. if ( pcc == NULL )
  67. {
  68. hr = THR( E_OUTOFMEMORY );
  69. goto Cleanup;
  70. } // if:
  71. hr = STHR( pcc->HrInit( punkOuterIn, phClusterIn, pclsidMajorIn, pcszNameIn ) );
  72. if ( FAILED( hr ) )
  73. goto Cleanup;
  74. if ( hr == S_FALSE )
  75. {
  76. *ppunkOut = NULL;
  77. goto Cleanup;
  78. }
  79. hr = THR( pcc->TypeSafeQI( IUnknown, ppunkOut ) );
  80. Cleanup:
  81. if ( pcc != NULL )
  82. {
  83. pcc->Release( );
  84. } // if:
  85. HRETURN( hr );
  86. InvalidArg:
  87. hr = THR( E_INVALIDARG );
  88. goto Cleanup;
  89. } //*** CResourcePhysicalDisk::S_HrCreateInitializedInstance()
  90. //////////////////////////////////////////////////////////////////////////////
  91. //++
  92. //
  93. // CResourcePhysicalDisk::CResourcePhysicalDisk()
  94. //
  95. // Description:
  96. // Constructor of the CResourcePhysicalDisk class. This initializes
  97. // the m_cRef variable to 1 instead of 0 to account of possible
  98. // QueryInterface failure in DllGetClassObject.
  99. //
  100. // Arguments:
  101. // None.
  102. //
  103. // Return Value:
  104. // None.
  105. //
  106. // Remarks:
  107. // None.
  108. //
  109. //--
  110. //////////////////////////////////////////////////////////////////////////////
  111. CResourcePhysicalDisk::CResourcePhysicalDisk( void )
  112. : m_cRef( 1 )
  113. {
  114. TraceFunc( "" );
  115. InterlockedIncrement( &g_cObjects );
  116. Assert( m_cRef == 1 );
  117. Assert( m_punkOuter == NULL );
  118. Assert( m_pcccb == NULL );
  119. Assert( m_phCluster == NULL );
  120. Assert( m_pclsidMajor == NULL );
  121. // Assert( m_cplResource );
  122. // Assert( m_cplResourceRO );
  123. // Assert( m_cpvlDiskInfo );
  124. Assert( m_dwFlags == 0 );
  125. Assert( m_cParitions == 0 );
  126. Assert( m_ppPartitions == NULL );
  127. Assert( m_ulCurrent == 0 );
  128. TraceFuncExit();
  129. } //*** CResourcePhysicalDisk::CResourcePhysicalDisk()
  130. //////////////////////////////////////////////////////////////////////////////
  131. //++
  132. //
  133. // CResourcePhysicalDisk::CResourcePhysicalDisk()
  134. //
  135. // Description:
  136. // Destructor of the CResourcePhysicalDisk class.
  137. //
  138. // Arguments:
  139. // None.
  140. //
  141. // Return Value:
  142. // None.
  143. //
  144. // Remarks:
  145. // None.
  146. //
  147. //--
  148. //////////////////////////////////////////////////////////////////////////////
  149. CResourcePhysicalDisk::~CResourcePhysicalDisk( void )
  150. {
  151. TraceFunc( "" );
  152. // m_cRef - noop
  153. if ( m_punkOuter != NULL )
  154. {
  155. m_punkOuter->Release( );
  156. }
  157. if ( m_pcccb != NULL )
  158. {
  159. m_pcccb->Release();
  160. } // if:
  161. // m_phCluster - DO NOT CLOSE!
  162. // m_pclsidMajor - noop
  163. // m_cplResource - has its own dtor
  164. // m_cplResourceRO - has its own dtor
  165. // m_cpvlDiskInfo - has its own dtor
  166. // m_dwFlags - noop
  167. if ( m_ppPartitions != NULL )
  168. {
  169. while( m_cParitions != 0 )
  170. {
  171. m_cParitions --;
  172. if ( m_ppPartitions[ m_cParitions ] != NULL )
  173. {
  174. m_ppPartitions[ m_cParitions ]->Release( );
  175. }
  176. }
  177. TraceFree( m_ppPartitions );
  178. }
  179. // m_ulCurrent
  180. InterlockedDecrement( &g_cObjects );
  181. TraceFuncExit();
  182. } //*** CResourcePhysicalDisk::~CResourcePhysicalDisk()
  183. //////////////////////////////////////////////////////////////////////////////
  184. //++
  185. //
  186. // CResourcePhysicalDisk::HrInit()
  187. //
  188. // Description:
  189. //
  190. // Arguments:
  191. //
  192. // Return Value:
  193. //
  194. // Remarks:
  195. // None.
  196. //
  197. //--
  198. //////////////////////////////////////////////////////////////////////////////
  199. HRESULT
  200. CResourcePhysicalDisk::HrInit(
  201. IUnknown * punkOuterIn,
  202. HCLUSTER * phClusterIn,
  203. CLSID * pclsidMajorIn,
  204. LPCWSTR pcszNameIn
  205. )
  206. {
  207. TraceFunc( "" );
  208. HRESULT hr;
  209. DWORD sc;
  210. DWORD cb;
  211. ULONG cPartition;
  212. HRESOURCE hResource = NULL;
  213. IUnknown * punk = NULL;
  214. //
  215. // Gather information from the input parameters.
  216. //
  217. if ( punkOuterIn != NULL )
  218. {
  219. m_punkOuter = punkOuterIn;
  220. m_punkOuter->AddRef( );
  221. }
  222. if ( phClusterIn == NULL )
  223. goto InvalidArg;
  224. m_phCluster = phClusterIn;
  225. if ( pclsidMajorIn != NULL )
  226. {
  227. m_pclsidMajor = pclsidMajorIn;
  228. }
  229. else
  230. {
  231. m_pclsidMajor = (CLSID *) &TASKID_Major_Client_And_Server_Log;
  232. }
  233. if ( pcszNameIn == NULL )
  234. goto InvalidArg;
  235. //
  236. // See if we can callback.
  237. //
  238. hr = THR( m_punkOuter->TypeSafeQI( IClusCfgCallback, &m_pcccb ) );
  239. if ( FAILED( hr ) )
  240. goto Cleanup;
  241. //
  242. // Retrieve the properties.
  243. //
  244. hResource = OpenClusterResource( *m_phCluster, pcszNameIn );
  245. if ( hResource == NULL )
  246. {
  247. hr = HRESULT_FROM_WIN32( TW32( GetLastError( ) ) );
  248. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_OpenClusterResource_Failed, hr );
  249. goto Cleanup;
  250. }
  251. sc = TW32( m_cplResource.ScGetResourceProperties( hResource, CLUSCTL_RESOURCE_GET_COMMON_PROPERTIES ) );
  252. if ( sc != ERROR_SUCCESS )
  253. {
  254. hr = HRESULT_FROM_WIN32( sc );
  255. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ScGetResourceProperties_Failed, hr );
  256. goto Cleanup;
  257. }
  258. //
  259. // We only handle Physical Disk resources.
  260. //
  261. sc = TW32( m_cplResource.ScMoveToPropertyByName( L"Type" ) );
  262. if ( sc != ERROR_SUCCESS )
  263. {
  264. hr = HRESULT_FROM_WIN32( sc );
  265. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ScMoveToPropertyByName_Failed, hr );
  266. goto Cleanup;
  267. }
  268. Assert( m_cplResource.CbhCurrentValue( ).pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  269. if ( _wcsicmp( m_cplResource.CbhCurrentValue( ).pStringValue->sz, L"Physical Disk" ) != 0 )
  270. {
  271. //
  272. // The resource isn't a physical disk.
  273. //
  274. hr = S_FALSE;
  275. goto Cleanup;
  276. }
  277. sc = TW32( m_cplResourceRO.ScGetResourceProperties( hResource, CLUSCTL_RESOURCE_GET_RO_COMMON_PROPERTIES ) );
  278. if ( sc != ERROR_SUCCESS )
  279. {
  280. hr = HRESULT_FROM_WIN32( sc );
  281. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ScGetResourceProperties_Failed, hr );
  282. goto Cleanup;
  283. }
  284. sc = TW32( m_cpvlDiskInfo.ScGetResourceValueList( hResource, CLUSCTL_RESOURCE_STORAGE_GET_DISK_INFO ) );
  285. if ( sc != ERROR_SUCCESS )
  286. {
  287. hr = HRESULT_FROM_WIN32( sc );
  288. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ScGetResourceValueList_Failed, hr );
  289. goto Cleanup;
  290. }
  291. sc = TW32( ClusterResourceControl( hResource, NULL, CLUSCTL_RESOURCE_GET_FLAGS, NULL, NULL, &m_dwFlags, sizeof(m_dwFlags), &cb ) );
  292. if ( sc != ERROR_SUCCESS )
  293. {
  294. hr = HRESULT_FROM_WIN32( sc );
  295. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ClusterResourceControl_Failed, hr );
  296. goto Cleanup;
  297. }
  298. Assert( cb == sizeof(m_dwFlags) );
  299. //
  300. // Figure out how many partitions there are.
  301. //
  302. m_cParitions = 0;
  303. sc = TW32( m_cpvlDiskInfo.ScMoveToFirstValue() );
  304. if ( sc != ERROR_SUCCESS )
  305. {
  306. hr = HRESULT_FROM_WIN32( sc );
  307. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_HrInit_ScMoveToFirstValue_Failed, hr );
  308. goto Cleanup;
  309. } // if:
  310. do
  311. {
  312. if ( m_cpvlDiskInfo.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_PARTITION_INFO )
  313. {
  314. m_cParitions ++;
  315. }
  316. // Move to the next item.
  317. sc = m_cpvlDiskInfo.ScCheckIfAtLastValue();
  318. if ( sc == ERROR_NO_MORE_ITEMS )
  319. {
  320. break;
  321. } // if:
  322. sc = TW32( m_cpvlDiskInfo.ScMoveToNextValue() );
  323. if ( sc != ERROR_SUCCESS )
  324. {
  325. hr = HRESULT_FROM_WIN32( sc );
  326. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_HrInit_ScMoveToNextValue_Failed, hr );
  327. goto Cleanup;
  328. }
  329. } while( sc == ERROR_SUCCESS );
  330. //
  331. // Allocate the array to store pointers to the partition objects.
  332. //
  333. m_ppPartitions = (IClusCfgPartitionInfo **) TraceAlloc( 0, m_cParitions * sizeof(IClusCfgPartitionInfo *) );
  334. if ( m_ppPartitions == NULL )
  335. goto OutOfMemory;
  336. //
  337. // Now loop again creating partition objects.
  338. //
  339. cPartition = 0;
  340. sc = TW32( m_cpvlDiskInfo.ScMoveToFirstValue() );
  341. if ( sc != ERROR_SUCCESS )
  342. {
  343. hr = HRESULT_FROM_WIN32( sc );
  344. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_HrInit_ScMoveToFirstValue_Failed, hr );
  345. goto Cleanup;
  346. } // if:
  347. do
  348. {
  349. if ( m_cpvlDiskInfo.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_PARTITION_INFO )
  350. {
  351. // Create the object
  352. hr = THR( CResourcePhysicalDiskPartition::S_HrCreateInstance( &punk ) );
  353. if ( FAILED( hr ) )
  354. {
  355. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_HrInit_Create_CResourcePhysicalDiskPartition_Failed, hr );
  356. goto Cleanup;
  357. }
  358. hr = THR( punk->TypeSafeQI( IClusCfgPartitionInfo, &m_ppPartitions[ cPartition ] ) );
  359. if ( FAILED( hr ) )
  360. {
  361. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_HrInit_QI_Failed, hr );
  362. goto Cleanup;
  363. }
  364. punk->Release( );
  365. punk = NULL;
  366. cPartition ++;
  367. }
  368. // Move to the next item.
  369. sc = m_cpvlDiskInfo.ScCheckIfAtLastValue();
  370. if ( sc == ERROR_NO_MORE_ITEMS )
  371. {
  372. break;
  373. } // if:
  374. sc = TW32( m_cpvlDiskInfo.ScMoveToNextValue() );
  375. if ( sc != ERROR_SUCCESS )
  376. {
  377. hr = HRESULT_FROM_WIN32( sc );
  378. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_HrInit_ScMoveToNextValue2_Failed, hr );
  379. goto Cleanup;
  380. }
  381. } while( sc == ERROR_SUCCESS && cPartition < m_cParitions );
  382. hr = S_OK;
  383. Cleanup:
  384. if ( hResource != NULL )
  385. {
  386. BOOL bRet;
  387. bRet = CloseClusterResource( hResource );
  388. Assert( bRet );
  389. }
  390. if ( punk != NULL )
  391. {
  392. punk->Release( );
  393. }
  394. HRETURN( hr );
  395. InvalidArg:
  396. hr = THR( E_INVALIDARG );
  397. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_PhysDisk_HrInit_InvalidArg, hr );
  398. goto Cleanup;
  399. OutOfMemory:
  400. hr = E_OUTOFMEMORY;
  401. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_OutOfMemory, hr );
  402. goto Cleanup;
  403. } //*** CResourcePhysicalDisk::HrInit()
  404. //*************************************************************************//
  405. /////////////////////////////////////////////////////////////////////////////
  406. // CResourcePhysicalDisk -- IUknkown interface.
  407. /////////////////////////////////////////////////////////////////////////////
  408. //////////////////////////////////////////////////////////////////////////////
  409. //++
  410. //
  411. // CResourcePhysicalDisk:: [INKNOWN] QueryInterface()
  412. //
  413. // Description:
  414. // Query this object for the passed in interface.
  415. //
  416. // Arguments:
  417. // IN REFIID riid,
  418. // Id of interface requested.
  419. //
  420. // OUT void ** ppv
  421. // Pointer to the requested interface.
  422. //
  423. // Return Value:
  424. // S_OK
  425. // If the interface is available on this object.
  426. //
  427. // E_NOINTERFACE
  428. // If the interface is not available.
  429. //
  430. // Remarks:
  431. // None.
  432. //
  433. //--
  434. //////////////////////////////////////////////////////////////////////////////
  435. STDMETHODIMP
  436. CResourcePhysicalDisk::QueryInterface(
  437. REFIID riid,
  438. LPVOID *ppv
  439. )
  440. {
  441. TraceQIFunc( riid, ppv );
  442. HRESULT hr = E_NOINTERFACE;
  443. if ( IsEqualIID( riid, IID_IUnknown ) )
  444. {
  445. *ppv = static_cast< IClusCfgManagedResourceInfo * >( this );
  446. hr = S_OK;
  447. } // if: IUnknown
  448. else if ( IsEqualIID( riid, IID_IClusCfgManagedResourceInfo ) )
  449. {
  450. *ppv = TraceInterface( __THISCLASS__, IClusCfgManagedResourceInfo, this, 0 );
  451. hr = S_OK;
  452. }
  453. else if ( IsEqualIID( riid, IID_IEnumClusCfgPartitions ) )
  454. {
  455. *ppv = TraceInterface( __THISCLASS__, IEnumClusCfgPartitions, this, 0 );
  456. hr = S_OK;
  457. }
  458. if ( SUCCEEDED( hr ) )
  459. {
  460. ((IUnknown*) *ppv)->AddRef( );
  461. } // if: success
  462. QIRETURN_IGNORESTDMARSHALLING( hr, riid );
  463. } //*** CConfigClusApi::QueryInterface( )
  464. //////////////////////////////////////////////////////////////////////////////
  465. //++
  466. //
  467. // STDMETHODIMP_( ULONG )
  468. // CResourcePhysicalDisk:: [IUNKNOWN] AddRef()
  469. //
  470. // Description:
  471. // Increment the reference count of this object by one.
  472. //
  473. // Arguments:
  474. // None.
  475. //
  476. // Return Value:
  477. // The new reference count.
  478. //
  479. // Remarks:
  480. // None.
  481. //
  482. //--
  483. //////////////////////////////////////////////////////////////////////////////
  484. STDMETHODIMP_(ULONG)
  485. CResourcePhysicalDisk::AddRef( void )
  486. {
  487. TraceFunc( "[IUnknown]" );
  488. InterlockedIncrement( &m_cRef );
  489. RETURN( m_cRef );
  490. } //*** CResourcePhysicalDisk::AddRef()
  491. //////////////////////////////////////////////////////////////////////////////
  492. //++
  493. //
  494. // STDMETHODIMP_( ULONG )
  495. // CResourcePhysicalDisk:: [IUNKNOWN] Release()
  496. //
  497. // Description:
  498. // Decrement the reference count of this object by one.
  499. //
  500. // Arguments:
  501. // None.
  502. //
  503. // Return Value:
  504. // The new reference count.
  505. //
  506. // Remarks:
  507. // None.
  508. //
  509. //--
  510. //////////////////////////////////////////////////////////////////////////////
  511. STDMETHODIMP_(ULONG)
  512. CResourcePhysicalDisk::Release( void )
  513. {
  514. TraceFunc( "[IUnknown]" );
  515. InterlockedDecrement( &m_cRef );
  516. if ( m_cRef )
  517. RETURN( m_cRef );
  518. TraceDo( delete this );
  519. RETURN( 0 );
  520. } //*** CResourcePhysicalDisk::Release()
  521. //*************************************************************************//
  522. /////////////////////////////////////////////////////////////////////////////
  523. // CResourcePhysicalDisk -- IClusCfgManagedResourceInfo interface.
  524. /////////////////////////////////////////////////////////////////////////////
  525. //////////////////////////////////////////////////////////////////////////////
  526. //++
  527. //
  528. // CResourcePhysicalDisk::GetName()
  529. //
  530. // Description:
  531. //
  532. // Arguments:
  533. //
  534. // Return Value:
  535. //
  536. // Remarks:
  537. // None.
  538. //
  539. //--
  540. //////////////////////////////////////////////////////////////////////////////
  541. STDMETHODIMP
  542. CResourcePhysicalDisk::GetName(
  543. BSTR * pbstrNameOut
  544. )
  545. {
  546. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  547. HRESULT hr;
  548. DWORD sc;
  549. if ( pbstrNameOut == NULL )
  550. goto InvalidPointer;
  551. //
  552. // "Major Version"
  553. //
  554. sc = TW32( m_cplResourceRO.ScMoveToPropertyByName( L"Name" ) );
  555. if ( sc != ERROR_SUCCESS )
  556. {
  557. hr = HRESULT_FROM_WIN32( sc );
  558. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetName_ScMoveToPropertyByName_MajorVersion_Failed, hr );
  559. goto Cleanup;
  560. } // if:
  561. Assert( m_cplResourceRO.CbhCurrentValue( ).pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  562. *pbstrNameOut = SysAllocString( m_cplResourceRO.CbhCurrentValue( ).pStringValue->sz );
  563. if ( *pbstrNameOut == NULL )
  564. goto OutOfMemory;
  565. hr = S_OK;
  566. Cleanup:
  567. HRETURN( hr );
  568. InvalidPointer:
  569. hr = THR( E_INVALIDARG );
  570. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetName_InvalidPointer, hr );
  571. goto Cleanup;
  572. OutOfMemory:
  573. hr = E_OUTOFMEMORY;
  574. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetName_OutOfMemory, hr );
  575. goto Cleanup;
  576. } //*** CResourcePhysicalDisk::GetName()
  577. //////////////////////////////////////////////////////////////////////////////
  578. //++
  579. //
  580. // CResourcePhysicalDisk::GetUID()
  581. //
  582. // Description:
  583. //
  584. // Arguments:
  585. //
  586. // Return Value:
  587. //
  588. // Remarks:
  589. // None.
  590. //
  591. //--
  592. //////////////////////////////////////////////////////////////////////////////
  593. STDMETHODIMP
  594. CResourcePhysicalDisk::GetUID(
  595. BSTR * pbstrUIDOut
  596. )
  597. {
  598. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  599. HRESULT hr;
  600. DWORD sc;
  601. UCHAR TargetId;
  602. UCHAR Lun;
  603. WCHAR sz[ 32 ];
  604. if ( pbstrUIDOut == NULL )
  605. goto InvalidPointer;
  606. // loop through all the properties.
  607. sc = TW32( m_cpvlDiskInfo.ScMoveToFirstValue() );
  608. if ( sc != ERROR_SUCCESS )
  609. {
  610. hr = HRESULT_FROM_WIN32( sc );
  611. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_ScMoveToFirstValue_Failed, hr );
  612. goto Cleanup;
  613. } // if:
  614. do
  615. {
  616. if ( m_cpvlDiskInfo.CbhCurrentValue().pSyntax->dw == CLUSPROP_SYNTAX_SCSI_ADDRESS )
  617. break; // found it!
  618. // Move to the next item.
  619. sc = m_cpvlDiskInfo.ScCheckIfAtLastValue();
  620. if ( sc == ERROR_NO_MORE_ITEMS )
  621. {
  622. break;
  623. } // if:
  624. sc = TW32( m_cpvlDiskInfo.ScMoveToNextValue() );
  625. if ( sc != ERROR_SUCCESS )
  626. {
  627. hr = HRESULT_FROM_WIN32( sc );
  628. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_ScMoveToNextValue_Failed, hr );
  629. goto Cleanup;
  630. }
  631. } while( sc == ERROR_SUCCESS );
  632. TargetId = m_cpvlDiskInfo.CbhCurrentValue().pScsiAddressValue->TargetId;
  633. Lun = m_cpvlDiskInfo.CbhCurrentValue().pScsiAddressValue->Lun;
  634. // Print the UID identical to the others.
  635. _snwprintf( sz, ARRAYSIZE( sz ), L"SCSI Tid %ld, SCSI Lun %ld", TargetId, Lun );
  636. *pbstrUIDOut = TraceSysAllocString( sz );
  637. if ( *pbstrUIDOut == NULL )
  638. goto OutOfMemory;
  639. hr = S_OK;
  640. Cleanup:
  641. HRETURN( hr );
  642. InvalidPointer:
  643. hr = THR( E_POINTER );
  644. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_InvalidPointer, hr );
  645. goto Cleanup;
  646. OutOfMemory:
  647. hr = E_OUTOFMEMORY;
  648. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetUID_OutOfMemory, hr );
  649. goto Cleanup;
  650. } //*** CResourcePhysicalDisk::GetUID()
  651. //////////////////////////////////////////////////////////////////////////////
  652. //++
  653. //
  654. // CResourcePhysicalDisk::IsManaged()
  655. //
  656. // Description:
  657. //
  658. // Arguments:
  659. //
  660. // Return Value:
  661. // S_OK
  662. // Is managed.
  663. //
  664. // S_FALSE
  665. // Is not managed.
  666. //
  667. // Remarks:
  668. // None.
  669. //
  670. //--
  671. //////////////////////////////////////////////////////////////////////////////
  672. STDMETHODIMP
  673. CResourcePhysicalDisk::IsManaged( void )
  674. {
  675. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  676. HRESULT hr = S_OK;
  677. HRETURN( hr );
  678. } //*** CResourcePhysicalDisk::IsManaged()
  679. //////////////////////////////////////////////////////////////////////////////
  680. //++
  681. //
  682. // CResourcePhysicalDisk::IsQuorumDevice()
  683. //
  684. // Description:
  685. //
  686. // Arguments:
  687. //
  688. // Return Value:
  689. // S_OK
  690. // Is quorum device.
  691. //
  692. // S_FALSE
  693. // Is not quorum device.
  694. //
  695. // Remarks:
  696. // None.
  697. //
  698. //--
  699. //////////////////////////////////////////////////////////////////////////////
  700. STDMETHODIMP
  701. CResourcePhysicalDisk::IsQuorumDevice( void )
  702. {
  703. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  704. HRESULT hr;
  705. if ( m_dwFlags & CLUS_FLAG_CORE )
  706. {
  707. hr = S_OK;
  708. } // if:
  709. else
  710. {
  711. hr = S_FALSE;
  712. } // else:
  713. HRETURN( hr );
  714. } //*** CResourcePhysicalDisk::IsQuorumDevice()
  715. //////////////////////////////////////////////////////////////////////////////
  716. //++
  717. //
  718. // CResourcePhysicalDisk::IsQuorumCapable()
  719. //
  720. // Description:
  721. //
  722. // Arguments:
  723. //
  724. // Return Value:
  725. // S_OK
  726. // Is quorum capable device.
  727. //
  728. // S_FALSE
  729. // Is not quorum capable device.
  730. //
  731. // Remarks:
  732. // None.
  733. //
  734. //--
  735. //////////////////////////////////////////////////////////////////////////////
  736. STDMETHODIMP
  737. CResourcePhysicalDisk::IsQuorumCapable( void )
  738. {
  739. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  740. HRESULT hr = S_OK;
  741. HRETURN( hr );
  742. } //*** CResourcePhysicalDisk::IsQuorumCapable()
  743. //////////////////////////////////////////////////////////////////////////////
  744. //++
  745. //
  746. // CResourcePhysicalDisk::GetDriveLetterMappings()
  747. //
  748. // Description:
  749. //
  750. // Arguments:
  751. //
  752. // Return Value:
  753. //
  754. // Remarks:
  755. // None.
  756. //
  757. //--
  758. //////////////////////////////////////////////////////////////////////////////
  759. STDMETHODIMP
  760. CResourcePhysicalDisk::GetDriveLetterMappings(
  761. SDriveLetterMapping * pdlmDriveLetterMappingOut
  762. )
  763. {
  764. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  765. HRESULT hr = S_FALSE;
  766. if ( pdlmDriveLetterMappingOut == NULL )
  767. {
  768. hr = THR( E_POINTER );
  769. } // if:
  770. ZeroMemory( pdlmDriveLetterMappingOut, sizeof(*pdlmDriveLetterMappingOut) );
  771. HRETURN( hr );
  772. } //*** CResourcePhysicalDisk::GetDriveLetterMappings()
  773. //
  774. // KB: Some of these methods are supported in a limited sense for compatability.
  775. // Those methods compare the request with the current data and succeede if they
  776. // match, and fail otherwise. All other methods assert and fail when called.
  777. // If they are used, appropriate handling should be done in the upper level,
  778. // And the THR removed from that section of code.
  779. //
  780. //////////////////////////////////////////////////////////////////////////////
  781. //++
  782. //
  783. // CResourcePhysicalDisk::SetDriveLetterMappings()
  784. //
  785. // Description:
  786. //
  787. // Arguments:
  788. //
  789. // Return Value:
  790. //
  791. // Remarks:
  792. // None.
  793. //
  794. //--
  795. //////////////////////////////////////////////////////////////////////////////
  796. STDMETHODIMP
  797. CResourcePhysicalDisk::SetDriveLetterMappings(
  798. SDriveLetterMapping dlmDriveLetterMappingIn
  799. )
  800. {
  801. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  802. HRESULT hr = THR( E_NOTIMPL );
  803. HRETURN( hr );
  804. } //*** CResourcePhysicalDisk::SetDriveLetterMappings()
  805. //////////////////////////////////////////////////////////////////////////////
  806. //++
  807. //
  808. // CResourcePhysicalDisk::IsDeviceJoinable()
  809. //
  810. // Description:
  811. //
  812. // Arguments:
  813. //
  814. // Return Value:
  815. // S_OK
  816. // Is Joinable device.
  817. //
  818. // S_FALSE
  819. // Is not quorum capable device.
  820. //
  821. // Remarks:
  822. // None.
  823. //
  824. //--
  825. //////////////////////////////////////////////////////////////////////////////
  826. STDMETHODIMP
  827. CResourcePhysicalDisk::IsDeviceJoinable( void )
  828. {
  829. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  830. HRESULT hr = S_OK;
  831. HRETURN( hr );
  832. } //*** CResourcePhysicalDisk::IsDeviceJoinable()
  833. //////////////////////////////////////////////////////////////////////////////
  834. //++
  835. //
  836. // CResourcePhysicalDisk::SetDeviceJoinable()
  837. //
  838. // Description:
  839. //
  840. // Arguments:
  841. //
  842. // Return Value:
  843. // S_OK
  844. // Is Joinable device.
  845. //
  846. // S_FALSE
  847. // Is not quorum capable device.
  848. //
  849. // Remarks:
  850. // This function should never be called.
  851. //
  852. //--
  853. //////////////////////////////////////////////////////////////////////////////
  854. STDMETHODIMP
  855. CResourcePhysicalDisk::SetDeviceJoinable( BOOL fIsJoinableIn )
  856. {
  857. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  858. HRETURN( THR( E_NOTIMPL ) );
  859. } //*** CResourcePhysicalDisk::SetDeviceJoinable()
  860. //////////////////////////////////////////////////////////////////////////////
  861. //++
  862. //
  863. // CResourcePhysicalDisk::SetName()
  864. //
  865. // Description:
  866. //
  867. // Arguments:
  868. //
  869. // Return Value:
  870. //
  871. // Remarks:
  872. // None.
  873. //
  874. //--
  875. //////////////////////////////////////////////////////////////////////////////
  876. STDMETHODIMP
  877. CResourcePhysicalDisk::SetName(
  878. LPCWSTR pcszNameIn
  879. )
  880. {
  881. TraceFunc1( "[IClusCfgManagedResourceInfo] pcszNameIn = '%ls'", pcszNameIn == NULL ? L"<null>" : pcszNameIn );
  882. HRESULT hr = S_FALSE;
  883. HRETURN( hr );
  884. } //*** CResourcePhysicalDisk::SetName()
  885. //////////////////////////////////////////////////////////////////////////////
  886. //++
  887. //
  888. // CResourcePhysicalDisk::SetManaged()
  889. //
  890. // Description:
  891. //
  892. // Arguments:
  893. //
  894. // Return Value:
  895. //
  896. // Remarks:
  897. // None.
  898. //
  899. //--
  900. //////////////////////////////////////////////////////////////////////////////
  901. STDMETHODIMP
  902. CResourcePhysicalDisk::SetManaged(
  903. BOOL fIsManagedIn
  904. )
  905. {
  906. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  907. HRESULT hr = S_OK;
  908. Assert( fIsManagedIn );
  909. if ( !fIsManagedIn )
  910. {
  911. hr = THR( E_FAIL );
  912. }
  913. HRETURN( hr );
  914. } //*** CResourcePhysicalDisk::SetManaged()
  915. //////////////////////////////////////////////////////////////////////////////
  916. //++
  917. //
  918. // CResourcePhysicalDisk::SetQuorumedDevice()
  919. //
  920. // Description:
  921. //
  922. // Arguments:
  923. //
  924. // Return Value:
  925. //
  926. // Remarks:
  927. // None.
  928. //
  929. //--
  930. //////////////////////////////////////////////////////////////////////////////
  931. STDMETHODIMP
  932. CResourcePhysicalDisk::SetQuorumedDevice(
  933. BOOL fIsQuorumDeviceIn
  934. )
  935. {
  936. TraceFunc( "[IClusCfgManagedResourceInfo]" );
  937. HRESULT hr;
  938. if ( m_dwFlags & CLUS_FLAG_CORE )
  939. {
  940. if ( fIsQuorumDeviceIn )
  941. {
  942. hr = S_OK;
  943. }
  944. else
  945. {
  946. hr = THR( E_FAIL );
  947. }
  948. }
  949. else
  950. {
  951. if ( !fIsQuorumDeviceIn )
  952. {
  953. hr = S_OK;
  954. }
  955. else
  956. {
  957. hr = THR( E_FAIL );
  958. }
  959. }
  960. HRETURN( hr );
  961. } //*** CResourcePhysicalDisk::SetQuorumedDevice()
  962. //*************************************************************************//
  963. /////////////////////////////////////////////////////////////////////////////
  964. // CResourcePhysicalDisk -- IEnumClusCfgPartitions interface.
  965. /////////////////////////////////////////////////////////////////////////////
  966. //////////////////////////////////////////////////////////////////////////////
  967. //++
  968. //
  969. // CResourcePhysicalDisk::Next()
  970. //
  971. // Description:
  972. //
  973. // Arguments:
  974. //
  975. // Return Value:
  976. //
  977. // Remarks:
  978. // None.
  979. //
  980. //--
  981. //////////////////////////////////////////////////////////////////////////////
  982. STDMETHODIMP
  983. CResourcePhysicalDisk::Next(
  984. ULONG cNumberRequestedIn,
  985. IClusCfgPartitionInfo ** rgpPartitionInfoOut,
  986. ULONG * pcNumberFetchedOut
  987. )
  988. {
  989. TraceFunc( "[IEnumClusCfgPartitions]" );
  990. HRESULT hr;
  991. ULONG cFetched = min(cNumberRequestedIn, m_cParitions - m_ulCurrent);
  992. if ( rgpPartitionInfoOut == NULL )
  993. goto InvalidPointer;
  994. for ( ; cFetched < cNumberRequestedIn; cFetched++, m_ulCurrent++ )
  995. {
  996. hr = THR( (m_ppPartitions[ m_ulCurrent ])->TypeSafeQI( IClusCfgPartitionInfo,
  997. &rgpPartitionInfoOut[ cFetched ]
  998. ) );
  999. if ( FAILED( hr ) )
  1000. {
  1001. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_Next_QI_Failed, hr );
  1002. goto Cleanup;
  1003. }
  1004. }
  1005. if ( cFetched < cNumberRequestedIn )
  1006. {
  1007. hr = S_FALSE;
  1008. }
  1009. else
  1010. {
  1011. hr = S_OK;
  1012. }
  1013. Cleanup:
  1014. if ( FAILED( hr ) )
  1015. {
  1016. while ( cFetched != 0 );
  1017. {
  1018. cFetched --;
  1019. rgpPartitionInfoOut[ cFetched ]->Release( );
  1020. }
  1021. }
  1022. if ( pcNumberFetchedOut != NULL )
  1023. {
  1024. *pcNumberFetchedOut = cFetched;
  1025. }
  1026. HRETURN( hr );
  1027. InvalidPointer:
  1028. hr = THR( E_POINTER );
  1029. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2kProxy_PhysDisk_Next_InvalidPointer, hr );
  1030. goto Cleanup;
  1031. } //*** CResourcePhysicalDisk::Next()
  1032. //////////////////////////////////////////////////////////////////////////////
  1033. //++
  1034. //
  1035. // CResourcePhysicalDisk::Reset()
  1036. //
  1037. // Description:
  1038. //
  1039. // Arguments:
  1040. //
  1041. // Return Value:
  1042. //
  1043. // Remarks:
  1044. // None.
  1045. //
  1046. //--
  1047. //////////////////////////////////////////////////////////////////////////////
  1048. STDMETHODIMP
  1049. CResourcePhysicalDisk::Reset( void )
  1050. {
  1051. TraceFunc( "[IEnumClusCfgPartitions]" );
  1052. HRESULT hr = S_OK;
  1053. m_ulCurrent = 0;
  1054. HRETURN( hr );
  1055. } //*** CResourcePhysicalDisk::Reset()
  1056. //////////////////////////////////////////////////////////////////////////////
  1057. //++
  1058. //
  1059. // CResourcePhysicalDisk::Skip()
  1060. //
  1061. // Description:
  1062. //
  1063. // Arguments:
  1064. //
  1065. // Return Value:
  1066. //
  1067. // Remarks:
  1068. // None.
  1069. //
  1070. //--
  1071. //////////////////////////////////////////////////////////////////////////////
  1072. STDMETHODIMP
  1073. CResourcePhysicalDisk::Skip(
  1074. ULONG cNumberToSkipIn
  1075. )
  1076. {
  1077. TraceFunc( "[IEnumClusCfgPartitions]" );
  1078. HRESULT hr = S_OK;
  1079. m_ulCurrent += cNumberToSkipIn;
  1080. if ( m_ulCurrent >= m_cParitions )
  1081. {
  1082. hr = S_FALSE;
  1083. m_ulCurrent = m_cParitions;
  1084. }
  1085. else
  1086. {
  1087. hr = S_OK;
  1088. }
  1089. HRETURN( hr );
  1090. } //*** CResourcePhysicalDisk::Skip()
  1091. //////////////////////////////////////////////////////////////////////////////
  1092. //++
  1093. //
  1094. // CResourcePhysicalDisk::Clone()
  1095. //
  1096. // Description:
  1097. //
  1098. // Arguments:
  1099. //
  1100. // Return Value:
  1101. //
  1102. // Remarks:
  1103. // None.
  1104. //
  1105. //--
  1106. //////////////////////////////////////////////////////////////////////////////
  1107. STDMETHODIMP
  1108. CResourcePhysicalDisk::Clone( IEnumClusCfgPartitions ** ppEnumPartitions )
  1109. {
  1110. TraceFunc( "[IEnumClusCfgPartitions]" );
  1111. HRESULT hr = THR( E_NOTIMPL );
  1112. HRETURN( hr );
  1113. } //*** CResourcePhysicalDisk::Clone()
  1114. //////////////////////////////////////////////////////////////////////////////
  1115. //++
  1116. //
  1117. // CResourcePhysicalDisk::Count()
  1118. //
  1119. // Description:
  1120. //
  1121. // Arguments:
  1122. //
  1123. // Return Value:
  1124. //
  1125. // Remarks:
  1126. // None.
  1127. //
  1128. //--
  1129. //////////////////////////////////////////////////////////////////////////////
  1130. STDMETHODIMP
  1131. CResourcePhysicalDisk::Count( DWORD * pnCountOut )
  1132. {
  1133. TraceFunc( "[IEnumClusCfgPartitions]" );
  1134. HRESULT hr = THR( S_OK );
  1135. if ( pnCountOut == NULL )
  1136. {
  1137. hr = THR( E_POINTER );
  1138. goto Cleanup;
  1139. }
  1140. *pnCountOut = m_cParitions;
  1141. Cleanup:
  1142. HRETURN( hr );
  1143. } //*** CResourcePhysicalDisk::Count()
  1144. //****************************************************************************
  1145. //
  1146. // IClusCfgCallback
  1147. //
  1148. //****************************************************************************
  1149. //////////////////////////////////////////////////////////////////////////////
  1150. //++
  1151. //
  1152. // CResourcePhysicalDisk::SendStatusReport()
  1153. //
  1154. // Description:
  1155. //
  1156. // Arguments:
  1157. //
  1158. // Return Value:
  1159. //
  1160. // Remarks:
  1161. // None.
  1162. //
  1163. //--
  1164. //////////////////////////////////////////////////////////////////////////////
  1165. STDMETHODIMP
  1166. CResourcePhysicalDisk::SendStatusReport(
  1167. LPCWSTR pcszNodeNameIn
  1168. , CLSID clsidTaskMajorIn
  1169. , CLSID clsidTaskMinorIn
  1170. , ULONG ulMinIn
  1171. , ULONG ulMaxIn
  1172. , ULONG ulCurrentIn
  1173. , HRESULT hrStatusIn
  1174. , LPCWSTR pcszDescriptionIn
  1175. , FILETIME * pftTimeIn
  1176. , LPCWSTR pcszReferenceIn
  1177. )
  1178. {
  1179. TraceFunc( "[IClusCfgCallback]" );
  1180. HRESULT hr = S_OK;
  1181. if ( m_pcccb != NULL )
  1182. {
  1183. hr = THR( m_pcccb->SendStatusReport( pcszNodeNameIn,
  1184. clsidTaskMajorIn,
  1185. clsidTaskMinorIn,
  1186. ulMinIn,
  1187. ulMaxIn,
  1188. ulCurrentIn,
  1189. hrStatusIn,
  1190. pcszDescriptionIn,
  1191. pftTimeIn,
  1192. pcszReferenceIn
  1193. ) );
  1194. } // if:
  1195. HRETURN( hr );
  1196. } //*** CResourcePhysicalDisk::SendStatusReport()