Commit a22f8253 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] partition parsing cleanup

struct gendisk and partition parsers divorced; all these parsers (IBM style,
disklabel, etc.) just fill the structure they get from check_partitions().

Actual setting the things up (filling hd_struct arrays, telling RAID that
we had found partitions worth a look, etc.) is taken into check_partitions()
and done only when we are done with parsing.  Parsers don't know (or care)
what majors/minors they are dealing with; that knowledge also went to
check_partitions().
parent d6d4f980
...@@ -1254,10 +1254,11 @@ void mfm_setup(char *str, int *ints) ...@@ -1254,10 +1254,11 @@ void mfm_setup(char *str, int *ints)
* since if there are any non-ADFS partitions on the disk, this won't work! * since if there are any non-ADFS partitions on the disk, this won't work!
* Hence, I want to get rid of this... * Hence, I want to get rid of this...
*/ */
void xd_set_geometry(kdev_t dev, unsigned char secsptrack, unsigned char heads, void xd_set_geometry(struct block_device *bdev, unsigned char secsptrack,
unsigned long discsize, unsigned int secsize) unsigned char heads, unsigned int secsize)
{ {
int drive = minor(dev) >> 6; int drive = MINOR(bdev->bd_dev) >> 6;
unsigned long disksize = bdev->bd_inode->i_size;
if (mfm_info[drive].cylinders == 1) { if (mfm_info[drive].cylinders == 1) {
mfm_info[drive].sectors = secsptrack; mfm_info[drive].sectors = secsptrack;
...@@ -1265,7 +1266,7 @@ void xd_set_geometry(kdev_t dev, unsigned char secsptrack, unsigned char heads, ...@@ -1265,7 +1266,7 @@ void xd_set_geometry(kdev_t dev, unsigned char secsptrack, unsigned char heads,
mfm_info[drive].cylinders = discsize / (secsptrack * heads * secsize); mfm_info[drive].cylinders = discsize / (secsptrack * heads * secsize);
if ((heads < 1) || (mfm_info[drive].cylinders > 1024)) { if ((heads < 1) || (mfm_info[drive].cylinders > 1024)) {
printk("mfm%c: Insane disc shape! Setting to 512/4/32\n",'a' + (dev >> 6)); printk("mfm%c: Insane disc shape! Setting to 512/4/32\n",'a' + drive);
/* These values are fairly arbitary, but are there so that if your /* These values are fairly arbitary, but are there so that if your
* lucky you can pick apart your disc to find out what is going on - * lucky you can pick apart your disc to find out what is going on -
......
This diff is collapsed.
...@@ -50,6 +50,4 @@ struct ptec_partition { ...@@ -50,6 +50,4 @@ struct ptec_partition {
}; };
int acorn_partition(struct gendisk *hd, struct block_device *bdev, int acorn_partition(struct parsed_partitions *state, struct block_device *bdev);
unsigned long first_sect, int first_minor);
...@@ -7,14 +7,7 @@ ...@@ -7,14 +7,7 @@
* Re-organised Feb 1998 Russell King * Re-organised Feb 1998 Russell King
*/ */
#include <linux/fs.h> #include <linux/types.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/blk.h>
#include <asm/byteorder.h>
#include <linux/affs_hardblocks.h> #include <linux/affs_hardblocks.h>
#include "check.h" #include "check.h"
...@@ -31,14 +24,14 @@ checksum_block(u32 *m, int size) ...@@ -31,14 +24,14 @@ checksum_block(u32 *m, int size)
} }
int int
amiga_partition(struct gendisk *hd, struct block_device *bdev, amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
unsigned long first_sector, int first_part_minor)
{ {
Sector sect; Sector sect;
unsigned char *data; unsigned char *data;
struct RigidDiskBlock *rdb; struct RigidDiskBlock *rdb;
struct PartitionBlock *pb; struct PartitionBlock *pb;
int start_sect, nr_sects, blk, part, res = 0; int start_sect, nr_sects, blk, part, res = 0;
int slot = 1;
for (blk = 0; ; blk++, put_dev_sector(sect)) { for (blk = 0; ; blk++, put_dev_sector(sect)) {
if (blk == RDB_ALLOCATION_LIMIT) if (blk == RDB_ALLOCATION_LIMIT)
...@@ -100,8 +93,7 @@ amiga_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -100,8 +93,7 @@ amiga_partition(struct gendisk *hd, struct block_device *bdev,
start_sect = be32_to_cpu(pb->pb_Environment[9]) * start_sect = be32_to_cpu(pb->pb_Environment[9]) *
be32_to_cpu(pb->pb_Environment[3]) * be32_to_cpu(pb->pb_Environment[3]) *
be32_to_cpu(pb->pb_Environment[5]); be32_to_cpu(pb->pb_Environment[5]);
add_gd_partition(hd,first_part_minor,start_sect,nr_sects); put_partition(state,slot++,start_sect,nr_sects);
first_part_minor++;
res = 1; res = 1;
} }
printk("\n"); printk("\n");
......
...@@ -2,7 +2,5 @@ ...@@ -2,7 +2,5 @@
* fs/partitions/amiga.h * fs/partitions/amiga.h
*/ */
int int amiga_partition(struct parsed_partitions *state, struct block_device *bdev);
amiga_partition(struct gendisk *hd, struct block_device *bdev,
unsigned long first_sector, int first_part_minor);
...@@ -7,17 +7,7 @@ ...@@ -7,17 +7,7 @@
* Re-organised Feb 1998 Russell King * Re-organised Feb 1998 Russell King
*/ */
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/blk.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <asm/byteorder.h>
#include <asm/system.h>
#include "check.h" #include "check.h"
#include "atari.h" #include "atari.h"
...@@ -40,15 +30,14 @@ static inline int OK_id(char *s) ...@@ -40,15 +30,14 @@ static inline int OK_id(char *s)
memcmp (s, "RAW", 3) == 0 ; memcmp (s, "RAW", 3) == 0 ;
} }
int atari_partition (struct gendisk *hd, struct block_device *bdev, int atari_partition(struct parsed_partitions *state, struct block_device *bdev)
unsigned long first_sector, int minor)
{ {
int m_lim = minor + (1 << hd->minor_shift);
Sector sect; Sector sect;
struct rootsector *rs; struct rootsector *rs;
struct partition_info *pi; struct partition_info *pi;
u32 extensect; u32 extensect;
u32 hd_size; u32 hd_size;
int slot;
#ifdef ICD_PARTS #ifdef ICD_PARTS
int part_fmt = 0; /* 0:unknown, 1:AHDI, 2:ICD/Supra */ int part_fmt = 0; /* 0:unknown, 1:AHDI, 2:ICD/Supra */
#endif #endif
...@@ -58,7 +47,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev, ...@@ -58,7 +47,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev,
return -1; return -1;
/* Verify this is an Atari rootsector: */ /* Verify this is an Atari rootsector: */
hd_size = hd->part[minor - 1].nr_sects; hd_size = bdev->bd_inode->i_size >> 9;
if (!VALID_PARTITION(&rs->part[0], hd_size) && if (!VALID_PARTITION(&rs->part[0], hd_size) &&
!VALID_PARTITION(&rs->part[1], hd_size) && !VALID_PARTITION(&rs->part[1], hd_size) &&
!VALID_PARTITION(&rs->part[2], hd_size) && !VALID_PARTITION(&rs->part[2], hd_size) &&
...@@ -74,7 +63,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev, ...@@ -74,7 +63,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev,
pi = &rs->part[0]; pi = &rs->part[0];
printk (" AHDI"); printk (" AHDI");
for (; pi < &rs->part[4] && minor < m_lim; minor++, pi++) { for (slot = 1; pi < &rs->part[4] && slot < state->limit; slot++, pi++) {
struct rootsector *xrs; struct rootsector *xrs;
Sector sect2; Sector sect2;
ulong partsect; ulong partsect;
...@@ -84,7 +73,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev, ...@@ -84,7 +73,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev,
/* active partition */ /* active partition */
if (memcmp (pi->id, "XGM", 3) != 0) { if (memcmp (pi->id, "XGM", 3) != 0) {
/* we don't care about other id's */ /* we don't care about other id's */
add_gd_partition (hd, minor, be32_to_cpu(pi->st), put_partition (state, slot, be32_to_cpu(pi->st),
be32_to_cpu(pi->siz)); be32_to_cpu(pi->siz));
continue; continue;
} }
...@@ -109,7 +98,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev, ...@@ -109,7 +98,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev,
break; break;
} }
add_gd_partition(hd, minor, put_partition(state, slot,
partsect + be32_to_cpu(xrs->part[0].st), partsect + be32_to_cpu(xrs->part[0].st),
be32_to_cpu(xrs->part[0].siz)); be32_to_cpu(xrs->part[0].siz));
...@@ -126,8 +115,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev, ...@@ -126,8 +115,7 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev,
partsect = be32_to_cpu(xrs->part[1].st) + extensect; partsect = be32_to_cpu(xrs->part[1].st) + extensect;
put_dev_sector(sect2); put_dev_sector(sect2);
minor++; if (++slot == state->limit) {
if (minor >= m_lim) {
printk( "\nMaximum number of partitions reached!\n" ); printk( "\nMaximum number of partitions reached!\n" );
break; break;
} }
...@@ -140,12 +128,12 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev, ...@@ -140,12 +128,12 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev,
/* sanity check: no ICD format if first partition invalid */ /* sanity check: no ICD format if first partition invalid */
if (OK_id(pi->id)) { if (OK_id(pi->id)) {
printk(" ICD<"); printk(" ICD<");
for (; pi < &rs->icdpart[8] && minor < m_lim; minor++, pi++) { for (; pi < &rs->icdpart[8] && slot < state->limit; slot++, pi++) {
/* accept only GEM,BGM,RAW,LNX,SWP partitions */ /* accept only GEM,BGM,RAW,LNX,SWP partitions */
if (!((pi->flg & 1) && OK_id(pi->id))) if (!((pi->flg & 1) && OK_id(pi->id)))
continue; continue;
part_fmt = 2; part_fmt = 2;
add_gd_partition (hd, minor, put_partition (state, slot,
be32_to_cpu(pi->st), be32_to_cpu(pi->st),
be32_to_cpu(pi->siz)); be32_to_cpu(pi->siz));
} }
...@@ -159,4 +147,3 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev, ...@@ -159,4 +147,3 @@ int atari_partition (struct gendisk *hd, struct block_device *bdev,
return 1; return 1;
} }
...@@ -31,6 +31,4 @@ struct rootsector ...@@ -31,6 +31,4 @@ struct rootsector
u16 checksum; /* checksum for bootable disks */ u16 checksum; /* checksum for bootable disks */
} __attribute__((__packed__)); } __attribute__((__packed__));
int atari_partition (struct gendisk *hd, struct block_device *bdev, int atari_partition(struct parsed_partitions *state, struct block_device *bdev);
unsigned long first_sector, int first_part_minor);
...@@ -34,10 +34,13 @@ ...@@ -34,10 +34,13 @@
#include "ultrix.h" #include "ultrix.h"
#include "efi.h" #include "efi.h"
#if CONFIG_BLK_DEV_MD
extern void md_autodetect_dev(kdev_t dev);
#endif
int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/ int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
static int (*check_part[])(struct gendisk *hd, struct block_device *bdev, static int (*check_part[])(struct parsed_partitions *, struct block_device *) = {
unsigned long first_sect, int first_minor) = {
#ifdef CONFIG_ACORN_PARTITION #ifdef CONFIG_ACORN_PARTITION
acorn_partition, acorn_partition,
#endif #endif
...@@ -199,28 +202,6 @@ char *disk_name (struct gendisk *hd, int minor, char *buf) ...@@ -199,28 +202,6 @@ char *disk_name (struct gendisk *hd, int minor, char *buf)
return buf; return buf;
} }
/*
* Add a partitions details to the devices partition description.
*/
void add_gd_partition(struct gendisk *hd, int minor, int start, int size)
{
#ifndef CONFIG_DEVFS_FS
char buf[40];
#endif
hd->part[minor].start_sect = start;
hd->part[minor].nr_sects = size;
#ifdef CONFIG_DEVFS_FS
printk(" p%d", (minor & ((1 << hd->minor_shift) - 1)));
#else
if ((hd->major >= COMPAQ_SMART2_MAJOR+0 && hd->major <= COMPAQ_SMART2_MAJOR+7) ||
(hd->major >= COMPAQ_CISS_MAJOR+0 && hd->major <= COMPAQ_CISS_MAJOR+7))
printk(" p%d", (minor & ((1 << hd->minor_shift) - 1)));
else
printk(" %s", disk_name(hd, minor, buf));
#endif
}
/* Driverfs file support */ /* Driverfs file support */
static ssize_t partition_device_kdev_read(struct device *driverfs_dev, static ssize_t partition_device_kdev_read(struct device *driverfs_dev,
char *page, size_t count, loff_t off) char *page, size_t count, loff_t off)
...@@ -351,12 +332,13 @@ void driverfs_remove_partitions(struct gendisk *hd, int minor) ...@@ -351,12 +332,13 @@ void driverfs_remove_partitions(struct gendisk *hd, int minor)
return; return;
} }
static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor) static void check_partition(struct gendisk *hd, kdev_t dev)
{ {
devfs_handle_t de = NULL; devfs_handle_t de = NULL;
unsigned long first_sector; unsigned long first_sector;
struct block_device *bdev; struct block_device *bdev;
char buf[64]; char buf[64];
struct parsed_partitions *state;
int i; int i;
first_sector = hd->part[minor(dev)].start_sect; first_sector = hd->part[minor(dev)].start_sect;
...@@ -369,14 +351,26 @@ static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor ...@@ -369,14 +351,26 @@ static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor
hd->part[minor(dev)].start_sect = 0; hd->part[minor(dev)].start_sect = 0;
return; return;
} }
if (first_sector != 0)
BUG();
state = kmalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
if (!state)
return;
if (hd->de_arr) if (hd->de_arr)
de = hd->de_arr[minor(dev) >> hd->minor_shift]; de = hd->de_arr[minor(dev) >> hd->minor_shift];
i = devfs_generate_path (de, buf, sizeof buf); i = devfs_generate_path (de, buf, sizeof buf);
if (i >= 0) if (i >= 0) {
printk(KERN_INFO " /dev/%s:", buf + i); printk(KERN_INFO " /dev/%s:", buf + i);
else sprintf(state->name, "p");
printk(KERN_INFO " %s:", disk_name(hd, minor(dev), buf)); } else {
unsigned n = hd->major;
disk_name(hd, minor(dev), state->name);
printk(KERN_INFO " %s:", state->name);
if (n - COMPAQ_SMART2_MAJOR <= 7 || n - COMPAQ_CISS_MAJOR <= 7)
sprintf(state->name, "p");
}
bdev = bdget(kdev_t_to_nr(dev)); bdev = bdget(kdev_t_to_nr(dev));
bdev->bd_contains = bdev; bdev->bd_contains = bdev;
bdev->bd_inode->i_size = (loff_t)hd->part[minor(dev)].nr_sects << 9; bdev->bd_inode->i_size = (loff_t)hd->part[minor(dev)].nr_sects << 9;
...@@ -395,14 +389,30 @@ static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor ...@@ -395,14 +389,30 @@ static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor
bdev->bd_block_size = bsize; bdev->bd_block_size = bsize;
bdev->bd_inode->i_blkbits = blksize_bits(bsize); bdev->bd_inode->i_blkbits = blksize_bits(bsize);
} }
state->limit = 1<<hd->minor_shift;
for (i = 0; check_part[i]; i++) { for (i = 0; check_part[i]; i++) {
int res; int res, j;
res = check_part[i](hd, bdev, first_sector, first_part_minor); memset(&state->parts, 0, sizeof(state->parts));
if (res) { res = check_part[i](state, bdev);
if (res < 0 && warn_no_part) if (!res)
continue;
if (res < 0) {
if (warn_no_part)
printk(" unable to read partition table\n"); printk(" unable to read partition table\n");
goto setup_devfs; goto setup_devfs;
} }
for (j = 1; j < state->limit; j++) {
hd->part[j + minor(dev)].start_sect =
state->parts[j].from;
hd->part[j + minor(dev)].nr_sects =
state->parts[j].size;
#if CONFIG_BLK_DEV_MD
if (!state->parts[j].flags)
continue;
md_autodetect_dev(mk_kdev(major(dev),minor(dev)+j));
#endif
}
goto setup_devfs;
} }
printk(" unknown partition table\n"); printk(" unknown partition table\n");
...@@ -410,15 +420,14 @@ static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor ...@@ -410,15 +420,14 @@ static void check_partition(struct gendisk *hd, kdev_t dev, int first_part_minor
invalidate_bdev(bdev, 1); invalidate_bdev(bdev, 1);
truncate_inode_pages(bdev->bd_inode->i_mapping, 0); truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
bdput(bdev); bdput(bdev);
i = first_part_minor - 1;
/* Setup driverfs tree */ /* Setup driverfs tree */
if (hd->sizes) if (hd->sizes)
driverfs_create_partitions(hd, i); driverfs_create_partitions(hd, minor(dev));
else else
driverfs_remove_partitions(hd, i); driverfs_remove_partitions(hd, minor(dev));
devfs_register_partitions (hd, i, hd->sizes ? 0 : 1); devfs_register_partitions (hd, minor(dev), hd->sizes ? 0 : 1);
} }
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
...@@ -564,7 +573,7 @@ void grok_partitions(kdev_t dev, long size) ...@@ -564,7 +573,7 @@ void grok_partitions(kdev_t dev, long size)
if (!size) if (!size)
return; return;
check_partition(g, mk_kdev(g->major, first_minor), 1 + first_minor); check_partition(g, mk_kdev(g->major, first_minor));
/* /*
* We need to set the sizes array before we will be able to access * We need to set the sizes array before we will be able to access
...@@ -632,28 +641,3 @@ int wipe_partitions(kdev_t dev) ...@@ -632,28 +641,3 @@ int wipe_partitions(kdev_t dev)
} }
return 0; return 0;
} }
/*
* Make sure that a proposed subpartition is strictly contained inside
* the parent partition. If all is well, call add_gd_partition().
*/
int
check_and_add_subpartition(struct gendisk *hd, int super_minor, int minor,
int sub_start, int sub_size)
{
int start = hd->part[super_minor].start_sect;
int size = hd->part[super_minor].nr_sects;
if (start == sub_start && size == sub_size) {
/* full parent partition, we have it already */
return 0;
}
if (start <= sub_start && start+size >= sub_start+sub_size) {
add_gd_partition(hd, minor, sub_start, sub_size);
return 1;
}
printk("bad subpartition - ignored\n");
return 0;
}
...@@ -5,12 +5,28 @@ ...@@ -5,12 +5,28 @@
* add_gd_partition adds a partitions details to the devices partition * add_gd_partition adds a partitions details to the devices partition
* description. * description.
*/ */
void add_gd_partition(struct gendisk *hd, int minor, int start, int size);
/* enum { MAX_PART = 256 };
* check_and_add_subpartition does the same for subpartitions
*/ struct parsed_partitions {
int check_and_add_subpartition(struct gendisk *hd, int super_minor, char name[40];
int minor, int sub_start, int sub_size); struct {
unsigned long from;
unsigned long size;
int flags;
} parts[MAX_PART];
int next;
int limit;
};
static inline void
put_partition(struct parsed_partitions *p, int n, int from, int size)
{
if (n < p->limit) {
p->parts[n].from = from;
p->parts[n].size = size;
printk(" %s%d", p->name, n);
}
}
extern int warn_no_part; extern int warn_no_part;
This diff is collapsed.
...@@ -112,9 +112,7 @@ typedef struct _legacy_mbr { ...@@ -112,9 +112,7 @@ typedef struct _legacy_mbr {
} __attribute__ ((packed)) legacy_mbr; } __attribute__ ((packed)) legacy_mbr;
/* Functions */ /* Functions */
extern int extern int efi_partition(struct parsed_partitions *state, struct block_device *bdev);
efi_partition(struct gendisk *hd, struct block_device *bdev,
unsigned long first_sector, int first_part_minor);
#endif #endif
......
...@@ -88,8 +88,7 @@ ibm_ioctl_unopened(struct block_device *bdev, unsigned cmd, unsigned long arg) ...@@ -88,8 +88,7 @@ ibm_ioctl_unopened(struct block_device *bdev, unsigned cmd, unsigned long arg)
/* /*
*/ */
int int
ibm_partition(struct gendisk *hd, struct block_device *bdev, ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
unsigned long first_sector, int first_part_minor)
{ {
int blocksize, offset, size; int blocksize, offset, size;
dasd_information_t *info; dasd_information_t *info;
...@@ -100,9 +99,6 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -100,9 +99,6 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev,
unsigned char *data; unsigned char *data;
Sector sect; Sector sect;
if ( first_sector != 0 )
BUG();
if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL) if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL)
goto out_noinfo; goto out_noinfo;
if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL)
...@@ -155,9 +151,7 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -155,9 +151,7 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev,
offset = (info->label_block + 1); offset = (info->label_block + 1);
size = bdev->bd_inode->i_size >> 9; size = bdev->bd_inode->i_size >> 9;
} }
// add_gd_partition(hd, first_part_minor - 1, 0, size); put_partition(state, 1, offset*(blocksize >> 9),
add_gd_partition(hd, first_part_minor,
offset*(blocksize >> 9),
size-offset*(blocksize >> 9)); size-offset*(blocksize >> 9));
} else if (strncmp(type, "VOL1", 4) == 0) { } else if (strncmp(type, "VOL1", 4) == 0) {
/* /*
...@@ -194,9 +188,9 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -194,9 +188,9 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev,
offset = cchh2blk(&f1.DS1EXT1.llimit, geo); offset = cchh2blk(&f1.DS1EXT1.llimit, geo);
size = cchh2blk(&f1.DS1EXT1.ulimit, geo) - size = cchh2blk(&f1.DS1EXT1.ulimit, geo) -
offset + geo->sectors; offset + geo->sectors;
if (counter >= (1 << hd->minor_shift)) if (counter >= state->limit)
break; break;
add_gd_partition(hd, first_part_minor + counter, put_partition(state, counter + 1,
offset * (blocksize >> 9), offset * (blocksize >> 9),
size * (blocksize >> 9)); size * (blocksize >> 9));
counter++; counter++;
...@@ -212,9 +206,7 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -212,9 +206,7 @@ ibm_partition(struct gendisk *hd, struct block_device *bdev,
printk("(nonl)/%8s:", name); printk("(nonl)/%8s:", name);
offset = (info->label_block + 1); offset = (info->label_block + 1);
size = (bdev->bd_inode->i_size >> 9); size = (bdev->bd_inode->i_size >> 9);
// add_gd_partition(hd, first_part_minor - 1, 0, size); put_partition(state, 1, offset*(blocksize >> 9),
add_gd_partition(hd, first_part_minor,
offset*(blocksize >> 9),
size-offset*(blocksize >> 9)); size-offset*(blocksize >> 9));
} }
......
int ibm_partition(struct gendisk *, struct block_device *, unsigned long, int); int ibm_partition(struct parsed_partitions *, struct block_device *);
...@@ -23,12 +23,6 @@ ...@@ -23,12 +23,6 @@
* *
* 28/10/2001 - Added sorting of ldm partitions. (AIA) * 28/10/2001 - Added sorting of ldm partitions. (AIA)
*/ */
#include <linux/types.h>
#include <asm/unaligned.h>
#include <asm/byteorder.h>
#include <linux/pagemap.h>
#include <linux/genhd.h>
#include <linux/blkdev.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "check.h" #include "check.h"
#include "ldm.h" #include "ldm.h"
...@@ -57,7 +51,6 @@ static void ldm_debug(const char *f, ...); ...@@ -57,7 +51,6 @@ static void ldm_debug(const char *f, ...);
#endif /* !CONFIG_LDM_DEBUG */ #endif /* !CONFIG_LDM_DEBUG */
/* Necessary forward declarations. */ /* Necessary forward declarations. */
static int create_partition(struct gendisk *, int, int, int);
static int parse_privhead(const u8 *, struct privhead *); static int parse_privhead(const u8 *, struct privhead *);
static u64 get_vnum(const u8 *, int *); static u64 get_vnum(const u8 *, int *);
static int get_vstr(const u8 *, u8 *, const int); static int get_vstr(const u8 *, u8 *, const int);
...@@ -161,8 +154,7 @@ static int parse_vblk(const u8 *buffer, const int buf_size, struct vblk *vb) ...@@ -161,8 +154,7 @@ static int parse_vblk(const u8 *buffer, const int buf_size, struct vblk *vb)
/** /**
* add_partition_to_list - insert partition into a partition list * add_partition_to_list - insert partition into a partition list
* @pl: sorted list of partitions * @pl: sorted list of partitions
* @hd: gendisk structure to which the data partition belongs * @disk_size: number of sectors on the disk device
* @disk_minor: minor number of the disk device
* @start: first sector within the disk device * @start: first sector within the disk device
* @size: number of sectors on the partition device * @size: number of sectors on the partition device
* *
...@@ -174,16 +166,15 @@ static int parse_vblk(const u8 *buffer, const int buf_size, struct vblk *vb) ...@@ -174,16 +166,15 @@ static int parse_vblk(const u8 *buffer, const int buf_size, struct vblk *vb)
* *
* TODO: Add sanity check for overlapping partitions. (AIA) * TODO: Add sanity check for overlapping partitions. (AIA)
*/ */
static int add_partition_to_list(struct list_head *pl, const struct gendisk *hd, static int add_partition_to_list(struct list_head *pl,
const int disk_minor, const unsigned long start, const unsigned long disk_size,
const unsigned long start,
const unsigned long size) const unsigned long size)
{ {
struct ldm_part *lp, *lptmp; struct ldm_part *lp, *lptmp;
struct list_head *tmp; struct list_head *tmp;
if (!hd->part) if (start < 1 || start + size > disk_size) {
return -1;
if ((start < 1) || ((start + size) > hd->part[disk_minor].nr_sects)) {
printk(LDM_CRIT "LDM partition exceeds physical disk. " printk(LDM_CRIT "LDM partition exceeds physical disk. "
"Skipping.\n"); "Skipping.\n");
return -1; return -1;
...@@ -215,7 +206,6 @@ static int add_partition_to_list(struct list_head *pl, const struct gendisk *hd, ...@@ -215,7 +206,6 @@ static int add_partition_to_list(struct list_head *pl, const struct gendisk *hd,
/** /**
* create_data_partitions - create the data partition devices * create_data_partitions - create the data partition devices
* @hd: gendisk structure in which to create the data partitions * @hd: gendisk structure in which to create the data partitions
* @first_sector: first sector within the disk device
* @first_part_minor: first minor number of data partition devices * @first_part_minor: first minor number of data partition devices
* @dev: partition device holding the LDM database * @dev: partition device holding the LDM database
* @vm: in memory vmdb structure of @dev * @vm: in memory vmdb structure of @dev
...@@ -234,9 +224,8 @@ static int add_partition_to_list(struct list_head *pl, const struct gendisk *hd, ...@@ -234,9 +224,8 @@ static int add_partition_to_list(struct list_head *pl, const struct gendisk *hd,
* *
* Return 1 on success and -1 on error. * Return 1 on success and -1 on error.
*/ */
static int create_data_partitions(struct gendisk *hd, static int create_data_partitions(struct parsed_partitions *state,
const unsigned long first_sector, int first_part_minor, int slot, struct block_device *bdev, const struct vmdb *vm,
struct block_device *bdev, const struct vmdb *vm,
const struct privhead *ph, const struct ldmdisk *dk, const struct privhead *ph, const struct ldmdisk *dk,
unsigned long base) unsigned long base)
{ {
...@@ -249,7 +238,7 @@ static int create_data_partitions(struct gendisk *hd, ...@@ -249,7 +238,7 @@ static int create_data_partitions(struct gendisk *hd,
int vblk; int vblk;
int vsize; /* VBLK size. */ int vsize; /* VBLK size. */
int perbuf; /* VBLKs per buffer. */ int perbuf; /* VBLKs per buffer. */
int buffer, lastbuf, lastofs, err, disk_minor; int buffer, lastbuf, lastofs, err;
vb = (struct vblk*)kmalloc(sizeof(struct vblk), GFP_KERNEL); vb = (struct vblk*)kmalloc(sizeof(struct vblk), GFP_KERNEL);
if (!vb) if (!vb)
...@@ -268,11 +257,6 @@ static int create_data_partitions(struct gendisk *hd, ...@@ -268,11 +257,6 @@ static int create_data_partitions(struct gendisk *hd,
if (OFF_VBLK * LDM_BLOCKSIZE + vm->last_vblk_seq * vsize > if (OFF_VBLK * LDM_BLOCKSIZE + vm->last_vblk_seq * vsize >
ph->config_size * 512) ph->config_size * 512)
goto err_out; goto err_out;
/*
* Get the minor number of the parent device so we can check we don't
* go beyond the end of the device.
*/
disk_minor = (first_part_minor >> hd->minor_shift) << hd->minor_shift;
for (buffer = 0; buffer < lastbuf; buffer++) { for (buffer = 0; buffer < lastbuf; buffer++) {
data = read_dev_sector(bdev, base + 2*OFF_VBLK + buffer, &sect); data = read_dev_sector(bdev, base + 2*OFF_VBLK + buffer, &sect);
if (!data) if (!data)
...@@ -292,8 +276,9 @@ static int create_data_partitions(struct gendisk *hd, ...@@ -292,8 +276,9 @@ static int create_data_partitions(struct gendisk *hd,
if (dk->obj_id != vb->disk_id) if (dk->obj_id != vb->disk_id)
continue; continue;
/* Ignore invalid partition errors. */ /* Ignore invalid partition errors. */
if (add_partition_to_list(&pl, hd, disk_minor, if (add_partition_to_list(&pl,
first_sector + vb->start_sector + bdev->bd_inode->i_size>>9,
vb->start_sector +
ph->logical_disk_start, ph->logical_disk_start,
vb->num_sectors) < -1) vb->num_sectors) < -1)
goto brelse_out; goto brelse_out;
...@@ -306,7 +291,7 @@ static int create_data_partitions(struct gendisk *hd, ...@@ -306,7 +291,7 @@ static int create_data_partitions(struct gendisk *hd,
printk(" <"); printk(" <");
list_for_each(tmp, &pl) { list_for_each(tmp, &pl) {
lp = list_entry(tmp, struct ldm_part, part_list); lp = list_entry(tmp, struct ldm_part, part_list);
add_gd_partition(hd, first_part_minor++, lp->start, lp->size); put_partition(state, slot++, lp->start, lp->size);
} }
printk(" >\n"); printk(" >\n");
if (!list_empty(&pl)) { if (!list_empty(&pl)) {
...@@ -819,42 +804,6 @@ static int validate_privheads(struct block_device *bdev, ...@@ -819,42 +804,6 @@ static int validate_privheads(struct block_device *bdev,
goto out; goto out;
} }
/**
* create_partition - validate input and create a kernel partition device
* @hd: gendisk structure in which to create partition
* @minor: minor number for device to create
* @start: starting offset of the partition into the parent device
* @size: size of the partition
*
* This validates the range, then puts an entry into the kernel's partition
* table.
*
* @start and @size are numbers of sectors.
*
* Return 1 on succes and -1 on error.
*/
static int create_partition(struct gendisk *hd, const int minor,
const int start, const int size)
{
int disk_minor;
if (!hd->part)
return -1;
/*
* Get the minor number of the parent device so we can check we don't
* go beyond the end of the device.
*/
disk_minor = (minor >> hd->minor_shift) << hd->minor_shift;
if ((start < 1) || ((start + size) > hd->part[disk_minor].nr_sects)) {
printk(LDM_CRIT "LDM Partition exceeds physical disk. "
"Aborting.\n");
return -1;
}
add_gd_partition(hd, minor, start, size);
ldm_debug("Created partition successfully.\n");
return 1;
}
/** /**
* parse_privhead - parse the LDM database PRIVHEAD structure * parse_privhead - parse the LDM database PRIVHEAD structure
* @buffer: LDM database privhead structure loaded from the device * @buffer: LDM database privhead structure loaded from the device
...@@ -901,19 +850,16 @@ static int parse_privhead(const u8 *buffer, struct privhead *ph) ...@@ -901,19 +850,16 @@ static int parse_privhead(const u8 *buffer, struct privhead *ph)
} }
/** /**
* create_db_partition - create a dedicated partition for our database * find_db_partition - find our database
* @hd: gendisk structure in which to create partition
* @dev: device of which to create partition * @dev: device of which to create partition
* @ph: @dev's LDM database private header * @ph: @dev's LDM database private header
* *
* Find the primary private header, locate the LDM database, then create a * Find the primary private header and the LDM database
* partition to wrap it. * partition to wrap it.
* *
* Return 1 on succes, 0 if device is not a dynamic disk and -1 on error. * Return 1 on succes, 0 if device is not a dynamic disk and -1 on error.
*/ */
static int create_db_partition(struct gendisk *hd, struct block_device *bdev, static int find_db_partition(struct block_device *bdev, struct privhead *ph)
const unsigned long first_sector, const int first_part_minor,
struct privhead *ph)
{ {
Sector sect; Sector sect;
unsigned char *data; unsigned char *data;
...@@ -930,10 +876,15 @@ static int create_db_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -930,10 +876,15 @@ static int create_db_partition(struct gendisk *hd, struct block_device *bdev,
return 0; return 0;
} }
err = parse_privhead(data, ph); err = parse_privhead(data, ph);
if (err == 1)
err = create_partition(hd, first_part_minor, first_sector +
ph->config_start, ph->config_size);
put_dev_sector(sect); put_dev_sector(sect);
if (err <= 0)
return err;
if (ph->config_start < 1 ||
ph->config_start + ph->config_size > bdev->bd_inode->i_size >> 9) {
printk(LDM_CRIT "LDM Partition exceeds physical disk. "
"Aborting.\n");
err = -1;
}
return err; return err;
} }
...@@ -990,8 +941,6 @@ static int validate_partition_table(struct block_device *bdev) ...@@ -990,8 +941,6 @@ static int validate_partition_table(struct block_device *bdev)
* ldm_partition - find out whether a device is a dynamic disk and handle it * ldm_partition - find out whether a device is a dynamic disk and handle it
* @hd: gendisk structure in which to return the handled disk * @hd: gendisk structure in which to return the handled disk
* @dev: device we need to look at * @dev: device we need to look at
* @first_sector: first sector within the device
* @first_part_minor: first minor number of partitions for the device
* *
* Description: * Description:
* *
...@@ -1010,8 +959,7 @@ static int validate_partition_table(struct block_device *bdev) ...@@ -1010,8 +959,7 @@ static int validate_partition_table(struct block_device *bdev)
* 0 if @dev is not a dynamic disk, * 0 if @dev is not a dynamic disk,
* -1 if an error occured. * -1 if an error occured.
*/ */
int ldm_partition(struct gendisk *hd, struct block_device *bdev, int ldm_partition(struct parsed_partitions *state, struct block_device *bdev)
unsigned long first_sector, int first_part_minor)
{ {
struct privhead *ph = NULL; struct privhead *ph = NULL;
struct tocblock *toc = NULL; struct tocblock *toc = NULL;
...@@ -1020,8 +968,6 @@ int ldm_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -1020,8 +968,6 @@ int ldm_partition(struct gendisk *hd, struct block_device *bdev,
unsigned long db_first; unsigned long db_first;
int err; int err;
if (!hd)
return 0;
/* Check the partition table. */ /* Check the partition table. */
err = validate_partition_table(bdev); err = validate_partition_table(bdev);
if (err != 1) if (err != 1)
...@@ -1029,10 +975,11 @@ int ldm_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -1029,10 +975,11 @@ int ldm_partition(struct gendisk *hd, struct block_device *bdev,
if (!(ph = (struct privhead*)kmalloc(sizeof(*ph), GFP_KERNEL))) if (!(ph = (struct privhead*)kmalloc(sizeof(*ph), GFP_KERNEL)))
goto no_mem; goto no_mem;
/* Create the LDM database device. */ /* Create the LDM database device. */
err = create_db_partition(hd, bdev, first_sector, first_part_minor, ph); err = find_db_partition(bdev, ph);
if (err != 1) if (err != 1)
goto out; goto out;
db_first = hd->part[first_part_minor].start_sect; db_first = ph->config_start;
put_partition(state, 1, db_first, ph->config_size);
/* Check the backup privheads. */ /* Check the backup privheads. */
err = validate_privheads(bdev, ph, db_first); err = validate_privheads(bdev, ph, db_first);
if (err != 1) if (err != 1)
...@@ -1056,8 +1003,8 @@ int ldm_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -1056,8 +1003,8 @@ int ldm_partition(struct gendisk *hd, struct block_device *bdev,
if (err != 1) if (err != 1)
goto out; goto out;
/* Finally, create the data partition devices. */ /* Finally, create the data partition devices. */
err = create_data_partitions(hd, first_sector, first_part_minor + err = create_data_partitions(state, 1 + LDM_FIRST_PART_OFFSET,
LDM_FIRST_PART_OFFSET, bdev, vm, ph, dk, db_first); bdev, vm, ph, dk, db_first);
if (err == 1) if (err == 1)
ldm_debug("Parsed LDM database successfully.\n"); ldm_debug("Parsed LDM database successfully.\n");
out: out:
...@@ -1071,4 +1018,3 @@ int ldm_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -1071,4 +1018,3 @@ int ldm_partition(struct gendisk *hd, struct block_device *bdev,
err = -1; err = -1;
goto out; goto out;
} }
...@@ -150,8 +150,7 @@ struct ldm_part { ...@@ -150,8 +150,7 @@ struct ldm_part {
unsigned long size; unsigned long size;
}; };
int ldm_partition(struct gendisk *hd, struct block_device *bdev, int ldm_partition(struct parsed_partitions *state, struct block_device *bdev);
unsigned long first_sector, int first_part_minor);
#endif /* _FS_PT_LDM_H_ */ #endif /* _FS_PT_LDM_H_ */
...@@ -7,16 +7,7 @@ ...@@ -7,16 +7,7 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/blk.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <asm/system.h>
#include "check.h" #include "check.h"
#include "mac.h" #include "mac.h"
...@@ -36,9 +27,9 @@ static inline void mac_fix_string(char *stg, int len) ...@@ -36,9 +27,9 @@ static inline void mac_fix_string(char *stg, int len)
stg[i] = 0; stg[i] = 0;
} }
int mac_partition(struct gendisk *hd, struct block_device *bdev, int mac_partition(struct parsed_partitions *state, struct block_device *bdev)
unsigned long fsec, int first_part_minor)
{ {
int slot = 1;
Sector sect; Sector sect;
unsigned char *data; unsigned char *data;
int blk, blocks_in_map; int blk, blocks_in_map;
...@@ -79,8 +70,8 @@ int mac_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -79,8 +70,8 @@ int mac_partition(struct gendisk *hd, struct block_device *bdev,
part = (struct mac_partition *) (data + pos%512); part = (struct mac_partition *) (data + pos%512);
if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC)
break; break;
add_gd_partition(hd, first_part_minor, put_partition(state, slot,
fsec + be32_to_cpu(part->start_block) * (secsize/512), be32_to_cpu(part->start_block) * (secsize/512),
be32_to_cpu(part->block_count) * (secsize/512)); be32_to_cpu(part->block_count) * (secsize/512));
#ifdef CONFIG_ALL_PPC #ifdef CONFIG_ALL_PPC
...@@ -126,7 +117,7 @@ int mac_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -126,7 +117,7 @@ int mac_partition(struct gendisk *hd, struct block_device *bdev,
} }
#endif /* CONFIG_ALL_PPC */ #endif /* CONFIG_ALL_PPC */
++first_part_minor; ++slot;
} }
#ifdef CONFIG_ALL_PPC #ifdef CONFIG_ALL_PPC
if (found_root_goodness) if (found_root_goodness)
...@@ -138,4 +129,3 @@ int mac_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -138,4 +129,3 @@ int mac_partition(struct gendisk *hd, struct block_device *bdev,
printk("\n"); printk("\n");
return 1; return 1;
} }
...@@ -41,4 +41,4 @@ struct mac_driver_desc { ...@@ -41,4 +41,4 @@ struct mac_driver_desc {
/* ... more stuff */ /* ... more stuff */
}; };
int mac_partition(struct gendisk *hd, struct block_device *bdev, unsigned long fsec, int first_part_minor); int mac_partition(struct parsed_partitions *state, struct block_device *bdev);
This diff is collapsed.
...@@ -4,6 +4,5 @@ ...@@ -4,6 +4,5 @@
#define MSDOS_LABEL_MAGIC 0xAA55 #define MSDOS_LABEL_MAGIC 0xAA55
int msdos_partition(struct gendisk *hd, struct block_device *bdev, int msdos_partition(struct parsed_partitions *state, struct block_device *bdev);
unsigned long first_sector, int first_part_minor);
...@@ -7,23 +7,15 @@ ...@@ -7,23 +7,15 @@
* Re-organised Feb 1998 Russell King * Re-organised Feb 1998 Russell King
*/ */
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/blk.h>
#include "check.h" #include "check.h"
#include "osf.h" #include "osf.h"
int osf_partition(struct gendisk *hd, struct block_device *bdev, int osf_partition(struct parsed_partitions *state, struct block_device *bdev)
unsigned long first_sector, int current_minor)
{ {
int i; int i;
int slot = 1;
Sector sect; Sector sect;
unsigned char *data; unsigned char *data;
int mask = (1 << hd->minor_shift) - 1;
struct disklabel { struct disklabel {
u32 d_magic; u32 d_magic;
u16 d_type,d_subtype; u16 d_type,d_subtype;
...@@ -72,16 +64,14 @@ int osf_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -72,16 +64,14 @@ int osf_partition(struct gendisk *hd, struct block_device *bdev,
return 0; return 0;
} }
for (i = 0 ; i < le16_to_cpu(label->d_npartitions); i++, partition++) { for (i = 0 ; i < le16_to_cpu(label->d_npartitions); i++, partition++) {
if ((current_minor & mask) == 0) if (slot == state->limit)
break; break;
if (le32_to_cpu(partition->p_size)) if (le32_to_cpu(partition->p_size))
add_gd_partition(hd, current_minor, put_partition(state, slot++,
first_sector+le32_to_cpu(partition->p_offset), le32_to_cpu(partition->p_offset),
le32_to_cpu(partition->p_size)); le32_to_cpu(partition->p_size));
current_minor++;
} }
printk("\n"); printk("\n");
put_dev_sector(sect); put_dev_sector(sect);
return 1; return 1;
} }
...@@ -4,6 +4,4 @@ ...@@ -4,6 +4,4 @@
#define DISKLABELMAGIC (0x82564557UL) #define DISKLABELMAGIC (0x82564557UL)
int osf_partition(struct gendisk *hd, struct block_device *bdev, int osf_partition(struct parsed_partitions *state, struct block_device *bdev);
unsigned long first_sector, int current_minor);
...@@ -4,22 +4,13 @@ ...@@ -4,22 +4,13 @@
* Code extracted from drivers/block/genhd.c * Code extracted from drivers/block/genhd.c
*/ */
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/blk.h>
#include <asm/byteorder.h>
#include <asm/system.h>
#include "check.h" #include "check.h"
#include "sgi.h" #include "sgi.h"
int sgi_partition(struct gendisk *hd, struct block_device *bdev, unsigned long first_sector, int current_minor) int sgi_partition(struct parsed_partitions *state, struct block_device *bdev)
{ {
int i, csum, magic; int i, csum, magic;
int slot = 1;
unsigned int *ui, start, blocks, cs; unsigned int *ui, start, blocks, cs;
Sector sect; Sector sect;
struct sgi_disklabel { struct sgi_disklabel {
...@@ -73,10 +64,8 @@ int sgi_partition(struct gendisk *hd, struct block_device *bdev, unsigned long f ...@@ -73,10 +64,8 @@ int sgi_partition(struct gendisk *hd, struct block_device *bdev, unsigned long f
for(i = 0; i < 16; i++, p++) { for(i = 0; i < 16; i++, p++) {
blocks = be32_to_cpu(p->num_blocks); blocks = be32_to_cpu(p->num_blocks);
start = be32_to_cpu(p->first_block); start = be32_to_cpu(p->first_block);
if(!blocks) if (blocks)
continue; put_partition(state, slot++, start, blocks);
add_gd_partition(hd, current_minor, start, blocks);
current_minor++;
} }
printk("\n"); printk("\n");
put_dev_sector(sect); put_dev_sector(sect);
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
* fs/partitions/sgi.h * fs/partitions/sgi.h
*/ */
extern int sgi_partition(struct gendisk *hd, struct block_device *bdev, extern int sgi_partition(struct parsed_partitions *state, struct block_device *bdev);
unsigned long first_sector, int first_part_minor);
#define SGI_LABEL_MAGIC 0x0be5a941 #define SGI_LABEL_MAGIC 0x0be5a941
...@@ -7,21 +7,13 @@ ...@@ -7,21 +7,13 @@
* Re-organised Feb 1998 Russell King * Re-organised Feb 1998 Russell King
*/ */
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/blk.h>
#include <asm/system.h>
#include "check.h" #include "check.h"
#include "sun.h" #include "sun.h"
int sun_partition(struct gendisk *hd, struct block_device *bdev, unsigned long first_sector, int first_part_minor) int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
{ {
int i, csum; int i, csum;
int slot = 1;
unsigned short *ush; unsigned short *ush;
Sector sect; Sector sect;
struct sun_disklabel { struct sun_disklabel {
...@@ -74,11 +66,10 @@ int sun_partition(struct gendisk *hd, struct block_device *bdev, unsigned long f ...@@ -74,11 +66,10 @@ int sun_partition(struct gendisk *hd, struct block_device *bdev, unsigned long f
unsigned long st_sector; unsigned long st_sector;
int num_sectors; int num_sectors;
st_sector = first_sector + be32_to_cpu(p->start_cylinder) * spc; st_sector = be32_to_cpu(p->start_cylinder) * spc;
num_sectors = be32_to_cpu(p->num_sectors); num_sectors = be32_to_cpu(p->num_sectors);
if (num_sectors) if (num_sectors)
add_gd_partition(hd, first_part_minor, st_sector, num_sectors); put_partition(state, slot++, st_sector, num_sectors);
first_part_minor++;
} }
printk("\n"); printk("\n");
put_dev_sector(sect); put_dev_sector(sect);
......
...@@ -4,6 +4,4 @@ ...@@ -4,6 +4,4 @@
#define SUN_LABEL_MAGIC 0xDABE #define SUN_LABEL_MAGIC 0xDABE
int sun_partition(struct gendisk *hd, struct block_device *bdev, int sun_partition(struct parsed_partitions *state, struct block_device *bdev);
unsigned long first_sector, int first_part_minor);
...@@ -6,16 +6,9 @@ ...@@ -6,16 +6,9 @@
* Re-organised Jul 1999 Russell King * Re-organised Jul 1999 Russell King
*/ */
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/blk.h>
#include "check.h" #include "check.h"
int ultrix_partition(struct gendisk *hd, struct block_device *bdev, int ultrix_partition(struct parsed_partitions *state, struct block_device *bdev)
unsigned long first_sector, int first_part_minor)
{ {
int i; int i;
Sector sect; Sector sect;
...@@ -39,9 +32,9 @@ int ultrix_partition(struct gendisk *hd, struct block_device *bdev, ...@@ -39,9 +32,9 @@ int ultrix_partition(struct gendisk *hd, struct block_device *bdev,
label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label)); label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label));
if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) { if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) {
for (i=0; i<8; i++, first_part_minor++) for (i=0; i<8; i++)
if (label->pt_part[i].pi_nblocks) if (label->pt_part[i].pi_nblocks)
add_gd_partition(hd, first_part_minor, put_partition(state, i+1,
label->pt_part[i].pi_blkoff, label->pt_part[i].pi_blkoff,
label->pt_part[i].pi_nblocks); label->pt_part[i].pi_nblocks);
put_dev_sector(sect); put_dev_sector(sect);
......
...@@ -2,6 +2,4 @@ ...@@ -2,6 +2,4 @@
* fs/partitions/ultrix.h * fs/partitions/ultrix.h
*/ */
int ultrix_partition(struct gendisk *hd, struct block_device *bdev, int ultrix_partition(struct parsed_partitions *state, struct block_device *bdev);
unsigned long first_sector, int first_part_minor);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment