<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META content="MSHTML 5.00.2314.1000" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<DIV>Hello everybody,</DIV>
<DIV> </DIV>
<DIV>i am just learning programming in linux. i was just working with
character</DIV>
<DIV>device files. i tried the following program on redhat 6.2 with kernel
2.2.14</DIV>
<DIV>i am getting this error</DIV>
<DIV>unresolved symbol __put_user_X<BR>did i miss any #includes or #defines
??</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>#include<linux/kernel.h><BR>#include<linux/module.h><BR>#include<linux/fs.h><BR>#include<linux/wrapper.h><BR>#include<asm/uaccess.h></DIV>
<DIV> </DIV>
<DIV>static char message[60];<BR>static char *messptr;<BR>static int
dev_open_cnt=0;</DIV>
<DIV> </DIV>
<DIV>static int dev_open(struct inode *inode, struct file *file)<BR>{</DIV>
<DIV> </DIV>
<DIV> dev_open_cnt++; <BR> sprintf(message,"Youve opened it the %dxx
time",dev_open_cnt);<BR> messptr=message;<BR> <BR> return
0;<BR>}</DIV>
<DIV> </DIV>
<DIV>static void dev_release(struct inode *inode, struct file
*file)<BR>{<BR> dev_open_cnt--;<BR>}</DIV>
<DIV> </DIV>
<DIV>static ssize_t dev_read(struct file *file, char *buffer, size_t
length,<BR> loff_t *offset)<BR>{<BR> int bytes_read=0;</DIV>
<DIV> </DIV>
<DIV> if(*messptr==0) return 0;</DIV>
<DIV> </DIV>
<DIV> while(length && *messptr)<BR> {<BR>
put_user(*messptr++,buffer++); /* is this
the error zone ???*/<BR> bytes_read++;<BR>
length--;<BR> }<BR> return bytes_read;<BR>}</DIV>
<DIV> </DIV>
<DIV>static ssize_t dev_write(struct inode *inode, struct file *file, const char
*buffer,<BR> int length)<BR>{<BR> return
-EINVAL;<BR>}<BR> <BR>static int major;<BR>struct file_operations
fops=<BR>{<BR> NULL,<BR> dev_read,<BR> dev_write,<BR> NULL,<BR> NULL,<BR> NULL,<BR> NULL,<BR> dev_open,<BR> NULL,<BR> dev_release<BR>};</DIV>
<DIV> </DIV>
<DIV>int
init_module()<BR>{<BR> major=module_register_chrdev(0,"chrdev",&fops);<BR> printk("major
%d \n",major); <BR> return 0;<BR>}</DIV>
<DIV> </DIV>
<DIV>void
cleanup_module()<BR>{<BR> module_unregister_chrdev(major,"chrdev");<BR>}</DIV></BODY></HTML>