static int refresh_total_sectors(BlockDriverState *bs, int64_t hint)

{

    BlockDriver *drv = bs->drv;



    /* Do not attempt drv->bdrv_getlength() on scsi-generic devices */

    if (bs->sg)

        return 0;



    /* query actual device if possible, otherwise just trust the hint */

    if (drv->bdrv_getlength) {

        int64_t length = drv->bdrv_getlength(bs);

        if (length < 0) {

            return length;

        }

        hint = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE);

    }



    bs->total_sectors = hint;

    return 0;

}

static int refresh_total_sectors(BlockDriverState *bs, int64_t hint)

{

    BlockDriver *drv = bs->drv;



    

    if (bs->sg)

        return 0;



    

    if (drv->bdrv_getlength) {

        int64_t length = drv->bdrv_getlength(bs);

        if (length < 0) {

            return length;

        }

        hint = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE);

    }



    bs->total_sectors = hint;

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1)

{

    BlockDriver *drv = VAR_0->drv;



    

    if (VAR_0->sg)

        return 0;



    

    if (drv->bdrv_getlength) {

        int64_t length = drv->bdrv_getlength(VAR_0);

        if (length < 0) {

            return length;

        }

        VAR_1 = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE);

    }



    VAR_0->total_sectors = VAR_1;

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1)
{ BlockDriver *drv = VAR_0->drv; if (VAR_0->sg)
return 0; if (drv->bdrv_getlength) { int64_t length = drv->bdrv_getlength(VAR_0); if (length < 0) { return length; } VAR_1 = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE); } VAR_0->total_sectors = VAR_1; return 0; }