Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | #ifndef __LINUX_UIO_H |
2 | #define __LINUX_UIO_H |
||
3 | |||
4 | #include <linux/compiler.h> |
||
5 | #include <linux/types.h> |
||
6 | |||
7 | /* |
||
8 | * Berkeley style UIO structures - Alan Cox 1994. |
||
9 | * |
||
10 | * This program is free software; you can redistribute it and/or |
||
11 | * modify it under the terms of the GNU General Public License |
||
12 | * as published by the Free Software Foundation; either version |
||
13 | * 2 of the License, or (at your option) any later version. |
||
14 | */ |
||
15 | |||
16 | |||
17 | /* A word of warning: Our uio structure will clash with the C library one (which is now obsolete). Remove the C |
||
18 | library one from sys/uio.h if you have a very old library set */ |
||
19 | |||
20 | struct iovec |
||
21 | { |
||
22 | void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ |
||
23 | __kernel_size_t iov_len; /* Must be size_t (1003.1g) */ |
||
24 | }; |
||
25 | |||
26 | /* |
||
27 | * UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1) |
||
28 | */ |
||
29 | |||
30 | #define UIO_FASTIOV 8 |
||
31 | #define UIO_MAXIOV 1024 |
||
32 | #if 0 |
||
33 | #define UIO_MAXIOV 16 /* Maximum iovec's in one operation |
||
34 | 16 matches BSD */ |
||
35 | /* Beg pardon: BSD has 1024 --ANK */ |
||
36 | #endif |
||
37 | |||
38 | /* |
||
39 | * Total number of bytes covered by an iovec. |
||
40 | * |
||
41 | * NOTE that it is not safe to use this function until all the iovec's |
||
42 | * segment lengths have been validated. Because the individual lengths can |
||
43 | * overflow a size_t when added together. |
||
44 | */ |
||
45 | static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) |
||
46 | { |
||
47 | unsigned long seg; |
||
48 | size_t ret = 0; |
||
49 | |||
50 | for (seg = 0; seg < nr_segs; seg++) |
||
51 | ret += iov[seg].iov_len; |
||
52 | return ret; |
||
53 | } |
||
54 | |||
55 | unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to); |
||
56 | |||
57 | #endif |