writev and some fixes

This commit is contained in:
Balazs Gerofi
2012-04-23 14:25:21 +09:00
parent b3cc785796
commit 8fee884be3
9 changed files with 177 additions and 41 deletions

27
kernel/include/uio.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef __UIO_H
#define __UIO_H
struct iovec
{
void *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */
size_t iov_len; /* Must be size_t (1003.1g) */
};
/*
* Total number of bytes covered by an iovec.
*
* NOTE that it is not safe to use this function until all the iovec's
* segment lengths have been validated. Because the individual lengths can
* overflow a size_t when added together.
*/
static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
{
unsigned long seg;
size_t ret = 0;
for (seg = 0; seg < nr_segs; seg++)
ret += iov[seg].iov_len;
return ret;
}
#endif