int afs_osicred_initialized;
-afs_ucred_t afs_osi_cred;
afs_lock_t afs_xosi; /* lock is for tvattr */
extern struct osi_dev cacheDev;
extern struct mount *afs_cacheVfsp;
osi_FreeSmallSpace(afile);
osi_Panic("UFSOpen: igetinode failed");
}
+#if defined(AFS_NBSD60_ENV)
+ VOP_UNLOCK(vp);
+#else
VOP_UNLOCK(vp, 0);
+#endif
afile->vnode = vp;
afile->size = VTOI(vp)->i_ffs1_size;
afile->offset = 0;
struct vattr tvattr;
AFS_STATCNT(osi_Stat);
- MObtainWriteLock(&afs_xosi, 320);
+ ObtainWriteLock(&afs_xosi, 320);
AFS_GUNLOCK();
+#ifdef AFS_NBSD50_ENV
+ code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp);
+#else
code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp,
osi_curproc());
+#endif
AFS_GLOCK();
if (code == 0) {
astat->size = afile->size = tvattr.va_size;
astat->mtime = tvattr.va_mtime.tv_sec;
astat->atime = tvattr.va_atime.tv_sec;
}
- MReleaseWriteLock(&afs_xosi);
+ ReleaseWriteLock(&afs_xosi);
return code;
}
if (code || tstat.size <= asize)
return code;
- MObtainWriteLock(&afs_xosi, 321);
+ ObtainWriteLock(&afs_xosi, 321);
VATTR_NULL(&tvattr);
tvattr.va_size = asize;
AFS_GUNLOCK();
VOP_LOCK(afile->vnode, LK_EXCLUSIVE | LK_RETRY);
+#ifdef AFS_NBSD50_ENV
+ code = VOP_SETATTR(afile->vnode, &tvattr, afs_osi_credp);
+#else
code = VOP_SETATTR(afile->vnode, &tvattr, afs_osi_credp,
osi_curproc());
+#endif
+#ifdef AFS_NBSD60_ENV
+ VOP_UNLOCK(afile->vnode);
+#else
VOP_UNLOCK(afile->vnode, 0);
+#endif
AFS_GLOCK();
if (code == 0)
afile->size = asize;
- MReleaseWriteLock(&afs_xosi);
+ ReleaseWriteLock(&afs_xosi);
return code;
}
int
afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize)
{
- unsigned int resid;
+ size_t resid;
afs_int32 code;
AFS_STATCNT(osi_Read);
if (!afs_shuttingdown)
osi_Panic("osi_Read called with null param");
else
- return EIO;
+ return -EIO;
}
if (offset != -1)
} else {
afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
ICL_TYPE_INT32, code);
- code = -1;
+ if (code > 0) {
+ code *= -1;
+ }
}
return code;
}
afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
afs_int32 asize)
{
- unsigned int resid;
+ size_t resid;
afs_int32 code;
AFS_STATCNT(osi_Write);
afile->offset = offset;
AFS_GUNLOCK();
- VOP_LOCK(afile->vnode, LK_EXCLUSIVE | LK_RETRY);
code =
- vn_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset,
+ vn_rdwr(UIO_WRITE, afile->vnode, aptr, asize, afile->offset,
AFS_UIOSYS, IO_UNIT, afs_osi_credp, &resid, osi_curproc());
- VOP_UNLOCK(afile->vnode, 0);
AFS_GLOCK();
if (code == 0) {
afile->offset += code;
if (afile->offset > afile->size)
afile->size = afile->offset;
- } else
- code = -1;
+ } else {
+ if (code > 0) {
+ code *= -1;
+ }
+ }
if (afile->proc)
(*afile->proc) (afile, code);
* bit, but should still be pretty clear.
*/
int
-afs_osi_MapStrategy(int (*aproc) (), struct buf *bp)
+afs_osi_MapStrategy(int (*aproc)(struct buf *), struct buf *bp)
{
afs_int32 returnCode;