- Timestamp:
- Mar 26, 2009 1:59:14 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDiskImpl.cpp
r18269 r18313 729 729 m.state = MediaState_Created; 730 730 731 /* remember the open mode (defaults to ReadWrite) */ 732 mm.hddOpenMode = enOpenMode; 733 731 734 rc = setLocation (aLocation); 732 735 CheckComRCReturnRC (rc); 733 736 734 737 /* get all the information about the medium from the storage unit */ 735 rc = queryInfo((enOpenMode == OpenReadWrite) /* fWrite */ ); 736 if (SUCCEEDED (rc)) 738 rc = queryInfo(); 739 740 if (SUCCEEDED(rc)) 737 741 { 738 742 /* if the storage unit is not accessible, it's not acceptable for the … … 745 749 else 746 750 { 747 /* storage format must be detected by queryInfo() if the medium is 748 * accessible */ 749 AssertReturn (!m.id.isEmpty() && !mm.format.isNull(), E_FAIL); 751 AssertReturn(!m.id.isEmpty(), E_FAIL); 752 753 /* storage format must be detected by queryInfo() if the medium is accessible */ 754 AssertReturn(!mm.format.isNull(), E_FAIL); 750 755 } 751 756 } … … 2996 3001 * writing. 2997 3002 */ 2998 HRESULT HardDisk::queryInfo( bool fWrite)3003 HRESULT HardDisk::queryInfo() 2999 3004 { 3000 3005 AutoWriteLock alock (this); … … 3079 3084 * time in VirtualBox (such as VMDK for which VDOpen() needs to 3080 3085 * generate an UUID if it is missing) */ 3081 if (!fWrite || !isImport) 3086 if ( (mm.hddOpenMode == OpenReadOnly) 3087 || !isImport 3088 ) 3082 3089 flags |= VD_OPEN_FLAGS_READONLY; 3083 3090 3084 vrc = VDOpen (hdd, Utf8Str (mm.format), location, flags, 3085 mm.vdDiskIfaces); 3091 vrc = VDOpen(hdd, 3092 Utf8Str(mm.format), 3093 location, 3094 flags, 3095 mm.vdDiskIfaces); 3086 3096 if (RT_FAILURE (vrc)) 3087 3097 { … … 3096 3106 /* check the UUID */ 3097 3107 RTUUID uuid; 3098 vrc = VDGetUuid 3099 ComAssertRCThrow 3108 vrc = VDGetUuid(hdd, 0, &uuid); 3109 ComAssertRCThrow(vrc, E_FAIL); 3100 3110 3101 3111 if (isImport) 3102 3112 { 3103 unconst (m.id) = uuid; 3113 unconst(m.id) = uuid; 3114 3115 if (m.id.isEmpty() && (mm.hddOpenMode == OpenReadOnly)) 3116 // only when importing a VDMK that has no UUID, create one in memory 3117 unconst(m.id).create(); 3104 3118 } 3105 3119 else … … 3126 3140 /* generate an UUID for an imported UUID-less hard disk */ 3127 3141 if (isImport) 3128 unconst 3142 unconst(m.id).create(); 3129 3143 } 3130 3144 -
trunk/src/VBox/Main/MediumImpl.cpp
r18275 r18313 115 115 case MediaState_LockedWrite: 116 116 { 117 rc = queryInfo( true /* fWrite */);117 rc = queryInfo(); 118 118 break; 119 119 } … … 715 715 * size and description will be updated with the current information. 716 716 * 717 * The fWrite parameter is ignored in this variant, since this always opens718 * the medium read-only; it is however acknowledged by HardDisk::queryInfo(),719 * which overrides this implementation for hard disk media.720 *721 717 * @note This method may block during a system I/O call that checks image file 722 718 * accessibility. … … 724 720 * @note Locks this object for writing. 725 721 */ 726 HRESULT MediumBase::queryInfo( bool fWrite)722 HRESULT MediumBase::queryInfo() 727 723 { 728 724 AutoWriteLock alock (this); … … 966 962 967 963 /* get all the information about the medium from the file */ 968 rc = queryInfo(true); 969 if (SUCCEEDED (rc)) 964 rc = queryInfo(); 965 966 if (SUCCEEDED(rc)) 970 967 { 971 968 /* if the image file is not accessible, it's not acceptable for the -
trunk/src/VBox/Main/include/HardDiskImpl.h
r18275 r18313 256 256 HRESULT setFormat (CBSTR aFormat); 257 257 258 virtual HRESULT queryInfo( bool fWrite);258 virtual HRESULT queryInfo(); 259 259 260 260 HRESULT canClose(); … … 289 289 struct Data 290 290 { 291 Data() : type (HardDiskType_Normal), logicalSize (0), autoReset (false) 292 , implicit (false), numCreateDiffTasks (0) 293 , vdProgress (NULL) , vdDiskIfaces (NULL) {} 291 Data() 292 : type(HardDiskType_Normal), 293 logicalSize(0), 294 hddOpenMode(OpenReadWrite), 295 autoReset(false), 296 implicit(false), 297 numCreateDiffTasks(0), 298 vdProgress(NULL), 299 vdDiskIfaces(NULL) 300 {} 294 301 295 302 const Bstr format; … … 299 306 uint64_t logicalSize; /*< In MBytes. */ 300 307 308 HDDOpenMode hddOpenMode; 309 301 310 BOOL autoReset : 1; 302 311 -
trunk/src/VBox/Main/include/MediumImpl.h
r18275 r18313 143 143 144 144 virtual HRESULT setLocation (CBSTR aLocation); 145 virtual HRESULT queryInfo( bool fWrite);145 virtual HRESULT queryInfo(); 146 146 147 147 /**
Note:
See TracChangeset
for help on using the changeset viewer.