uio.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /* A word of warning: Our uio structure will clash with the C library one (which is now obsolete). Remove the C
  14. library one from sys/uio.h if you have a very old library set */
  15. struct iovec
  16. {
  17. void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */
  18. __kernel_size_t iov_len; /* Must be size_t (1003.1g) */
  19. };
  20. #ifdef __KERNEL__
  21. struct kvec {
  22. void *iov_base; /* and that should *never* hold a userland pointer */
  23. size_t iov_len;
  24. };
  25. #endif
  26. /*
  27. * UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)
  28. */
  29. #define UIO_FASTIOV 8
  30. #define UIO_MAXIOV 1024
  31. #if 0
  32. #define UIO_MAXIOV 16 /* Maximum iovec's in one operation
  33. 16 matches BSD */
  34. /* Beg pardon: BSD has 1024 --ANK */
  35. #endif
  36. /*
  37. * Total number of bytes covered by an iovec.
  38. *
  39. * NOTE that it is not safe to use this function until all the iovec's
  40. * segment lengths have been validated. Because the individual lengths can
  41. * overflow a size_t when added together.
  42. */
  43. static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
  44. {
  45. unsigned long seg;
  46. size_t ret = 0;
  47. for (seg = 0; seg < nr_segs; seg++)
  48. ret += iov[seg].iov_len;
  49. return ret;
  50. }
  51. unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
  52. #endif