VirtualBox

Changeset 3647 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 16, 2007 3:34:46 PM (18 years ago)
Author:
vboxsync
Message:

don't depend on the deprecated vl_vbox.h header anymore

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvVmdk.cpp

    r2981 r3647  
    6363#include <iprt/string.h>
    6464
    65 #include "vl_vbox.h"
    6665#include "Builtins.h"
    6766
     
    217216    if (buf_size < 4)
    218217        return 0;
    219     magic = be32_to_cpu(*(uint32_t *)buf);
     218    magic = RT_BE2H_U32(*(uint32_t *)buf);
    220219    if (magic == VMDK3_MAGIC ||
    221220        magic == VMDK4_MAGIC)
     
    261260        goto fail;
    262261
    263     magic = be32_to_cpu(magic);
     262    magic = RT_BE2H_U32(magic);
    264263    if (magic == VMDK3_MAGIC)
    265264    {
     
    269268        if (VBOX_FAILURE(rc))
    270269            goto fail;
    271         s->cluster_sectors = le32_to_cpu(header.granularity);
     270        s->cluster_sectors = RT_LE2H_U32(header.granularity);
    272271        s->l2_size = 1 << 9;
    273272        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;
    276275        s->l1_backup_table_offset = 0;
    277276        s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
    278277
    279278        /* 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);
    283282        pDisk->Geometry.cbSector = VMDK_GEOMETRY_SECTOR_SIZE;
    284283    }
     
    291290        if (VBOX_FAILURE(rc))
    292291            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);
    296295        s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
    297296        if (s->l1_entry_sectors <= 0)
     
    302301        s->l1_size = (s->total_sectors + s->l1_entry_sectors - 1)
    303302            / 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;
    306305
    307306        /* fill in the geometry structure */
     
    309308        //  of the Disk DescriptorFile. So, the below values are just a
    310309        //  quick hack.
    311         pDisk->Geometry.cCylinders = RT_MIN((le64_to_cpu(header.capacity) /
     310        pDisk->Geometry.cCylinders = RT_MIN((RT_LE2H_U64(header.capacity) /
    312311                                      (16 * 63)), 16383);
    313312        pDisk->Geometry.cHeads = 16;
     
    337336        goto fail;
    338337    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]);
    340339    }
    341340
     
    356355            goto fail;
    357356        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]);
    359358        }
    360359    }
     
    430429 found:
    431430    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]);
    433432    if (!cluster_offset) {
    434433        if (!allocate)
     
    444443        cluster_offset >>= 9;
    445444        /* update L2 table */
    446         tmp = cpu_to_le32(cluster_offset);
     445        tmp = RT_H2LE_U32(cluster_offset);
    447446        l2_table[l2_index] = tmp;
    448447        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.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette