* PATCH: ability to build blkmtd into the kernel and still use it
@ 2002-04-11 16:43 Mike Mattice
2002-04-11 19:39 ` spse
0 siblings, 1 reply; 3+ messages in thread
From: Mike Mattice @ 2002-04-11 16:43 UTC (permalink / raw)
To: linux-mtd; +Cc: Simon Evans
Basically all this does is point the *device to a bootdevice
var that's initialized by passing the kernel 'blkmtd=<non devfs device>'.
I have no idea why giving it arguments like /dev/discs/disc0/disc doesn't
work with devfs compiled in, but apparantly support is just not set
up by that time.
I'd ultimately like to be able to set blkmtd devices up at build time,
but my current project has enough room on the ide-emulated flash to
fit a stripped down lilo on it so it doesn't matter much now.
diff -rNubBw linux-2.4.18.orig/drivers/mtd/devices/blkmtd.c linux-2.4.18.mtddevel/drivers/mtd/devices/blkmtd.c
--- linux-2.4.18.orig/drivers/mtd/devices/blkmtd.c Tue Apr 9 11:08:22 2002
+++ linux-2.4.18.mtddevel/drivers/mtd/devices/blkmtd.c Thu Apr 11 11:26:31 2002
@@ -4,6 +4,7 @@
* blkmtd.c - use a block device as a fake MTD
*
* Author: Simon Evans <spse@secret.org.uk>
+ * Modified: Michael Mattice <mike@mattice.org>
*
* Copyright (C) 2001 Simon Evans
*
@@ -53,6 +54,7 @@
#include <linux/pagemap.h>
#include <linux/mtd/compatmac.h>
#include <linux/mtd/mtd.h>
+#include <linux/ctype.h>
#ifdef CONFIG_MTD_DEBUG
#ifdef CONFIG_PROC_FS
@@ -130,6 +132,8 @@
int bs; /* optionally force the block size (avoid using) */
int count; /* optionally force the block count (avoid using) */
int wqs; /* optionally set the write queue size */
+char bootdevice[64]; /* boot device option */
+int bootdevset = 0; /* flag for above */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
@@ -1073,9 +1077,13 @@
/* Check args */
if(device == 0) {
+ if (bootdevset) {
+ device = &bootdevice;
+ } else {
printk("blkmtd: error, missing `device' name\n");
return -EINVAL;
}
+ }
if(ro)
readonly = 1;
@@ -1312,6 +1320,26 @@
__free_pages(erase_page, 0);
return err;
}
+
+static int __init blkmtd_setup(char *line)
+{
+ int i;
+ char ch;
+
+ bootdevset = 1;
+ memset (bootdevice, 0, sizeof bootdevice);
+ for (i = 0; i < sizeof bootdevice - 1; ++i)
+ {
+ ch = line[i];
+ if ( isspace (ch) || (ch == ',') || (ch == '\0') ) break;
+ // don't have to worry about setting the last char to \0,
+ // because the memset has taken care of that for us.
+ bootdevice[i] = ch;
+ }
+ return 1;
+}
+
+__setup("blkmtd=", blkmtd_setup);
module_init(init_blkmtd);
module_exit(cleanup_blkmtd);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: ability to build blkmtd into the kernel and still use it
2002-04-11 16:43 PATCH: ability to build blkmtd into the kernel and still use it Mike Mattice
@ 2002-04-11 19:39 ` spse
2002-04-12 9:35 ` Stephan Linke
0 siblings, 1 reply; 3+ messages in thread
From: spse @ 2002-04-11 19:39 UTC (permalink / raw)
To: Mike Mattice; +Cc: linux-mtd
Hi,
The blkmtd.c in 2.4.18 should already have the code in it to take a kernel
argument (blkmtd_device).
The reason you cant use /dev/discs/... is because you may not have a root fs
at the time the module is initialised in the kernel (esp if you are
using the device as the root device). Therefore the only names allowed
are those sepecified in init/main.c (ie you have to use the non devfs name)
When compiled and built into the kernel it uses name_to_kdev_t to get the
major/minor.
cheers
si
>Basically all this does is point the *device to a bootdevice
>var that's initialized by passing the kernel 'blkmtd=<non devfs device>'.
>I have no idea why giving it arguments like /dev/discs/disc0/disc doesn't
>work with devfs compiled in, but apparantly support is just not set
>up by that time.
>
>I'd ultimately like to be able to set blkmtd devices up at build time,
>but my current project has enough room on the ide-emulated flash to
>fit a stripped down lilo on it so it doesn't matter much now.
>
>
>diff -rNubBw linux-2.4.18.orig/drivers/mtd/devices/blkmtd.c linux-2.4.18.mtdde
>vel/drivers/mtd/devices/blkmtd.c
>--- linux-2.4.18.orig/drivers/mtd/devices/blkmtd.c Tue Apr 9 11:08:22 200
>2
>+++ linux-2.4.18.mtddevel/drivers/mtd/devices/blkmtd.c Thu Apr 11 11:26:31 200
>2
>@@ -4,6 +4,7 @@
> * blkmtd.c - use a block device as a fake MTD
> *
> * Author: Simon Evans <spse@secret.org.uk>
>+ * Modified: Michael Mattice <mike@mattice.org>
> *
> * Copyright (C) 2001 Simon Evans
> *
>@@ -53,6 +54,7 @@
> #include <linux/pagemap.h>
> #include <linux/mtd/compatmac.h>
> #include <linux/mtd/mtd.h>
>+#include <linux/ctype.h>
>
> #ifdef CONFIG_MTD_DEBUG
> #ifdef CONFIG_PROC_FS
>@@ -130,6 +132,8 @@
> int bs; /* optionally force the block size (avoid using) */
> int count; /* optionally force the block count (avoid using) */
> int wqs; /* optionally set the write queue size */
>+char bootdevice[64]; /* boot device option */
>+int bootdevset = 0; /* flag for above */
>
>
> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
>@@ -1073,9 +1077,13 @@
>
> /* Check args */
> if(device == 0) {
>+ if (bootdevset) {
>+ device = &bootdevice;
>+ } else {
> printk("blkmtd: error, missing `device' name\n");
> return -EINVAL;
> }
>+ }
>
> if(ro)
> readonly = 1;
>@@ -1312,6 +1320,26 @@
> __free_pages(erase_page, 0);
> return err;
> }
>+
>+static int __init blkmtd_setup(char *line)
>+{
>+ int i;
>+ char ch;
>+
>+ bootdevset = 1;
>+ memset (bootdevice, 0, sizeof bootdevice);
>+ for (i = 0; i < sizeof bootdevice - 1; ++i)
>+ {
>+ ch = line[i];
>+ if ( isspace (ch) || (ch == ',') || (ch == '\0') ) break;
>+ // don't have to worry about setting the last char to \0,
>+ // because the memset has taken care of that for us.
>+ bootdevice[i] = ch;
>+ }
>+ return 1;
>+}
>+
>+__setup("blkmtd=", blkmtd_setup);
>
> module_init(init_blkmtd);
> module_exit(cleanup_blkmtd);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: PATCH: ability to build blkmtd into the kernel and still use it
2002-04-11 19:39 ` spse
@ 2002-04-12 9:35 ` Stephan Linke
0 siblings, 0 replies; 3+ messages in thread
From: Stephan Linke @ 2002-04-12 9:35 UTC (permalink / raw)
To: Mike Mattice; +Cc: linux-mtd
Hint: It is (theoreticaly) possible to add a new device in init/main.c if
you are missing one. (I did so.) They make a simple mapping of names to
major/minor device numbers.
Stephan
> ...
>
>
> Hi,
>
> The blkmtd.c in 2.4.18 should already have the code in it to take a kernel
> argument (blkmtd_device).
>
> The reason you cant use /dev/discs/... is because you may not
> have a root fs
> at the time the module is initialised in the kernel (esp if you are
> using the device as the root device). Therefore the only names allowed
> are those sepecified in init/main.c (ie you have to use the non
> devfs name)
> When compiled and built into the kernel it uses name_to_kdev_t to get the
> major/minor.
>
>
> cheers
> si
>
> >
> > ...
> >
>
> ...
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-04-12 9:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-11 16:43 PATCH: ability to build blkmtd into the kernel and still use it Mike Mattice
2002-04-11 19:39 ` spse
2002-04-12 9:35 ` Stephan Linke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox