Question: Write a linux kernel module that creates an entry in the /proc file system . Use the following code skeleton to write the module and

Write a linux kernel module that creates an entry in the /proc file system. Use the following code skeleton to write the module and replace the commented lines with the right code:

#include #include #include #include #include #include #def ine MAX_LEN 4096 int read_info (char *page, char **start, off_t off, int count, int *eof, void *data); ssize_t write_info (struct file *filp, const char __user *buff, unsigned long len, void *data);

static struct proc_dir_entry *proc_entry; static char *info; static int write_index; static int read_index ; int init_module (void) { int ret = 0; //allocated memory space for the proc entry info = (char *)vmalloc (MAX_LEN);

memset (info, 0, MAX_LEN);

//create the entry write_index = 0; read_index = 0; //register the write and read callback functions proc_entry?>read_proc = read_info; proc_entry?>write_proc = write_info; printk (KERN_INFO " test_proc created. "); return ret; } void cleanup_module (void) { //remove the proc entry and free info space }

ssize_t write_info (struct file *filp, const char __user *buff , unsigned long len , void *data) { //copy the written data from user space and save it in info return len; } int read_info(char *page, char **start, off_t off , int count , int *eof , void *data) { //output the content of info to users buffer pointed by page return l e n ; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!