Archive for the ‘Storage and Virtualization’ Category

Storage and Virtualization Course

January 15, 2011

This article contains some of the programs of the assignments that were carried out in the Storage and Virtualization Course.  Wherever possible I have included comments and references. Thought of sharing them, so that they can be of ready reference to others.

————————————————————————————————————————————————————————————–

Assignment No. 1 : Creating and Studying RAM Disk in Linux – Assignment1.pdf [ File Size: 237KB,  No. of Pages: 2]

————————————————————————————————————————————————————————————–

Assignment No. 2 : Writing Character Device Drivers in Linux – Assignment2.pdf [ File Size: 108KB,  No. of Pages: 1]

————————————————————————————————————————————————————————————–

Assignment No. 3 : Write a program to find out the different attributes of files and the mounted file systems. – Assignment3.pdf [ FileSize: 39KB,  No. of Pages: 1] Major System Calls used in the program : stat(), statvfs(). Following Structures were used : struct stat, struct statvfs. stat is used for getting information about a individual file. statvfs is used for querying the file system.

————————————————————————————————————————————————————————————–

Assignment No. 4 : Program code to display messages on module load and unload – Assignment4.pdf [ File Size: 166KB,  No. of Pages: 1]

————————————————————————————————————————————————————————————–

Assignment No. 5 : NFS: A Case Study – Assignment5.pdf [ File Size: 339 KB,  No. of Pages: 2]

Interpretation of the Linux Kernel Version

September 8, 2010

The Linux Kernel has a peculiar version system.

2.6.35.1 :-

First digit : Major Version

Second digit : Minor Version

Third digit : Revision Number

Fourth digit : Stable Version

Inserting a module in the Linux Kernel

August 19, 2010

The following article contains source code and steps for inserting a LOADABLE-KERNEL-MODULE in the linux kernel. P.S. : It is recommended that you download the kernel source code first from here, compile the new kernel and insert the module in the newly compiled kernel. Steps for Linux Kernel Compilation are available here.

Module Name: Hello World. <hello.c>


/*
Hello.c : Simplest Kernel Module
*/
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
#define DRIVER_AUTHOR “Ashwin Tumma”
#define DRIVER_DESC “A Sample Driver”
MODULE_LICENSE(“GPL”);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
int init_module(void)
{
printk(KERN_INFO “Hello World\n”);
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO “Goodbye World\n”);
}

Makefile:

#insmod hello.ko

Check in /var/log/messages : Your message init_module() gets displayed there.

#lsmod | grep hello
Will give the module number if the module is loaded in the Kernel.

#rmmod hello
Will remove the module from the Kernel.
Again check /var/log/messages : Your message exit_module() gets displayed there.

Steps for writing a character device driver : Steps Character_Device_Driver_Steps.pdf

Here’s a screenshot:

Creative Commons License
Inserting a module in the Linux Kernel by Ashwin Tumma is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 India License.