File: realksh.c.8

package info (click to toggle)
binfmtc 0.17-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 800 kB
  • sloc: sh: 1,116; ansic: 891; cpp: 81; makefile: 81; asm: 48; java: 5; fortran: 3
file content (81 lines) | stat: -rw-r--r-- 1,746 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
.TH "realksh" 8 "2006 Jan 1" "binfmt_misc Dancer" "binfmt_C"
.SH "NAME"
realksh.c \- A shell for running Kernel-mode C code
.SH "SYNOPSIS"
.BI "realksh.c "
.SH "DESCRIPTION"
.B "realksh.c"
is an interactive shell that runs C source code.
A line of input is handled as a line in
.B "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 
.B "KMSG: "
is copied to standard out for convenience, so that functions like 
.B "printk"
can be used for easy debugging.

If a line starting with
.B "#"
such as 
.B "#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
.B "##"

.SH "EXAMPLES"

The following is an example session

.nf
$ 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:

.hy

.SH "INTERNALS" 
The following is how the C code looks like.

.nf
#include <linux/module.h>
#include <linux/init.h>
MODULE_AUTHOR("dancerj");
MODULE_DESCRIPTION("....");
MODULE_LICENSE("GPL");
static int __init realkshmod2_init(void)
{
.I "input-line"
return 0; 
}
static void __exit realkshmod2_cleanup(void)
{
}
module_init(realkshmod2_init);
module_exit(realkshmod2_cleanup);
.hy

.SH "AUTHOR"
Junichi Uekawa (dancer@debian.org)

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

.SH "SEE ALSO"
.BR "binfmtc-interpreter" "(1)," 
.BR "realcsh.c" "(1)," 
.BR "realcxxsh.cc" "(1)"