2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "afs/param.h"
16 #include "afs/sysincludes.h" /* Standard vendor system headers */
17 #include "afsincludes.h" /* Afs-based standard headers */
18 #include "afs/afs_stats.h" /* statistics */
19 #include "afs/afs_cbqueue.h"
20 #include "afs/nfsclient.h"
21 #include "afs/afs_osidnlc.h"
28 /* routine to make copy of uio structure in ainuio, using aoutvec for space */
30 afsio_copy(struct uio *ainuio, struct uio *aoutuio,
31 register struct iovec *aoutvec)
34 register struct iovec *tvec;
36 AFS_STATCNT(afsio_copy);
37 if (ainuio->afsio_iovcnt > AFS_MAXIOVCNT)
39 memcpy((char *)aoutuio, (char *)ainuio, sizeof(struct uio));
40 tvec = ainuio->afsio_iov;
41 aoutuio->afsio_iov = aoutvec;
42 for (i = 0; i < ainuio->afsio_iovcnt; i++) {
43 memcpy((char *)aoutvec, (char *)tvec, sizeof(struct iovec));
44 tvec++; /* too many compiler bugs to do this as one expr */
50 /* trim the uio structure to the specified size */
52 afsio_trim(register struct uio *auio, register afs_int32 asize)
55 register struct iovec *tv;
57 AFS_STATCNT(afsio_trim);
58 auio->afsio_resid = asize;
60 /* It isn't clear that multiple iovecs work ok (hasn't been tested!) */
61 for (i = 0;; i++, tv++) {
62 if (i >= auio->afsio_iovcnt || asize <= 0) {
64 auio->afsio_iovcnt = i;
67 if (tv->iov_len <= asize)
68 /* entire iovec is included */
69 asize -= tv->iov_len; /* this many fewer bytes */
71 /* this is the last one */
73 auio->afsio_iovcnt = i + 1;
80 /* skip asize bytes in the current uio structure */
82 afsio_skip(register struct uio *auio, register afs_int32 asize)
84 register struct iovec *tv; /* pointer to current iovec */
87 AFS_STATCNT(afsio_skip);
88 /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */
89 while (asize > 0 && auio->afsio_resid) {
99 tv->iov_base = (char *)(tv->iov_base) + cnt;
101 auio->uio_resid -= cnt;
102 auio->uio_offset += cnt;