View | Details | Raw Unified | Return to bug 212139 | Differences between
and this patch

Collapse All | Expand All

(-)biosdisk.c (-9 / +10 lines)
Lines 497-503 Link Here
497
    char *buf, size_t *rsize)
497
    char *buf, size_t *rsize)
498
{
498
{
499
    struct disk_devdesc *dev = (struct disk_devdesc *)devdata;
499
    struct disk_devdesc *dev = (struct disk_devdesc *)devdata;
500
    int			blks;
500
    int			blks, remaining;
501
#ifdef BD_SUPPORT_FRAGS /* XXX: sector size */
501
#ifdef BD_SUPPORT_FRAGS /* XXX: sector size */
502
    char		fragbuf[BIOSDISK_SECSIZE];
502
    char		fragbuf[BIOSDISK_SECSIZE];
503
    size_t		fragsize;
503
    size_t		fragsize;
Lines 513-526 Link Here
513
    if (rsize)
513
    if (rsize)
514
	*rsize = 0;
514
	*rsize = 0;
515
515
516
    if (dblk >= BD(dev).bd_sectors) {
516
    /*
517
	DEBUG("IO past disk end %llu", (unsigned long long)dblk);
517
     * Perform partial read to prevent read-ahead crossing
518
	return (EIO);
518
     * the end of disk - or any 32 bit aliases of the end.
519
    }
519
     * Signed arithmetic is used to handle wrap-around cases
520
520
     * like we do for TCP sequence numbers.
521
    if (dblk + blks > BD(dev).bd_sectors) {
521
     */
522
	/* perform partial read */
522
    remaining = (int)(BD(dev).bd_sectors - dblk);	/* truncate */
523
	blks = BD(dev).bd_sectors - dblk;
523
    if (remaining > 0 && remaining < blks) {
524
	blks = remaining;
524
	size = blks * BD(dev).bd_sectorsize;
525
	size = blks * BD(dev).bd_sectorsize;
525
	DEBUG("short read %d", blks);
526
	DEBUG("short read %d", blks);
526
    }
527
    }

Return to bug 212139