I'm trying to write a driver with a Linux kernel module. I created a special file, with mknod, called "newfile". I'm executed chmod on that file to enable writing permission, and I put 777. I'm trying to write on this file whit this command from terminal: echo "Writing on file" > newfile but I got an error, and from my driver I got -EINVAL in vfs_write. This is my code:
static ssize_t device_write(struct file *flip, const char *buffer, size_t len, loff_t *offset) {
printk(KERN_INFO "writing on file; buffer is: %s len is: %d offest is: %lld \n",buffer,len,offset);
return file_write(flip, offset,buffer,len);
}
int file_write(struct file *file, unsigned long long offset, unsigned char *data, unsigned int size)
{
//mm_segment_t oldfs;
int ret;
//oldfs = get_fs();
//set_fs(get_ds());
ret = vfs_write(file, data, size, &offset);
if(ret == -EINVAL)
printk(KERN_INFO "is EINVAL!");
else
printk(KERN_INFO "not EINVAL!");
return ret;
}
Where is the problem?I can't understand