uio.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef __LINUX_UIO_H
  2. #define __LINUX_UIO_H
  3. #include <linux/compiler.h>
  4. #include <linux/types.h>
  5. /*
  6. * Berkeley style UIO structures - Alan Cox 1994.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. struct iovec
  14. {
  15. void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */
  16. __kernel_size_t iov_len; /* Must be size_t (1003.1g) */
  17. };
  18. /*
  19. * UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)
  20. */
  21. #define UIO_FASTIOV 8
  22. #define UIO_MAXIOV 1024
  23. #ifdef __KERNEL__
  24. struct kvec {
  25. void *iov_base; /* and that should *never* hold a userland pointer */
  26. size_t iov_len;
  27. };
  28. /*
  29. * Total number of bytes covered by an iovec.
  30. *
  31. * NOTE that it is not safe to use this function until all the iovec's
  32. * segment lengths have been validated. Because the individual lengths can
  33. * overflow a size_t when added together.
  34. */
  35. static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
  36. {
  37. unsigned long seg;
  38. size_t ret = 0;
  39. for (seg = 0; seg < nr_segs; seg++)
  40. ret += iov[seg].iov_len;
  41. return ret;
  42. }
  43. unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
  44. #endif
  45. #endif