Changeset 105627 in vbox
- Timestamp:
- Aug 8, 2024 3:58:25 PM (6 months ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/NvramStoreImpl.h
r99418 r105627 85 85 #endif 86 86 87 int i_getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile); 87 88 com::Utf8Str i_getNonVolatileStorageFile(); 88 89 void i_updateNonVolatileStorageFile(const com::Utf8Str &aNonVolatileStorageFile); -
trunk/src/VBox/Main/src-all/NvramStoreImpl.cpp
r105383 r105627 354 354 } 355 355 356 357 356 HRESULT NvramStore::getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile) 358 357 { 359 #ifndef VBOX_COM_INPROC 360 Utf8Str strTmp; 361 { 362 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 363 strTmp = m->bd->strNvramPath; 364 } 365 366 AutoReadLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); 367 if (strTmp.isEmpty()) 368 strTmp = m->pParent->i_getDefaultNVRAMFilename(); 369 if (strTmp.isNotEmpty()) 370 m->pParent->i_calculateFullPath(strTmp, aNonVolatileStorageFile); 371 #else 372 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 373 aNonVolatileStorageFile = m->bd->strNvramPath; 374 #endif 358 int vrc = i_getNonVolatileStorageFile(aNonVolatileStorageFile); 359 if (RT_FAILURE(vrc)) 360 return setError(E_FAIL, tr("This machine does not have an NVRAM store file")); 375 361 376 362 return S_OK; … … 382 368 #ifndef VBOX_COM_INPROC 383 369 Utf8Str strPath; 384 NvramStore::getNonVolatileStorageFile(strPath); 370 int vrc = i_getNonVolatileStorageFile(strPath); 371 if (RT_FAILURE(vrc)) 372 return setError(E_FAIL, tr("No NVRAM store file found")); 373 374 HRESULT hrc; 385 375 386 376 /* We need a write lock because of the lazy initialization. */ … … 388 378 389 379 /* Check if we have to create the UEFI variable store object */ 390 HRESULT hrc = S_OK;391 380 if (!m->pUefiVarStore) 392 381 { … … 394 383 if (!m->mapNvram.size()) 395 384 { 396 intvrc = i_loadStore(strPath.c_str());385 vrc = i_loadStore(strPath.c_str()); 397 386 if (RT_FAILURE(vrc)) 398 387 hrc = setError(E_FAIL, tr("Loading the NVRAM store failed (%Rrc)\n"), vrc); … … 408 397 } 409 398 else 410 hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("The UEFI NVRAM file is not existing for this machine ."));399 hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("The UEFI NVRAM file is not existing for this machine")); 411 400 } 412 401 } … … 464 453 if (FAILED(adep.hrc())) return adep.hrc(); 465 454 466 Utf8Str strPath; 467 NvramStore::getNonVolatileStorageFile(strPath); 455 Utf8Str strPath = i_getNonVolatileStorageFile(); 468 456 469 457 /* We need a write lock because of the lazy initialization. */ … … 526 514 527 515 516 /** 517 * Returns the path of the non-volatile storage file. 518 * 519 * @returns VBox status code. 520 * @retval VERR_FILE_NOT_FOUND if the storage file was not found. 521 * @param aNonVolatileStorageFile Returns path to non-volatile stroage file on success. 522 */ 523 int NvramStore::i_getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile) 524 { 525 #ifndef VBOX_COM_INPROC 526 Utf8Str strTmp; 527 { 528 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 529 strTmp = m->bd->strNvramPath; 530 } 531 532 AutoReadLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); 533 if (strTmp.isEmpty()) 534 strTmp = m->pParent->i_getDefaultNVRAMFilename(); 535 if (strTmp.isNotEmpty()) 536 m->pParent->i_calculateFullPath(strTmp, aNonVolatileStorageFile); 537 #else 538 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 539 aNonVolatileStorageFile = m->bd->strNvramPath; 540 #endif 541 542 if (aNonVolatileStorageFile.isEmpty()) 543 return VERR_FILE_NOT_FOUND; 544 545 return VINF_SUCCESS; 546 } 547 548 549 /** 550 * Returns the path of the non-volatile stroage file. 551 * 552 * @returns Path to non-volatile stroage file. Empty if not supported / found. 553 * 554 * @note Convenience function for machine object or other callers. 555 */ 528 556 Utf8Str NvramStore::i_getNonVolatileStorageFile() 529 557 { … … 532 560 533 561 Utf8Str strTmp; 534 NvramStore::getNonVolatileStorageFile(strTmp);562 /* rc ignored */ i_getNonVolatileStorageFile(strTmp); 535 563 return strTmp; 536 564 } … … 695 723 int NvramStore::i_loadStore(const char *pszPath) 696 724 { 725 AssertPtrReturn(pszPath, VERR_INVALID_POINTER); 726 AssertReturn(*pszPath, VERR_PATH_ZERO_LENGTH); /* IPRT below doesn't like empty strings. */ 727 697 728 uint64_t cbStore = 0; 698 729 int vrc = RTFileQuerySizeByPath(pszPath, &cbStore); … … 912 943 int vrc = VINF_SUCCESS; 913 944 914 Utf8Str strTmp; 915 NvramStore::getNonVolatileStorageFile(strTmp); 945 Utf8Str strPath = i_getNonVolatileStorageFile(); 916 946 917 947 /* … … 920 950 * see @bugref{10191}. 921 951 */ 922 if (str Tmp.isNotEmpty())952 if (strPath.isNotEmpty()) 923 953 { 924 954 /* … … 937 967 938 968 RTVFSIOSTREAM hVfsIosDst; 939 vrc = RTVfsIoStrmOpenNormal(str Tmp.c_str(), RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_NONE,969 vrc = RTVfsIoStrmOpenNormal(strPath.c_str(), RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_NONE, 940 970 &hVfsIosDst); 941 971 if (RT_SUCCESS(vrc)) … … 972 1002 } 973 1003 else if (m->mapNvram.size()) 974 vrc = i_saveStoreAsTar(str Tmp.c_str());1004 vrc = i_saveStoreAsTar(strPath.c_str()); 975 1005 /* else: No NVRAM content to store so we are done here. */ 976 1006 } … … 1084 1114 } 1085 1115 else 1086 hrc = setError(E_FAIL, tr("Opening the UEFI variable store failed (%Rrc) ."), vrc);1116 hrc = setError(E_FAIL, tr("Opening the UEFI variable store failed (%Rrc)"), vrc); 1087 1117 } 1088 1118 else 1089 hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("The UEFI NVRAM file is not existing for this machine ."));1119 hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("The UEFI NVRAM file is not existing for this machine")); 1090 1120 1091 1121 return hrc;
Note:
See TracChangeset
for help on using the changeset viewer.