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

{

    BDRVRawState *s = bs->opaque;

    int ret;



    posix_aio_init();



    s->type = FTYPE_FD;



    /* open will not fail even if no floppy is inserted, so add O_NONBLOCK */

    ret = raw_open_common(bs, filename, flags, O_NONBLOCK);

    if (ret)

        return ret;



    /* close fd so that we can reopen it as needed */

    close(s->fd);

    s->fd = -1;

    s->fd_media_changed = 1;



    return 0;

}

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

{

    BDRVRawState *s = bs->opaque;

    int ret;



    posix_aio_init();



    s->type = FTYPE_FD;



    

    ret = raw_open_common(bs, filename, flags, O_NONBLOCK);

    if (ret)

        return ret;



    

    close(s->fd);

    s->fd = -1;

    s->fd_media_changed = 1;



    return 0;

}

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

{

    BDRVRawState *s = VAR_0->opaque;

    int VAR_3;



    posix_aio_init();



    s->type = FTYPE_FD;



    

    VAR_3 = raw_open_common(VAR_0, VAR_1, VAR_2, O_NONBLOCK);

    if (VAR_3)

        return VAR_3;



    

    close(s->fd);

    s->fd = -1;

    s->fd_media_changed = 1;



    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2)
{ BDRVRawState *s = VAR_0->opaque; int VAR_3; posix_aio_init(); s->type = FTYPE_FD; VAR_3 = raw_open_common(VAR_0, VAR_1, VAR_2, O_NONBLOCK); if (VAR_3)
return VAR_3; close(s->fd); s->fd = -1; s->fd_media_changed = 1; return 0; }