From 82b97cbea5d5cee83d7dadc4b8582f7bbab16b22 Mon Sep 17 00:00:00 2001 From: Gilles Grandou Date: Thu, 11 Nov 2010 03:00:18 +0100 Subject: [PATCH 2/5] add cmdpart= boot parameter in place of partition table --- fs/partitions/Kconfig | 6 ++++ fs/partitions/Makefile | 1 + fs/partitions/check.c | 4 ++ fs/partitions/cmdline.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ fs/partitions/cmdline.h | 1 + 5 files changed, 85 insertions(+), 0 deletions(-) create mode 100644 fs/partitions/cmdline.c create mode 100644 fs/partitions/cmdline.h diff --git a/fs/partitions/Kconfig b/fs/partitions/Kconfig index cb5f0a3..c7a398d 100644 --- a/fs/partitions/Kconfig +++ b/fs/partitions/Kconfig @@ -249,3 +249,9 @@ config SYSV68_PARTITION partition table format used by Motorola Delta machines (using sysv68). Otherwise, say N. + +config CMDLINE_PARTITION + bool "Cmdline partition table support" if PARTITION_ADVANCED + default n + help + Pass partition table via cmdline diff --git a/fs/partitions/Makefile b/fs/partitions/Makefile index 03af8ea..11e3a89 100644 --- a/fs/partitions/Makefile +++ b/fs/partitions/Makefile @@ -18,3 +18,4 @@ obj-$(CONFIG_IBM_PARTITION) += ibm.o obj-$(CONFIG_EFI_PARTITION) += efi.o obj-$(CONFIG_KARMA_PARTITION) += karma.o obj-$(CONFIG_SYSV68_PARTITION) += sysv68.o +obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 7452408..9834042 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -32,6 +32,7 @@ #include "sgi.h" #include "sun.h" #include "ibm.h" +#include "cmdline.h" #include "ultrix.h" #include "efi.h" #include "karma.h" @@ -104,6 +105,9 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) = #ifdef CONFIG_IBM_PARTITION ibm_partition, #endif +#ifdef CONFIG_CMDLINE_PARTITION + cmdline_partition, +#endif #ifdef CONFIG_KARMA_PARTITION karma_partition, #endif diff --git a/fs/partitions/cmdline.c b/fs/partitions/cmdline.c new file mode 100644 index 0000000..1495653 --- /dev/null +++ b/fs/partitions/cmdline.c @@ -0,0 +1,73 @@ +#include +#include + +#include "check.h" +#include "cmdline.h" + +const char *partition_list = NULL; +static short set = 0; + +#define STATE_NUM 0 +#define STATE_START 1 +#define STATE_SIZE 2 + + +/* + */ +int +cmdline_partition(struct parsed_partitions *state, struct block_device *bdev) +{ + + if (state->parts[0].size) + return; + + int blocksize, res; + char *ptr = partition_list; + char *pstart = ptr; + short parse_state = STATE_NUM; + int conf[STATE_SIZE]; + + + res = 0; + blocksize = bdev_hardsect_size(bdev); + if (blocksize <= 0) + goto out_exit; + + res = 1; + + do { + + ptr++; + switch (*ptr) { + case ':': + case 0: + case ',': + conf[parse_state]=simple_strtol(pstart, NULL, 0); + + if(parse_state == STATE_SIZE) { + parse_state = STATE_NUM; + put_partition(state, conf[0], conf[1], conf[2]); + } else { + parse_state ++; + } + + if(*ptr) + pstart = ++ptr; + + } + } while (*ptr); + +out_exit: + return res; +} + +static int __init partition_setup(char *options) { + printk(KERN_INFO "partition setup %x\n", options); + + if (options && *options && !partition_list) + partition_list = options; + + return 0; + +} +__setup("cmdpart=", partition_setup); diff --git a/fs/partitions/cmdline.h b/fs/partitions/cmdline.h new file mode 100644 index 0000000..c753deb --- /dev/null +++ b/fs/partitions/cmdline.h @@ -0,0 +1 @@ +int cmdline_partition(struct parsed_partitions *, struct block_device *); -- 1.7.1