Hi all

   I was trying to write a kernel module and in that module I wanted to do following 
actions 

  1. open, write into a file
  2. open, read from a file
  3. use mmap on a file contents ..
  4. create a socket ( DGRAM )

   things like that .. I am not able to get much information in these issues.
  
   Since the library files doesn't make much sense in kernel level, how do I go about 
this .. ?

 I will attach the code I have started writing .. please get me some input in 
this ..


>>>>>

#define MODULE
#define __KERNEL

#define __KERNEL_SYSCALLS__

#include <linux/module.h>
#include <linux/string.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/mman.h>
#define BASE_ADDRESS (20 * 0x100000)

int init_module(void)
{
char *ptr;
int fd;
char str[10] = "suresh";
printk("<1>Hello/n");
ptr = (char *) BASE_ADDRESS;

fd  = filp_open ("/dev/mem", O_RDWR, 0);
if (fd < 0) { printk ("error\n"); }
ptr = (char *) mmap(0, 1, PROT_READ|PROT_WRITE, MAP_SHARED, fd, BASE_ADDRESS);
memcpy(ptr, str, 5);
return 0;
}

int cleanup_module(void)
{
printk("Bye");
}

<<<<<



  Help me correcting this program .. I could compile and make .o file..
but when I tried to insert, it says that unresolved 

regs
salil


-- 

_______________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup


1 cent a minute calls anywhere in the U.S.!

http://www.getpennytalk.com/cgi-bin/adforward.cgi?p_key=RG9853KJ&url=http://www.getpennytalk.com



_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to