realksh.c

Langue: en

Version: 304525 (debian - 07/07/09)

Section: 8 (Commandes administrateur)

NAME

realksh.c - A shell for running Kernel-mode C code

SYNOPSIS

realksh.c

DESCRIPTION

realksh.c is an interactive shell that runs C source code. A line of input is handled as a line in module_init() function, and the resulting C code is compiled to build a kernel module. The module is then inserted into the kernel, and removed from the kernel. kernel message output prepended with KMSG: is copied to standard out for convenience, so that functions like printk can be used for easy debugging.

If a line starting with # such as #include <stdio.h> is entered, it is added to every code after that at the start of sourcecode.

The list of such lines can be seen with ##

EXAMPLES

The following is an example session

 $ sudo ./realksh.c
 REAL ksh: printk ("hello\n");
   Building modules, stage 2.
 KMSG: <4>hello
 
 REAL ksh: printk ("%x\n", mfmsr());
   Building modules, stage 2.
 KMSG: <4>9032
 
 REAL ksh: printk ("%x\n", mfspr(SPRN_MMCR0));
   Building modules, stage 2.
 KMSG: <4>0
 
 REAL ksh:
 
 
 
 

INTERNALS

The following is how the C code looks like.
 #include <linux/module.h>
 #include <linux/init.h>
 MODULE_AUTHOR("dancerj");
 MODULE_DESCRIPTION("....");
 MODULE_LICENSE("GPL");
 static int __init realkshmod2_init(void)
 {
 input-line
 return 0; 
 }
 static void __exit realkshmod2_cleanup(void)
 {
 }
 module_init(realkshmod2_init);
 module_exit(realkshmod2_cleanup);
 
 
 

AUTHOR

Junichi Uekawa (dancer@debian.org)

Upstream page is available at http://www.netfort.gr.jp/~dancer/software/

SEE ALSO

binfmtc-interpreter(1), realcsh.c(1), realcxxsh.cc(1)