[PATCH] Partition table wrong with 2048 byte/sector

Jochen Stein (stein@cs.uni-duesseldorf.de)
Sat, 9 Jan 1999 21:54:34 +0100 (MET)


The MS-DOS partition table is calculated wrong on block devices with
a sector size of 2048 bytes (e.g. MO media with 640 MB capacity).
This inhibits mounting partitions of such devices.

The (tiny) patch below fixes this for the 4 primary partitions. It
is against 2.2.0pre5ac1 and can be easily extended to handle extended
partitions as well (I don't have media for testing). Please consider
including into 2.2.0.

JSt

--- drivers/block/genhd.c.ori Sat Jan 9 13:56:17 1999
+++ drivers/block/genhd.c Sat Jan 9 15:23:27 1999
@@ -130,6 +130,15 @@
SYS_IND(p) == LINUX_EXTENDED_PARTITION);
}

+static int sec_fac(kdev_t dev) /* JSt */
+{
+/* printk("--> hardsect_size[%d][%d] = %d\n",MAJOR(dev),MINOR(dev),hardsect_size[MAJOR(dev)][MINOR(dev)]); */
+ if (hardsect_size[MAJOR(dev)] != NULL)
+ return (hardsect_size[MAJOR(dev)][MINOR(dev)]/512);
+ else
+ return (1);
+}
+
static unsigned int get_ptable_blocksize(kdev_t dev)
{
int ret = 1024;
@@ -436,6 +445,7 @@
struct partition *p;
unsigned char *data;
int mask = (1 << hd->minor_shift) - 1;
+ int sf = sec_fac(dev);
#ifdef CONFIG_BSD_DISKLABEL
/* no bsd disklabel as a default */
kdev_t bsd_kdev = 0;
@@ -538,7 +548,7 @@
for (i=1 ; i<=4 ; minor++,i++,p++) {
if (!NR_SECTS(p))
continue;
- add_partition(hd, minor, first_sector+START_SECT(p), NR_SECTS(p));
+ add_partition(hd, minor, first_sector+START_SECT(p)*sf, NR_SECTS(p)*sf);
if (is_extended_partition(p)) {
printk(" <");
/*

-- 
Jochen A. Stein

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/