static int parallels_open(BlockDriverState *bs, int flags)

{

    BDRVParallelsState *s = bs->opaque;

    int i;

    struct parallels_header ph;



    bs->read_only = 1; // no write support yet



    if (bdrv_pread(bs->file, 0, &ph, sizeof(ph)) != sizeof(ph))

        goto fail;



    if (memcmp(ph.magic, HEADER_MAGIC, 16) ||

	(le32_to_cpu(ph.version) != HEADER_VERSION)) {

        goto fail;

    }



    bs->total_sectors = le32_to_cpu(ph.nb_sectors);



    s->tracks = le32_to_cpu(ph.tracks);



    s->catalog_size = le32_to_cpu(ph.catalog_entries);

    s->catalog_bitmap = g_malloc(s->catalog_size * 4);

    if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=

	s->catalog_size * 4)

	goto fail;

    for (i = 0; i < s->catalog_size; i++)

	le32_to_cpus(&s->catalog_bitmap[i]);



    qemu_co_mutex_init(&s->lock);

    return 0;

fail:

    if (s->catalog_bitmap)

	g_free(s->catalog_bitmap);

    return -1;

}

static int parallels_open(BlockDriverState *bs, int flags)

{

    BDRVParallelsState *s = bs->opaque;

    int i;

    struct parallels_header ph;



    bs->read_only = 1; 



    if (bdrv_pread(bs->file, 0, &ph, sizeof(ph)) != sizeof(ph))

        goto fail;



    if (memcmp(ph.magic, HEADER_MAGIC, 16) ||

	(le32_to_cpu(ph.version) != HEADER_VERSION)) {

        goto fail;

    }



    bs->total_sectors = le32_to_cpu(ph.nb_sectors);



    s->tracks = le32_to_cpu(ph.tracks);



    s->catalog_size = le32_to_cpu(ph.catalog_entries);

    s->catalog_bitmap = g_malloc(s->catalog_size * 4);

    if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=

	s->catalog_size * 4)

	goto fail;

    for (i = 0; i < s->catalog_size; i++)

	le32_to_cpus(&s->catalog_bitmap[i]);



    qemu_co_mutex_init(&s->lock);

    return 0;

fail:

    if (s->catalog_bitmap)

	g_free(s->catalog_bitmap);

    return -1;

}

    if (bdrv_pread(bs->file, 0, &ph, sizeof(ph)) != sizeof(ph)) 	(le32_to_cpu(ph.version) != HEADER_VERSION)) {     if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) != 	s->catalog_size * 4) 	goto fail;     if (s->catalog_bitmap) 	g_free(s->catalog_bitmap);     return -1;
static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)

{

    BDRVParallelsState *s = VAR_0->opaque;

    int VAR_2;

    struct parallels_header VAR_3;



    VAR_0->read_only = 1; 



    if (bdrv_pread(VAR_0->file, 0, &VAR_3, sizeof(VAR_3)) != sizeof(VAR_3))

        goto fail;



    if (memcmp(VAR_3.magic, HEADER_MAGIC, 16) ||

	(le32_to_cpu(VAR_3.version) != HEADER_VERSION)) {

        goto fail;

    }



    VAR_0->total_sectors = le32_to_cpu(VAR_3.nb_sectors);



    s->tracks = le32_to_cpu(VAR_3.tracks);



    s->catalog_size = le32_to_cpu(VAR_3.catalog_entries);

    s->catalog_bitmap = g_malloc(s->catalog_size * 4);

    if (bdrv_pread(VAR_0->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=

	s->catalog_size * 4)

	goto fail;

    for (VAR_2 = 0; VAR_2 < s->catalog_size; VAR_2++)

	le32_to_cpus(&s->catalog_bitmap[VAR_2]);



    qemu_co_mutex_init(&s->lock);

    return 0;

fail:

    if (s->catalog_bitmap)

	g_free(s->catalog_bitmap);

    return -1;

}

static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)
{ BDRVParallelsState *s = VAR_0->opaque; int VAR_2; struct parallels_header VAR_3; VAR_0->read_only = 1; if (bdrv_pread(VAR_0->file, 0, &VAR_3, sizeof(VAR_3)) != sizeof(VAR_3))
goto fail; if (memcmp(VAR_3.magic, HEADER_MAGIC, 16) ||
(le32_to_cpu(VAR_3.version) != HEADER_VERSION)) { goto fail; } VAR_0->total_sectors = le32_to_cpu(VAR_3.nb_sectors); s->tracks = le32_to_cpu(VAR_3.tracks); s->catalog_size = le32_to_cpu(VAR_3.catalog_entries); s->catalog_bitmap = g_malloc(s->catalog_size * 4); if (bdrv_pread(VAR_0->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=
s->catalog_size * 4)
goto fail; for (VAR_2 = 0; VAR_2 < s->catalog_size; VAR_2++) le32_to_cpus(&s->catalog_bitmap[VAR_2]); qemu_co_mutex_init(&s->lock); return 0; fail:
if (s->catalog_bitmap)
g_free(s->catalog_bitmap); return -1; }