BUGFIX: drivers/block/genhd.c BSD disklabel misdetection

Vadim S. Solomin (sovs@uic.nnov.ru)
Tue, 26 Jan 1999 17:07:35 +0300


This is a multi-part message in MIME format.
--------------E86F0BA063290B7CE6B62D54
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit

Hello!

I've recently installed FreeBSD on my linux box, and it appears that
somewhere between 2.1.125 and 2.2.0-pre6 additional checks were added to
genhd.c to test for
overlaps between BSD partitions inside a slice and other partitions.
Unfortunately those checks were broken and compared BSD partitions on a
certain disk with linux partitions on first (which is not necessarily
the same) disk on the same major number (e.g. BSD partitions inside
/dev/hdb2 (my BSD slice) were compared with partitions on /dev/hda).
Thus, depending on layout of the disk on minor, 0 BSD partitions on
other disks could be wrongly recognized as bad.

Patch against 2.2.0-final included.

--Vadim
--------------E86F0BA063290B7CE6B62D54
Content-Type: text/plain; charset=koi8-r;
name="patch-bsd-disklabel"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch-bsd-disklabel"

diff -u --recursive linux-2.2.0-final-broken/drivers/block/genhd.c linux/drivers/block/genhd.c
--- linux-2.2.0-final-broken/drivers/block/genhd.c Tue Jan 26 15:09:55 1999
+++ linux/drivers/block/genhd.c Sat Jan 23 21:33:26 1999
@@ -317,11 +317,13 @@
#endif

#ifdef CONFIG_BSD_DISKLABEL
-static void check_and_add_bsd_partition(struct gendisk *hd, struct bsd_partition *bsd_p)
+static void check_and_add_bsd_partition(struct gendisk *hd,
+ struct bsd_partition *bsd_p, kdev_t dev)
{
struct hd_struct *lin_p;
/* check relative position of partitions. */
- for (lin_p = hd->part + 1; lin_p - hd->part < current_minor; lin_p++) {
+ for (lin_p = hd->part + 1 + MINOR(dev);
+ lin_p - hd->part - MINOR(dev) < current_minor; lin_p++) {
/* no relationship -> try again */
if (lin_p->start_sect + lin_p->nr_sects <= bsd_p->p_offset
|| lin_p->start_sect >= bsd_p->p_offset + bsd_p->p_size)
@@ -383,7 +385,7 @@
break;

if (p->p_fstype != BSD_FS_UNUSED)
- check_and_add_bsd_partition(hd, p);
+ check_and_add_bsd_partition(hd, p, dev);
}
brelse(bh);

--------------E86F0BA063290B7CE6B62D54--

-
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/