Re: [PATCH] adjust /dev/{kmem,mem,port} write handlers

From: Jan Beulich
Date: Mon Mar 06 2006 - 03:07:41 EST


>> @@ -514,11 +510,10 @@ static ssize_t write_kmem(struct file *
>> if (len) {
>> written = copy_from_user(kbuf, buf, len);
>> if (written) {
>> - ssize_t ret;
>> -
>> + if (wrote + virtr)
>> + break;
>> free_page((unsigned long)kbuf);
>> - ret = wrote + virtr + (len - written);
>> - return ret ? ret : -EFAULT;
>> + return -EFAULT;
>> }
>> }
>> len = vwrite(kbuf, (char *)p, len);
>
>
>I think write_kmem() still isn't quie right - it needs to update `p' (and
>hence *ppos) to account for a partial copy_from_user(). (Please double-check)

No, I disagree. The actual write happens with the call to vwrite(), independent of the reading of the user buffer. If
any adjustment might be needed, then it would be to account for the potential of vwrite() (and similarly vread()) to
return 0, resulting in no progress being possible to be made anymore.

Jan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/