实验终于成功了,copy_to_user() && copy_from_user()
来源:互联网 发布:asp网页程序员招聘 编辑:程序博客网 时间:2024/05/16 09:55
//纠结了两天后,关于这两个函数的实验终于有点成就感了,网上关于这两个函数的用法说法不一,有人说使用前需要检查buf是否
//可用。急于实验的我参考了多种方案,结果还是没有成功。最后觉得还是很需要了解这两个函数的原型,以及file_operations的定
//义。通过查看源文件了解到这两个函数已经检查了buf是否可用,以及进一步了解了file_operations结构,实验发现原来
//copy_to_user(),与copy_from_user()的使用可以这么简洁!以下的注释是为了测试buf、buf_dev是否为整形变量,实验表明,
//那是可以的。
//随便提一下函数的定义在asm/uaccess.h,而file_operations则定义在linux/fs.h中
//实验平台:fedore 10
//日期2011_1_1
//Seven.Bao
//first_chrdev_m.c
#define
#define
#define
#include
#include
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Seven");
unsigned int test_major = 0;
static char buf_dev[100] = "kernel_data_2011_1_1";
//static int chrdev_var = 2011;
static ssize_t write_test(struct file *file,const char *buf,size_t count,loff_t* f_pos){
}
static ssize_t read_test(struct file *file,char *buf,size_t count,loff_t* f_pos){
}
static int open_test(struct inode *inode,struct file *file ) {
}
static void release_test(struct inode *inode,struct file *file ) {
}
static int ioctl_test(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){
}
struct file_operations test_fops = {
};
static int __init first_chrdev_init(void){
}
static int __exit first_chrdev_exit(void){
}
module_init(first_chrdev_init);
module_exit(first_chrdev_exit);
//first_chrdev_t.c
#define DEVICE_NAME "/dev/first_chrdev_m"
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main(int argc,char *argv[]){
}
- 实验终于成功了,copy_to_user() && copy_from_user()
- copy_to_user、copy_from_user
- copy_from_user && copy_to_user
- copy_to_user和copy_from_user函数
- copy_to_user 和 copy_from_user
- copy_to_user和copy_from_user
- copy_from_user and copy_to_user
- copy_to_user、copy_from_user 分析
- copy_to_user和copy_from_user
- copy_to_user、copy_from_user 分析
- copy_to_user和copy_from_user
- copy_to_user、copy_from_user 分析
- copy_to_user和copy_from_user
- copy_from_user与copy_to_user分析
- copy_to_user()和copy_from_user()
- linux copy_to_user() copy_from_user()
- copy_to_user和copy_from_user
- copy_to_user、copy_from_user 分析
- Android 4.1新特性
- Js动态创建div
- Weblogic 10g: Ant WLST Exception:Unable to create mbean: Could not create provider JMSQueue
- java中toArray用法注意事项
- 记者采访遭摔相机强行拖离 现场警察未施救-记者-掐脖子-摔相机
- 实验终于成功了,copy_to_user() && copy_from_user()
- HashMap<K, V>泛型类
- oracle 异常处理
- 如何随机产生唯一的app_key和app_secret
- 莫言最伤人的82句话
- 十七大以来纪检机关处分66万人 查处薄熙来等案-十七大-中纪委-党纪
- 参芪炖瘦肉
- SDRAM控制器
- Java面试宝典2013版(超长版)