Here is a patch for drivers/scsi/sd.c to fix the overflow
bug.
-- H.J. Lu (hjl@gnu.ai.mit.edu)--- Index: sd.c =================================================================== RCS file: /home/cvs/linux/linux/drivers/scsi/sd.c,v retrieving revision 1.1.1.11 diff -c -r1.1.1.11 sd.c *** sd.c 1996/04/11 05:46:39 1.1.1.11 --- sd.c 1996/04/11 06:59:28 *************** *** 1161,1174 **** * So I have created this table. See ll_rw_blk.c * Jacques Gelinas (Jacques@solucorp.qc.ca) */ ! int m, mb; int sz_quot, sz_rem; int hard_sector = rscsi_disks[i].sector_size; /* There are 16 minors allocated for each major device */ for (m=i<<4; m<((i+1)<<4); m++){ sd_hardsizes[m] = hard_sector; } ! mb = (hard_sector * rscsi_disks[i].capacity) / (1024*1024); /* sz = div(m/100, 10); this seems to not be in the libr */ m = (mb + 50) / 100; sz_quot = m / 10; --- 1161,1190 ---- * So I have created this table. See ll_rw_blk.c * Jacques Gelinas (Jacques@solucorp.qc.ca) */ ! int m, mb, one_mb; int sz_quot, sz_rem; int hard_sector = rscsi_disks[i].sector_size; /* There are 16 minors allocated for each major device */ for (m=i<<4; m<((i+1)<<4); m++){ sd_hardsizes[m] = hard_sector; } ! /* ! * mb = (hard_sector * rscsi_disks[i].capacity) / (1024*1024); ! * ! * hard_sector * rscsi_disks[i].capacity may be overflow. ! * We should be very careful. 1 MB is 1 << 20. ! * H.J. (hjl@lucon.org). ! */ ! one_mb = 20; ! for (mb = hard_sector; (mb & 0x1) == 0 && one_mb > 0; ! mb >>= 1, one_mb--); ! for (mb *= rscsi_disks[i].capacity; ! (mb & 0x1) == 0 && one_mb > 0; ! mb >>= 1, one_mb--); ! if (one_mb > 0) ! { ! mb >>= one_mb; ! } /* sz = div(m/100, 10); this seems to not be in the libr */ m = (mb + 50) / 100; sz_quot = m / 10;