diff -uNr linux-2.4.18.S18.scsimany/drivers/scsi/hosts.h linux-2.4.18.S18.scsimany3/drivers/scsi/hosts.h --- linux-2.4.18.S18.scsimany/drivers/scsi/hosts.h Mon Jul 15 15:48:28 2002 +++ linux-2.4.18.S18.scsimany3/drivers/scsi/hosts.h Tue Jul 16 13:22:21 2002 @@ -516,8 +516,6 @@ struct module * module; /* Used for loadable modules */ unsigned char scsi_type; unsigned int major; - unsigned int min_major; /* Minimum major in range. */ - unsigned int max_major; /* Maximum major in range. */ unsigned int nr_dev; /* Number currently attached */ unsigned int dev_noticed; /* Number of devices detected. */ unsigned int dev_max; /* Current size of arrays */ @@ -531,6 +529,7 @@ int (*init_command)(Scsi_Cmnd *); /* Used by new queueing code. Selects command for blkdevs */ int (*find_kdev)(Scsi_Device *, char*, kdev_t*); /* find back dev. */ + int (*drives_dev)(kdev_t); /* Does HL driver drive this major? */ }; void scsi_initialize_queue(Scsi_Device * SDpnt, struct Scsi_Host * SHpnt); diff -uNr linux-2.4.18.S18.scsimany/drivers/scsi/scsi_lib.c linux-2.4.18.S18.scsimany3/drivers/scsi/scsi_lib.c --- linux-2.4.18.S18.scsimany/drivers/scsi/scsi_lib.c Tue Jul 16 13:48:24 2002 +++ linux-2.4.18.S18.scsimany3/drivers/scsi/scsi_lib.c Tue Jul 16 12:07:05 2002 @@ -806,22 +806,8 @@ if (spnt->blk && spnt->major == major) { return spnt; } - /* - * I am still not entirely satisfied with this solution, - * but it is good enough for now. Disks have a number of - * major numbers associated with them, the primary - * 8, which we test above, and a secondary range of 7 - * different consecutive major numbers. If this ever - * becomes insufficient, then we could add another function - * to the structure, and generalize this completely. - */ - if( spnt->min_major != 0 - && spnt->max_major != 0 - && major >= spnt->min_major - && major <= spnt->max_major ) - { + if (spnt->drives_dev && (spnt->drives_dev)(dev)) return spnt; - } } return NULL; } diff -uNr linux-2.4.18.S18.scsimany/drivers/scsi/sd.c linux-2.4.18.S18.scsimany3/drivers/scsi/sd.c --- linux-2.4.18.S18.scsimany/drivers/scsi/sd.c Tue Jul 16 02:51:38 2002 +++ linux-2.4.18.S18.scsimany3/drivers/scsi/sd.c Tue Jul 16 13:52:21 2002 @@ -89,14 +89,13 @@ static void sd_detach(Scsi_Device *); static int sd_init_command(Scsi_Cmnd *); static int sd_find_kdev(Scsi_Device*, char*, kdev_t*); +static int sd_drives_dev(kdev_t); static struct Scsi_Device_Template sd_template = { name:"disk", tag:"sd", scsi_type:TYPE_DISK, major:SCSI_DISK0_MAJOR, -// min_major:SCSI_DISK1_MAJOR, -// max_major:SCSI_DISK7_MAJOR, blk:1, detect:sd_detect, init:sd_init, @@ -105,6 +104,7 @@ detach:sd_detach, init_command:sd_init_command, find_kdev:sd_find_kdev, + drives_dev:sd_drives_dev, }; @@ -306,6 +306,15 @@ return &dpnt->device->request_queue; } +static int sd_drives_dev(kdev_t dev) +{ + int midx = MAJOR_TO_MIDX(MAJOR(dev)); + if (midx == -1) + return 0; + else + return 1; +} + static int sd_init_command(Scsi_Cmnd * SCpnt) { int block, this_count, hw_ssize; diff -uNr linux-2.4.18.S18.scsimany/drivers/scsi/sd_dynalloc.c linux-2.4.18.S18.scsimany3/drivers/scsi/sd_dynalloc.c --- linux-2.4.18.S18.scsimany/drivers/scsi/sd_dynalloc.c Tue Jul 16 02:54:03 2002 +++ linux-2.4.18.S18.scsimany3/drivers/scsi/sd_dynalloc.c Tue Jul 16 13:53:11 2002 @@ -55,7 +55,7 @@ } /* Fill in defaults (except 0) */ -void sd_fill_defaults (SD_Major *sd_major) +static void sd_fill_defaults (SD_Major *sd_major) { int i; /* per part */ @@ -67,7 +67,7 @@ } /* Global per major arrays :-O need to be filled in */ -void sd_set_major_arrays (SD_Major *sd_major) +static void sd_set_major_arrays (SD_Major *sd_major) { const int major = sd_major->sd_gendisk.major; blksize_size[major] = sd_major->sd_blocksizes; @@ -78,7 +78,7 @@ read_ahead[major] = 8; } -void sd_gendisk_defaults (struct gendisk *gdp) +static void sd_gendisk_defaults (struct gendisk *gdp) { gdp->major_name = "sd"; gdp->minor_shift = SCSI_DISK_PART_BITS; //? @@ -87,7 +87,7 @@ } /* Fill in gendisk */ -void sd_fill_in_gendisk (SD_Major *sd_major) +static void sd_fill_in_gendisk (SD_Major *sd_major) { struct gendisk * const gdp = &sd_major->sd_gendisk; sd_gendisk_defaults (gdp); @@ -99,6 +99,21 @@ gdp->real_devices = (void*) sd_major->disks; } +#ifndef CONFIG_DEVFS_FS +#define FIRST_MAJOR 127 // SCSI_DISK7_MAJOR would be another poss. choice +static int sd_find_major (void) +{ + int maj = FIRST_MAJOR; + /* This has the nasty side-effect of triggering kmod on blockdevs + * after FIRST_MAJOR. However, this also makes it safe not to + * use the major of sb. else. And: there is nobody ... KG. */ + while (++maj < 255) + if (!get_blkfops(maj)) + return maj; + return -1; +} +#endif + request_queue_t *sd_find_queue(kdev_t dev); /* We should already have the lock in write mode when entering */ int sd_alloc_major (void) @@ -113,7 +128,11 @@ else if (sd_majors < 8) major = SCSI_DISK1_MAJOR-1+sd_majors; else { +#ifdef CONFIG_DEVFS_FS major = devfs_alloc_major(DEVFS_SPECIAL_BLK); +#else + major = sd_find_major (); +#endif if (major == -1) { SDD_PRINTK("alloc_major: could not get major\n"); return major; diff -uNr linux-2.4.18.S18.scsimany/include/linux/fs.h linux-2.4.18.S18.scsimany3/include/linux/fs.h --- linux-2.4.18.S18.scsimany/include/linux/fs.h Mon Jul 15 15:47:16 2002 +++ linux-2.4.18.S18.scsimany3/include/linux/fs.h Tue Jul 16 13:21:34 2002 @@ -1168,6 +1168,7 @@ enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW}; extern int register_blkdev(unsigned int, const char *, struct block_device_operations *); extern int unregister_blkdev(unsigned int, const char *); +extern const struct block_device_operations * get_blkfops(unsigned int major); extern struct block_device *bdget(dev_t); extern int bd_acquire(struct inode *inode); extern void bd_forget(struct inode *inode); diff -uNr linux-2.4.18.S18.scsimany/kernel/ksyms.c linux-2.4.18.S18.scsimany3/kernel/ksyms.c --- linux-2.4.18.S18.scsimany/kernel/ksyms.c Wed Jun 12 11:37:15 2002 +++ linux-2.4.18.S18.scsimany3/kernel/ksyms.c Tue Jul 16 13:25:07 2002 @@ -328,6 +328,7 @@ EXPORT_SYMBOL(unregister_chrdev); EXPORT_SYMBOL(register_blkdev); EXPORT_SYMBOL(unregister_blkdev); +EXPORT_SYMBOL(get_blkfops); EXPORT_SYMBOL(tty_register_driver); EXPORT_SYMBOL(tty_unregister_driver); EXPORT_SYMBOL(tty_std_termios);