static int blkverify_open(BlockDriverState *bs, const char *filename, int flags)

{

    BDRVBlkverifyState *s = bs->opaque;

    int ret;

    char *raw, *c;



    /* Parse the blkverify: prefix */

    if (strncmp(filename, "blkverify:", strlen("blkverify:"))) {

        return -EINVAL;

    }

    filename += strlen("blkverify:");



    /* Parse the raw image filename */

    c = strchr(filename, ':');

    if (c == NULL) {

        return -EINVAL;

    }



    raw = strdup(filename);

    raw[c - filename] = '\0';

    ret = bdrv_file_open(&bs->file, raw, flags);

    free(raw);

    if (ret < 0) {

        return ret;

    }

    filename = c + 1;



    /* Open the test file */

    s->test_file = bdrv_new("");

    ret = bdrv_open(s->test_file, filename, flags, NULL);

    if (ret < 0) {

        bdrv_delete(s->test_file);

        s->test_file = NULL;

        return ret;

    }



    return 0;

}

static int blkverify_open(BlockDriverState *bs, const char *filename, int flags)

{

    BDRVBlkverifyState *s = bs->opaque;

    int ret;

    char *raw, *c;



    

    if (strncmp(filename, "blkverify:", strlen("blkverify:"))) {

        return -EINVAL;

    }

    filename += strlen("blkverify:");



    

    c = strchr(filename, ':');

    if (c == NULL) {

        return -EINVAL;

    }



    raw = strdup(filename);

    raw[c - filename] = '\0';

    ret = bdrv_file_open(&bs->file, raw, flags);

    free(raw);

    if (ret < 0) {

        return ret;

    }

    filename = c + 1;



    

    s->test_file = bdrv_new("");

    ret = bdrv_open(s->test_file, filename, flags, NULL);

    if (ret < 0) {

        bdrv_delete(s->test_file);

        s->test_file = NULL;

        return ret;

    }



    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2)

{

    BDRVBlkverifyState *s = VAR_0->opaque;

    int VAR_3;

    char *VAR_4, *VAR_5;



    

    if (strncmp(VAR_1, "blkverify:", strlen("blkverify:"))) {

        return -EINVAL;

    }

    VAR_1 += strlen("blkverify:");



    

    VAR_5 = strchr(VAR_1, ':');

    if (VAR_5 == NULL) {

        return -EINVAL;

    }



    VAR_4 = strdup(VAR_1);

    VAR_4[VAR_5 - VAR_1] = '\0';

    VAR_3 = bdrv_file_open(&VAR_0->file, VAR_4, VAR_2);

    free(VAR_4);

    if (VAR_3 < 0) {

        return VAR_3;

    }

    VAR_1 = VAR_5 + 1;



    

    s->test_file = bdrv_new("");

    VAR_3 = bdrv_open(s->test_file, VAR_1, VAR_2, NULL);

    if (VAR_3 < 0) {

        bdrv_delete(s->test_file);

        s->test_file = NULL;

        return VAR_3;

    }



    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2)
{ BDRVBlkverifyState *s = VAR_0->opaque; int VAR_3; char *VAR_4, *VAR_5; if (strncmp(VAR_1, "blkverify:", strlen("blkverify:"))) { return -EINVAL; } VAR_1 += strlen("blkverify:"); VAR_5 = strchr(VAR_1, ':'); if (VAR_5 == NULL) { return -EINVAL; } VAR_4 = strdup(VAR_1); VAR_4[VAR_5 - VAR_1] = '\0'; VAR_3 = bdrv_file_open(&VAR_0->file, VAR_4, VAR_2); free(VAR_4); if (VAR_3 < 0) { return VAR_3; } VAR_1 = VAR_5 + 1; s->test_file = bdrv_new(""); VAR_3 = bdrv_open(s->test_file, VAR_1, VAR_2, NULL); if (VAR_3 < 0) { bdrv_delete(s->test_file); s->test_file = NULL; return VAR_3; } return 0; }