Commit 36bd834b authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (3/25) Removing useless minor arguments

	driverfs_remove_partitions(), devfs_register_partitions(),
driverfs_create_partitions(), devfs_register_partition(), devfs_register_disc(),
had lost 'minor' argument - it's always disk->first_minor these days.
disk_name() takes partition number instead of minor now.  Callers of
wipe_partitions() in fs/block_dev.c expanded.  Remaining caller passes
gendisk instead of kdev_t now.
parent 4e493886
...@@ -71,7 +71,6 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p) ...@@ -71,7 +71,6 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p)
long pstart, plength; long pstart, plength;
int i; int i;
kdev_t dev = to_kdev_t(bdev->bd_dev); kdev_t dev = to_kdev_t(bdev->bd_dev);
struct hd_struct *part;
/* convert bytes to sectors, check for fit in a hd_struct */ /* convert bytes to sectors, check for fit in a hd_struct */
ppstart = (p->start >> 9); ppstart = (p->start >> 9);
...@@ -86,7 +85,6 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p) ...@@ -86,7 +85,6 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p)
g = get_gendisk(dev); g = get_gendisk(dev);
if (!g) if (!g)
return -ENXIO; return -ENXIO;
part = g->part + minor(dev) - g->first_minor;
/* existing drive? */ /* existing drive? */
...@@ -97,19 +95,19 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p) ...@@ -97,19 +95,19 @@ int add_partition(struct block_device *bdev, struct blkpg_partition *p)
return -EINVAL; return -EINVAL;
/* partition number in use? */ /* partition number in use? */
if (part[p->pno].nr_sects != 0) if (g->part[p->pno].nr_sects != 0)
return -EBUSY; return -EBUSY;
/* overlap? */ /* overlap? */
for (i = 1; i < (1<<g->minor_shift); i++) for (i = 1; i < (1<<g->minor_shift); i++)
if (!(pstart+plength <= part[i].start_sect || if (!(pstart+plength <= g->part[i].start_sect ||
pstart >= part[i].start_sect + part[i].nr_sects)) pstart >= g->part[i].start_sect + g->part[i].nr_sects))
return -EBUSY; return -EBUSY;
/* all seems OK */ /* all seems OK */
part[p->pno].start_sect = pstart; g->part[p->pno].start_sect = pstart;
part[p->pno].nr_sects = plength; g->part[p->pno].nr_sects = plength;
devfs_register_partitions (g, minor(dev), 0); devfs_register_partitions (g, 0);
return 0; return 0;
} }
...@@ -128,22 +126,19 @@ int del_partition(struct block_device *bdev, struct blkpg_partition *p) ...@@ -128,22 +126,19 @@ int del_partition(struct block_device *bdev, struct blkpg_partition *p)
kdev_t dev = to_kdev_t(bdev->bd_dev); kdev_t dev = to_kdev_t(bdev->bd_dev);
struct gendisk *g; struct gendisk *g;
struct block_device *bdevp; struct block_device *bdevp;
struct hd_struct *part;
int holder; int holder;
/* find the drive major */ /* find the drive major */
g = get_gendisk(dev); g = get_gendisk(dev);
if (!g) if (!g)
return -ENXIO; return -ENXIO;
part = g->part + minor(dev) - g->first_minor;
if (bdev != bdev->bd_contains) if (bdev != bdev->bd_contains)
return -EINVAL; return -EINVAL;
if (p->pno <= 0 || p->pno >= (1 << g->minor_shift)) if (p->pno <= 0 || p->pno >= (1 << g->minor_shift))
return -EINVAL; return -EINVAL;
/* existing drive and partition? */ /* existing drive and partition? */
if (part[p->pno].nr_sects == 0) if (g->part[p->pno].nr_sects == 0)
return -ENXIO; return -ENXIO;
/* partition in use? Incomplete check for now. */ /* partition in use? Incomplete check for now. */
...@@ -159,9 +154,9 @@ int del_partition(struct block_device *bdev, struct blkpg_partition *p) ...@@ -159,9 +154,9 @@ int del_partition(struct block_device *bdev, struct blkpg_partition *p)
fsync_bdev(bdevp); fsync_bdev(bdevp);
invalidate_bdev(bdevp, 0); invalidate_bdev(bdevp, 0);
part[p->pno].start_sect = 0; g->part[p->pno].start_sect = 0;
part[p->pno].nr_sects = 0; g->part[p->pno].nr_sects = 0;
devfs_register_partitions (g, minor(dev), 0); devfs_register_partitions (g, 0);
bd_release(bdevp); bd_release(bdevp);
bdput(bdevp); bdput(bdevp);
......
...@@ -81,7 +81,7 @@ del_gendisk(struct gendisk *disk) ...@@ -81,7 +81,7 @@ del_gendisk(struct gendisk *disk)
{ {
struct gendisk **p; struct gendisk **p;
wipe_partitions(mk_kdev(disk->major, disk->first_minor)); wipe_partitions(disk);
write_lock(&gendisk_lock); write_lock(&gendisk_lock);
for (p = &gendisk_head; *p; p = &((*p)->next)) for (p = &gendisk_head; *p; p = &((*p)->next))
if (*p == disk) if (*p == disk)
...@@ -89,7 +89,7 @@ del_gendisk(struct gendisk *disk) ...@@ -89,7 +89,7 @@ del_gendisk(struct gendisk *disk)
if (*p) if (*p)
*p = (*p)->next; *p = (*p)->next;
write_unlock(&gendisk_lock); write_unlock(&gendisk_lock);
devfs_register_partitions(disk, disk->first_minor, 1); devfs_register_partitions(disk, 1);
} }
EXPORT_SYMBOL(del_gendisk); EXPORT_SYMBOL(del_gendisk);
...@@ -168,7 +168,7 @@ static int show_partition(struct seq_file *part, void *v) ...@@ -168,7 +168,7 @@ static int show_partition(struct seq_file *part, void *v)
seq_printf(part, "%4d %4d %10ld %s\n", seq_printf(part, "%4d %4d %10ld %s\n",
sgp->major, n + sgp->first_minor, sgp->major, n + sgp->first_minor,
sgp->part[n].nr_sects >> 1 , sgp->part[n].nr_sects >> 1 ,
disk_name(sgp, n + sgp->first_minor, buf)); disk_name(sgp, n, buf));
} }
return 0; return 0;
......
...@@ -276,7 +276,7 @@ char * partition_name(kdev_t dev) ...@@ -276,7 +276,7 @@ char * partition_name(kdev_t dev)
hd = get_gendisk (dev); hd = get_gendisk (dev);
dname->name = NULL; dname->name = NULL;
if (hd) if (hd)
dname->name = disk_name (hd, minor(dev), dname->namebuf); dname->name = disk_name(hd, minor(dev)-hd->first_minor, dname->namebuf);
if (!dname->name) { if (!dname->name) {
sprintf (dname->namebuf, "[dev %s]", kdevname(dev)); sprintf (dname->namebuf, "[dev %s]", kdevname(dev));
dname->name = dname->namebuf; dname->name = dname->namebuf;
......
...@@ -126,8 +126,6 @@ static void sd_rw_intr(Scsi_Cmnd * SCpnt); ...@@ -126,8 +126,6 @@ static void sd_rw_intr(Scsi_Cmnd * SCpnt);
static Scsi_Disk * sd_get_sdisk(int index); static Scsi_Disk * sd_get_sdisk(int index);
extern void driverfs_remove_partitions(struct gendisk *hd, int minor);
#if defined(CONFIG_PPC32) #if defined(CONFIG_PPC32)
/** /**
* sd_find_target - find kdev_t of first scsi disk that matches * sd_find_target - find kdev_t of first scsi disk that matches
...@@ -1424,7 +1422,7 @@ static void sd_detach(Scsi_Device * sdp) ...@@ -1424,7 +1422,7 @@ static void sd_detach(Scsi_Device * sdp)
if (sdkp->has_been_registered) { if (sdkp->has_been_registered) {
sdkp->has_been_registered = 0; sdkp->has_been_registered = 0;
dev = MKDEV_SD(dsk_nr); dev = MKDEV_SD(dsk_nr);
driverfs_remove_partitions(sd_disks[dsk_nr], minor(dev)); driverfs_remove_partitions(sd_disks[dsk_nr]);
del_gendisk(sd_disks[dsk_nr]); del_gendisk(sd_disks[dsk_nr]);
} }
sdp->attached--; sdp->attached--;
......
...@@ -528,16 +528,21 @@ int check_disk_change(struct block_device *bdev) ...@@ -528,16 +528,21 @@ int check_disk_change(struct block_device *bdev)
int full_check_disk_change(struct block_device *bdev) int full_check_disk_change(struct block_device *bdev)
{ {
int res; int res;
if (bdev->bd_contains != bdev)
BUG();
down(&bdev->bd_sem); down(&bdev->bd_sem);
res = check_disk_change(bdev); res = check_disk_change(bdev);
if (bdev->bd_invalidated && !bdev->bd_part_count) { if (bdev->bd_invalidated && !bdev->bd_part_count) {
struct gendisk *g = get_gendisk(to_kdev_t(bdev->bd_dev)); struct gendisk *disk = get_gendisk(to_kdev_t(bdev->bd_dev));
struct hd_struct *part; int p;
part = g->part + MINOR(bdev->bd_dev) - g->first_minor;
bdev->bd_invalidated = 0; bdev->bd_invalidated = 0;
wipe_partitions(to_kdev_t(bdev->bd_dev)); for (p = 1; p < 1<<disk->minor_shift; p++) {
if (part[0].nr_sects) disk->part[p].start_sect = 0;
check_partition(g, bdev); disk->part[p].nr_sects = 0;
}
res = invalidate_device(to_kdev_t(bdev->bd_dev), 1);
if (disk->part[0].nr_sects)
check_partition(disk, bdev);
} }
up(&bdev->bd_sem); up(&bdev->bd_sem);
return res; return res;
...@@ -650,11 +655,14 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * ...@@ -650,11 +655,14 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
bdev->bd_inode->i_data.backing_dev_info = bdi; bdev->bd_inode->i_data.backing_dev_info = bdi;
} }
if (bdev->bd_invalidated && !bdev->bd_part_count) { if (bdev->bd_invalidated && !bdev->bd_part_count) {
struct hd_struct *part; int p;
part = g->part + minor(dev) - g->first_minor;
bdev->bd_invalidated = 0; bdev->bd_invalidated = 0;
wipe_partitions(dev); for (p = 1; p < 1<<g->minor_shift; p++) {
if (part[0].nr_sects) g->part[p].start_sect = 0;
g->part[p].nr_sects = 0;
}
invalidate_device(dev, 1);
if (g->part[0].nr_sects)
check_partition(g, bdev); check_partition(g, bdev);
} }
} else { } else {
...@@ -791,12 +799,10 @@ static int blkdev_reread_part(struct block_device *bdev) ...@@ -791,12 +799,10 @@ static int blkdev_reread_part(struct block_device *bdev)
{ {
kdev_t dev = to_kdev_t(bdev->bd_dev); kdev_t dev = to_kdev_t(bdev->bd_dev);
struct gendisk *disk = get_gendisk(dev); struct gendisk *disk = get_gendisk(dev);
struct hd_struct *part; int p, res;
int res;
if (!disk || !disk->minor_shift) if (!disk || !disk->minor_shift || bdev != bdev->bd_contains)
return -EINVAL; return -EINVAL;
part = disk->part + minor(dev) - disk->first_minor;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
if (down_trylock(&bdev->bd_sem)) if (down_trylock(&bdev->bd_sem))
...@@ -805,11 +811,15 @@ static int blkdev_reread_part(struct block_device *bdev) ...@@ -805,11 +811,15 @@ static int blkdev_reread_part(struct block_device *bdev)
up(&bdev->bd_sem); up(&bdev->bd_sem);
return -EBUSY; return -EBUSY;
} }
res = wipe_partitions(dev); for (p = 1; p < 1 << disk->minor_shift; p++) {
disk->part[p].start_sect = 0;
disk->part[p].nr_sects = 0;
}
res = invalidate_device(dev, 1);
if (!res) { if (!res) {
if (bdev->bd_op->revalidate) if (bdev->bd_op->revalidate)
bdev->bd_op->revalidate(dev); bdev->bd_op->revalidate(dev);
if (part[0].nr_sects) if (disk->part[0].nr_sects)
check_partition(disk, bdev); check_partition(disk, bdev);
} }
up(&bdev->bd_sem); up(&bdev->bd_sem);
......
...@@ -87,28 +87,21 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) = ...@@ -87,28 +87,21 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) =
* a pointer to that same buffer (for convenience). * a pointer to that same buffer (for convenience).
*/ */
char *disk_name (struct gendisk *hd, int minor, char *buf) char *disk_name (struct gendisk *hd, int part, char *buf)
{ {
unsigned int part = minor - hd->first_minor; if (part < 1<<hd->minor_shift && hd->part[part].de) {
struct hd_struct *p = hd->part + part;
char s[40];
const char *maj;
if (part < 1<<hd->minor_shift && p->de) {
int pos; int pos;
pos = devfs_generate_path(p->de, buf, 64); pos = devfs_generate_path(hd->part[part].de, buf, 64);
if (pos >= 0) if (pos >= 0)
return buf + pos; return buf + pos;
} }
maj = hd->major_name;
if (!part) if (!part)
sprintf(buf, "%s", maj); sprintf(buf, "%s", hd->major_name);
else if (isdigit(maj[strlen(maj)-1])) else if (isdigit(hd->major_name[strlen(hd->major_name)-1]))
sprintf(buf, "%sp%d", maj, part); sprintf(buf, "%sp%d", hd->major_name, part);
else else
sprintf(buf, "%s%d", maj, part); sprintf(buf, "%s%d", hd->major_name, part);
return buf; return buf;
} }
...@@ -129,7 +122,7 @@ static ssize_t partition_device_type_read(struct device *driverfs_dev, ...@@ -129,7 +122,7 @@ static ssize_t partition_device_type_read(struct device *driverfs_dev,
} }
static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL); static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL);
void driverfs_create_partitions(struct gendisk *hd, int minor) static void driverfs_create_partitions(struct gendisk *hd)
{ {
int pos = -1; int pos = -1;
char dirname[256]; char dirname[256];
...@@ -137,7 +130,7 @@ void driverfs_create_partitions(struct gendisk *hd, int minor) ...@@ -137,7 +130,7 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
int max_p; int max_p;
int part; int part;
devfs_handle_t dir = 0; devfs_handle_t dir = 0;
struct hd_struct *p = hd->part + minor - hd->first_minor; struct hd_struct *p = hd->part;
/* get parent driverfs device structure */ /* get parent driverfs device structure */
if (hd->driverfs_dev_arr) if (hd->driverfs_dev_arr)
...@@ -154,7 +147,7 @@ void driverfs_create_partitions(struct gendisk *hd, int minor) ...@@ -154,7 +147,7 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
} }
if (pos < 0) { if (pos < 0) {
disk_name(hd, minor, dirname); disk_name(hd, 0, dirname);
pos = 0; pos = 0;
} }
...@@ -168,7 +161,7 @@ void driverfs_create_partitions(struct gendisk *hd, int minor) ...@@ -168,7 +161,7 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
current_driverfs_dev->parent = parent; current_driverfs_dev->parent = parent;
/* handle disc case */ /* handle disc case */
current_driverfs_dev->driver_data = current_driverfs_dev->driver_data =
(void *)(long)__mkdev(hd->major, minor+part); (void *)(long)__mkdev(hd->major, hd->first_minor+part);
if (part == 0) { if (part == 0) {
if (parent) { if (parent) {
sprintf(current_driverfs_dev->name, sprintf(current_driverfs_dev->name,
...@@ -204,12 +197,12 @@ void driverfs_create_partitions(struct gendisk *hd, int minor) ...@@ -204,12 +197,12 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
} }
} }
void driverfs_remove_partitions(struct gendisk *hd, int minor) void driverfs_remove_partitions(struct gendisk *hd)
{ {
int max_p; int max_p;
int part; int part;
struct device * current_driverfs_dev; struct device * current_driverfs_dev;
struct hd_struct *p = hd->part + minor - hd->first_minor; struct hd_struct *p = hd->part;
max_p=(1 << hd->minor_shift); max_p=(1 << hd->minor_shift);
...@@ -225,10 +218,8 @@ void driverfs_remove_partitions(struct gendisk *hd, int minor) ...@@ -225,10 +218,8 @@ void driverfs_remove_partitions(struct gendisk *hd, int minor)
} }
} }
current_driverfs_dev = &p->hd_driverfs_dev; current_driverfs_dev = &p->hd_driverfs_dev;
device_remove_file(current_driverfs_dev, device_remove_file(current_driverfs_dev, &dev_attr_type);
&dev_attr_type); device_remove_file(current_driverfs_dev, &dev_attr_kdev);
device_remove_file(current_driverfs_dev,
&dev_attr_kdev);
put_device(current_driverfs_dev); put_device(current_driverfs_dev);
return; return;
} }
...@@ -256,7 +247,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev) ...@@ -256,7 +247,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
sprintf(state->name, "p"); sprintf(state->name, "p");
} else { } else {
unsigned n = hd->major; unsigned n = hd->major;
disk_name(hd, minor(dev), state->name); disk_name(hd, 0, state->name);
printk(KERN_INFO " %s:", state->name); printk(KERN_INFO " %s:", state->name);
if (n - COMPAQ_SMART2_MAJOR <= 7 || n - COMPAQ_CISS_MAJOR <= 7) if (n - COMPAQ_SMART2_MAJOR <= 7 || n - COMPAQ_CISS_MAJOR <= 7)
sprintf(state->name, "p"); sprintf(state->name, "p");
...@@ -274,7 +265,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev) ...@@ -274,7 +265,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
printk(" unable to read partition table\n"); printk(" unable to read partition table\n");
goto out; goto out;
} }
p = hd->part + minor(dev) - hd->first_minor; p = hd->part;
for (j = 1; j < state->limit; j++) { for (j = 1; j < state->limit; j++) {
p[j].start_sect = state->parts[j].from; p[j].start_sect = state->parts[j].from;
p[j].nr_sects = state->parts[j].size; p[j].nr_sects = state->parts[j].size;
...@@ -289,16 +280,16 @@ void check_partition(struct gendisk *hd, struct block_device *bdev) ...@@ -289,16 +280,16 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
printk(" unknown partition table\n"); printk(" unknown partition table\n");
out: out:
driverfs_create_partitions(hd, minor(dev)); driverfs_create_partitions(hd);
devfs_register_partitions (hd, minor(dev), 0); devfs_register_partitions(hd, 0);
} }
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
static void devfs_register_partition (struct gendisk *dev, int minor, int part) static void devfs_register_partition(struct gendisk *dev, int part)
{ {
devfs_handle_t dir; devfs_handle_t dir;
unsigned int devfs_flags = DEVFS_FL_DEFAULT; unsigned int devfs_flags = DEVFS_FL_DEFAULT;
struct hd_struct *p = dev->part + minor - dev->first_minor; struct hd_struct *p = dev->part;
char devname[16]; char devname[16];
if (p[part].de) if (p[part].de)
...@@ -310,21 +301,21 @@ static void devfs_register_partition (struct gendisk *dev, int minor, int part) ...@@ -310,21 +301,21 @@ static void devfs_register_partition (struct gendisk *dev, int minor, int part)
devfs_flags |= DEVFS_FL_REMOVABLE; devfs_flags |= DEVFS_FL_REMOVABLE;
sprintf (devname, "part%d", part); sprintf (devname, "part%d", part);
p[part].de = devfs_register (dir, devname, devfs_flags, p[part].de = devfs_register (dir, devname, devfs_flags,
dev->major, minor + part, dev->major, dev->first_minor + part,
S_IFBLK | S_IRUSR | S_IWUSR, S_IFBLK | S_IRUSR | S_IWUSR,
dev->fops, NULL); dev->fops, NULL);
} }
static struct unique_numspace disc_numspace = UNIQUE_NUMBERSPACE_INITIALISER; static struct unique_numspace disc_numspace = UNIQUE_NUMBERSPACE_INITIALISER;
static void devfs_register_disc (struct gendisk *dev, int minor) static void devfs_register_disc(struct gendisk *dev)
{ {
int pos = 0; int pos = 0;
devfs_handle_t dir, slave; devfs_handle_t dir, slave;
unsigned int devfs_flags = DEVFS_FL_DEFAULT; unsigned int devfs_flags = DEVFS_FL_DEFAULT;
char dirname[64], symlink[16]; char dirname[64], symlink[16];
static devfs_handle_t devfs_handle; static devfs_handle_t devfs_handle;
struct hd_struct *p = dev->part + minor - dev->first_minor; struct hd_struct *p = dev->part;
if (p[0].de) if (p[0].de)
return; return;
...@@ -350,7 +341,8 @@ static void devfs_register_disc (struct gendisk *dev, int minor) ...@@ -350,7 +341,8 @@ static void devfs_register_disc (struct gendisk *dev, int minor)
sprintf(symlink, "disc%d", p[0].number); sprintf(symlink, "disc%d", p[0].number);
devfs_mk_symlink (devfs_handle, symlink, DEVFS_FL_DEFAULT, devfs_mk_symlink (devfs_handle, symlink, DEVFS_FL_DEFAULT,
dirname + pos, &slave, NULL); dirname + pos, &slave, NULL);
p[0].de = devfs_register (dir, "disc", devfs_flags, dev->major, minor, p[0].de = devfs_register (dir, "disc", devfs_flags,
dev->major, dev->first_minor,
S_IFBLK | S_IRUSR | S_IWUSR, dev->fops, NULL); S_IFBLK | S_IRUSR | S_IWUSR, dev->fops, NULL);
devfs_auto_unregister(p[0].de, slave); devfs_auto_unregister(p[0].de, slave);
if (!dev->de_arr) if (!dev->de_arr)
...@@ -358,14 +350,14 @@ static void devfs_register_disc (struct gendisk *dev, int minor) ...@@ -358,14 +350,14 @@ static void devfs_register_disc (struct gendisk *dev, int minor)
} }
#endif /* CONFIG_DEVFS_FS */ #endif /* CONFIG_DEVFS_FS */
void devfs_register_partitions (struct gendisk *dev, int minor, int unregister) void devfs_register_partitions (struct gendisk *dev, int unregister)
{ {
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
int part, max_p; int part, max_p;
struct hd_struct *p = dev->part + minor - dev->first_minor; struct hd_struct *p = dev->part;
if (!unregister) if (!unregister)
devfs_register_disc (dev, minor); devfs_register_disc(dev);
max_p = (1 << dev->minor_shift); max_p = (1 << dev->minor_shift);
for (part = 1; part < max_p; part++) { for (part = 1; part < max_p; part++) {
if ( unregister || (p[part].nr_sects < 1) ) { if ( unregister || (p[part].nr_sects < 1) ) {
...@@ -373,7 +365,7 @@ void devfs_register_partitions (struct gendisk *dev, int minor, int unregister) ...@@ -373,7 +365,7 @@ void devfs_register_partitions (struct gendisk *dev, int minor, int unregister)
p[part].de = NULL; p[part].de = NULL;
continue; continue;
} }
devfs_register_partition (dev, minor, part); devfs_register_partition(dev, part);
} }
if (unregister) { if (unregister) {
devfs_unregister(p[0].de); devfs_unregister(p[0].de);
...@@ -402,7 +394,7 @@ void register_disk(struct gendisk *g, kdev_t dev, unsigned minors, ...@@ -402,7 +394,7 @@ void register_disk(struct gendisk *g, kdev_t dev, unsigned minors,
if (!g) if (!g)
return; return;
p = g->part + minor(dev) - g->first_minor; p = g->part;
p[0].nr_sects = size; p[0].nr_sects = size;
/* No minors to use for partitions */ /* No minors to use for partitions */
...@@ -443,38 +435,24 @@ unsigned char *read_dev_sector(struct block_device *bdev, unsigned long n, Secto ...@@ -443,38 +435,24 @@ unsigned char *read_dev_sector(struct block_device *bdev, unsigned long n, Secto
return NULL; return NULL;
} }
int wipe_partitions(kdev_t dev) int wipe_partitions(struct gendisk *disk)
{ {
struct gendisk *g; int max_p = 1 << disk->minor_shift;
kdev_t devp; int p;
int p, major, minor, minor0, max_p, res;
struct hd_struct *part;
g = get_gendisk(dev);
if (g == NULL)
return -EINVAL;
max_p = 1 << g->minor_shift;
major = major(dev);
minor = minor(dev);
minor0 = minor & ~(max_p - 1);
if (minor0 != minor) /* for now only whole-disk reread */
return -EINVAL; /* %%% later.. */
part = g->part + minor - g->first_minor;
/* invalidate stuff */ /* invalidate stuff */
for (p = max_p - 1; p >= 0; p--) { for (p = max_p - 1; p >= 0; p--) {
minor = minor0 + p; kdev_t devp = mk_kdev(disk->major,disk->first_minor + p);
devp = mk_kdev(major,minor); int res;
#if 0 /* %%% superfluous? */ #if 0 /* %%% superfluous? */
if (part[p].nr_sects == 0) if (disk->part[p].nr_sects == 0)
continue; continue;
#endif #endif
res = invalidate_device(devp, 1); res = invalidate_device(devp, 1);
if (res) if (res)
return res; return res;
part[p].start_sect = 0; disk->part[p].start_sect = 0;
part[p].nr_sects = 0; disk->part[p].nr_sects = 0;
} }
return 0; return 0;
} }
...@@ -281,7 +281,7 @@ struct sec_size { ...@@ -281,7 +281,7 @@ struct sec_size {
extern struct sec_size * blk_sec[MAX_BLKDEV]; extern struct sec_size * blk_sec[MAX_BLKDEV];
extern struct blk_dev_struct blk_dev[MAX_BLKDEV]; extern struct blk_dev_struct blk_dev[MAX_BLKDEV];
extern int wipe_partitions(kdev_t dev); extern int wipe_partitions(struct gendisk *disk);
extern void register_disk(struct gendisk *dev, kdev_t first, unsigned minors, struct block_device_operations *ops, long size); extern void register_disk(struct gendisk *dev, kdev_t first, unsigned minors, struct block_device_operations *ops, long size);
extern void check_partition(struct gendisk *disk, struct block_device *bdev); extern void check_partition(struct gendisk *disk, struct block_device *bdev);
extern void generic_make_request(struct bio *bio); extern void generic_make_request(struct bio *bio);
......
...@@ -240,11 +240,10 @@ struct unixware_disklabel { ...@@ -240,11 +240,10 @@ struct unixware_disklabel {
#ifdef __KERNEL__ #ifdef __KERNEL__
char *disk_name (struct gendisk *hd, int minor, char *buf); char *disk_name (struct gendisk *hd, int part, char *buf);
extern void devfs_register_partitions (struct gendisk *dev, int minor, extern void devfs_register_partitions (struct gendisk *dev, int unregister);
int unregister); extern void driverfs_remove_partitions (struct gendisk *hd);
extern void driverfs_remove_partitions (struct gendisk *hd, int minor);
static inline unsigned int disk_index (kdev_t dev) static inline unsigned int disk_index (kdev_t dev)
{ {
......
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