static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,

                     uint8_t *buf, int count)

{

    BDRVRawState *s = bs->opaque;

    int ret;



    ret = fd_open(bs);

    if (ret < 0)

        return ret;



    ret = pread(s->fd, buf, count, offset);

    if (ret == count)

        goto label__raw_read__success;



    /* Allow reads beyond the end (needed for pwrite) */

    if ((ret == 0) && bs->growable) {

        int64_t size = raw_getlength(bs);

        if (offset >= size) {

            memset(buf, 0, count);

            ret = count;

            goto label__raw_read__success;

        }

    }



    DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64

                      "] read failed %d : %d = %s\n",

                      s->fd, bs->filename, offset, buf, count,

                      bs->total_sectors, ret, errno, strerror(errno));



    /* Try harder for CDrom. */

    if (bs->type == BDRV_TYPE_CDROM) {

        ret = pread(s->fd, buf, count, offset);

        if (ret == count)

            goto label__raw_read__success;

        ret = pread(s->fd, buf, count, offset);

        if (ret == count)

            goto label__raw_read__success;



        DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64

                          "] retry read failed %d : %d = %s\n",

                          s->fd, bs->filename, offset, buf, count,

                          bs->total_sectors, ret, errno, strerror(errno));

    }



label__raw_read__success:



    return  (ret < 0) ? -errno : ret;

}

static int raw_pread_aligned(BlockDriverState *bs, int64_t offset,

                     uint8_t *buf, int count)

{

    BDRVRawState *s = bs->opaque;

    int ret;



    ret = fd_open(bs);

    if (ret < 0)

        return ret;



    ret = pread(s->fd, buf, count, offset);

    if (ret == count)

        goto label__raw_read__success;



    

    if ((ret == 0) && bs->growable) {

        int64_t size = raw_getlength(bs);

        if (offset >= size) {

            memset(buf, 0, count);

            ret = count;

            goto label__raw_read__success;

        }

    }



    DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64

                      "] read failed %d : %d = %s\n",

                      s->fd, bs->filename, offset, buf, count,

                      bs->total_sectors, ret, errno, strerror(errno));



    

    if (bs->type == BDRV_TYPE_CDROM) {

        ret = pread(s->fd, buf, count, offset);

        if (ret == count)

            goto label__raw_read__success;

        ret = pread(s->fd, buf, count, offset);

        if (ret == count)

            goto label__raw_read__success;



        DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64

                          "] retry read failed %d : %d = %s\n",

                          s->fd, bs->filename, offset, buf, count,

                          bs->total_sectors, ret, errno, strerror(errno));

    }



label__raw_read__success:



    return  (ret < 0) ? -errno : ret;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,

                     uint8_t *VAR_2, int VAR_3)

{

    BDRVRawState *s = VAR_0->opaque;

    int VAR_4;



    VAR_4 = fd_open(VAR_0);

    if (VAR_4 < 0)

        return VAR_4;



    VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);

    if (VAR_4 == VAR_3)

        goto label__raw_read__success;



    

    if ((VAR_4 == 0) && VAR_0->growable) {

        int64_t size = raw_getlength(VAR_0);

        if (VAR_1 >= size) {

            memset(VAR_2, 0, VAR_3);

            VAR_4 = VAR_3;

            goto label__raw_read__success;

        }

    }



    DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64

                      "] read failed %d : %d = %s\n",

                      s->fd, VAR_0->filename, VAR_1, VAR_2, VAR_3,

                      VAR_0->total_sectors, VAR_4, errno, strerror(errno));



    

    if (VAR_0->type == BDRV_TYPE_CDROM) {

        VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);

        if (VAR_4 == VAR_3)

            goto label__raw_read__success;

        VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1);

        if (VAR_4 == VAR_3)

            goto label__raw_read__success;



        DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64

                          "] retry read failed %d : %d = %s\n",

                          s->fd, VAR_0->filename, VAR_1, VAR_2, VAR_3,

                          VAR_0->total_sectors, VAR_4, errno, strerror(errno));

    }



label__raw_read__success:



    return  (VAR_4 < 0) ? -errno : VAR_4;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
uint8_t *VAR_2, int VAR_3)
{ BDRVRawState *s = VAR_0->opaque; int VAR_4; VAR_4 = fd_open(VAR_0); if (VAR_4 < 0)
return VAR_4; VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1); if (VAR_4 == VAR_3)
goto label__raw_read__success; if ((VAR_4 == 0) && VAR_0->growable) { int64_t size = raw_getlength(VAR_0); if (VAR_1 >= size) { memset(VAR_2, 0, VAR_3); VAR_4 = VAR_3; goto label__raw_read__success; } } DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] read failed %d : %d = %s\n",
s->fd, VAR_0->filename, VAR_1, VAR_2, VAR_3,
VAR_0->total_sectors, VAR_4, errno, strerror(errno)); if (VAR_0->type == BDRV_TYPE_CDROM) { VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1); if (VAR_4 == VAR_3)
goto label__raw_read__success; VAR_4 = pread(s->fd, VAR_2, VAR_3, VAR_1); if (VAR_4 == VAR_3)
goto label__raw_read__success; DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] retry read failed %d : %d = %s\n",
s->fd, VAR_0->filename, VAR_1, VAR_2, VAR_3,
VAR_0->total_sectors, VAR_4, errno, strerror(errno)); } label__raw_read__success:
return  (VAR_4 < 0) ? -errno : VAR_4; }