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"
15 #include "../afs/sysincludes.h" /* Standard vendor system headers */
16 #include "../afs/afsincludes.h" /* Afs-based standard headers */
17 #include "../afs/afs_stats.h" /* statistics */
18 #include "../afs/afs_cbqueue.h"
19 #include "../afs/nfsclient.h"
20 #include "../afs/afs_osidnlc.h"
27 /* routine to make copy of uio structure in ainuio, using aoutvec for space */
28 afsio_copy(ainuio, aoutuio, aoutvec)
29 struct uio *ainuio, *aoutuio;
30 register struct iovec *aoutvec; {
32 register struct iovec *tvec;
34 AFS_STATCNT(afsio_copy);
35 if (ainuio->afsio_iovcnt > AFS_MAXIOVCNT) return EINVAL;
36 memcpy((char *)aoutuio, (char *)ainuio, sizeof(struct uio));
37 tvec = ainuio->afsio_iov;
38 aoutuio->afsio_iov = aoutvec;
39 for(i=0;i<ainuio->afsio_iovcnt;i++){
40 memcpy((char *)aoutvec, (char *)tvec, sizeof(struct iovec));
41 tvec++; /* too many compiler bugs to do this as one expr */
47 /* trim the uio structure to the specified size */
48 afsio_trim(auio, asize)
49 register struct uio *auio;
50 register afs_int32 asize; {
52 register struct iovec *tv;
54 AFS_STATCNT(afsio_trim);
55 auio->afsio_resid = asize;
57 /* It isn't clear that multiple iovecs work ok (hasn't been tested!) */
59 if (i >= auio->afsio_iovcnt || asize <= 0) {
61 auio->afsio_iovcnt = i;
64 if (tv->iov_len <= asize)
65 /* entire iovec is included */
66 asize -= tv->iov_len; /* this many fewer bytes */
68 /* this is the last one */
70 auio->afsio_iovcnt = i+1;
77 /* skip asize bytes in the current uio structure */
78 afsio_skip(auio, asize)
79 register struct uio *auio;
80 register afs_int32 asize; {
81 register struct iovec *tv; /* pointer to current iovec */
84 AFS_STATCNT(afsio_skip);
85 /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */
86 while (asize > 0 && auio->afsio_resid) {
96 tv->iov_base = (char *)(tv->iov_base) + cnt;
98 auio->uio_resid -= cnt;
99 auio->uio_offset += cnt;