0

使用 cat 命令从设备文件中读取时,我会循环打印字符设备上的写入数据。我是新手,所以我可能做错了,希望能得到一些帮助来解决这个问题`

static ssize_t device_read( struct file* file,
                        char __user* buffer,
                        size_t       length,
                        loff_t*      offset )
{
  // read doesnt really do anything (for now)
  int i;
  printk( "Invocing device_read(%p,%d) - "
      "operation not supported yet\n"
      "(last written - %s)\n",
      file, length, the_message );
  for(i = 0; i < length && i < BUF_LEN; ++i )
  {
    put_user(the_message[i],&buffer[i]);
  }
  return i;
  //invalid argument error
  return -EINVAL;
}
4

0 回答 0