[Updated] 2048 bytes/sector patch

Jochen Stein (stein@cs.uni-duesseldorf.de)
Sat, 16 Jan 1999 21:23:52 +0100 (MET)


Hello,

further down you will find the latest version of my patch to support
2048 bytes/sector disks (e.g. 600 MB media for Fujitsu MO drives).
This version supports also extended partitions, as requested by
Meelis Roos. It was done with help from Bas Vermeulen. The patch
is against 2.2.0-pre7 (actually -ac4, but genhd.c did not change).

Here is my test result: I created 7 partitions on a medium with
Fujitsu's fdisk program, then formatted one with mke2fs.
Linux partition check:
sdc: sdc1 sdc2 < sdc5 sdc6 sdc7 sdc8 sdc9 sdc10 >

mount output:
/dev/sdc1 on /dos/g type vfat (rw)
/dev/sdc5 on /dos/g/5 type vfat (rw)
/dev/sdc6 on /dos/g/6 type ext2 (rw)
/dev/sdc7 on /dos/g/7 type vfat (rw)
/dev/sdc8 on /dos/g/8 type vfat (rw)
/dev/sdc9 on /dos/g/9 type vfat (rw)
/dev/sdc10 on /dos/g/10 type vfat (rw)

df -k output:
/dev/sdc1 102118 12 102106 0% /dos/g
/dev/sdc5 102118 0 102118 0% /dos/g/5
/dev/sdc6 99104 26 93962 0% /dos/g/6
/dev/sdc7 102118 0 102118 0% /dos/g/7
/dev/sdc8 102118 0 102118 0% /dos/g/8
/dev/sdc9 53062 0 53062 0% /dos/g/9
/dev/sdc10 53062 0 53062 0% /dos/g/10

/proc/partitions:
8 33 102336 sdc1
8 34 1 sdc2
8 37 102336 sdc5
8 38 102336 sdc6
8 39 102336 sdc7
8 40 102336 sdc8
8 41 53184 sdc9
8 42 53184 sdc10

Only fdisk from util-linux 2.9 fails to recognize the extended partitions.

Please review, test and consider including into 2.2.x. I think breaking
compatibility with 2.0.3x, DOS and Windows here is not a good idea. There
still is lots of Linux support for my old and obscure hardware and I am
surprised to be unable to proper use one of my more recent devices
with 2.2.0-preX.

JSt
(please CC)

--- linux/drivers/block/genhd.c.ori Sat Jan 16 14:58:38 1999
+++ linux/drivers/block/genhd.c Sat Jan 16 15:11:26 1999
@@ -130,6 +130,14 @@
SYS_IND(p) == LINUX_EXTENDED_PARTITION);
}

+static int sec_fac(kdev_t dev) /* JSt */
+{
+ 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;
@@ -196,6 +204,7 @@
struct partition *p;
unsigned long first_sector, first_size, this_sector, this_size;
int mask = (1 << hd->minor_shift) - 1;
+ int sector_size = sec_fac(dev);
int i;

first_sector = hd->part[MINOR(dev)].start_sect;
@@ -245,7 +254,7 @@
first_sector + first_size))
continue;

- add_partition(hd, current_minor, this_sector+START_SECT(p), NR_SECTS(p));
+ add_partition(hd, current_minor, this_sector+START_SECT(p)*sector_size, NR_SECTS(p)*sector_size);
current_minor++;
if ((current_minor & mask) == 0)
goto done;
@@ -267,9 +276,9 @@
if (i == 4)
goto done; /* nothing left to do */

- hd->part[current_minor].nr_sects = NR_SECTS(p);
- hd->part[current_minor].start_sect = first_sector + START_SECT(p);
- this_sector = first_sector + START_SECT(p);
+ hd->part[current_minor].nr_sects = NR_SECTS(p) * sector_size; /* JSt */
+ hd->part[current_minor].start_sect = first_sector + START_SECT(p) * sector_size;
+ this_sector = first_sector + START_SECT(p) * sector_size;
dev = MKDEV(hd->major, current_minor);
brelse(bh);
}
@@ -436,6 +445,7 @@
struct partition *p;
unsigned char *data;
int mask = (1 << hd->minor_shift) - 1;
+ int sector_size = 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)*sector_size, NR_SECTS(p)*sector_size);
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/