ssize_t probchar_write(struct file *filp,
const char __user *data, size_t s, loff_t *off) {
printk(KERN_DEBUG "Data> |%s|\n", data); // only for debug
char chars[MAX_LENGHT];
if(s > MAX_LENGHT)
s = MAX_LENGHT;
if (copy_from_user(chars, data, s)) {
return -EFAULT;
}
printk(KERN_DEBUG "Chars> |%s|\n", chars);
return s;
}
This is dmesg output
[66777.956582] Data> |45
[66777.956596] |
[66777.956634] Chars> |45
[66777.956636] � Ҩ�H�� H�� |
Why the copied chain has more characters in the end?