当前位置: 技术问答>linux和unix
为什么这个字符驱动不能正常工作??
来源: 互联网 发布时间:2016-11-13
本文导语: #include #include #include #include #include #include #include #include #include #include #include MODULE_LICENSE("Dual BSD/GPL"); int memory_init(void); int memory_exit(void); int memory_open(struct inode *node,struct file *filp); int memory_release(struct inode...
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
MODULE_LICENSE("Dual BSD/GPL");
int memory_init(void);
int memory_exit(void);
int memory_open(struct inode *node,struct file *filp);
int memory_release(struct inode *node,struct file *filp);
int memory_read(struct file *filp,char *buf,size_t count,loff_t *f_pos);
int memory_write(struct file *filp,char *buf,size_t count,loff_t *f_pos );
int memory_major=60;
char *memory_buffer;
struct file_operations memory_fops=
{
.owner=THIS_MODULE,
.open=memory_open,
.release=memory_release,
.read=memory_read,
.write=memory_write,
};
module_init(memory_init);
module_exit(memory_exit);
int memory_init(void)
{
int result;
result=register_chrdev(memory_major,"memory",&memory_fops);
if(result