patch-2.1.90 linux/net/core/iovec.c
Next file: linux/net/core/neighbour.c
Previous file: linux/net/core/dst.c
Back to the patch index
Back to the overall index
- Lines: 92
- Date:
Thu Mar 12 10:32:03 1998
- Orig file:
v2.1.89/linux/net/core/iovec.c
- Orig date:
Tue Mar 10 10:03:36 1998
diff -u --recursive --new-file v2.1.89/linux/net/core/iovec.c linux/net/core/iovec.c
@@ -80,18 +80,21 @@
/*
* Copy kernel to iovec.
+ *
+ * Note: this modifies the original iovec.
*/
int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
{
- int err = -EFAULT;
+ int err;
while(len>0)
{
if(iov->iov_len)
{
int copy = min(iov->iov_len, len);
- if (copy_to_user(iov->iov_base, kdata, copy))
+ err = copy_to_user(iov->iov_base, kdata, copy);
+ if (err)
goto out;
kdata+=copy;
len-=copy;
@@ -107,6 +110,8 @@
/*
* Copy iovec to kernel.
+ *
+ * Note: this modifies the original iovec.
*/
int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len)
@@ -187,9 +192,8 @@
* call to this function will be unaligned also.
*/
-int csum_partial_copy_fromiovecend(unsigned char *kdata,
- struct iovec *iov, int offset,
- unsigned int len, int *csump)
+int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
+ int offset, unsigned int len, int *csump)
{
int partial_cnt = 0;
int err = 0;
@@ -246,9 +250,9 @@
if (copy_from_user(kdata, base, copy))
goto out_fault;
kdata += copy;
- base += copy;
+ base += copy;
partial_cnt += copy;
- len -= copy;
+ len -= copy;
iov++;
if (len)
continue;
@@ -260,9 +264,9 @@
goto out_fault;
csum = csum_partial(kdata - partial_cnt, 4, csum);
kdata += par_len;
- base += par_len;
- copy -= par_len;
- len -= par_len;
+ base += par_len;
+ copy -= par_len;
+ len -= par_len;
partial_cnt = 0;
}
@@ -278,16 +282,12 @@
}
}
- /* Why do we want to break?? There may be more to copy ... */
- if (copy == 0) {
-if (len > partial_cnt)
-printk("csum_iovec: early break? len=%d, partial=%d\n", len, partial_cnt);
- break;
+ if (copy) {
+ csum = csum_and_copy_from_user(base, kdata, copy,
+ csum, &err);
+ if (err)
+ goto out;
}
-
- csum = csum_and_copy_from_user(base, kdata, copy, csum, &err);
- if (err)
- goto out;
len -= copy + partial_cnt;
kdata += copy + partial_cnt;
iov++;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov