Difference between revisions of "How-to compile the Scull examples"

From Klaus' wiki
Jump to: navigation, search
Line 62: Line 62:
 
</source>
 
</source>
  
 +
In the program misc-progs/setlevel.c you have to change a line of code:
 +
 +
At line 30 insert this code and put in comments on the line defining _syscall3
 +
<source lang="C">
 +
#include <sys/klog.h>
 +
//_syscall3(int, syslog, int, type, char *, bufp, int, len);
 +
</source>
  
 
Remember that only root can insmod a module in the kernel.
 
Remember that only root can insmod a module in the kernel.

Revision as of 16:35, 7 February 2011

As root on your virtual server execute the following commands:

$ yum install gcc kernel-xen-devel ncurses-devel
$ yum update
#
# If a new kernel came in restart the server
#
$ init 6
#
# Wait a few minutes and login once again
#

Next create the ordinary users for the system with

$ adduser <username>
$ passwd <username>

As root edit the /etc/group file and add a new group at the end. Copy the line above (one of the ordinary useres) and change the group number to bee different from any other numbers assigned in the file. Add the usernames after the last : having the file looking something like this:

klausk:x:500:
moduledev:x:501:klausk

Now as an ordinary user unpack the example sources if you haven't done that already.

$ mkdir -p /home/eml1
$ chgrp moduledev /home/eml1
$ cd /home/eml1
#
# Copy the examples to this location from where you've stored them i.e. cp /path/examples.tar.gz .
#
$ tar zxvf examples.tar.gz
$ chgrp -R moduledev examples
$ cd examples

Create a helper script as described below.

Helper script called settings.sh - to be run every time you enter this directory. It sets up the environment. To be placed in the examples directory.

#!/bin/bash
#
# Preparation for the compilation of the scull example code
#
KERNELDIR=/usr/src/kernels/2.6.18-194.11.4.el5-xen-i686/
export KERNELDIR

When entering the example directory execute this

$ . settings.sh
#
# To make the scull module perform:
#
$ cd scull
$ make modules

In the program misc-progs/setlevel.c you have to change a line of code:

At line 30 insert this code and put in comments on the line defining _syscall3

#include <sys/klog.h>
//_syscall3(int, syslog, int, type, char *, bufp, int, len);

Remember that only root can insmod a module in the kernel.

If you add a line like this into /etc/sudoers using visudo

klausk  ALL=(ALL)       NOPASSWD: ALL

You can now issue this to insert the module in the kernel:

$ sudo ./scull_load
#
# check if the module is loaded in the kernel
#
$ sudo /sbin/lsmod