- 论坛徽章:
- 0
|
static ssize_t read_test(struct file *file,char *outbuf,size_t count,loff_t *f_pos)
{
printk(KERN_ALERT "read1\n");
int bytes_read=0;
if(verify_area(VERIFY_WRITE,outbuf,count)==-EFAULT)
return -EFAULT;
Message_Ptr=kbuf;
while(count && *Message_Ptr)
{
if(put_user(*(Message_Ptr++),outbuf++))
return -EINVAL;
count--;
bytes_read++;
}
memset(kbuf,0,sizeof(kbuf));
return bytes_read;
}
里面的函数在开始已经全部定义过,wirte只是简单的copy_from_user(kbuf,outbuf,count);下面是问题,①测试时什么都不输入时,希望read有个初始值,假设为hello,world,希望能够输出hello,world,再次运行测试函数,输入字符串,显示字符串的内容和长度(这个上面的做的出来,不能算是问题),②当再次不输入时,显示出上次输入时的字符串.
请问程序改如何改呀,谢谢!!!!!!
[ 本帖最后由 yyykkk1229 于 2008-8-14 12:15 编辑 ] |
|