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 "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 int afsio_copy(struct uio *ainuio, struct uio *aoutuio,
29 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 int afsio_trim(register struct uio *auio, register afs_int32 asize)
51 register struct iovec *tv;
53 AFS_STATCNT(afsio_trim);
54 auio->afsio_resid = asize;
56 /* It isn't clear that multiple iovecs work ok (hasn't been tested!) */
58 if (i >= auio->afsio_iovcnt || asize <= 0) {
60 auio->afsio_iovcnt = i;
63 if (tv->iov_len <= asize)
64 /* entire iovec is included */
65 asize -= tv->iov_len; /* this many fewer bytes */
67 /* this is the last one */
69 auio->afsio_iovcnt = i+1;
76 /* skip asize bytes in the current uio structure */
77 int afsio_skip(register struct uio *auio, register afs_int32 asize)
79 register struct iovec *tv; /* pointer to current iovec */
82 AFS_STATCNT(afsio_skip);
83 /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */
84 while (asize > 0 && auio->afsio_resid) {
94 tv->iov_base = (char *)(tv->iov_base) + cnt;
96 auio->uio_resid -= cnt;
97 auio->uio_offset += cnt;