Commit 7e06e792 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] clean up major_name

->major_name for per-disk gendisks set to full name - i.e.
IDE gendisks have "hda", "hdb", etc. instead of "hd".
As the result, we kill a lot of crap in check.c::disk_name().
In particular, now we can afford ->minor_shift set to 0
for ide-cd (disk_name() was the only obstacle)
parent 814bd2ba
...@@ -1257,14 +1257,14 @@ static struct gendisk mfm_gendisk[2] = { ...@@ -1257,14 +1257,14 @@ static struct gendisk mfm_gendisk[2] = {
{ {
major: MAJOR_NR, major: MAJOR_NR,
first_minor: 0, first_minor: 0,
major_name: "mfm", major_name: "mfma",
minor_shift: 6, minor_shift: 6,
part: mfm, part: mfm,
}, },
{ {
major: MAJOR_NR, major: MAJOR_NR,
first_minor: 64, first_minor: 64,
major_name: "mfm", major_name: "mfmb",
minor_shift: 6, minor_shift: 6,
part: mfm + 64, part: mfm + 64,
}; };
......
...@@ -327,14 +327,6 @@ static char *pd_errs[17] = { "ERR","INDEX","ECC","DRQ","SEEK","WRERR", ...@@ -327,14 +327,6 @@ static char *pd_errs[17] = { "ERR","INDEX","ECC","DRQ","SEEK","WRERR",
extern struct block_device_operations pd_fops; extern struct block_device_operations pd_fops;
static struct gendisk pd_gendisk = {
major: PD_MAJOR,
major_name: PD_NAME,
minor_shift: PD_BITS,
fops: &pd_fops,
nr_real: 1,
};
static struct block_device_operations pd_fops = { static struct block_device_operations pd_fops = {
owner: THIS_MODULE, owner: THIS_MODULE,
open: pd_open, open: pd_open,
...@@ -706,7 +698,11 @@ static int pd_detect( void ) ...@@ -706,7 +698,11 @@ static int pd_detect( void )
} }
for (unit=0;unit<PD_UNITS;unit++) { for (unit=0;unit<PD_UNITS;unit++) {
if (PD.present) { if (PD.present) {
PD.gd = pd_gendisk; PD.gd.major_name = PD.name;
PD.gd.minor_shift = PD_BITS;
PD.gd.fops = &pd_fops;
PD.gd.nr_real = 1;
PD.gd.major = major;
PD.gd.first_minor = unit << PD_BITS; PD.gd.first_minor = unit << PD_BITS;
PD.gd.part = pd_hd + (unit << PD_BITS); PD.gd.part = pd_hd + (unit << PD_BITS);
add_gendisk(&PD.gd); add_gendisk(&PD.gd);
...@@ -947,8 +943,6 @@ static int __init pd_init(void) ...@@ -947,8 +943,6 @@ static int __init pd_init(void)
blk_init_queue(q, do_pd_request, &pd_lock); blk_init_queue(q, do_pd_request, &pd_lock);
blk_queue_max_sectors(q, cluster); blk_queue_max_sectors(q, cluster);
pd_gendisk.major = major;
pd_gendisk.major_name = name;
printk("%s: %s version %s, major %d, cluster %d, nice %d\n", printk("%s: %s version %s, major %d, cluster %d, nice %d\n",
name,name,PD_VERSION,major,cluster,nice); name,name,PD_VERSION,major,cluster,nice);
pd_init_units(); pd_init_units();
......
...@@ -166,7 +166,7 @@ int __init xd_init (void) ...@@ -166,7 +166,7 @@ int __init xd_init (void)
printk("xd: Unable to get major number %d\n",MAJOR_NR); printk("xd: Unable to get major number %d\n",MAJOR_NR);
return -1; return -1;
} }
devfs_handle = devfs_mk_dir (NULL, xd_gendisk.major_name, NULL); devfs_handle = devfs_mk_dir (NULL, "xd", NULL);
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_xd_request, &xd_lock); blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_xd_request, &xd_lock);
add_gendisk(&xd_gendisk); add_gendisk(&xd_gendisk);
xd_geninit(); xd_geninit();
......
...@@ -712,14 +712,14 @@ static struct gendisk hd_gendisk[2] = { ...@@ -712,14 +712,14 @@ static struct gendisk hd_gendisk[2] = {
{ {
.major = MAJOR_NR, .major = MAJOR_NR,
.first_minor = 0, .first_minor = 0,
.major_name = "hd", .major_name = "hda",
.minor_shift = 6, .minor_shift = 6,
.part = hd, .part = hd,
.fops = &hd_fops, .fops = &hd_fops,
},{ },{
.major = MAJOR_NR, .major = MAJOR_NR,
.first_minor = 64, .first_minor = 64,
.major_name = "hd", .major_name = "hdb",
.minor_shift = 6, .minor_shift = 6,
.part = hd + 64, .part = hd + 64,
.fops = &hd_fops, .fops = &hd_fops,
......
...@@ -493,6 +493,7 @@ void ide_unregister(struct ata_channel *ch) ...@@ -493,6 +493,7 @@ void ide_unregister(struct ata_channel *ch)
int i; int i;
for (i = 0; i < MAX_DRIVES; i++) for (i = 0; i < MAX_DRIVES; i++)
del_gendisk(gd + i); del_gendisk(gd + i);
kfree(gd->major_name);
kfree(gd->part); kfree(gd->part);
if (gd->de_arr) if (gd->de_arr)
kfree (gd->de_arr); kfree (gd->de_arr);
......
...@@ -1048,6 +1048,7 @@ static void channel_init(struct ata_channel *ch) ...@@ -1048,6 +1048,7 @@ static void channel_init(struct ata_channel *ch)
char *flags; char *flags;
unsigned int unit; unsigned int unit;
extern devfs_handle_t ide_devfs_handle; extern devfs_handle_t ide_devfs_handle;
char *names;
if (!ch->present) if (!ch->present)
return; return;
...@@ -1127,6 +1128,11 @@ static void channel_init(struct ata_channel *ch) ...@@ -1127,6 +1128,11 @@ static void channel_init(struct ata_channel *ch)
goto err_kmalloc_gd_flags; goto err_kmalloc_gd_flags;
memset(flags, 0, sizeof(char) * MAX_DRIVES); memset(flags, 0, sizeof(char) * MAX_DRIVES);
names = kmalloc (4 * MAX_DRIVES, GFP_KERNEL);
if (!names)
goto err_kmalloc_gd_names;
memset(names, 0, 4 * MAX_DRIVES);
for (unit = 0; unit < MAX_DRIVES; ++unit) { for (unit = 0; unit < MAX_DRIVES; ++unit) {
gd[unit].part = part + (unit << PARTN_BITS); gd[unit].part = part + (unit << PARTN_BITS);
gd[unit].de_arr = de_arr + unit; gd[unit].de_arr = de_arr + unit;
...@@ -1134,8 +1140,8 @@ static void channel_init(struct ata_channel *ch) ...@@ -1134,8 +1140,8 @@ static void channel_init(struct ata_channel *ch)
ch->drives[unit].part = gd[unit].part; ch->drives[unit].part = gd[unit].part;
gd[unit].major = ch->major; gd[unit].major = ch->major;
gd[unit].first_minor = unit << PARTN_BITS; gd[unit].first_minor = unit << PARTN_BITS;
/* treated special in genhd.c */ sprintf(names + 4*unit, "hd%c", 'a'+ch->index*MAX_DRIVES+unit);
gd[unit].major_name = IDE_MAJOR_NAME; gd[unit].major_name = names + 4*unit;
gd[unit].minor_shift = PARTN_BITS; gd[unit].minor_shift = PARTN_BITS;
gd[unit].nr_real = 1; gd[unit].nr_real = 1;
gd[unit].fops = ide_fops; gd[unit].fops = ide_fops;
...@@ -1161,6 +1167,8 @@ static void channel_init(struct ata_channel *ch) ...@@ -1161,6 +1167,8 @@ static void channel_init(struct ata_channel *ch)
return; return;
err_kmalloc_gd_names:
kfree(names);
err_kmalloc_gd_flags: err_kmalloc_gd_flags:
kfree(de_arr); kfree(de_arr);
err_kmalloc_gd_de_arr: err_kmalloc_gd_de_arr:
......
...@@ -125,6 +125,7 @@ MODULE_PARM(shuffle_freq, "i"); ...@@ -125,6 +125,7 @@ MODULE_PARM(shuffle_freq, "i");
/* Each memory region corresponds to a minor device */ /* Each memory region corresponds to a minor device */
typedef struct partition_t { typedef struct partition_t {
struct mtd_info *mtd; struct mtd_info *mtd;
struct gndisk *disk;
u_int32_t state; u_int32_t state;
u_int32_t *VirtualBlockMap; u_int32_t *VirtualBlockMap;
u_int32_t *VirtualPageMap; u_int32_t *VirtualPageMap;
...@@ -176,13 +177,6 @@ static struct mtd_notifier ftl_notifier = { ...@@ -176,13 +177,6 @@ static struct mtd_notifier ftl_notifier = {
static struct hd_struct ftl_hd[MINOR_NR(MAX_DEV, 0, 0)]; static struct hd_struct ftl_hd[MINOR_NR(MAX_DEV, 0, 0)];
static struct gendisk ftl_gendisk = {
major: FTL_MAJOR,
major_name: "ftl",
minor_shift: PART_BITS,
part: ftl_hd,
};
/*====================================================================*/ /*====================================================================*/
static int ftl_ioctl(struct inode *inode, struct file *file, static int ftl_ioctl(struct inode *inode, struct file *file,
...@@ -850,7 +844,7 @@ static int ftl_open(struct inode *inode, struct file *file) ...@@ -850,7 +844,7 @@ static int ftl_open(struct inode *inode, struct file *file)
if (partition->state != FTL_FORMATTED) if (partition->state != FTL_FORMATTED)
return -ENXIO; return -ENXIO;
if (ftl_gendisk.part[minor].nr_sects == 0) if (partition->disk->part[0].nr_sects == 0)
return -ENXIO; return -ENXIO;
if (!get_mtd_device(partition->mtd, -1)) if (!get_mtd_device(partition->mtd, -1))
...@@ -1181,15 +1175,13 @@ static void do_ftl_request(request_arg_t) ...@@ -1181,15 +1175,13 @@ static void do_ftl_request(request_arg_t)
switch (CURRENT->cmd) { switch (CURRENT->cmd) {
case READ: case READ:
ret = ftl_read(part, CURRENT->buffer, ret = ftl_read(part, CURRENT->buffer, CURRENT->sector,
CURRENT->sector+ftl_hd[minor].start_sect,
CURRENT->current_nr_sectors); CURRENT->current_nr_sectors);
if (ret) printk("ftl_read returned %d\n", ret); if (ret) printk("ftl_read returned %d\n", ret);
break; break;
case WRITE: case WRITE:
ret = ftl_write(part, CURRENT->buffer, ret = ftl_write(part, CURRENT->buffer, CURRENT->sector,
CURRENT->sector+ftl_hd[minor].start_sect,
CURRENT->current_nr_sectors); CURRENT->current_nr_sectors);
if (ret) printk("ftl_write returned %d\n", ret); if (ret) printk("ftl_write returned %d\n", ret);
break; break;
...@@ -1241,6 +1233,8 @@ void ftl_freepart(partition_t *part) ...@@ -1241,6 +1233,8 @@ void ftl_freepart(partition_t *part)
static void ftl_notify_add(struct mtd_info *mtd) static void ftl_notify_add(struct mtd_info *mtd)
{ {
partition_t *partition; partition_t *partition;
struct gendisk *disk;
char *name;
int device; int device;
for (device=0; device < MAX_MTD_DEVICES && myparts[device]; device++) for (device=0; device < MAX_MTD_DEVICES && myparts[device]; device++)
...@@ -1253,30 +1247,48 @@ static void ftl_notify_add(struct mtd_info *mtd) ...@@ -1253,30 +1247,48 @@ static void ftl_notify_add(struct mtd_info *mtd)
} }
partition = kmalloc(sizeof(partition_t), GFP_KERNEL); partition = kmalloc(sizeof(partition_t), GFP_KERNEL);
disk = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
name = kmalloc(4, GFP_KERNEL);
if (!partition) { if (!partition||!disk||!name) {
printk(KERN_WARNING "No memory to scan for FTL on %s\n", printk(KERN_WARNING "No memory to scan for FTL on %s\n",
mtd->name); mtd->name);
kfree(partition);
kfree(disk);
kfree(name);
return; return;
} }
memset(partition, 0, sizeof(partition_t)); memset(partition, 0, sizeof(partition_t));
memset(disk, 0, sizeof(struct gendisk));
sprintf(name, "ftl%c", 'a' + device);
disk->major = FTL_MAJOR;
disk->first_minor = device << 4;
disk->major_name = name;
disk->minor_shift = PART_BITS;
disk->part = ftl_hd + (device << 4);
disk->fops = &ftl_blk_fops;
disk->nr_real = 1;
partition->mtd = mtd; partition->mtd = mtd;
partition->disk = disk;
if ((scan_header(partition) == 0) && (build_maps(partition) == 0)) { if ((scan_header(partition) == 0) && (build_maps(partition) == 0)) {
partition->state = FTL_FORMATTED; partition->state = FTL_FORMATTED;
atomic_set(&partition->open, 0); atomic_set(&partition->open, 0);
myparts[device] = partition; myparts[device] = partition;
register_disk(&ftl_gendisk, mk_kdev(MAJOR_NR, device << 4), add_gendisk(disk);
register_disk(disk, mk_kdev(MAJOR_NR, device << 4),
MAX_PART, &ftl_blk_fops, MAX_PART, &ftl_blk_fops,
le32_to_cpu(partition->header.FormattedSize)/SECTOR_SIZE); le32_to_cpu(partition->header.FormattedSize)/SECTOR_SIZE);
#ifdef PCMCIA_DEBUG #ifdef PCMCIA_DEBUG
printk(KERN_INFO "ftl_cs: opening %d kb FTL partition\n", printk(KERN_INFO "ftl_cs: opening %d kb FTL partition\n",
le32_to_cpu(partition->header.FormattedSize) >> 10); le32_to_cpu(partition->header.FormattedSize) >> 10);
#endif #endif
} else } else {
kfree(partition); kfree(partition);
kfree(disk);
kfree(name);
}
} }
static void ftl_notify_remove(struct mtd_info *mtd) static void ftl_notify_remove(struct mtd_info *mtd)
...@@ -1300,10 +1312,10 @@ static void ftl_notify_remove(struct mtd_info *mtd) ...@@ -1300,10 +1312,10 @@ static void ftl_notify_remove(struct mtd_info *mtd)
ftl_freepart(myparts[i]); ftl_freepart(myparts[i]);
myparts[i]->state = 0; myparts[i]->state = 0;
for (j=0; j<16; j++) { wipe_partitions(mk_kdev(MAJOR_NR, i<<4));
ftl_gendisk.part[j].nr_sects=0; del_gendisk(myparts[i]->disk);
ftl_gendisk.part[j].start_sect=0; kfree(myparts[i]->disk->name);
} kfree(myparts[i]->disk);
kfree(myparts[i]); kfree(myparts[i]);
myparts[i] = NULL; myparts[i] = NULL;
} }
...@@ -1312,9 +1324,6 @@ static void ftl_notify_remove(struct mtd_info *mtd) ...@@ -1312,9 +1324,6 @@ static void ftl_notify_remove(struct mtd_info *mtd)
int init_ftl(void) int init_ftl(void)
{ {
int i; int i;
memset(myparts, 0, sizeof(myparts));
DEBUG(0, "$Id: ftl.c,v 1.39 2001/10/02 15:05:11 dwmw2 Exp $\n"); DEBUG(0, "$Id: ftl.c,v 1.39 2001/10/02 15:05:11 dwmw2 Exp $\n");
if (register_blkdev(FTL_MAJOR, "ftl", &ftl_blk_fops)) { if (register_blkdev(FTL_MAJOR, "ftl", &ftl_blk_fops)) {
...@@ -1322,15 +1331,7 @@ int init_ftl(void) ...@@ -1322,15 +1331,7 @@ int init_ftl(void)
"device number!\n"); "device number!\n");
return -EAGAIN; return -EAGAIN;
} }
for (i = 0; i < MAX_DEV*MAX_PART; i++) {
ftl_hd[i].nr_sects = 0;
ftl_hd[i].start_sect = 0;
}
ftl_gendisk.major = FTL_MAJOR;
blk_init_queue(BLK_DEFAULT_QUEUE(FTL_MAJOR), &do_ftl_request); blk_init_queue(BLK_DEFAULT_QUEUE(FTL_MAJOR), &do_ftl_request);
add_gendisk(&ftl_gendisk);
register_mtd_user(&ftl_notifier); register_mtd_user(&ftl_notifier);
return 0; return 0;
...@@ -1339,12 +1340,9 @@ int init_ftl(void) ...@@ -1339,12 +1340,9 @@ int init_ftl(void)
static void __exit cleanup_ftl(void) static void __exit cleanup_ftl(void)
{ {
unregister_mtd_user(&ftl_notifier); unregister_mtd_user(&ftl_notifier);
unregister_blkdev(FTL_MAJOR, "ftl"); unregister_blkdev(FTL_MAJOR, "ftl");
blk_cleanup_queue(BLK_DEFAULT_QUEUE(FTL_MAJOR)); blk_cleanup_queue(BLK_DEFAULT_QUEUE(FTL_MAJOR));
blk_clear(FTL_MAJOR); blk_clear(FTL_MAJOR);
del_gendisk(&ftl_gendisk);
} }
module_init(init_ftl); module_init(init_ftl);
......
...@@ -58,12 +58,6 @@ ...@@ -58,12 +58,6 @@
struct hd_struct part_table[256]; struct hd_struct part_table[256];
static struct block_device_operations nftl_fops; static struct block_device_operations nftl_fops;
static struct gendisk nftl_gendisk = {
major: MAJOR_NR,
major_name: "nftl",
minor_shift: NFTL_PARTN_BITS, /* # of partition bits */
part: part_table, /* hd struct */
};
struct NFTLrecord *NFTLs[MAX_NFTLS]; struct NFTLrecord *NFTLs[MAX_NFTLS];
...@@ -73,6 +67,8 @@ static void NFTL_setup(struct mtd_info *mtd) ...@@ -73,6 +67,8 @@ static void NFTL_setup(struct mtd_info *mtd)
struct NFTLrecord *nftl; struct NFTLrecord *nftl;
unsigned long temp; unsigned long temp;
int firstfree = -1; int firstfree = -1;
struct gendisk *gd;
char *name;
DEBUG(MTD_DEBUG_LEVEL1,"NFTL_setup\n"); DEBUG(MTD_DEBUG_LEVEL1,"NFTL_setup\n");
...@@ -91,7 +87,12 @@ static void NFTL_setup(struct mtd_info *mtd) ...@@ -91,7 +87,12 @@ static void NFTL_setup(struct mtd_info *mtd)
} }
nftl = kmalloc(sizeof(struct NFTLrecord), GFP_KERNEL); nftl = kmalloc(sizeof(struct NFTLrecord), GFP_KERNEL);
if (!nftl) { gd = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
name = kmalloc(6, GFP_KERNEL);
if (!nftl || !gd || !name) {
kfree(nftl);
kfree(gd);
kfree(name);
printk(KERN_WARNING "Out of memory for NFTL data structures\n"); printk(KERN_WARNING "Out of memory for NFTL data structures\n");
return; return;
} }
...@@ -106,6 +107,8 @@ static void NFTL_setup(struct mtd_info *mtd) ...@@ -106,6 +107,8 @@ static void NFTL_setup(struct mtd_info *mtd)
if (NFTL_mount(nftl) < 0) { if (NFTL_mount(nftl) < 0) {
printk(KERN_WARNING "Could not mount NFTL device\n"); printk(KERN_WARNING "Could not mount NFTL device\n");
kfree(nftl); kfree(nftl);
kfree(gd);
kfree(name);
return; return;
} }
...@@ -142,19 +145,18 @@ static void NFTL_setup(struct mtd_info *mtd) ...@@ -142,19 +145,18 @@ static void NFTL_setup(struct mtd_info *mtd)
/* Oh no we don't have nftl->nr_sects = nftl->heads * nftl->cylinders * nftl->sectors; */ /* Oh no we don't have nftl->nr_sects = nftl->heads * nftl->cylinders * nftl->sectors; */
} }
NFTLs[firstfree] = nftl; NFTLs[firstfree] = nftl;
/* Finally, set up the block device sizes */ memset(gd, 0, sizeof(struct gendisk));
part_table[firstfree * 16].nr_sects = nftl->nr_sects; sprintf(name, "nftl%c", 'a' + firstfree);
gd->major = MAJOR_NR;
nftl_gendisk.nr_real++; gd->first_minor = firstfree << NFTL_PARTN_BITS;
gd->minor_shift = NFTL_PARTN_BITS;
/* partition check ... */ gd->part = part_table + (firstfree << NFTL_PARTN_BITS);
#if LINUX_VERSION_CODE < 0x20328 gd->major_name = name;
resetup_one_dev(&nftl_gendisk, firstfree); gd->nr_real = 1;
#else nftl->disk = gd;
register_disk(&nftl_gendisk, add_gendisk(gd);
mk_kdev(MAJOR_NR,firstfree<<NFTL_PARTN_BITS), register_disk(gd, mk_kdev(MAJOR_NR,firstfree<<NFTL_PARTN_BITS),
1<<NFTL_PARTN_BITS, &nftl_fops, nftl->nr_sects); 1<<NFTL_PARTN_BITS, &nftl_fops, nftl->nr_sects);
#endif
} }
static void NFTL_unsetup(int i) static void NFTL_unsetup(int i)
...@@ -169,8 +171,9 @@ static void NFTL_unsetup(int i) ...@@ -169,8 +171,9 @@ static void NFTL_unsetup(int i)
kfree(nftl->ReplUnitTable); kfree(nftl->ReplUnitTable);
if (nftl->EUNtable) if (nftl->EUNtable)
kfree(nftl->EUNtable); kfree(nftl->EUNtable);
del_gendisk(nftl->disk);
nftl_gendisk.nr_real--; kfree(nftl->disk->major_name);
kfree(nftl->disk);
kfree(nftl); kfree(nftl);
} }
...@@ -964,16 +967,6 @@ static int nftl_release(struct inode *inode, struct file *fp) ...@@ -964,16 +967,6 @@ static int nftl_release(struct inode *inode, struct file *fp)
return 0; return 0;
} }
#if LINUX_VERSION_CODE < 0x20326
static struct file_operations nftl_fops = {
read: block_read,
write: block_write,
ioctl: nftl_ioctl,
open: nftl_open,
release: nftl_release,
fsync: block_fsync,
};
#else
static struct block_device_operations nftl_fops = static struct block_device_operations nftl_fops =
{ {
owner: THIS_MODULE, owner: THIS_MODULE,
...@@ -981,9 +974,6 @@ static struct block_device_operations nftl_fops = ...@@ -981,9 +974,6 @@ static struct block_device_operations nftl_fops =
release: nftl_release, release: nftl_release,
ioctl: nftl_ioctl ioctl: nftl_ioctl
}; };
#endif
/**************************************************************************** /****************************************************************************
* *
...@@ -1009,10 +999,8 @@ int __init init_nftl(void) ...@@ -1009,10 +999,8 @@ int __init init_nftl(void)
if (register_blkdev(MAJOR_NR, "nftl", &nftl_fops)){ if (register_blkdev(MAJOR_NR, "nftl", &nftl_fops)){
printk("unable to register NFTL block device on major %d\n", MAJOR_NR); printk("unable to register NFTL block device on major %d\n", MAJOR_NR);
return -EBUSY; return -EBUSY;
} else {
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), &nftl_request, &nftl_lock);
add_gendisk(&nftl_gendisk);
} }
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), &nftl_request, &nftl_lock);
register_mtd_user(&nftl_notifier); register_mtd_user(&nftl_notifier);
...@@ -1023,10 +1011,7 @@ static void __exit cleanup_nftl(void) ...@@ -1023,10 +1011,7 @@ static void __exit cleanup_nftl(void)
{ {
unregister_mtd_user(&nftl_notifier); unregister_mtd_user(&nftl_notifier);
unregister_blkdev(MAJOR_NR, "nftl"); unregister_blkdev(MAJOR_NR, "nftl");
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
del_gendisk(&nftl_gendisk);
} }
module_init(init_nftl); module_init(init_nftl);
......
...@@ -1318,6 +1318,7 @@ static int sd_attach(Scsi_Device * sdp) ...@@ -1318,6 +1318,7 @@ static int sd_attach(Scsi_Device * sdp)
devfs_handle_t de; devfs_handle_t de;
struct device *dev; struct device *dev;
char flags; char flags;
char name[5];
} *p; } *p;
struct gendisk *gd; struct gendisk *gd;
...@@ -1368,10 +1369,14 @@ static int sd_attach(Scsi_Device * sdp) ...@@ -1368,10 +1369,14 @@ static int sd_attach(Scsi_Device * sdp)
gd->driverfs_dev_arr[0] = &sdp->sdev_driverfs_dev; gd->driverfs_dev_arr[0] = &sdp->sdev_driverfs_dev;
gd->major = SD_MAJOR(dsk_nr>>4); gd->major = SD_MAJOR(dsk_nr>>4);
gd->first_minor = (dsk_nr & 15)<<4; gd->first_minor = (dsk_nr & 15)<<4;
gd->major_name = "sd";
gd->minor_shift = 4; gd->minor_shift = 4;
gd->part = sd + (dsk_nr << 4); gd->part = sd + (dsk_nr << 4);
gd->fops = &sd_fops; gd->fops = &sd_fops;
if (dsk_nr > 26)
sprintf(p->name, "sd%c%c", 'a'+dsk_nr/26-1, 'a'+dsk_nr%26);
else
sprintf(p->name, "sd%c", 'a'+dsk_nr%26);
gd->major_name = p->name;
if (sdp->removable) if (sdp->removable)
gd->flags[0] |= GENHD_FL_REMOVABLE; gd->flags[0] |= GENHD_FL_REMOVABLE;
sd_disks[dsk_nr] = gd; sd_disks[dsk_nr] = gd;
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/buffer_head.h> /* for invalidate_bdev() */
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/ctype.h>
#include "check.h" #include "check.h"
...@@ -104,10 +104,11 @@ EXPORT_SYMBOL(genhd_dasd_ioctl); ...@@ -104,10 +104,11 @@ EXPORT_SYMBOL(genhd_dasd_ioctl);
char *disk_name (struct gendisk *hd, int minor, char *buf) char *disk_name (struct gendisk *hd, int minor, char *buf)
{ {
const char *maj = hd->major_name;
unsigned int unit = (minor >> hd->minor_shift); unsigned int unit = (minor >> hd->minor_shift);
unsigned int part = (minor & ((1 << hd->minor_shift) -1 )); unsigned int part = (minor & ((1 << hd->minor_shift) -1 ));
struct hd_struct *p = hd->part + minor - hd->first_minor; struct hd_struct *p = hd->part + minor - hd->first_minor;
char s[40];
const char *maj;
if ((((minor - hd->first_minor) >> hd->minor_shift) < hd->nr_real) && if ((((minor - hd->first_minor) >> hd->minor_shift) < hd->nr_real) &&
p->de) { p->de) {
...@@ -124,83 +125,51 @@ char *disk_name (struct gendisk *hd, int minor, char *buf) ...@@ -124,83 +125,51 @@ char *disk_name (struct gendisk *hd, int minor, char *buf)
return buf; return buf;
#endif #endif
/* /*
* IDE devices use multiple major numbers, but the drives * Yes, I know, ... in cases is gccism and not a pretty one.
* are named as: {hda,hdb}, {hdc,hdd}, {hde,hdf}, {hdg,hdh}.. * However, the first variant will eventually consume _all_ cases
* This requires special handling here. * and switch will disappear.
*/ */
switch (hd->major) { switch (hd->major) {
case IDE9_MAJOR: default:
unit += 2; maj = hd->major_name;
case IDE8_MAJOR:
unit += 2;
case IDE7_MAJOR:
unit += 2;
case IDE6_MAJOR:
unit += 2;
case IDE5_MAJOR:
unit += 2;
case IDE4_MAJOR:
unit += 2;
case IDE3_MAJOR:
unit += 2;
case IDE2_MAJOR:
unit += 2;
case IDE1_MAJOR:
unit += 2;
case IDE0_MAJOR:
maj = "hd";
break; break;
case MD_MAJOR: case MD_MAJOR:
sprintf(buf, "%s%d", maj, unit); sprintf(s, "%s%d", "md", unit);
return buf; maj = s;
} break;
if (hd->major >= SCSI_DISK1_MAJOR && hd->major <= SCSI_DISK7_MAJOR) { case COMPAQ_SMART2_MAJOR ... COMPAQ_SMART2_MAJOR+7:
unit = unit + (hd->major - SCSI_DISK1_MAJOR + 1) * 16; sprintf(s, "ida/c%dd%d",
if (unit+'a' > 'z') { hd->major - COMPAQ_SMART2_MAJOR, unit);
unit -= 26; maj = s;
sprintf(buf, "sd%c%c", 'a' + unit / 26, 'a' + unit % 26); break;
if (part) case COMPAQ_CISS_MAJOR ... COMPAQ_CISS_MAJOR+7:
sprintf(buf + 4, "%d", part); sprintf(s, "cciss/c%dd%d",
return buf; hd->major - COMPAQ_CISS_MAJOR, unit);
} maj = s;
} break;
if (hd->major >= COMPAQ_SMART2_MAJOR && hd->major <= COMPAQ_SMART2_MAJOR+7) { case DAC960_MAJOR ... DAC960_MAJOR+7:
int ctlr = hd->major - COMPAQ_SMART2_MAJOR; sprintf(s, "rd/c%dd%d",
if (part == 0) hd->major - DAC960_MAJOR, unit);
sprintf(buf, "%s/c%dd%d", maj, ctlr, unit); maj = s;
else break;
sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part); case ATARAID_MAJOR:
return buf; sprintf(s, "ataraid/d%d", unit);
} maj = s;
if (hd->major >= COMPAQ_CISS_MAJOR && hd->major <= COMPAQ_CISS_MAJOR+7) { break;
int ctlr = hd->major - COMPAQ_CISS_MAJOR; case ACSI_MAJOR:
if (part == 0) case PS2ESDI_MAJOR:
sprintf(buf, "%s/c%dd%d", maj, ctlr, unit); case XT_DISK_MAJOR:
else case I2O_MAJOR:
sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part); case DASD_MAJOR:
return buf; sprintf(s, "%s%c", hd->major_name, unit + 'a');
} maj = s;
if (hd->major >= DAC960_MAJOR && hd->major <= DAC960_MAJOR+7) {
int ctlr = hd->major - DAC960_MAJOR;
if (part == 0)
sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
else
sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
return buf;
}
if (hd->major == ATARAID_MAJOR) {
int disk = minor >> hd->minor_shift;
int part = minor & (( 1 << hd->minor_shift) - 1);
if (part == 0)
sprintf(buf, "%s/d%d", maj, disk);
else
sprintf(buf, "%s/d%dp%d", maj, disk, part);
return buf;
} }
if (part) if (!part)
sprintf(buf, "%s%c%d", maj, unit+'a', part); sprintf(buf, "%s", maj);
else if (isdigit(maj[strlen(maj)-1]))
sprintf(buf, "%sp%d", maj, part);
else else
sprintf(buf, "%s%c", maj, unit+'a'); sprintf(buf, "%s%d", maj, part);
return buf; return buf;
} }
......
...@@ -104,6 +104,7 @@ struct NFTLrecord { ...@@ -104,6 +104,7 @@ struct NFTLrecord {
unsigned int nb_blocks; /* number of physical blocks */ unsigned int nb_blocks; /* number of physical blocks */
unsigned int nb_boot_blocks; /* number of blocks used by the bios */ unsigned int nb_boot_blocks; /* number of blocks used by the bios */
struct erase_info instr; struct erase_info instr;
struct gendisk *disk;
}; };
int NFTL_mount(struct NFTLrecord *s); int NFTL_mount(struct NFTLrecord *s);
......
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