Infinite printing on read command of character device (through cat command)

28 views Asked by At

I'm getting looped printing of the written data on the character device when using the cat command to read from the device file. I'm new to this so I'm probably doing it wrong, would appreciate some help trying to figure this out`

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;
}
0

There are 0 answers