Changeset 80512 in vbox
- Timestamp:
- Aug 30, 2019 11:40:05 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133013
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ImageMounter/vboximg-mount/vboximg-mount.cpp
r80511 r80512 91 91 92 92 #define VBOX_EXTPACK "Oracle VM VirtualBox Extension Pack" 93 #define GPT_PTABLE_SIZE 32 * BLOCKSIZE/** Max size we to read for GPT partition table */93 #define GPT_PTABLE_SIZE 32 * 512 /** Max size we to read for GPT partition table */ 94 94 #define MBR_PARTITIONS_MAX 4 /** Fixed number of partitions in Master Boot Record */ 95 95 #define BASENAME_MAX 256 /** Maximum name for the basename of a path (for RTStrNLen()*/ 96 96 #define VBOXIMG_PARTITION_MAX 256 /** How much storage to allocate to store partition info */ 97 97 #define PARTITION_NAME_MAX 72 /** Maximum partition name size (accomodates GPT partition name) */ 98 #define BLOCKSIZE 512 /** Commonly used disk block size */99 98 #define DOS_BOOT_RECORD_SIGNATURE 0xaa55 /** MBR and EBR (partition table) signature [EOT boundary] */ 100 99 #define NULL_BOOT_RECORD_SIGNATURE 0x0000 /** MBR or EBR null signature value */ 101 100 #define MAX_UUID_LEN 256 /** Max length of a UUID */ 102 #define LBA(n) (n * BLOCKSIZE) 103 #define VD_SECTOR_SIZE 512 /** Virtual disk sector/blocksize */ 104 #define VD_SECTOR_MASK (VD_SECTOR_SIZE - 1) /** Masks off a blocks worth of data */ 105 #define VD_SECTOR_OUT_OF_BOUNDS_MASK (~UINT64_C(VD_SECTOR_MASK)) /** Masks the overflow of a blocks worth of data */ 101 #define LBA(n) (n * g_cbSector) 106 102 #define VERBOSE g_vboximgOpts.fVerbose 107 #define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100)108 103 109 104 #define PARTTYPE_IS_NULL(parType) ((uint8_t)parType == 0x00) … … 121 116 122 117 static RTVFSFILE g_hVfsFileDisk; /** Disk as VFS file handle. */ 123 static char *g_pszDiskUuid; /** UUID of image (if known, otherwise NULL) */ 118 static uint32_t g_cbSector; /** Disk sector size. */ 119 static char *g_pszDiskUuid; /** UUID of image (if known, otherwise NULL) */ 124 120 static off_t g_vDiskOffset; /** Biases r/w from start of VD */ 125 121 static off_t g_vDiskSize; /** Limits r/w length for VD */ … … 642 638 643 639 ppi->idxPartition = idxPartition; 644 ppi->offPartition = (off_t) pMbrPartitionEntry->partitionLba * BLOCKSIZE;645 ppi->cbPartition = (off_t) pMbrPartitionEntry->partitionBlkCnt * BLOCKSIZE;640 ppi->offPartition = (off_t) pMbrPartitionEntry->partitionLba * g_cbSector; 641 ppi->cbPartition = (off_t) pMbrPartitionEntry->partitionBlkCnt * g_cbSector; 646 642 ppi->fBootable = pMbrPartitionEntry->bootIndicator == 0x80; 647 643 ppi->partitionType.legacy = pMbrPartitionEntry->type; … … 689 685 if (!pEntry->firstLba) 690 686 break; 691 ppi->offPartition = pEntry->firstLba * BLOCKSIZE;692 ppi->cbPartition = (pEntry->lastLba - pEntry->firstLba) * BLOCKSIZE;687 ppi->offPartition = pEntry->firstLba * g_cbSector; 688 ppi->cbPartition = (pEntry->lastLba - pEntry->firstLba) * g_cbSector; 693 689 ppi->fBootable = pEntry->attrFlags & (1 << GPT_LEGACY_BIOS_BOOTABLE); 694 690 ppi->partitionType.gptGuidTypeSpecifier = pEntry->partitionTypeGuid; … … 708 704 uint32_t firstEbrLba 709 705 = g_aParsedPartitionInfo[idxEbrPartitionInMbr].partitionEntry.mbrEntry.partitionLba; 710 off_t firstEbrOffset = (off_t)firstEbrLba * BLOCKSIZE;706 off_t firstEbrOffset = (off_t)firstEbrLba * g_cbSector; 711 707 off_t chainedEbrOffset = 0; 712 708 … … 738 734 PARTITIONINFO *ppi = &g_aParsedPartitionInfo[idxPartition]; 739 735 ppi->idxPartition = idxPartition; 740 ppi->offPartition = currentEbrOffset + (off_t)pEbrPartitionEntry->partitionLba * BLOCKSIZE;741 ppi->cbPartition = (off_t)pEbrPartitionEntry->partitionBlkCnt * BLOCKSIZE;736 ppi->offPartition = currentEbrOffset + (off_t)pEbrPartitionEntry->partitionLba * g_cbSector; 737 ppi->cbPartition = (off_t)pEbrPartitionEntry->partitionBlkCnt * g_cbSector; 742 738 ppi->fBootable = pEbrPartitionEntry->bootIndicator == 0x80; 743 739 ppi->partitionType.legacy = pEbrPartitionEntry->type; … … 751 747 return RTMsgErrorExitFailure("Logical partition chain broken"); 752 748 753 chainedEbrOffset = ebr.chainingPartitionEntry.partitionLba * BLOCKSIZE;749 chainedEbrOffset = ebr.chainingPartitionEntry.partitionLba * g_cbSector; 754 750 } 755 751 } … … 825 821 if (colBoot) 826 822 tbl.setCell(row, colBoot, ppi->fBootable ? '*' : ' '); 827 tbl.setCell(row, colStart, ppi->offPartition / BLOCKSIZE);828 tbl.setCell(row, colSectors, ppi->cbPartition / BLOCKSIZE);823 tbl.setCell(row, colStart, ppi->offPartition / g_cbSector); 824 tbl.setCell(row, colSectors, ppi->cbPartition / g_cbSector); 829 825 tbl.setCell(row, colSize, vboximgScaledSize(ppi->cbPartition)); 830 826 tbl.setCell(row, colOffset, ppi->offPartition); … … 875 871 tbl.setCell(row, colPartition, g_pszBaseImageName, idxPartition); 876 872 tbl.setCell(row, colBoot, p->fBootable ? '*' : ' '); 877 tbl.setCell(row, colStart, p->offPartition / BLOCKSIZE);878 tbl.setCell(row, colSectors, p->cbPartition / BLOCKSIZE);873 tbl.setCell(row, colStart, p->offPartition / g_cbSector); 874 tbl.setCell(row, colSectors, p->cbPartition / g_cbSector); 879 875 tbl.setCell(row, colSize, vboximgScaledSize(p->cbPartition)); 880 876 tbl.setCell(row, colOffset, p->offPartition); … … 1232 1228 1233 1229 rc = VDOpen(pVDisk, 1234 CSTR(pszFormat),1230 pszFormat, 1235 1231 CSTR(pCurMedium->pImagePath), 1236 1232 pCurMedium->fWriteable, … … 1256 1252 if (RT_FAILURE(rc)) 1257 1253 return RTMsgErrorExitFailure("Error querying disk image size from VFS wrapper\n"); 1254 1255 g_cbSector = VDGetSectorSize(pVDisk, VD_LAST_IMAGE); 1258 1256 1259 1257 if (g_vboximgOpts.fList) … … 1318 1316 if (VERBOSE) 1319 1317 RTPrintf("\nPartition %d specified. Only sectors %llu to %llu of disk will be accessible\n", 1320 g_vboximgOpts.idxPartition, g_vDiskOffset / BLOCKSIZE, g_vDiskSize / BLOCKSIZE);1318 g_vboximgOpts.idxPartition, g_vDiskOffset / g_cbSector, g_vDiskSize / g_cbSector); 1321 1319 } 1322 1320 } … … 1330 1328 1331 1329 if (VERBOSE) 1332 RTPrintf("Setting r/w bias (offset) to user requested value for sector %llu\n", g_vDiskOffset / BLOCKSIZE);1330 RTPrintf("Setting r/w bias (offset) to user requested value for sector %llu\n", g_vDiskOffset / g_cbSector); 1333 1331 1334 1332 g_vDiskOffset = g_vboximgOpts.offset; … … 1339 1337 1340 1338 if (VERBOSE) 1341 RTPrintf("Setting r/w size limit to user requested value %llu\n", g_vDiskSize / BLOCKSIZE);1339 RTPrintf("Setting r/w size limit to user requested value %llu\n", g_vDiskSize / g_cbSector); 1342 1340 1343 1341 g_vDiskSize = g_vboximgOpts.size;
Note:
See TracChangeset
for help on using the changeset viewer.