Commit 22dda8bf authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] gendisk fixes

 - fixes an idiocy with floppy_find() et.al. - they forgot to set
   *part to 0.  As the result, open() on anything other than fd0 had
   lead to interesting effects...

 - fixes off-by-1 in set_disk_ro().
parent b3caff53
......@@ -1528,6 +1528,7 @@ static struct gendisk *floppy_find(dev_t dev, int *part, void *data)
int drive = *part & 3;
if ((*part >> 2) > NUM_DISK_TYPES || drive >= FD_MAX_UNITS)
return NULL;
*part = 0;
return get_disk(disks[drive]);
}
......
......@@ -1765,6 +1765,7 @@ static struct gendisk *floppy_find(dev_t dev, int *part, void *data)
int drive = *part & 3;
if (unit[drive].type->code == FD_NODRIVE)
return NULL;
*part = 0;
return get_disk(unit[drive].gendisk);
}
......
......@@ -1919,6 +1919,7 @@ static struct gendisk *floppy_find(dev_t dev, int *part, void *data)
int type = *part >> 2;
if (drive >= FD_MAX_UNITS || type > NUM_DISK_MINORS)
return NULL;
*part = 0;
return get_disk(unit[drive].disk);
}
......
......@@ -4210,6 +4210,7 @@ static struct gendisk *floppy_find(dev_t dev, int *part, void *data)
!(allowed_drive_mask & (1 << drive)) ||
fdc_state[FDC(drive)].version == FDC_NONE)
return NULL;
*part = 0;
return get_disk(disks[drive]);
}
......
......@@ -92,9 +92,7 @@ EXPORT_SYMBOL(blk_unregister_region);
static struct gendisk *exact_match(dev_t dev, int *part, void *data)
{
struct gendisk *p = data;
*part = MINOR(dev) - p->first_minor;
return p;
return data;
}
static int exact_lock(dev_t dev, void *data)
......@@ -363,7 +361,7 @@ void set_disk_ro(struct gendisk *disk, int flag)
{
int i;
disk->policy = flag;
for (i = 0; i < disk->minors; i++)
for (i = 0; i < disk->minors - 1; i++)
disk->part[i].policy = flag;
}
......
......@@ -982,7 +982,7 @@ static int ata_lock(dev_t dev, void *data)
struct gendisk *ata_probe(dev_t dev, int *part, void *data)
{
ide_hwif_t *hwif = data;
int unit = MINOR(dev) >> PARTN_BITS;
int unit = *part >> PARTN_BITS;
ide_drive_t *drive = &hwif->drives[unit];
if (!drive->present)
return NULL;
......@@ -1000,6 +1000,7 @@ struct gendisk *ata_probe(dev_t dev, int *part, void *data)
}
if (!drive->driver)
return NULL;
*part &= (1 << PARTN_BITS) - 1;
return get_disk(drive->disk);
}
......
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