static int enable_write_target(BlockDriverState *bs, Error **errp)

{

    BDRVVVFATState *s = bs->opaque;

    BlockDriver *bdrv_qcow = NULL;

    BlockDriverState *backing;

    QemuOpts *opts = NULL;

    int ret;

    int size = sector2cluster(s, s->sector_count);

    QDict *options;



    s->used_clusters = calloc(size, 1);



    array_init(&(s->commits), sizeof(commit_t));



    s->qcow_filename = g_malloc(PATH_MAX);

    ret = get_tmp_filename(s->qcow_filename, PATH_MAX);

    if (ret < 0) {

        error_setg_errno(errp, -ret, "can't create temporary file");

        goto err;

    }



    bdrv_qcow = bdrv_find_format("qcow");

    if (!bdrv_qcow) {

        error_setg(errp, "Failed to locate qcow driver");

        ret = -ENOENT;

        goto err;

    }



    opts = qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abort);

    qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512,

                        &error_abort);

    qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:", &error_abort);



    ret = bdrv_create(bdrv_qcow, s->qcow_filename, opts, errp);

    qemu_opts_del(opts);

    if (ret < 0) {

        goto err;

    }



    options = qdict_new();

    qdict_put(options, "write-target.driver", qstring_from_str("qcow"));

    s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs,

                              &child_vvfat_qcow, false, errp);

    QDECREF(options);

    if (!s->qcow) {

        ret = -EINVAL;

        goto err;

    }



#ifndef _WIN32

    unlink(s->qcow_filename);

#endif



    backing = bdrv_new();

    bdrv_set_backing_hd(s->bs, backing);

    bdrv_unref(backing);



    s->bs->backing->bs->drv = &vvfat_write_target;

    s->bs->backing->bs->opaque = g_new(void *, 1);

    *(void**)s->bs->backing->bs->opaque = s;



    return 0;



err:

    g_free(s->qcow_filename);

    s->qcow_filename = NULL;

    return ret;

}

static int enable_write_target(BlockDriverState *bs, Error **errp)

{

    BDRVVVFATState *s = bs->opaque;

    BlockDriver *bdrv_qcow = NULL;

    BlockDriverState *backing;

    QemuOpts *opts = NULL;

    int ret;

    int size = sector2cluster(s, s->sector_count);

    QDict *options;



    s->used_clusters = calloc(size, 1);



    array_init(&(s->commits), sizeof(commit_t));



    s->qcow_filename = g_malloc(PATH_MAX);

    ret = get_tmp_filename(s->qcow_filename, PATH_MAX);

    if (ret < 0) {

        error_setg_errno(errp, -ret, "can't create temporary file");

        goto err;

    }



    bdrv_qcow = bdrv_find_format("qcow");

    if (!bdrv_qcow) {

        error_setg(errp, "Failed to locate qcow driver");

        ret = -ENOENT;

        goto err;

    }



    opts = qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abort);

    qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512,

                        &error_abort);

    qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:", &error_abort);



    ret = bdrv_create(bdrv_qcow, s->qcow_filename, opts, errp);

    qemu_opts_del(opts);

    if (ret < 0) {

        goto err;

    }



    options = qdict_new();

    qdict_put(options, "write-target.driver", qstring_from_str("qcow"));

    s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs,

                              &child_vvfat_qcow, false, errp);

    QDECREF(options);

    if (!s->qcow) {

        ret = -EINVAL;

        goto err;

    }



#ifndef _WIN32

    unlink(s->qcow_filename);

#endif



    backing = bdrv_new();

    bdrv_set_backing_hd(s->bs, backing);

    bdrv_unref(backing);



    s->bs->backing->bs->drv = &vvfat_write_target;

    s->bs->backing->bs->opaque = g_new(void *, 1);

    *(void**)s->bs->backing->bs->opaque = s;



    return 0;



err:

    g_free(s->qcow_filename);

    s->qcow_filename = NULL;

    return ret;

}

    backing = bdrv_new();     s->bs->backing->bs->drv = &vvfat_write_target;     s->bs->backing->bs->opaque = g_new(void *, 1);     *(void**)s->bs->backing->bs->opaque = s;
static int FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)

{

    BDRVVVFATState *s = VAR_0->opaque;

    BlockDriver *bdrv_qcow = NULL;

    BlockDriverState *backing;

    QemuOpts *opts = NULL;

    int VAR_2;

    int VAR_3 = sector2cluster(s, s->sector_count);

    QDict *options;



    s->used_clusters = calloc(VAR_3, 1);



    array_init(&(s->commits), sizeof(commit_t));



    s->qcow_filename = g_malloc(PATH_MAX);

    VAR_2 = get_tmp_filename(s->qcow_filename, PATH_MAX);

    if (VAR_2 < 0) {

        error_setg_errno(VAR_1, -VAR_2, "can't create temporary file");

        goto err;

    }



    bdrv_qcow = bdrv_find_format("qcow");

    if (!bdrv_qcow) {

        error_setg(VAR_1, "Failed to locate qcow driver");

        VAR_2 = -ENOENT;

        goto err;

    }



    opts = qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abort);

    qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512,

                        &error_abort);

    qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:", &error_abort);



    VAR_2 = bdrv_create(bdrv_qcow, s->qcow_filename, opts, VAR_1);

    qemu_opts_del(opts);

    if (VAR_2 < 0) {

        goto err;

    }



    options = qdict_new();

    qdict_put(options, "write-target.driver", qstring_from_str("qcow"));

    s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", VAR_0,

                              &child_vvfat_qcow, false, VAR_1);

    QDECREF(options);

    if (!s->qcow) {

        VAR_2 = -EINVAL;

        goto err;

    }



#ifndef _WIN32

    unlink(s->qcow_filename);

#endif



    backing = bdrv_new();

    bdrv_set_backing_hd(s->VAR_0, backing);

    bdrv_unref(backing);



    s->VAR_0->backing->VAR_0->drv = &vvfat_write_target;

    s->VAR_0->backing->VAR_0->opaque = g_new(void *, 1);

    *(void**)s->VAR_0->backing->VAR_0->opaque = s;



    return 0;



err:

    g_free(s->qcow_filename);

    s->qcow_filename = NULL;

    return VAR_2;

}

static int FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)
{ BDRVVVFATState *s = VAR_0->opaque; BlockDriver *bdrv_qcow = NULL; BlockDriverState *backing; QemuOpts *opts = NULL; int VAR_2; int VAR_3 = sector2cluster(s, s->sector_count); QDict *options; s->used_clusters = calloc(VAR_3, 1); array_init(&(s->commits), sizeof(commit_t)); s->qcow_filename = g_malloc(PATH_MAX); VAR_2 = get_tmp_filename(s->qcow_filename, PATH_MAX); if (VAR_2 < 0) { error_setg_errno(VAR_1, -VAR_2, "can't create temporary file"); goto err; } bdrv_qcow = bdrv_find_format("qcow"); if (!bdrv_qcow) { error_setg(VAR_1, "Failed to locate qcow driver"); VAR_2 = -ENOENT; goto err; } opts = qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abort); qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512,
&error_abort); qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:", &error_abort); VAR_2 = bdrv_create(bdrv_qcow, s->qcow_filename, opts, VAR_1); qemu_opts_del(opts); if (VAR_2 < 0) { goto err; } options = qdict_new(); qdict_put(options, "write-target.driver", qstring_from_str("qcow")); s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", VAR_0,
&child_vvfat_qcow, false, VAR_1); QDECREF(options); if (!s->qcow) { VAR_2 = -EINVAL; goto err; } #ifndef _WIN32
unlink(s->qcow_filename); #endif
backing = bdrv_new(); bdrv_set_backing_hd(s->VAR_0, backing); bdrv_unref(backing); s->VAR_0->backing->VAR_0->drv = &vvfat_write_target; s->VAR_0->backing->VAR_0->opaque = g_new(void *, 1); *(void**)s->VAR_0->backing->VAR_0->opaque = s; return 0; err:
g_free(s->qcow_filename); s->qcow_filename = NULL; return VAR_2; }