From 44b50138620ff5d3d2093eba56d709b28cfb7182 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 4 Jul 1993 07:09:59 +0000 Subject: [PATCH] Reject non block-aligned transfers (where a block is 512 bytes in length); they were causing scsi controller lockups. Replace an occurrence of "512" with SECSIZE, which is #defined to be 512. --- sys/dev/scsipi/sd.c | 10 ++++++++-- sys/scsi/sd.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c index bfd10164778a..ea494e0445ff 100644 --- a/sys/dev/scsipi/sd.c +++ b/sys/dev/scsipi/sd.c @@ -13,7 +13,7 @@ * on the understanding that TFS is not responsible for the correct * functioning of this software in any circumstances. * - * $Id: sd.c,v 1.15 1993/06/27 06:59:20 andrew Exp $ + * $Id: sd.c,v 1.16 1993/07/04 07:09:59 andrew Exp $ */ #include "sd.h" @@ -367,6 +367,12 @@ sdstrategy(struct buf *bp) printf("sd%d: %d bytes @ blk%d\n", unit, bp->b_bcount, bp->b_blkno); + /* Reject non block-aligned transfers */ + if (bp->b_bcount % SECSIZE) { + bp->b_error = EINVAL; + goto bad; + } + sdminphys(bp); /* If the device has been made invalid, error out */ @@ -750,7 +756,7 @@ sdgetdisklabel(u_char unit) sd->disklabel.d_partitions[RAW_PART].p_offset = 0; sd->disklabel.d_partitions[RAW_PART].p_size = sd->params.disksize; sd->disklabel.d_npartitions = MAXPARTITIONS; - sd->disklabel.d_secsize = 512; /* as long as it's not 0 */ + sd->disklabel.d_secsize = SECSIZE; /* as long as it's not 0 */ sd->disklabel.d_ntracks = sd->params.heads; sd->disklabel.d_nsectors = sd->params.sectors; sd->disklabel.d_ncylinders = sd->params.cyls; diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index bfd10164778a..ea494e0445ff 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -13,7 +13,7 @@ * on the understanding that TFS is not responsible for the correct * functioning of this software in any circumstances. * - * $Id: sd.c,v 1.15 1993/06/27 06:59:20 andrew Exp $ + * $Id: sd.c,v 1.16 1993/07/04 07:09:59 andrew Exp $ */ #include "sd.h" @@ -367,6 +367,12 @@ sdstrategy(struct buf *bp) printf("sd%d: %d bytes @ blk%d\n", unit, bp->b_bcount, bp->b_blkno); + /* Reject non block-aligned transfers */ + if (bp->b_bcount % SECSIZE) { + bp->b_error = EINVAL; + goto bad; + } + sdminphys(bp); /* If the device has been made invalid, error out */ @@ -750,7 +756,7 @@ sdgetdisklabel(u_char unit) sd->disklabel.d_partitions[RAW_PART].p_offset = 0; sd->disklabel.d_partitions[RAW_PART].p_size = sd->params.disksize; sd->disklabel.d_npartitions = MAXPARTITIONS; - sd->disklabel.d_secsize = 512; /* as long as it's not 0 */ + sd->disklabel.d_secsize = SECSIZE; /* as long as it's not 0 */ sd->disklabel.d_ntracks = sd->params.heads; sd->disklabel.d_nsectors = sd->params.sectors; sd->disklabel.d_ncylinders = sd->params.cyls;