#define osi_curcred() &afs_osi_cred
#ifdef AFS_DARWIN80_ENV
-uio_t afsio_darwin_partialcopy(uio_t auio, int size);
-
-#define uprintf printf
+# define afsio_free(X) uio_free(X)
+# define afsio_setoffset(X, Y) uio_setoffset(X, Y)
+# define uprintf printf
#endif
/* Vnode related macros */
}
#ifdef AFS_DARWIN80_ENV
-uio_t
-afsio_darwin_partialcopy(uio_t auio, int size)
+struct uio *
+afsio_partialcopy(struct uio *auio, size_t size)
{
- uio_t res;
+ struct uio *res;
int i;
user_addr_t iovaddr;
user_size_t iovsize;
afs_int32 trimlen;
struct dcache *tdc = 0;
afs_int32 error, trybusy = 1;
-#ifdef AFS_DARWIN80_ENV
- uio_t tuiop = NULL;
-#else
- struct uio tuio;
- struct uio *tuiop = &tuio;
- struct iovec *tvec = NULL;
-#endif
+ struct uio *tuiop = NULL;
afs_int32 code;
struct vrequest treq;
}
#endif
-#ifndef AFS_DARWIN80_ENV
- tvec = osi_AllocSmallSpace(sizeof(struct iovec));
-#endif
totalLength = AFS_UIO_RESID(auio);
filePos = AFS_UIO_OFFSET(auio);
afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc,
if (len > AFS_ZEROS)
len = sizeof(afs_zeros); /* and in 0 buffer */
len = 0;
-#ifdef AFS_DARWIN80_ENV
- trimlen = len;
- tuiop = afsio_darwin_partialcopy(auio, trimlen);
-#else
- afsio_copy(auio, &tuio, tvec);
trimlen = len;
- afsio_trim(&tuio, trimlen);
-#endif
+ tuiop = afsio_partialcopy(auio, trimlen);
AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, tuiop, code);
}
len = tlen;
if (len > AFS_ZEROS)
len = sizeof(afs_zeros); /* and in 0 buffer */
-#ifdef AFS_DARWIN80_ENV
- trimlen = len;
- tuiop = afsio_darwin_partialcopy(auio, trimlen);
-#else
- afsio_copy(auio, &tuio, tvec);
trimlen = len;
- afsio_trim(&tuio, trimlen);
-#endif
+ tuiop = afsio_partialcopy(auio, trimlen);
AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, tuiop, code);
if (code) {
error = code;
/* get the data from the cache */
/* mung uio structure to be right for this transfer */
-#ifdef AFS_DARWIN80_ENV
- trimlen = len;
- tuiop = afsio_darwin_partialcopy(auio, trimlen);
- uio_setoffset(tuiop, offset);
-#else
- afsio_copy(auio, &tuio, tvec);
trimlen = len;
- afsio_trim(&tuio, trimlen);
- tuio.afsio_offset = offset;
-#endif
+ tuiop = afsio_partialcopy(auio, trimlen);
+ AFS_UIO_SETOFFSET(tuiop, offset);
code = (*(afs_cacheType->vreadUIO))(&tdc->f.inode, tuiop);
if (len <= 0)
break; /* surprise eof */
-#ifdef AFS_DARWIN80_ENV
if (tuiop) {
- uio_free(tuiop);
- tuiop = 0;
+ afsio_free(tuiop);
+ tuiop = NULL;
}
-#endif
} /* the whole while loop */
/*
code = afs_CheckCode(error, &treq, 10);
-#ifdef AFS_DARWIN80_ENV
if (tuiop)
- uio_free(tuiop);
-#else
- osi_FreeSmallSpace(tvec);
-#endif
+ afsio_free(tuiop);
out:
AFS_DISCON_UNLOCK();
#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV)
struct vnode *vp = AFSTOV(avc);
#endif
-#ifdef AFS_DARWIN80_ENV
- uio_t tuiop = NULL;
-#else
- struct uio tuio;
- struct uio *tuiop = &tuio;
- struct iovec *tvec; /* again, should have define */
-#endif
+ struct uio *tuiop = NULL;
afs_int32 code;
struct vrequest treq;
afs_FakeOpen(avc);
#endif
avc->f.states |= CDirty;
-#ifndef AFS_DARWIN80_ENV
- tvec = osi_AllocSmallSpace(sizeof(struct iovec));
-#endif
+
while (totalLength > 0) {
tdc = afs_ObtainDCacheForWriting(avc, filePos, totalLength, &treq,
noLock);
len = max - offset;
}
-#ifdef AFS_DARWIN80_ENV
if (tuiop)
- uio_free(tuiop);
- trimlen = len;
- tuiop = afsio_darwin_partialcopy(auio, trimlen);
-#else
- /* mung uio structure to be right for this transfer */
- afsio_copy(auio, &tuio, tvec);
+ afsio_free(tuiop);
trimlen = len;
- afsio_trim(&tuio, trimlen);
-#endif
+ tuiop = afsio_partialcopy(auio, trimlen);
AFS_UIO_SETOFFSET(tuiop, offset);
code = (*(afs_cacheType->vwriteUIO))(avc, &tdc->f.inode, tuiop);
avc->vc_error = error;
if (!noLock)
ReleaseWriteLock(&avc->lock);
-#ifdef AFS_DARWIN80_ENV
- uio_free(tuiop);
-#else
- osi_FreeSmallSpace(tvec);
-#endif
+ afsio_free(tuiop);
+
#ifndef AFS_VM_RDWR_ENV
/*
* If write is implemented via VM, afs_fsync() is called from the high-level
}
return 0;
}
+
+/* Allocate space for, then partially copy, over an existing iovec up to the
+ * length given in len.
+ *
+ * This requires that SmallSpace can alloc space big enough to hold a struct
+ * UIO, plus 16 iovecs
+ */
+
+struct uio *
+afsio_partialcopy(struct uio *auio, size_t len) {
+ char *space;
+ struct uio *newuio;
+ struct iovec *newvec;
+
+ /* Allocate a block that can contain both the UIO and the iovec */
+ space = osi_AllocSmallSpace(sizeof(struct uio) +
+ sizeof(struct iovec) * AFS_MAXIOVCNT);
+
+ newuio = (struct uio *) space;
+ newvec = (struct iovec *) (space + sizeof(struct uio));
+
+ afsio_copy(auio, newuio, newvec);
+ afsio_trim(newuio, len);
+
+ return newuio;
+}
+
+void
+afsio_free(struct uio *uio) {
+ osi_FreeSmallSpace(uio);
+}
#endif
/* skip asize bytes in the current uio structure */
extern afs_int32 PagInCred(afs_ucred_t *cred);
/* afs_osi_uio.c */
+#if !defined(AFS_DARWIN80_ENV)
extern int afsio_copy(struct uio *ainuio, struct uio *aoutuio,
struct iovec *aoutvec);
extern int afsio_trim(struct uio *auio, afs_int32 asize);
+extern void afsio_free(struct uio *auio);
+#endif
+
+extern struct uio* afsio_partialcopy(struct uio *auio, size_t size);
extern int afsio_skip(struct uio *auio, afs_int32 asize);
/* afs_osi_vm.c */