static int vmdk_open_desc_file(BlockDriverState *bs, int flags,

                               int64_t desc_offset)

{

    int ret;

    char buf[2048];

    char ct[128];

    BDRVVmdkState *s = bs->opaque;



    ret = bdrv_pread(bs->file, desc_offset, buf, sizeof(buf));

    if (ret < 0) {

        return ret;

    }

    buf[2047] = '\0';

    if (vmdk_parse_description(buf, "createType", ct, sizeof(ct))) {

        return -EINVAL;

    }

    if (strcmp(ct, "monolithicFlat") &&

        strcmp(ct, "twoGbMaxExtentSparse") &&

        strcmp(ct, "twoGbMaxExtentFlat")) {

        fprintf(stderr,

                "VMDK: Not supported image type \"%s\""".\n", ct);

        return -ENOTSUP;

    }

    s->desc_offset = 0;

    ret = vmdk_parse_extents(buf, bs, bs->file->filename);

    if (ret) {

        return ret;

    }



    /* try to open parent images, if exist */

    if (vmdk_parent_open(bs)) {

        g_free(s->extents);

        return -EINVAL;

    }

    s->parent_cid = vmdk_read_cid(bs, 1);

    return 0;

}

static int vmdk_open_desc_file(BlockDriverState *bs, int flags,

                               int64_t desc_offset)

{

    int ret;

    char buf[2048];

    char ct[128];

    BDRVVmdkState *s = bs->opaque;



    ret = bdrv_pread(bs->file, desc_offset, buf, sizeof(buf));

    if (ret < 0) {

        return ret;

    }

    buf[2047] = '\0';

    if (vmdk_parse_description(buf, "createType", ct, sizeof(ct))) {

        return -EINVAL;

    }

    if (strcmp(ct, "monolithicFlat") &&

        strcmp(ct, "twoGbMaxExtentSparse") &&

        strcmp(ct, "twoGbMaxExtentFlat")) {

        fprintf(stderr,

                "VMDK: Not supported image type \"%s\""".\n", ct);

        return -ENOTSUP;

    }

    s->desc_offset = 0;

    ret = vmdk_parse_extents(buf, bs, bs->file->filename);

    if (ret) {

        return ret;

    }



    

    if (vmdk_parent_open(bs)) {

        g_free(s->extents);

        return -EINVAL;

    }

    s->parent_cid = vmdk_read_cid(bs, 1);

    return 0;

}

        g_free(s->extents);
static int FUNC_0(BlockDriverState *VAR_0, int VAR_1,

                               int64_t VAR_2)

{

    int VAR_3;

    char VAR_4[2048];

    char VAR_5[128];

    BDRVVmdkState *s = VAR_0->opaque;



    VAR_3 = bdrv_pread(VAR_0->file, VAR_2, VAR_4, sizeof(VAR_4));

    if (VAR_3 < 0) {

        return VAR_3;

    }

    VAR_4[2047] = '\0';

    if (vmdk_parse_description(VAR_4, "createType", VAR_5, sizeof(VAR_5))) {

        return -EINVAL;

    }

    if (strcmp(VAR_5, "monolithicFlat") &&

        strcmp(VAR_5, "twoGbMaxExtentSparse") &&

        strcmp(VAR_5, "twoGbMaxExtentFlat")) {

        fprintf(stderr,

                "VMDK: Not supported image type \"%s\""".\n", VAR_5);

        return -ENOTSUP;

    }

    s->VAR_2 = 0;

    VAR_3 = vmdk_parse_extents(VAR_4, VAR_0, VAR_0->file->filename);

    if (VAR_3) {

        return VAR_3;

    }



    

    if (vmdk_parent_open(VAR_0)) {

        g_free(s->extents);

        return -EINVAL;

    }

    s->parent_cid = vmdk_read_cid(VAR_0, 1);

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, int VAR_1,
int64_t VAR_2)
{ int VAR_3; char VAR_4[2048]; char VAR_5[128]; BDRVVmdkState *s = VAR_0->opaque; VAR_3 = bdrv_pread(VAR_0->file, VAR_2, VAR_4, sizeof(VAR_4)); if (VAR_3 < 0) { return VAR_3; } VAR_4[2047] = '\0'; if (vmdk_parse_description(VAR_4, "createType", VAR_5, sizeof(VAR_5))) { return -EINVAL; } if (strcmp(VAR_5, "monolithicFlat") &&
strcmp(VAR_5, "twoGbMaxExtentSparse") &&
strcmp(VAR_5, "twoGbMaxExtentFlat")) { fprintf(stderr,
"VMDK: Not supported image type \"%s\""".\n", VAR_5); return -ENOTSUP; } s->VAR_2 = 0; VAR_3 = vmdk_parse_extents(VAR_4, VAR_0, VAR_0->file->filename); if (VAR_3) { return VAR_3; } if (vmdk_parent_open(VAR_0)) { g_free(s->extents); return -EINVAL; } s->parent_cid = vmdk_read_cid(VAR_0, 1); return 0; }