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 #ifndef AFS_DARWIN80_ENV
29 /* routine to make copy of uio structure in ainuio, using aoutvec for space */
31 afsio_copy(struct uio *ainuio, struct uio *aoutuio,
32 register struct iovec *aoutvec)
35 register struct iovec *tvec;
37 AFS_STATCNT(afsio_copy);
38 if (ainuio->afsio_iovcnt > AFS_MAXIOVCNT)
40 memcpy((char *)aoutuio, (char *)ainuio, sizeof(struct uio));
41 tvec = ainuio->afsio_iov;
42 aoutuio->afsio_iov = aoutvec;
43 for (i = 0; i < ainuio->afsio_iovcnt; i++) {
44 memcpy((char *)aoutvec, (char *)tvec, sizeof(struct iovec));
45 tvec++; /* too many compiler bugs to do this as one expr */
51 /* trim the uio structure to the specified size */
53 afsio_trim(register struct uio *auio, register afs_int32 asize)
56 register struct iovec *tv;
58 AFS_STATCNT(afsio_trim);
59 auio->afsio_resid = asize;
61 /* It isn't clear that multiple iovecs work ok (hasn't been tested!) */
62 for (i = 0;; i++, tv++) {
63 if (i >= auio->afsio_iovcnt || asize <= 0) {
65 auio->afsio_iovcnt = i;
68 if (tv->iov_len <= asize)
69 /* entire iovec is included */
70 asize -= tv->iov_len; /* this many fewer bytes */
72 /* this is the last one */
74 auio->afsio_iovcnt = i + 1;
82 /* skip asize bytes in the current uio structure */
84 afsio_skip(register struct uio *auio, register afs_int32 asize)
86 register struct iovec *tv; /* pointer to current iovec */
89 AFS_STATCNT(afsio_skip);
90 #ifdef AFS_DARWIN80_ENV
91 uio_update(auio, asize);
93 /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */
94 while (asize > 0 && auio->afsio_resid) {
104 tv->iov_base = (char *)(tv->iov_base) + cnt;
106 auio->uio_resid -= cnt;
107 auio->afsio_offset += cnt;