lkml.org 
[lkml]   [2000]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] swap=<device> kernel commandline
This patch adds a swap kernel commandline option, so that you can add a
swap partition before init starts running on a low-memory machine.

The patch is against 2.4.0-test11-pre7

This is my first try at a kernel patch so... I hope someone finds it
usefull.

--- init/main.c-2.4.0test11-pre7 Sat Nov 18 12:30:59 2000
+++ init/main.c Sat Nov 18 12:35:08 2000
@@ -131,6 +131,7 @@
int root_mountflags = MS_RDONLY;
char *execute_command;
char root_device_name[64];
+char swap_device_name[64];


static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
@@ -297,6 +298,25 @@

__setup("root=", root_dev_setup);

+static int __init swap_dev_setup(char *line)
+{
+ int i;
+ char ch;
+
+ memset (swap_device_name, 0, sizeof swap_device_name);
+ for (i = 0; i < sizeof swap_device_name - 1; ++i)
+ {
+ ch = line[i];
+ if ( isspace (ch) || (ch == ',') || (ch == '\0') ) break;
+ swap_device_name[i] = ch;
+ }
+ return 1;
+}
+
+
+__setup("swap=", swap_dev_setup);
+
+
static int __init checksetup(char *line)
{
struct kernel_param *p;
@@ -725,6 +745,15 @@

mount_devfs_fs ();

+ if (swap_device_name[0]!=0) {
+ printk("Setting up swap: %s \n",swap_device_name);
+ if ( sys_swapon(swap_device_name,0)==0 ) {
+ printk("Swapon ok\n");
+ } else {
+ printk("Swapon failed!\n");
+ }
+ }
+
#ifdef CONFIG_BLK_DEV_INITRD
root_mountflags = real_root_mountflags;
if (mount_initrd && ROOT_DEV != real_root_dev
@@ -780,3 +809,4 @@
execve("/bin/sh",argv_init,envp_init);
panic("No init found. Try passing init= option to kernel.");
}
+
\
 
 \ /
  Last update: 2005-03-22 12:47    [W:2.460 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site