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"
14 #include "afs/sysincludes.h" /* Standard vendor system headers */
15 #include "afsincludes.h" /* Afs-based standard headers */
16 #include "afs/afs_stats.h" /* statistics */
17 #include "afs/afs_cbqueue.h"
18 #include "afs/nfsclient.h"
19 #include "afs/afs_osidnlc.h"
26 #ifndef AFS_DARWIN80_ENV
27 /* routine to make copy of uio structure in ainuio, using aoutvec for space */
29 afsio_copy(struct uio *ainuio, struct uio *aoutuio,
30 register struct iovec *aoutvec)
33 register struct iovec *tvec;
35 AFS_STATCNT(afsio_copy);
36 if (ainuio->afsio_iovcnt > AFS_MAXIOVCNT)
38 memcpy((char *)aoutuio, (char *)ainuio, sizeof(struct uio));
39 tvec = ainuio->afsio_iov;
40 aoutuio->afsio_iov = aoutvec;
41 for (i = 0; i < ainuio->afsio_iovcnt; i++) {
42 memcpy((char *)aoutvec, (char *)tvec, sizeof(struct iovec));
43 tvec++; /* too many compiler bugs to do this as one expr */
49 /* trim the uio structure to the specified size */
51 afsio_trim(register struct uio *auio, register afs_int32 asize)
54 register struct iovec *tv;
56 AFS_STATCNT(afsio_trim);
57 auio->afsio_resid = asize;
59 /* It isn't clear that multiple iovecs work ok (hasn't been tested!) */
60 for (i = 0;; i++, tv++) {
61 if (i >= auio->afsio_iovcnt || asize <= 0) {
63 auio->afsio_iovcnt = i;
66 if (tv->iov_len <= asize)
67 /* entire iovec is included */
68 asize -= tv->iov_len; /* this many fewer bytes */
70 /* this is the last one */
72 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 #ifdef AFS_DARWIN80_ENV
89 uio_update(auio, asize);
91 /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */
92 while (asize > 0 && auio->afsio_resid) {
102 tv->iov_base = (char *)(tv->iov_base) + cnt;
104 auio->uio_resid -= cnt;
105 auio->afsio_offset += cnt;