diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-01-31 20:08:47 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-02-17 22:21:11 -0500 |
commit | 4b8164b91d9fdff4dbac0a742d076bdff7fda21b (patch) | |
tree | 694a818c62c0716194e63179670af3035413ef74 /mm/iov_iter.c | |
parent | f5af19d10d151c5a2afae3306578f485c244db25 (diff) | |
download | linux-4b8164b91d9fdff4dbac0a742d076bdff7fda21b.tar.gz linux-4b8164b91d9fdff4dbac0a742d076bdff7fda21b.tar.bz2 linux-4b8164b91d9fdff4dbac0a742d076bdff7fda21b.zip |
new helper: dup_iter()
Copy iter and kmemdup the underlying array for the copy. Returns
a pointer to result of kmemdup() to be kfree()'d later.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/iov_iter.c')
-rw-r--r-- | mm/iov_iter.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mm/iov_iter.c b/mm/iov_iter.c index 827732047da1..9d96e283520c 100644 --- a/mm/iov_iter.c +++ b/mm/iov_iter.c @@ -751,3 +751,18 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages) return npages; } EXPORT_SYMBOL(iov_iter_npages); + +const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags) +{ + *new = *old; + if (new->type & ITER_BVEC) + return new->bvec = kmemdup(new->bvec, + new->nr_segs * sizeof(struct bio_vec), + flags); + else + /* iovec and kvec have identical layout */ + return new->iov = kmemdup(new->iov, + new->nr_segs * sizeof(struct iovec), + flags); +} +EXPORT_SYMBOL(dup_iter); |