static int raw_open(BlockDriverState *bs, QDict *options, int flags,

                    Error **errp)

{

    BDRVRawState *s = bs->opaque;

    int access_flags;

    DWORD overlapped;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *filename;

    int ret;



    s->type = FTYPE_FILE;



    opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);

    qemu_opts_absorb_qdict(opts, options, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    filename = qemu_opt_get(opts, "filename");



    raw_parse_flags(flags, &access_flags, &overlapped);



    if (filename[0] && filename[1] == ':') {

        snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", filename[0]);

    } else if (filename[0] == '\\' && filename[1] == '\\') {

        s->drive_path[0] = 0;

    } else {

        /* Relative path.  */

        char buf[MAX_PATH];

        GetCurrentDirectory(MAX_PATH, buf);

        snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", buf[0]);

    }



    s->hfile = CreateFile(filename, access_flags,

                          FILE_SHARE_READ, NULL,

                          OPEN_EXISTING, overlapped, NULL);

    if (s->hfile == INVALID_HANDLE_VALUE) {

        int err = GetLastError();



        if (err == ERROR_ACCESS_DENIED) {

            ret = -EACCES;

        } else {

            ret = -EINVAL;

        }

        goto fail;

    }



    if (flags & BDRV_O_NATIVE_AIO) {

        s->aio = win32_aio_init();

        if (s->aio == NULL) {

            CloseHandle(s->hfile);

            error_setg(errp, "Could not initialize AIO");

            ret = -EINVAL;

            goto fail;

        }



        ret = win32_aio_attach(s->aio, s->hfile);

        if (ret < 0) {

            win32_aio_cleanup(s->aio);

            CloseHandle(s->hfile);

            error_setg_errno(errp, -ret, "Could not enable AIO");

            goto fail;

        }



        win32_aio_attach_aio_context(s->aio, bdrv_get_aio_context(bs));

    }



    raw_probe_alignment(bs);

    ret = 0;

fail:

    qemu_opts_del(opts);

    return ret;

}

static int raw_open(BlockDriverState *bs, QDict *options, int flags,

                    Error **errp)

{

    BDRVRawState *s = bs->opaque;

    int access_flags;

    DWORD overlapped;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *filename;

    int ret;



    s->type = FTYPE_FILE;



    opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);

    qemu_opts_absorb_qdict(opts, options, &local_err);

    if (local_err) {

        error_propagate(errp, local_err);

        ret = -EINVAL;

        goto fail;

    }



    filename = qemu_opt_get(opts, "filename");



    raw_parse_flags(flags, &access_flags, &overlapped);



    if (filename[0] && filename[1] == ':') {

        snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", filename[0]);

    } else if (filename[0] == '\\' && filename[1] == '\\') {

        s->drive_path[0] = 0;

    } else {

        

        char buf[MAX_PATH];

        GetCurrentDirectory(MAX_PATH, buf);

        snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", buf[0]);

    }



    s->hfile = CreateFile(filename, access_flags,

                          FILE_SHARE_READ, NULL,

                          OPEN_EXISTING, overlapped, NULL);

    if (s->hfile == INVALID_HANDLE_VALUE) {

        int err = GetLastError();



        if (err == ERROR_ACCESS_DENIED) {

            ret = -EACCES;

        } else {

            ret = -EINVAL;

        }

        goto fail;

    }



    if (flags & BDRV_O_NATIVE_AIO) {

        s->aio = win32_aio_init();

        if (s->aio == NULL) {

            CloseHandle(s->hfile);

            error_setg(errp, "Could not initialize AIO");

            ret = -EINVAL;

            goto fail;

        }



        ret = win32_aio_attach(s->aio, s->hfile);

        if (ret < 0) {

            win32_aio_cleanup(s->aio);

            CloseHandle(s->hfile);

            error_setg_errno(errp, -ret, "Could not enable AIO");

            goto fail;

        }



        win32_aio_attach_aio_context(s->aio, bdrv_get_aio_context(bs));

    }



    raw_probe_alignment(bs);

    ret = 0;

fail:

    qemu_opts_del(opts);

    return ret;

}

static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,

                    Error **VAR_3)

{

    BDRVRawState *s = VAR_0->opaque;

    int VAR_4;

    DWORD overlapped;

    QemuOpts *opts;

    Error *local_err = NULL;

    const char *VAR_5;

    int VAR_6;



    s->type = FTYPE_FILE;



    opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);

    qemu_opts_absorb_qdict(opts, VAR_1, &local_err);

    if (local_err) {

        error_propagate(VAR_3, local_err);

        VAR_6 = -EINVAL;

        goto fail;

    }



    VAR_5 = qemu_opt_get(opts, "VAR_5");



    raw_parse_flags(VAR_2, &VAR_4, &overlapped);



    if (VAR_5[0] && VAR_5[1] == ':') {

        snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", VAR_5[0]);

    } else if (VAR_5[0] == '\\' && VAR_5[1] == '\\') {

        s->drive_path[0] = 0;

    } else {

        

        char VAR_7[MAX_PATH];

        GetCurrentDirectory(MAX_PATH, VAR_7);

        snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", VAR_7[0]);

    }



    s->hfile = CreateFile(VAR_5, VAR_4,

                          FILE_SHARE_READ, NULL,

                          OPEN_EXISTING, overlapped, NULL);

    if (s->hfile == INVALID_HANDLE_VALUE) {

        int VAR_8 = GetLastError();



        if (VAR_8 == ERROR_ACCESS_DENIED) {

            VAR_6 = -EACCES;

        } else {

            VAR_6 = -EINVAL;

        }

        goto fail;

    }



    if (VAR_2 & BDRV_O_NATIVE_AIO) {

        s->aio = win32_aio_init();

        if (s->aio == NULL) {

            CloseHandle(s->hfile);

            error_setg(VAR_3, "Could not initialize AIO");

            VAR_6 = -EINVAL;

            goto fail;

        }



        VAR_6 = win32_aio_attach(s->aio, s->hfile);

        if (VAR_6 < 0) {

            win32_aio_cleanup(s->aio);

            CloseHandle(s->hfile);

            error_setg_errno(VAR_3, -VAR_6, "Could not enable AIO");

            goto fail;

        }



        win32_aio_attach_aio_context(s->aio, bdrv_get_aio_context(VAR_0));

    }



    raw_probe_alignment(VAR_0);

    VAR_6 = 0;

fail:

    qemu_opts_del(opts);

    return VAR_6;

}

static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,
Error **VAR_3)
{ BDRVRawState *s = VAR_0->opaque; int VAR_4; DWORD overlapped; QemuOpts *opts; Error *local_err = NULL; const char *VAR_5; int VAR_6; s->type = FTYPE_FILE; opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, VAR_1, &local_err); if (local_err) { error_propagate(VAR_3, local_err); VAR_6 = -EINVAL; goto fail; } VAR_5 = qemu_opt_get(opts, "VAR_5"); raw_parse_flags(VAR_2, &VAR_4, &overlapped); if (VAR_5[0] && VAR_5[1] == ':') { snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", VAR_5[0]); } else if (VAR_5[0] == '\\' && VAR_5[1] == '\\') { s->drive_path[0] = 0; } else { char VAR_7[MAX_PATH]; GetCurrentDirectory(MAX_PATH, VAR_7); snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", VAR_7[0]); } s->hfile = CreateFile(VAR_5, VAR_4,
FILE_SHARE_READ, NULL,
OPEN_EXISTING, overlapped, NULL); if (s->hfile == INVALID_HANDLE_VALUE) { int VAR_8 = GetLastError(); if (VAR_8 == ERROR_ACCESS_DENIED) { VAR_6 = -EACCES; } else { VAR_6 = -EINVAL; } goto fail; } if (VAR_2 & BDRV_O_NATIVE_AIO) { s->aio = win32_aio_init(); if (s->aio == NULL) { CloseHandle(s->hfile); error_setg(VAR_3, "Could not initialize AIO"); VAR_6 = -EINVAL; goto fail; } VAR_6 = win32_aio_attach(s->aio, s->hfile); if (VAR_6 < 0) { win32_aio_cleanup(s->aio); CloseHandle(s->hfile); error_setg_errno(VAR_3, -VAR_6, "Could not enable AIO"); goto fail; } win32_aio_attach_aio_context(s->aio, bdrv_get_aio_context(VAR_0)); } raw_probe_alignment(VAR_0); VAR_6 = 0; fail:
qemu_opts_del(opts); return VAR_6; }