Messages in this thread Patch in this message | | | From | "Adam J. Richter" <> | Date | Sun, 19 Mar 2000 22:50:31 -0800 | Subject | Patch(v2) modulizing fs/partitions in 2.3.99-pre2 |
| |
This is the second version of my patch that modulizes the disk partitioning handlers in 2.3.99pre2. It includes the locking support suggested by Alan Cox, and omits my apparently misguided effort at using kmod. The resulting kernel gets a panic, but this is after it mounts the initial ramdisk, and I think it may be unrelated. I would appreciate it if others would try this patch before I submit it to Linus.
NOTE: After applying this patch, do the following from the top level of the linux source tree:
mv fs/partitions/msdos.c fs/partitions/msdos_part.c
This renaming avoids a collision with the msdos file system module. The patch already reflects this name change.
Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104 adam@yggdrasil.com \ / San Jose, California 95129-1034 +1 408 261-6630 | g g d r a s i l United States of America fax +1 408 261-6631 "Free Software For The Rest Of Us." ------------------------------CUT HERE---------------------------- --- linux-2.3.99-pre2/include/linux/blkdev.h Sat Mar 18 12:11:01 2000 +++ linux/include/linux/blkdev.h Sat Mar 18 22:24:00 2000 @@ -107,6 +107,14 @@ unsigned block_size_bits; }; +struct partition_ops { + int (*check)(struct gendisk *hd, + kdev_t dev, + unsigned long first_sect, + int first_minor); + struct partition_ops *next; +}; + /* * Used to indicate the default queue for drivers that don't bother * to implement multiple queues. We have this access macro here @@ -118,6 +126,8 @@ extern struct sec_size * blk_sec[MAX_BLKDEV]; extern struct blk_dev_struct blk_dev[MAX_BLKDEV]; extern wait_queue_head_t wait_for_request; +extern void register_partition_ops(struct partition_ops *ops); +extern void unregister_partition_ops(struct partition_ops *ops); extern void grok_partitions(struct gendisk *dev, int drive, unsigned minors, long size); extern void register_disk(struct gendisk *dev, kdev_t first, unsigned minors, struct block_device_operations *ops, long size); extern void generic_unplug_device(void * data); --- linux-2.3.99-pre2/fs/Makefile Wed Feb 16 15:42:05 2000 +++ linux/fs/Makefile Sat Mar 18 20:49:31 2000 @@ -22,6 +22,7 @@ openpromfs autofs4 SUB_DIRS := partitions +MOD_SUB_DIRS := partitions ifeq ($(CONFIG_QUOTA),y) O_OBJS += dquot.o diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/Config.in linux/fs/partitions/Config.in --- linux-2.3.99-pre2/fs/partitions/Config.in Thu Feb 10 22:02:32 2000 +++ linux/fs/partitions/Config.in Sat Mar 18 17:45:56 2000 @@ -3,7 +3,7 @@ # bool 'Advanced partition selection' CONFIG_PARTITION_ADVANCED if [ "$CONFIG_PARTITION_ADVANCED" = "y" ]; then - bool ' Acorn partition support' CONFIG_ACORN_PARTITION + tristate ' Acorn partition support' CONFIG_ACORN_PARTITION if [ "$CONFIG_ACORN_PARTITION" != "n" ]; then # bool ' Cumana partition support' CONFIG_ACORN_PARTITION_CUMANA bool ' ICS partition support' CONFIG_ACORN_PARTITION_ICS @@ -11,18 +11,18 @@ bool ' PowerTec partition support' CONFIG_ACORN_PARTITION_POWERTEC bool ' RISCiX partition support' CONFIG_ACORN_PARTITION_RISCIX fi - bool ' Alpha OSF partition support' CONFIG_OSF_PARTITION - bool ' Amiga partition table support' CONFIG_AMIGA_PARTITION - bool ' Atari partition table support' CONFIG_ATARI_PARTITION - bool ' Macintosh partition map support' CONFIG_MAC_PARTITION - bool ' PC BIOS (MSDOS partition tables) support' CONFIG_MSDOS_PARTITION - if [ "$CONFIG_MSDOS_PARTITION" = "y" ]; then + tristate ' Alpha OSF partition support' CONFIG_OSF_PARTITION + tristate ' Amiga partition table support' CONFIG_AMIGA_PARTITION + tristate ' Atari partition table support' CONFIG_ATARI_PARTITION + tristate ' Macintosh partition map support' CONFIG_MAC_PARTITION + tristate ' PC BIOS (MSDOS partition tables) support' CONFIG_MSDOS_PARTITION + if [ "$CONFIG_MSDOS_PARTITION" != "n" ]; then bool ' BSD disklabel (FreeBSD partition tables) support' CONFIG_BSD_DISKLABEL bool ' Solaris (x86) partition table support' CONFIG_SOLARIS_X86_PARTITION bool ' Unixware slices support' CONFIG_UNIXWARE_DISKLABEL fi - bool 'SGI partition support' CONFIG_SGI_PARTITION - bool 'Sun partition tables support' CONFIG_SUN_PARTITION + tristate 'SGI partition support' CONFIG_SGI_PARTITION + tristate 'Sun partition tables support' CONFIG_SUN_PARTITION else if [ "$ARCH" = "alpha" ]; then define_bool CONFIG_OSF_PARTITION y diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/Makefile linux/fs/partitions/Makefile --- linux-2.3.99-pre2/fs/partitions/Makefile Thu Aug 12 12:26:06 1999 +++ linux/fs/partitions/Makefile Sat Mar 18 22:05:28 2000 @@ -8,42 +8,19 @@ # Note 2! The CFLAGS definitions are now in the main makefile... O_TARGET := partitions.o -O_OBJS := check.o +OX_OBJS := check.o -ifeq ($(CONFIG_ACORN_PARTITION),y) -O_OBJS += acorn.o -endif +obj-$(CONFIG_ACORN_PARTITION) += acorn.o +obj-$(CONFIG_AMIGA_PARTITION) += amiga.o +obj-$(CONFIG_ATARI_PARTITION) += atari.o +obj-$(CONFIG_MAC_PARTITION) += mac.o +obj-$(CONFIG_MSDOS_PARTITION) += msdos_part.o +obj-$(CONFIG_OSF_PARTITION) += osf.o +obj-$(CONFIG_SGI_PARTITION) += sgi.o +obj-$(CONFIG_SUN_PARTITION) += sun.o +obj-$(CONFIG_ULTRIX_PARTITION) += ultrix.o -ifeq ($(CONFIG_AMIGA_PARTITION),y) -O_OBJS += amiga.o -endif - -ifeq ($(CONFIG_ATARI_PARTITION),y) -O_OBJS += atari.o -endif - -ifeq ($(CONFIG_MAC_PARTITION),y) -O_OBJS += mac.o -endif - -ifeq ($(CONFIG_MSDOS_PARTITION),y) -O_OBJS += msdos.o -endif - -ifeq ($(CONFIG_OSF_PARTITION),y) -O_OBJS += osf.o -endif - -ifeq ($(CONFIG_SGI_PARTITION),y) -O_OBJS += sgi.o -endif - -ifeq ($(CONFIG_SUN_PARTITION),y) -O_OBJS += sun.o -endif - -ifeq ($(CONFIG_ULTRIX_PARTITION),y) -O_OBJS += ultrix.o -endif +O_OBJS += $(obj-y) +M_OBJS += $(obj-m) include $(TOPDIR)/Rules.make diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/acorn.c linux/fs/partitions/acorn.c --- linux-2.3.99-pre2/fs/partitions/acorn.c Sat Mar 18 11:38:04 2000 +++ linux/fs/partitions/acorn.c Sat Mar 18 18:23:55 2000 @@ -491,3 +491,6 @@ printk("\n"); return r; } + +#define check_partition acorn_partition +#include "partition_module.c" diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/amiga.c linux/fs/partitions/amiga.c --- linux-2.3.99-pre2/fs/partitions/amiga.c Wed Feb 16 15:42:06 2000 +++ linux/fs/partitions/amiga.c Sat Mar 18 17:45:56 2000 @@ -118,3 +118,6 @@ set_blocksize(dev,old_blocksize); return res; } + +#define check_partition amiga_partition +#include "partition_module.c" diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/atari.c linux/fs/partitions/atari.c --- linux-2.3.99-pre2/fs/partitions/atari.c Sun Mar 12 19:39:39 2000 +++ linux/fs/partitions/atari.c Sat Mar 18 18:23:55 2000 @@ -175,3 +175,5 @@ return 1; } +#define check_partition atari_partition +#include "partition_module.c" diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/check.c linux/fs/partitions/check.c --- linux-2.3.99-pre2/fs/partitions/check.c Sat Feb 26 08:25:35 2000 +++ linux/fs/partitions/check.c Sun Mar 19 22:30:23 2000 @@ -19,6 +19,7 @@ #include <linux/blk.h> #include <linux/init.h> #include <linux/raid/md.h> +#include <linux/smp_lock.h> #include "check.h" @@ -40,35 +41,36 @@ struct gendisk *gendisk_head; int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/ -static int (*check_part[])(struct gendisk *hd, kdev_t dev, unsigned long first_sect, int first_minor) = { +static DECLARE_MUTEX(part_ops_mutex); +static struct partition_ops *part_ops = NULL; +static struct partition_ops initial_part_ops[] = { #ifdef CONFIG_ACORN_PARTITION - acorn_partition, + {acorn_partition, NULL}, #endif #ifdef CONFIG_MSDOS_PARTITION - msdos_partition, + {msdos_partition, NULL}, #endif #ifdef CONFIG_OSF_PARTITION - osf_partition, + {osf_partition, NULL}, #endif #ifdef CONFIG_SUN_PARTITION - sun_partition, + {sun_partition, NULL}, #endif #ifdef CONFIG_AMIGA_PARTITION - amiga_partition, + {amiga_partition, NULL}, #endif #ifdef CONFIG_ATARI_PARTITION - atari_partition, + {atari_partition, NULL}, #endif #ifdef CONFIG_MAC_PARTITION - mac_partition, + {mac_partition, NULL}, #endif #ifdef CONFIG_SGI_PARTITION - sgi_partition, + {sgi_partition, NULL}, #endif #ifdef CONFIG_ULTRIX_PARTITION - ultrix_partition, + {ultrix_partition, NULL}, #endif - NULL }; /* @@ -257,6 +259,7 @@ unsigned long first_sector; char buf[64]; int i; + struct partition_ops *ops; if (first_time) printk(KERN_INFO "Partition check:\n"); @@ -279,12 +282,13 @@ printk(KERN_INFO " /dev/%s:", buf + i); else printk(KERN_INFO " %s:", disk_name(hd, MINOR(dev), buf)); - for (i = 0; check_part[i]; i++) - if (check_part[i](hd, dev, first_sector, first_part_minor)) + down(&part_ops_mutex); + for (ops = part_ops; ops != NULL; ops = ops->next) + if ((*ops->check)(hd, dev, first_sector, first_part_minor)) goto setup_devfs; - printk(" unknown partition table\n"); setup_devfs: + up(&part_ops_mutex); i = first_part_minor - 1; devfs_register_partitions (hd, i, hd->sizes ? 0 : 1); } @@ -390,6 +394,29 @@ grok_partitions(gdev, MINOR(dev)>>gdev->minor_shift, minors, size); } +void register_partition_ops(struct partition_ops *ops) +{ + down(&part_ops_mutex); + ops->next = part_ops; + part_ops = ops; + up(&part_ops_mutex); +} + +void unregister_partition_ops(struct partition_ops *ops) +{ + struct partition_ops **tmp; + down(&part_ops_mutex); + for (tmp = &part_ops; *tmp != NULL; tmp = &(*tmp)->next) { + if (*tmp == ops) { + *tmp = ops->next; + break; + } + } + up(&part_ops_mutex); +} + + + void grok_partitions(struct gendisk *dev, int drive, unsigned minors, long size) { int i; @@ -420,6 +447,14 @@ int __init partition_setup(void) { + int i; + + for (i = 0; + i < sizeof(initial_part_ops) / sizeof(struct partition_ops); + i++) { + register_partition_ops(&initial_part_ops[i]); + } + device_init(); #ifdef CONFIG_BLK_DEV_RAM @@ -440,3 +475,4 @@ } __initcall(partition_setup); +EXPORT_SYMBOL(get_ptable_blocksize); diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/mac.c linux/fs/partitions/mac.c --- linux-2.3.99-pre2/fs/partitions/mac.c Wed Feb 9 19:43:53 2000 +++ linux/fs/partitions/mac.c Sat Mar 18 18:23:55 2000 @@ -150,3 +150,5 @@ return 1; } +#define check_partition mac_partition +#include "partition_module.c" diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/msdos.c linux/fs/partitions/msdos.c --- linux-2.3.99-pre2/fs/partitions/msdos.c Thu Mar 16 14:01:05 2000 +++ linux/fs/partitions/msdos.c Sat Mar 18 21:51:35 2000 @@ -495,3 +495,6 @@ bforget(bh); return 1; } + +#define check_partition msdos_partition +#include "partition_module.c" diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/osf.c linux/fs/partitions/osf.c --- linux-2.3.99-pre2/fs/partitions/osf.c Wed Feb 16 15:42:06 2000 +++ linux/fs/partitions/osf.c Sat Mar 18 18:23:55 2000 @@ -84,3 +84,5 @@ return 1; } +#define check_partition osf_partition +#include "partition_module.c" diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/partition_module.c linux/fs/partitions/partition_module.c --- linux-2.3.99-pre2/fs/partitions/partition_module.c Wed Dec 31 16:00:00 1969 +++ linux/fs/partitions/partition_module.c Sat Mar 18 21:45:29 2000 @@ -0,0 +1,30 @@ +/* Copyright 2000 Yggdrasil Computing, Inc. + Written by Adam J. Richter + + This file may be copied under the terms and conditions of version + 2 of the GNU General Public License, as published by the Free + Software Foundation (Cambridge, Massachussetts, USA). +*/ + +#ifdef MODULE + +#include <linux/blkdev.h> + +static struct partition_ops ops = { + check_partition, + NULL +}; + +int +init_module(void) +{ + register_partition_ops(&ops); + return 0; +} + +void +cleanup_module(void) +{ + unregister_partition_ops(&ops); +} +#endif /* MODULE */ diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/sgi.c linux/fs/partitions/sgi.c --- linux-2.3.99-pre2/fs/partitions/sgi.c Sun Mar 12 19:39:39 2000 +++ linux/fs/partitions/sgi.c Sat Mar 18 17:45:56 2000 @@ -84,3 +84,6 @@ brelse(bh); return 1; } + +#define check_partition sgi_partition +#include "partition_module.c" diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/sun.c linux/fs/partitions/sun.c --- linux-2.3.99-pre2/fs/partitions/sun.c Wed Feb 16 15:42:06 2000 +++ linux/fs/partitions/sun.c Sat Mar 18 18:23:55 2000 @@ -87,3 +87,5 @@ return 1; } +#define check_partition sun_partition +#include "partition_module.c" diff --new-file -u -r linux-2.3.99-pre2/fs/partitions/ultrix.c linux/fs/partitions/ultrix.c --- linux-2.3.99-pre2/fs/partitions/ultrix.c Wed Feb 16 15:42:06 2000 +++ linux/fs/partitions/ultrix.c Sat Mar 18 17:45:56 2000 @@ -58,3 +58,6 @@ } } + +#define check_partition ultrix_partition +#include "partition_module.c" - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |