Dear All,
I have a character driver
compiled successfully but giving problem while reading/writting oprations.
Here is the code
Code:
struct a_sample
{
char *buffer;
};
static ssize_t device_read(struct file *flip, char *buff,size_t length,loff_t *offset)
{
struct a_sample *dev = flip->private_data;
if(copy_to_user (buff,dev->buffer,sizeof(dev->buffer)))
return -EFAULT;
printk("read data-----> %s\n", buff);
return 100;
}
static ssize_t device_write (struct file *flip, const char *buff, size_t len, loff_t *off)
{
struct a_sample *dev = flip->private_data;
if(copy_from_user(dev->buffer,buff,len))
{
return -EFAULT;
}
printk("written data is = %s\n", buff);
return len;
}
mknod /dev/sampl1 c 243 0
Issues:
1. while writting echo "test" > /dev/sampl1 terminal was closed/exit
2. on reading showing error segmentation fault.
Thanks in advance ...