Changeset 67511 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jun 20, 2017 2:30:30 PM (7 years ago)
- Location:
- trunk/src/VBox/Runtime/common/fs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp
r67502 r67511 1397 1397 static int rtFsIsoMakerCmdOptImportIso(PRTFSISOMAKERCMDOPTS pOpts, const char *pszIsoSpec) 1398 1398 { 1399 uint32_t offError = UINT32_MAX; 1400 RTERRINFOSTATIC ErrInfo; 1401 int rc = RTFsIsoMakerImport(pOpts->hIsoMaker, pszIsoSpec, 0 /*fFlags*/, &offError, RTErrInfoInitStatic(&ErrInfo)); 1399 RTFSISOMAKERIMPORTRESULTS Results; 1400 RTERRINFOSTATIC ErrInfo; 1401 int rc = RTFsIsoMakerImport(pOpts->hIsoMaker, pszIsoSpec, 0 /*fFlags*/, &Results, RTErrInfoInitStatic(&ErrInfo)); 1402 1403 pOpts->cItemsAdded += Results.cAddedFiles; 1404 pOpts->cItemsAdded += Results.cAddedDirs; 1405 pOpts->cItemsAdded += Results.cBootCatEntries; 1406 pOpts->cItemsAdded += Results.cbSysArea != 0 ? 1 : 0; 1407 1408 rtFsIsoMakerPrintf(pOpts, "ISO imported statistics for '%s'\n", pszIsoSpec); 1409 rtFsIsoMakerPrintf(pOpts, " cAddedNames: %'14RU32\n", Results.cAddedNames); 1410 rtFsIsoMakerPrintf(pOpts, " cAddedDirs: %'14RU32\n", Results.cAddedDirs); 1411 rtFsIsoMakerPrintf(pOpts, " cbAddedDataBlocks: %'14RU64 bytes\n", Results.cbAddedDataBlocks); 1412 rtFsIsoMakerPrintf(pOpts, " cAddedFiles: %'14RU32\n", Results.cAddedFiles); 1413 if (Results.cBootCatEntries == UINT32_MAX) 1414 rtFsIsoMakerPrintf(pOpts, " cBootCatEntries: none\n"); 1415 else 1416 rtFsIsoMakerPrintf(pOpts, " cBootCatEntries: %'14RU32\n", Results.cBootCatEntries); 1417 rtFsIsoMakerPrintf(pOpts, " cbSysArea: %'14RU32\n", Results.cbSysArea); 1418 rtFsIsoMakerPrintf(pOpts, " cErrors: %'14RU32\n", Results.cErrors); 1419 1402 1420 if (RT_SUCCESS(rc)) 1403 1421 return rc; 1404 if ( offError != UINT32_MAX)1405 return rtFsIsoMakerCmdChainError(pOpts, "RTFsIsoMakerImport", pszIsoSpec, rc, offError, &ErrInfo.Core);1422 if (Results.offError != UINT32_MAX) 1423 return rtFsIsoMakerCmdChainError(pOpts, "RTFsIsoMakerImport", pszIsoSpec, rc, Results.offError, &ErrInfo.Core); 1406 1424 if (RTErrInfoIsSet(&ErrInfo.Core)) 1407 1425 return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerImport failed: %Rrc - %s", rc, ErrInfo.Core.pszMsg); -
trunk/src/VBox/Runtime/common/fs/isomakerimport.cpp
r67503 r67511 129 129 /** Set if we've already seen a joliet volume descriptor. */ 130 130 bool fSeenJoliet; 131 132 /** Pointer to the import results structure (output). */ 133 PRTFSISOMAKERIMPORTRESULTS pResults; 131 134 132 135 /** Sector buffer for volume descriptors and such. */ … … 204 207 #define VERR_ISOMK_IMPORT_TOO_DEEP_DIR_TREE (-24921) 205 208 209 /** Import ISO contains a bad directory record. */ 206 210 #define VERR_ISOMK_IMPORT_BAD_DIR_REC (-24922) 211 /** Import ISO directory record with a mismatching volume sequence number. */ 207 212 #define VERR_ISOMK_IMPORT_DIR_REC_VOLUME_SEQ_NO (-24923) 213 /** Import ISO directory with an extent that is out of bounds. */ 208 214 #define VERR_ISOMK_IMPORT_DIR_REC_EXTENT_OUT_OF_BOUNDS (-24924) 215 /** Import ISO directory with a bad record length. */ 209 216 #define VERR_ISOMK_IMPORT_BAD_DIR_REC_LENGTH (-24925) 217 /** Import ISO directory with a bad name length. */ 210 218 #define VERR_ISOMK_IMPORT_DOT_DIR_REC_BAD_NAME_LENGTH (-24926) 219 /** Import ISO directory with a bad name. */ 211 220 #define VERR_ISOMK_IMPORT_DOT_DIR_REC_BAD_NAME (-24927) 212 221 … … 224 233 static int rtFsIsoImpErrorV(PRTFSISOMKIMPORTER pThis, int rc, const char *pszFormat, va_list va) 225 234 { 235 va_list vaCopy; 236 va_copy(vaCopy, va); 237 LogRel(("RTFsIsoMkImport error %Rrc: %N\n", rc, pszFormat, &vaCopy)); 238 va_end(vaCopy); 239 226 240 if (RT_SUCCESS(pThis->rc)) 227 241 { … … 229 243 rc = RTErrInfoSetV(pThis->pErrInfo, rc, pszFormat, va); 230 244 } 245 246 pThis->pResults->cErrors++; 231 247 return rc; 232 248 } … … 380 396 return rc; 381 397 398 cbChunk -= pDirRec->cbDirRec; 382 399 pDirRec = (PCISO9660DIRREC)((uintptr_t)pDirRec + pDirRec->cbDirRec); 383 cbChunk -= pDirRec->cbDirRec;384 400 385 401 /* 386 402 * Work our way thru all the directory records. 387 403 */ 388 Log3(("rtFsIsoImportProcessIso9660TreeWorker: Starting at @%#RX64 LB %#zx\n", off - cbChunk, cbChunk)); 404 Log3(("rtFsIsoImportProcessIso9660TreeWorker: Starting at @%#RX64 LB %#RX32 (out of %#RX32) in %#x\n", 405 off - cbChunk, cbChunk, cbChunk + cbDir, idxDir)); 389 406 while (cbChunk > 0) 390 407 { … … 405 422 return rtFsIsoImpError(pThis, rc, "Error reading %#RX32 bytes at %#RX64 (dir): %Rrc", off, cbToRead); 406 423 407 Log3(("rtFsIsoImportProcessIso9660TreeWorker: Read %#zx more bytes @%#RX64, now got @%#RX64 LB %# zx\n",424 Log3(("rtFsIsoImportProcessIso9660TreeWorker: Read %#zx more bytes @%#RX64, now got @%#RX64 LB %#RX32\n", 408 425 cbToRead, off, off - cbChunk, cbChunk + cbToRead)); 409 426 off += cbToRead; … … 427 444 continue; 428 445 } 429 Log3(("rtFsIsoImportProcessIso9660TreeWorker: cbDirRec=0 --> jumped to @%#RX64 LB %#zx\n", off - cbChunk, cbChunk)); 446 Log3(("rtFsIsoImportProcessIso9660TreeWorker: cbDirRec=0 --> jumped %#RX32 to @%#RX64 LB %#RX32\n", 447 cbSkip, off - cbChunk, cbChunk)); 430 448 } 431 449 /* ASSUMES we're working in multiples of sectors! */ … … 440 458 return rtFsIsoImpError(pThis, rc, "Error reading %#RX32 bytes at %#RX64 (dir): %Rrc", off, cbToRead); 441 459 442 Log3(("rtFsIsoImportProcessIso9660TreeWorker: cbDirRec=0 --> Read %#zx more bytes @%#RX64, now got @%#RX64 LB %# zx\n",460 Log3(("rtFsIsoImportProcessIso9660TreeWorker: cbDirRec=0 --> Read %#zx more bytes @%#RX64, now got @%#RX64 LB %#RX32\n", 443 461 cbToRead, off, off - cbChunk, cbChunk + cbToRead)); 444 462 off += cbToRead; … … 456 474 - pDirRec->bFileIdLength - !(pDirRec->bFileIdLength & 1); 457 475 uint8_t const * const pbSys = (uint8_t const *)&pDirRec->achFileId[pDirRec->bFileIdLength + !(pDirRec->bFileIdLength & 1)]; 458 Log3(("pDirRec=%p @%#010RX64 cb=%#04x ff=%#04x off=%#010RX32 cb=%#010RX32 cbSys=%#x id=%.*Rhxs\n", 459 pDirRec, off - cbChunk, pDirRec->cbDirRec, pDirRec->fFileFlags, ISO9660_GET_ENDIAN(&pDirRec->offExtent), 460 ISO9660_GET_ENDIAN(&pDirRec->cbData), cbSys, pDirRec->bFileIdLength, pDirRec->achFileId)); 476 Log3(("pDirRec=&abBuf[%#07zx]: @%#010RX64 cb=%#04x ff=%#04x off=%#010RX32 cb=%#010RX32 cbSys=%#x id=%.*Rhxs\n", 477 (uintptr_t)pDirRec - (uintptr_t)&pThis->abBuf[0], off - cbChunk, pDirRec->cbDirRec, pDirRec->fFileFlags, 478 ISO9660_GET_ENDIAN(&pDirRec->offExtent), ISO9660_GET_ENDIAN(&pDirRec->cbData), cbSys, 479 pDirRec->bFileIdLength, pDirRec->achFileId)); 461 480 rc = rtFsIsoImportValidateDirRec(pThis, pDirRec, cbChunk); 462 481 if (RT_FAILURE(rc)) … … 496 515 pThis->szNameBuf[cchName - offName] = '\0'; 497 516 } 498 Log3((" name='%s'\n", pThis->szNameBuf));517 Log3((" --> name='%s'\n", pThis->szNameBuf)); 499 518 500 519 /** @todo rock ridge. */ … … 509 528 uint32_t idxObj = UINT32_MAX; 510 529 if (pDirRec->fFileFlags & ISO9660_FILE_FLAGS_DIRECTORY) 530 { 511 531 rc = RTFsIsoMakerAddUnnamedDir(pThis->hIsoMaker, &idxObj); 532 Log3((" --> added directory #%#x'\n", idxObj)); 533 if (RT_SUCCESS(rc)) 534 pThis->pResults->cAddedDirs++; 535 } 512 536 else 513 537 { … … 525 549 pBlock2File = (PRTFSISOMKIMPBLOCK2FILE)RTAvlU32Get(&pThis->Block2FileRoot, ISO9660_GET_ENDIAN(&pDirRec->offExtent)); 526 550 if (!pBlock2File) 551 { 527 552 rc = RTFsIsoMakerAddUnnamedFileWithCommonSrc(pThis->hIsoMaker, pThis->idxSrcFile, 528 ISO9660_GET_ENDIAN(&pDirRec->offExtent) * ISO9660_SECTOR_SIZE,553 ISO9660_GET_ENDIAN(&pDirRec->offExtent) * (uint64_t)ISO9660_SECTOR_SIZE, 529 554 ISO9660_GET_ENDIAN(&pDirRec->cbData), NULL /*pObjInfo*/, &idxObj); 555 Log3((" --> added new file #%#x\n", idxObj)); 556 if (RT_SUCCESS(rc)) 557 { 558 pThis->pResults->cAddedFiles++; 559 pThis->pResults->cbAddedDataBlocks += RT_ALIGN_32(ISO9660_GET_ENDIAN(&pDirRec->cbData), ISO9660_SECTOR_SIZE); 560 } 561 } 530 562 else 531 563 { 532 564 idxObj = pBlock2File->idxObj; 565 Log3((" --> existing file #%#x'\n", idxObj)); 533 566 rc = VINF_SUCCESS; 534 567 } … … 541 574 if (RT_SUCCESS(rc)) 542 575 { 576 pThis->pResults->cAddedNames++; 577 543 578 /* 544 579 * Remember the data location if this is a file, if it's a … … 625 660 if (!pNext) 626 661 break; 662 idxDir = pNext->idxObj; 663 offDirBlock = pNext->offDirBlock; 664 cbDir = pNext->cbDir; 627 665 cDepth = pNext->cDepth; 628 cbDir = pNext->cbDir;629 offDirBlock = pNext->offDirBlock;630 666 RTMemFree(pNext); 631 667 } … … 891 927 */ 892 928 RTDECL(int) RTFsIsoMakerImport(RTFSISOMAKER hIsoMaker, const char *pszIso, uint32_t fFlags, 893 uint32_t *poffError, PRTERRINFO pErrInfo)929 PRTFSISOMAKERIMPORTRESULTS pResults, PRTERRINFO pErrInfo) 894 930 { 895 931 /* 896 932 * Validate input. 897 933 */ 934 AssertPtrReturn(pResults, VERR_INVALID_POINTER); 935 pResults->cAddedNames = 0; 936 pResults->cAddedDirs = 0; 937 pResults->cbAddedDataBlocks = 0; 938 pResults->cAddedFiles = 0; 939 pResults->cBootCatEntries = UINT32_MAX; 940 pResults->cbSysArea = 0; 941 pResults->cErrors = 0; 942 pResults->offError = UINT32_MAX; 898 943 AssertReturn(!(fFlags & ~RTFSISOMK_IMPORT_F_VALID_MASK), VERR_INVALID_FLAGS); 899 944 … … 902 947 */ 903 948 RTVFSFILE hSrcFile; 904 int rc = RTVfsChainOpenFile(pszIso, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hSrcFile, poffError, pErrInfo); 949 int rc = RTVfsChainOpenFile(pszIso, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, 950 &hSrcFile, &pResults->offError, pErrInfo); 905 951 if (RT_FAILURE(rc)) 906 952 return rc; 953 pResults->offError = UINT32_MAX; 954 907 955 908 956 /* … … 924 972 //pThis->idPrimaryVol = 0; 925 973 //pThis->fSeenJoliet = false; 974 pThis->pResults = pResults; 926 975 927 976 /* … … 948 997 uint32_t iElTorito = UINT32_MAX; 949 998 uint32_t iVolDesc = 0; 950 for (;; iVolDesc++)999 for (;;) 951 1000 { 952 1001 switch (pThis->uSectorBuf.VolDescHdr.bDescType) … … 994 1043 * Read the next volume descriptor and check the signature. 995 1044 */ 1045 iVolDesc++; 996 1046 if (iVolDesc >= 32) 997 1047 { … … 1036 1086 if (!ASMMemIsAllU8(pThis->abBuf, _32K, 0)) 1037 1087 { 1088 /* Drop zero sectors from the end. */ 1089 uint32_t cbSysArea = _32K; 1090 while ( cbSysArea >= ISO9660_SECTOR_SIZE 1091 && ASMMemIsAllU8(&pThis->abBuf[cbSysArea - ISO9660_SECTOR_SIZE], ISO9660_SECTOR_SIZE, 0)) 1092 cbSysArea -= ISO9660_SECTOR_SIZE; 1093 1038 1094 /** @todo HFS */ 1039 rc = RTFsIsoMakerSetSysAreaContent(hIsoMaker, pThis->abBuf, _32K, 0); 1095 pThis->pResults->cbSysArea = cbSysArea; 1096 rc = RTFsIsoMakerSetSysAreaContent(hIsoMaker, pThis->abBuf, cbSysArea, 0); 1040 1097 if (RT_FAILURE(rc)) 1041 1098 rtFsIsoImpError(pThis, rc, "RTFsIsoMakerSetSysAreaContent failed: %Rrc", rc);
Note:
See TracChangeset
for help on using the changeset viewer.