static int vmdk_L2update(BlockDriverState *bs, VmdkMetaData *m_data)

{

    BDRVVmdkState *s = bs->opaque;



    /* update L2 table */

    if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),

                    &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))

        return -1;

    /* update backup L2 table */

    if (s->l1_backup_table_offset != 0) {

        m_data->l2_offset = s->l1_backup_table[m_data->l1_index];

        if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),

                        &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))

            return -1;

    }



    return 0;

}

static int vmdk_L2update(BlockDriverState *bs, VmdkMetaData *m_data)

{

    BDRVVmdkState *s = bs->opaque;



    

    if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),

                    &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))

        return -1;

    

    if (s->l1_backup_table_offset != 0) {

        m_data->l2_offset = s->l1_backup_table[m_data->l1_index];

        if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),

                        &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))

            return -1;

    }



    return 0;

}

    if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),                     &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))         if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),                         &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
static int FUNC_0(BlockDriverState *VAR_0, VmdkMetaData *VAR_1)

{

    BDRVVmdkState *s = VAR_0->opaque;



    

    if (bdrv_pwrite(VAR_0->file, ((int64_t)VAR_1->l2_offset * 512) + (VAR_1->l2_index * sizeof(VAR_1->offset)),

                    &(VAR_1->offset), sizeof(VAR_1->offset)) != sizeof(VAR_1->offset))

        return -1;

    

    if (s->l1_backup_table_offset != 0) {

        VAR_1->l2_offset = s->l1_backup_table[VAR_1->l1_index];

        if (bdrv_pwrite(VAR_0->file, ((int64_t)VAR_1->l2_offset * 512) + (VAR_1->l2_index * sizeof(VAR_1->offset)),

                        &(VAR_1->offset), sizeof(VAR_1->offset)) != sizeof(VAR_1->offset))

            return -1;

    }



    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, VmdkMetaData *VAR_1)
{ BDRVVmdkState *s = VAR_0->opaque; if (bdrv_pwrite(VAR_0->file, ((int64_t)VAR_1->l2_offset * 512) + (VAR_1->l2_index * sizeof(VAR_1->offset)),
&(VAR_1->offset), sizeof(VAR_1->offset)) != sizeof(VAR_1->offset))
return -1; if (s->l1_backup_table_offset != 0) { VAR_1->l2_offset = s->l1_backup_table[VAR_1->l1_index]; if (bdrv_pwrite(VAR_0->file, ((int64_t)VAR_1->l2_offset * 512) + (VAR_1->l2_index * sizeof(VAR_1->offset)),
&(VAR_1->offset), sizeof(VAR_1->offset)) != sizeof(VAR_1->offset))
return -1; } return 0; }