I am writing a character device driver, but at the moment it freezes, and i have to reboot to stop it or crashes and the terminal exitsI have a global array
char* array;
On which i use kmalloc(9, GFP_KERNEL)
so it should be the size of 9. If i wanted to use file operations .write
to set a specific index how would i do that?This is my current code (which crashes and terminal exits)
ssize_t mydriver_write(struct file *filp, const char* buf, size_t count, loff_t *f_pos){ raw_copy_to_user(array[*buf], 'x', 1);}
EDIT:I have already tried this version aswell
raw_copy_to_user(&array[3], x, 1);
where x
is kmalloc'd to size 1 and x[0]='x'
But in this case my program freezes and i cannot remove the driver and the machine requires a reboot to remove it.