forked from grate-driver/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/ker…
…nel/git/rusty/linux Pull virtio fixes from Rusty Russell: "A build fix and a uapi exposure fix. The build fix is later than I liked, but my first version broke linux-next due to overzealous header clean." * tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: virtio_console: fix uapi header Hoist memcpy_fromiovec/memcpy_toiovec into lib/
- Loading branch information
Showing
8 changed files
with
60 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <linux/uaccess.h> | ||
#include <linux/export.h> | ||
#include <linux/uio.h> | ||
|
||
/* | ||
* Copy iovec to kernel. Returns -EFAULT on error. | ||
* | ||
* Note: this modifies the original iovec. | ||
*/ | ||
|
||
int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len) | ||
{ | ||
while (len > 0) { | ||
if (iov->iov_len) { | ||
int copy = min_t(unsigned int, len, iov->iov_len); | ||
if (copy_from_user(kdata, iov->iov_base, copy)) | ||
return -EFAULT; | ||
len -= copy; | ||
kdata += copy; | ||
iov->iov_base += copy; | ||
iov->iov_len -= copy; | ||
} | ||
iov++; | ||
} | ||
|
||
return 0; | ||
} | ||
EXPORT_SYMBOL(memcpy_fromiovec); | ||
|
||
/* | ||
* Copy kernel to iovec. Returns -EFAULT on error. | ||
* | ||
* Note: this modifies the original iovec. | ||
*/ | ||
|
||
int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len) | ||
{ | ||
while (len > 0) { | ||
if (iov->iov_len) { | ||
int copy = min_t(unsigned int, iov->iov_len, len); | ||
if (copy_to_user(iov->iov_base, kdata, copy)) | ||
return -EFAULT; | ||
kdata += copy; | ||
len -= copy; | ||
iov->iov_len -= copy; | ||
iov->iov_base += copy; | ||
} | ||
iov++; | ||
} | ||
|
||
return 0; | ||
} | ||
EXPORT_SYMBOL(memcpy_toiovec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters