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 "../afs/param.h" /* Should be always first */
11 #include "../afs/sysincludes.h" /* Standard vendor system headers */
12 #include "../afs/afsincludes.h" /* Afs-based standard headers */
13 #include "../afs/afs_stats.h" /* statistics */
14 #include "../afs/afs_cbqueue.h"
15 #include "../afs/nfsclient.h"
16 #include "../afs/afs_osidnlc.h"
23 /* routine to make copy of uio structure in ainuio, using aoutvec for space */
24 afsio_copy(ainuio, aoutuio, aoutvec)
25 struct uio *ainuio, *aoutuio;
26 register struct iovec *aoutvec; {
28 register struct iovec *tvec;
30 AFS_STATCNT(afsio_copy);
31 if (ainuio->afsio_iovcnt > AFS_MAXIOVCNT) return EINVAL;
32 bcopy((char *)ainuio, (char *)aoutuio, sizeof(struct uio));
33 tvec = ainuio->afsio_iov;
34 aoutuio->afsio_iov = aoutvec;
35 for(i=0;i<ainuio->afsio_iovcnt;i++){
36 bcopy((char *)tvec, (char *)aoutvec, sizeof(struct iovec));
37 tvec++; /* too many compiler bugs to do this as one expr */
43 /* trim the uio structure to the specified size */
44 afsio_trim(auio, asize)
45 register struct uio *auio;
46 register afs_int32 asize; {
48 register struct iovec *tv;
50 AFS_STATCNT(afsio_trim);
51 auio->afsio_resid = asize;
53 /* It isn't clear that multiple iovecs work ok (hasn't been tested!) */
55 if (i >= auio->afsio_iovcnt || asize <= 0) {
57 auio->afsio_iovcnt = i;
60 if (tv->iov_len <= asize)
61 /* entire iovec is included */
62 asize -= tv->iov_len; /* this many fewer bytes */
64 /* this is the last one */
66 auio->afsio_iovcnt = i+1;
73 /* skip asize bytes in the current uio structure */
74 afsio_skip(auio, asize)
75 register struct uio *auio;
76 register afs_int32 asize; {
77 register struct iovec *tv; /* pointer to current iovec */
80 AFS_STATCNT(afsio_skip);
81 /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */
82 while (asize > 0 && auio->afsio_resid) {
92 tv->iov_base = (char *)(tv->iov_base) + cnt;
94 auio->uio_resid -= cnt;
95 auio->uio_offset += cnt;