/* Generic read interface */ int afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize) { afs_ucred_t *oldCred; unsigned int resid; afs_int32 code; afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ if (!afile) { if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else return -EIO; } if (offset != -1) afile->offset = offset; retry_IO: /* Note the difference in the way the afile->offset is passed (see comments in gop_rdwr() in afs_aix_subr.c for comments) */ AFS_GUNLOCK(); #ifdef AFS_64BIT_KERNEL code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, &afile->offset, AFS_UIOSYS, NULL, &resid); #else code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, (off_t) & afile->offset, AFS_UIOSYS, NULL, &resid); #endif AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code); /* * To handle periodic low-level EFAULT failures that we've seen with the * Weitek chip; in all observed failed cases a second read succeeded. */ if ((code == EFAULT) && (cnt1++ < 5)) { afs_stats_cmperf.osiread_efaults++; goto retry_IO; } setuerror(code); if (code > 0) { code = -code; } } return code; }
/* Generic write interface */ int afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) { afs_ucred_t *oldCred; ssize_t resid; afs_int32 code; AFS_STATCNT(osi_Write); if (!afile) osi_Panic("afs_osi_Write called with null param"); if (offset != -1) afile->offset = offset; AFS_GUNLOCK(); code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; } else { if (code == ENOSPC) afs_warnuser ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); if (code > 0) { code = -code; } } if (afile->proc) { (*afile->proc) (afile, code); } return code; }
/* Generic write interface */ int afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) { unsigned int resid; afs_int32 code; AFS_STATCNT(osi_Write); if (!afile) osi_Panic("afs_osi_Write called with null param"); if (offset != -1) afile->offset = offset; { AFS_GUNLOCK(); code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, AFS_UIOSYS, IO_UNIT, afs_osi_credp, &resid); AFS_GLOCK(); } if (code == 0) { code = asize - resid; afile->offset += code; } else { if (code > 0) { code *= -1; } } if (afile->proc) { (*afile->proc) (afile, code); } return code; }
/* Generic write interface */ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) { struct AFS_UCRED *oldCred; long resid; register afs_int32 code; AFS_STATCNT(osi_Write); if (!afile) osi_Panic("afs_osi_Write called with null param"); if (offset != -1) afile->offset = offset; AFS_GUNLOCK(); code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, AFS_UIOSYS, IO_UNIT, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; } else { if (code == ENOSPC) afs_warnuser ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); setuerror(code); code = -1; } if (afile->proc) { (*afile->proc) (afile, code); } return code; }
/* Generic write interface */ int afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) { afs_ucred_t *oldCred; ssize_t resid; afs_int32 code; AFS_STATCNT(osi_Write); if (!afile) osi_Panic("afs_osi_Write called with null param"); if (offset != -1) afile->offset = offset; AFS_GUNLOCK(); code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, AFS_UIOSYS, 0, RLIM64_INFINITY, afs_osi_credp, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; } else { if (code > 0) { code = -code; } } if (afile->proc) { (*afile->proc) (afile, code); } return code; }
/* Generic write interface */ int afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) { afs_ucred_t *oldCred; unsigned int resid; afs_int32 code; AFS_STATCNT(osi_Write); if (!afile) osi_Panic("afs_osi_Write called with null param"); if (offset != -1) afile->offset = offset; /* Note the difference in the way the afile->offset is passed (see comments in gop_rdwr() in afs_aix_subr.c for comments) */ AFS_GUNLOCK(); #ifdef AFS_64BIT_KERNEL code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, &afile->offset, AFS_UIOSYS, NULL, &resid); #else code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, (off_t) & afile->offset, AFS_UIOSYS, NULL, &resid); #endif AFS_GLOCK(); if (code == 0) { if (resid) afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED, ICL_TYPE_INT32, asize, ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code); code = asize - resid; afile->offset += code; } else { afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED, ICL_TYPE_INT32, asize, ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code); if (code == ENOSPC) afs_warnuser ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); setuerror(code); if (code > 0) { code = -code; } } if (afile->proc) { (*afile->proc) (afile, code); } return code; }
/* Generic read interface */ int afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize) { afs_ucred_t *oldCred; afs_size_t resid; afs_int32 code; #ifdef AFS_DARWIN80_ENV uio_t uio; #endif AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ if (!afile) { if (afs_shuttingdown == AFS_RUNNING) osi_Panic("osi_Read called with null param"); else return -EIO; } if (offset != -1) afile->offset = offset; AFS_GUNLOCK(); #ifdef AFS_DARWIN80_ENV uio=uio_create(1, afile->offset, AFS_UIOSYS, UIO_READ); uio_addiov(uio, CAST_USER_ADDR_T(aptr), asize); code = VNOP_READ(afile->vnode, uio, IO_UNIT, afs_osi_ctxtp); resid = AFS_UIO_RESID(uio); uio_free(uio); #else code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); #endif AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code); if (code > 0) { code *= -1; } } return code; }
/* Generic read interface */ int afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize) { afs_ucred_t *oldCred; long resid; afs_int32 code; afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ if (!afile) { if (afs_shuttingdown == AFS_RUNNING) osi_Panic("osi_Read called with null param"); else return -EIO; } if (offset != -1) afile->offset = offset; retry_IO: AFS_GUNLOCK(); code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, AFS_UIOSYS, IO_UNIT, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, (afs_int32) resid, ICL_TYPE_INT32, code); /* * To handle periodic low-level EFAULT failures that we've seen with the * Weitek chip; in all observed failed cases a second read succeeded. */ if ((code == EFAULT) && (cnt1++ < 5)) { afs_stats_cmperf.osiread_efaults++; goto retry_IO; } setuerror(code); if (code > 0) { code *= -1; } } return code; }
/* Generic write interface */ int afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) { afs_ucred_t *oldCred; afs_size_t resid; afs_int32 code; #ifdef AFS_DARWIN80_ENV uio_t uio; #endif AFS_STATCNT(osi_Write); if (!afile) osi_Panic("afs_osi_Write called with null param"); if (offset != -1) afile->offset = offset; { AFS_GUNLOCK(); #ifdef AFS_DARWIN80_ENV uio=uio_create(1, afile->offset, AFS_UIOSYS, UIO_WRITE); uio_addiov(uio, CAST_USER_ADDR_T(aptr), asize); code = VNOP_WRITE(afile->vnode, uio, IO_UNIT, afs_osi_ctxtp); resid = AFS_UIO_RESID(uio); uio_free(uio); #else code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); #endif AFS_GLOCK(); } if (code == 0) { code = asize - resid; afile->offset += code; } else { if (code > 0) { code *= -1; } } if (afile->proc) { (*afile->proc) (afile, code); } return code; }
/* Generic read interface */ int afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize) { afs_ucred_t *oldCred; ssize_t resid; afs_int32 code; afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ if (!afile) { if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else return -EIO; } if (offset != -1) afile->offset = offset; AFS_GUNLOCK(); code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, AFS_UIOSYS, 0, 0, afs_osi_credp, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code); if (code > 0) { code = -code; } } return code; }