Changeset 3647 in vbox for trunk/src/VBox
- Timestamp:
- Jul 16, 2007 3:34:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvVmdk.cpp
r2981 r3647 63 63 #include <iprt/string.h> 64 64 65 #include "vl_vbox.h"66 65 #include "Builtins.h" 67 66 … … 217 216 if (buf_size < 4) 218 217 return 0; 219 magic = be32_to_cpu(*(uint32_t *)buf);218 magic = RT_BE2H_U32(*(uint32_t *)buf); 220 219 if (magic == VMDK3_MAGIC || 221 220 magic == VMDK4_MAGIC) … … 261 260 goto fail; 262 261 263 magic = be32_to_cpu(magic);262 magic = RT_BE2H_U32(magic); 264 263 if (magic == VMDK3_MAGIC) 265 264 { … … 269 268 if (VBOX_FAILURE(rc)) 270 269 goto fail; 271 s->cluster_sectors = le32_to_cpu(header.granularity);270 s->cluster_sectors = RT_LE2H_U32(header.granularity); 272 271 s->l2_size = 1 << 9; 273 272 s->l1_size = 1 << 6; 274 s->total_sectors = le32_to_cpu(header.disk_sectors);275 s->l1_table_offset = le32_to_cpu(header.l1dir_offset) << 9;273 s->total_sectors = RT_LE2H_U32(header.disk_sectors); 274 s->l1_table_offset = RT_LE2H_U32(header.l1dir_offset) << 9; 276 275 s->l1_backup_table_offset = 0; 277 276 s->l1_entry_sectors = s->l2_size * s->cluster_sectors; 278 277 279 278 /* fill in the geometry structure */ 280 pDisk->Geometry.cCylinders = le32_to_cpu(header.cylinders);281 pDisk->Geometry.cHeads = le32_to_cpu(header.heads);282 pDisk->Geometry.cSectors = le32_to_cpu(header.sectors_per_track);279 pDisk->Geometry.cCylinders = RT_LE2H_U32(header.cylinders); 280 pDisk->Geometry.cHeads = RT_LE2H_U32(header.heads); 281 pDisk->Geometry.cSectors = RT_LE2H_U32(header.sectors_per_track); 283 282 pDisk->Geometry.cbSector = VMDK_GEOMETRY_SECTOR_SIZE; 284 283 } … … 291 290 if (VBOX_FAILURE(rc)) 292 291 goto fail; 293 s->total_sectors = le64_to_cpu(header.capacity);294 s->cluster_sectors = le64_to_cpu(header.granularity);295 s->l2_size = le32_to_cpu(header.num_gtes_per_gte);292 s->total_sectors = RT_LE2H_U64(header.capacity); 293 s->cluster_sectors = RT_LE2H_U64(header.granularity); 294 s->l2_size = RT_LE2H_U32(header.num_gtes_per_gte); 296 295 s->l1_entry_sectors = s->l2_size * s->cluster_sectors; 297 296 if (s->l1_entry_sectors <= 0) … … 302 301 s->l1_size = (s->total_sectors + s->l1_entry_sectors - 1) 303 302 / s->l1_entry_sectors; 304 s->l1_table_offset = le64_to_cpu(header.rgd_offset) << 9;305 s->l1_backup_table_offset = le64_to_cpu(header.gd_offset) << 9;303 s->l1_table_offset = RT_LE2H_U64(header.rgd_offset) << 9; 304 s->l1_backup_table_offset = RT_LE2H_U64(header.gd_offset) << 9; 306 305 307 306 /* fill in the geometry structure */ … … 309 308 // of the Disk DescriptorFile. So, the below values are just a 310 309 // quick hack. 311 pDisk->Geometry.cCylinders = RT_MIN(( le64_to_cpu(header.capacity) /310 pDisk->Geometry.cCylinders = RT_MIN((RT_LE2H_U64(header.capacity) / 312 311 (16 * 63)), 16383); 313 312 pDisk->Geometry.cHeads = 16; … … 337 336 goto fail; 338 337 for(i = 0; i < s->l1_size; i++) { 339 le32_to_cpus(&s->l1_table[i]);338 s->l1_table[i] = RT_LE2H_U32(s->l1_table[i]); 340 339 } 341 340 … … 356 355 goto fail; 357 356 for(i = 0; i < s->l1_size; i++) { 358 le32_to_cpus(&s->l1_backup_table[i]);357 s->l1_backup_table[i] = RT_LE2H_U32(s->l1_backup_table[i]); 359 358 } 360 359 } … … 430 429 found: 431 430 l2_index = ((offset >> 9) / s->cluster_sectors) % s->l2_size; 432 cluster_offset = le32_to_cpu(l2_table[l2_index]);431 cluster_offset = RT_LE2H_U32(l2_table[l2_index]); 433 432 if (!cluster_offset) { 434 433 if (!allocate) … … 444 443 cluster_offset >>= 9; 445 444 /* update L2 table */ 446 tmp = cpu_to_le32(cluster_offset);445 tmp = RT_H2LE_U32(cluster_offset); 447 446 l2_table[l2_index] = tmp; 448 447 rc = RTFileSeek(s->File, ((int64_t)l2_offset * VMDK_GEOMETRY_SECTOR_SIZE) + (l2_index * sizeof(tmp)), RTFILE_SEEK_BEGIN, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.