static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)

{

    char desc[DESC_SIZE], tmp_desc[DESC_SIZE];

    char *p_name, *tmp_str;

    BDRVVmdkState *s = bs->opaque;



    memset(desc, 0, sizeof(desc));

    if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) {

        return -EIO;

    }



    tmp_str = strstr(desc,"parentCID");

    pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str);

    if ((p_name = strstr(desc,"CID")) != NULL) {

        p_name += sizeof("CID");

        snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid);

        pstrcat(desc, sizeof(desc), tmp_desc);

    }



    if (bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE) < 0) {

        return -EIO;

    }

    return 0;

}

static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)

{

    char desc[DESC_SIZE], tmp_desc[DESC_SIZE];

    char *p_name, *tmp_str;

    BDRVVmdkState *s = bs->opaque;



    memset(desc, 0, sizeof(desc));

    if (bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE) != DESC_SIZE) {

        return -EIO;

    }



    tmp_str = strstr(desc,"parentCID");

    pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str);

    if ((p_name = strstr(desc,"CID")) != NULL) {

        p_name += sizeof("CID");

        snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid);

        pstrcat(desc, sizeof(desc), tmp_desc);

    }



    if (bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE) < 0) {

        return -EIO;

    }

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, uint32_t VAR_1)

{

    char VAR_2[DESC_SIZE], tmp_desc[DESC_SIZE];

    char *VAR_3, *VAR_4;

    BDRVVmdkState *s = VAR_0->opaque;



    memset(VAR_2, 0, sizeof(VAR_2));

    if (bdrv_pread(VAR_0->file, s->desc_offset, VAR_2, DESC_SIZE) != DESC_SIZE) {

        return -EIO;

    }



    VAR_4 = strstr(VAR_2,"parentCID");

    pstrcpy(tmp_desc, sizeof(tmp_desc), VAR_4);

    if ((VAR_3 = strstr(VAR_2,"CID")) != NULL) {

        VAR_3 += sizeof("CID");

        snprintf(VAR_3, sizeof(VAR_2) - (VAR_3 - VAR_2), "%x\n", VAR_1);

        pstrcat(VAR_2, sizeof(VAR_2), tmp_desc);

    }



    if (bdrv_pwrite_sync(VAR_0->file, s->desc_offset, VAR_2, DESC_SIZE) < 0) {

        return -EIO;

    }

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, uint32_t VAR_1)
{ char VAR_2[DESC_SIZE], tmp_desc[DESC_SIZE]; char *VAR_3, *VAR_4; BDRVVmdkState *s = VAR_0->opaque; memset(VAR_2, 0, sizeof(VAR_2)); if (bdrv_pread(VAR_0->file, s->desc_offset, VAR_2, DESC_SIZE) != DESC_SIZE) { return -EIO; } VAR_4 = strstr(VAR_2,"parentCID"); pstrcpy(tmp_desc, sizeof(tmp_desc), VAR_4); if ((VAR_3 = strstr(VAR_2,"CID")) != NULL) { VAR_3 += sizeof("CID"); snprintf(VAR_3, sizeof(VAR_2) - (VAR_3 - VAR_2), "%x\n", VAR_1); pstrcat(VAR_2, sizeof(VAR_2), tmp_desc); } if (bdrv_pwrite_sync(VAR_0->file, s->desc_offset, VAR_2, DESC_SIZE) < 0) { return -EIO; } return 0; }