Wednesday 15 August 2012

linux - printing number of processes in kernel module -



linux - printing number of processes in kernel module -

i'm new kernel programming , have written little kernel module this,

mod.c

#include<linux/kernel.h> #include<linux/module.h> #include<sys/sysinfo.h> int init_module(void) { int k; struct sysinfo info; printk(kern_info "hello\n"); k = sysinfo(&info); printk(kern_emerg "procs = %d\n", info.procs) homecoming 0; } void cleanup_module(void) { printk(kern_info "goodbye\n"); }

and makefile looks this,

obj-m +=mod.o all: create -c /lib/modules/$(shell uname -r)/build m=$(pwd) modules clean: create -c /lib/modules/$(shell uname -r)/build m=$(pwd) clean

if issue create terminal, gives error fatal error: sys/sysinfo.h: no such file or directory

could tell me what's problem here?

thanks lot, gmcode

if still looking how this, solved sometime ago, here solution. works debian linux 3.16 version. if want take @ code here.

https://github.com/st0rmi/rootkit_programming/blob/master/assignment01/assignment01_mod.c

linux kernel kernel-module sysinfo

No comments:

Post a Comment