[LCP]problem with put_user function

Srinath redindian at zxmail.com
Sun Sep 2 01:02:45 UTC 2001


Hello everybody,

i am just learning programming in linux. i was just working with character
device files. i tried the following program on redhat 6.2 with kernel 2.2.14
i am getting this error
unresolved symbol __put_user_X
did i miss any #includes or #defines ??


#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/fs.h>
#include<linux/wrapper.h>
#include<asm/uaccess.h>

static char message[60];
static char *messptr;
static int dev_open_cnt=0;

static int dev_open(struct inode *inode, struct file *file)
{

 dev_open_cnt++; 
 sprintf(message,"Youve opened it the %dxx time",dev_open_cnt);
 messptr=message;
 
 return 0;
}

static void dev_release(struct inode *inode, struct file *file)
{
 dev_open_cnt--;
}

static ssize_t dev_read(struct file *file, char *buffer, size_t length,
 loff_t *offset)
{
 int bytes_read=0;

 if(*messptr==0) return 0;

 while(length && *messptr)
 {
  put_user(*messptr++,buffer++);        /* is this the error zone ???*/
  bytes_read++;
  length--;
 }
 return bytes_read;
}

static ssize_t dev_write(struct inode *inode, struct file *file, const char *buffer,
 int length)
{
 return -EINVAL;
}
 
static int major;
struct file_operations fops=
{
 NULL,
 dev_read,
 dev_write,
 NULL,
 NULL,
 NULL,
 NULL,
 dev_open,
 NULL,
 dev_release
};

int init_module()
{
 major=module_register_chrdev(0,"chrdev",&fops);
 printk("major %d \n",major); 
 return 0;
}

void cleanup_module()
{
 module_unregister_chrdev(major,"chrdev");
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux.org.au/pipermail/linuxcprogramming/attachments/20010902/c6006f3a/attachment.htm 


More information about the linuxCprogramming mailing list