Ramdisk patch...

Chad Page (page0588@sundance.sjsu.edu)
Fri, 26 Apr 1996 19:35:51 -0700 (PDT)


This ramdisk patch does three things :

1. Re-enables the "ramdisk=<size>" parameter (actually it's
ramdisk_size=<size>, but I put the ramdisk one in for compatibility)

2. Changes the default ramdisk size to 4MB, and the default # to
16 ramdisks. I remember a lot of complaints about the 2.88MB default,
since gzip can often do >2:1 compression with filesystems.

3. Prints a diagnostic banner which states the number and size
of the ramdisks at bootup.

This patch dosen't change anything else - I don't think anything
should break from this, so it's probably safe even for Code Freeze (tm)
kernels...

- Chad,
who should have done this months ago, but never got a Round-Tuit.

--- Documentation/ramdisk.txt.orig Thu Jan 25 11:01:32 1996
+++ Documentation/ramdisk.txt Fri Apr 26 19:03:33 1996
@@ -28,10 +28,15 @@
of the "rdev -r" or "ramsize" (usually a symbolic link to "rdev")
command has changed.

-The old "ramdisk=<ram_size>" is now obsolete. The kernel will ignore
-such old commands, and thus they will be passed on through to the init
-program, which will then complain. You should remove any of these old
-style commands from config files such as "/etc/lilo.config".
+Also, the new ramdisk supports up to 16 ramdisks out of the box, and can
+be reconfigured in rd.c to support up to 255 ramdisks. To use multiple
+ramdisk support with your system, run 'mknod /dev/ramX b 1 X' and chmod
+(to change it's permissions) it to your liking. The default /dev/ram(disk)
+uses minor #1, so start with ram2 and go from there.
+
+The old "ramdisk=<ram_size>" has been changed to "ramdisk_size=<ram_size>"
+to make it clearer. The original "ramdisk=<ram_size>" has been kept around
+for compatiblity reasons, but it will probably be removed in 2.1.x.

The new ramdisk also has the ability to load compressed ramdisk images,
allowing one to squeeze more programs onto an average installation or
@@ -92,6 +97,11 @@
and thus "prompt_ramdisk=1" can be used. Since this is the default
value, it doesn't really need to be specified.

+ ramdisk_size=N
+ ==============
+
+This parameter tells the ramdisk driver to set up ramdisks of Nk size. The
+default is 4096 (4MB).

3) Using "rdev -r" With New Kernels
-----------------------------------
--- init/main.c.orig Thu Apr 25 21:12:30 1996
+++ init/main.c Fri Apr 26 19:04:14 1996
@@ -121,6 +121,7 @@
static void ramdisk_start_setup(char *str, int *ints);
static void load_ramdisk(char *str, int *ints);
static void prompt_ramdisk(char *str, int *ints);
+static void ramdisk_size(char *str, int *ints);
#ifdef CONFIG_BLK_DEV_INITRD
static void no_initrd(char *s,int *ints);
#endif
@@ -163,6 +164,7 @@
#ifdef CONFIG_BLK_DEV_RAM
extern int rd_doload; /* 1 = load ramdisk, 0 = don't load */
extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */
+extern int rd_size; /* Size of the ramdisk(s) */
extern int rd_image_start; /* starting block # of image */
#ifdef CONFIG_BLK_DEV_INITRD
kdev_t real_root_dev;
@@ -224,6 +226,8 @@
{ "ramdisk_start=", ramdisk_start_setup },
{ "load_ramdisk=", load_ramdisk },
{ "prompt_ramdisk=", prompt_ramdisk },
+ { "ramdisk=", ramdisk_size },
+ { "ramdisk_size=", ramdisk_size },
#ifdef CONFIG_BLK_DEV_INITRD
{ "noinitrd", no_initrd },
#endif
@@ -373,6 +377,13 @@
if (ints[0] > 0 && ints[1] >= 0)
rd_prompt = ints[1] & 1;
}
+
+static void ramdisk_size(char *str, int *ints)
+{
+ if (ints[0] > 0 && ints[1] >= 0)
+ rd_size = ints[1];
+}
+
#endif

static int checksetup(char *line)
--- drivers/block/rd.c.orig Sat Mar 9 03:31:43 1996
+++ drivers/block/rd.c Fri Apr 26 19:03:46 1996
@@ -32,6 +32,9 @@
* Default ramdisk size changed to 2.88MB
*
* Added initrd: Werner Almesberger & Hans Lermen, Feb '96
+ *
+ * 4/25/96 : Made ramdisk size a parameter (default is now 4MB)
+ * - Chad Page
*/

#include <linux/config.h>
@@ -60,9 +63,8 @@
#define MAJOR_NR RAMDISK_MAJOR
#include <linux/blk.h>

-/* These *should* be defined as parameters */
-#define NUM_RAMDISKS 8
-#define RD_DEFAULTSIZE 2880 /* 2.88 MB */
+/* The ramdisk size is now a parameter */
+#define NUM_RAMDISKS 16 /* This cannot be overridden (yet) */

#ifndef MODULE
/* We don't have to load ramdisks or gunzip them in a module... */
@@ -92,6 +94,7 @@
int rd_doload = 0; /* 1 = load ramdisk, 0 = don't load */
int rd_prompt = 1; /* 1 = prompt for ramdisk, 0 = don't prompt */
int rd_image_start = 0; /* starting block # of image */
+int rd_size = 4096; /* Size of the ramdisks */
#ifdef CONFIG_BLK_DEV_INITRD
unsigned long initrd_start,initrd_end;
int mount_initrd = 1; /* zero if initrd should not be mounted */
@@ -272,11 +275,14 @@
blk_dev[MAJOR_NR].request_fn = &rd_request;

for (i = 0; i < NUM_RAMDISKS; i++) {
- rd_length[i] = (RD_DEFAULTSIZE * 1024);
+ rd_length[i] = (rd_size * 1024);
rd_blocksizes[i] = 1024;
}

blksize_size[MAJOR_NR] = rd_blocksizes;
+
+ printk("Ramdisk driver initialized : %d ramdisks of %dK size\n",
+ NUM_RAMDISKS, rd_size);

return 0;
}