yuchi518 / kubridge

Kernel/User Mode bridge lib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KUBridge

Kernel/User mode bridge. KUBridge uses IOCtrl to transfer commands(short message) between kernel module and user program. I try to let the interface as simple as possible.

Version

0.3

Tech

KUBridge uses a number of open source projects to work properly:

  • [uthash] - A hash lib in C lang. I modified a little code to support kernel mode. (Link: http://troydhanson.github.io/uthash/)
  • [list] - double linked list, comes from linux kernel source.

Installation

You should understand how to compile the kernel module and what tools you should install first. I test the code in Ubuntu 12.04.

Make the test code.

$ make

Install the kernel module.

$ sudo ./load.sh

Run the user program.

$sudo ./kubridge_u

You will see 2 tasks try to communicate with kernel module at same time.

You can see the kubridge usage by following command.

$cat /proc/kubinfo
kubridge usage:
[0] listen 10000 times, send  10000 times
[1] listen 1 times, send  2000 times
[2] listen 0 times, send  0 times
[3] listen 0 times, send  0 times

or

$cat /sys/kernel/kub/info0/usage
kubridge usage:
[0] listen 10000 times, send 10000 tiems.
$cat /sys/kernel/kub/info1/usage
kubridge usage:
[1] listen 1 times, send 2000 tiems.

Uninstall the kernel module.

$sudo ./unload.sh

Development

If you are interested in how to write your kernel module and user programe, you can refer the kubridge_k_task[0-1].c, kubridge_u_tasks.c and kubridge_u.h.

  • task0 - A calculator, kernel module supports four operators (+,-,*,/).
  • task1 - Data generator, kernel module generates data continually.

In your kernel module, you should only includes following 4 fiels. Make sure compiling these codes with a predefine __KERNEL__ (Add it in your makefile).

kubrideg.h kubridge_k.c list.h uthash.h 

In your user programe, you should includes following 4 files.

kubridge.h kubridge_u.c list.h uthash.h

Todo's

  • Many things.

License

GPLv2

About

Kernel/User Mode bridge lib

License:GNU General Public License v2.0


Languages

Language:C 96.2%Language:C++ 2.4%Language:Shell 1.0%Language:Makefile 0.4%