#include <afsconfig.h>
#include "afs/param.h"
-RCSID
- ("$Header$");
#include "afs/sysincludes.h" /* Standard vendor system headers */
#include "afs/afsincludes.h" /* Afs-based standard headers */
int afs_osicred_initialized;
-struct AFS_UCRED afs_osi_cred;
+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;
void *
-osi_UFSOpen(afs_int32 ainode)
+osi_UFSOpen(afs_dcache_id_t *ainode)
{
struct osi_file *afile;
struct vnode *vp;
if (cacheDiskType != AFS_FCACHE_TYPE_UFS)
osi_Panic("UFSOpen called for non-UFS cache\n");
afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
- code = VFS_VGET(cacheDev.mp, (ino_t) ainode, &vp);
- if (vp->v_type == VNON)
+ AFS_GUNLOCK();
+ code = VFS_VGET(cacheDev.mp, ainode->ufs, &vp);
+ AFS_GLOCK();
+ if (code == 0 && vp->v_type == VNON)
code = ENOENT;
if (code) {
osi_FreeSmallSpace(afile);
osi_Panic("UFSOpen: igetinode failed");
}
+ VOP_UNLOCK(vp, 0, curproc);
afile->vnode = vp;
+#ifdef AFS_OBSD39_ENV
+ afile->size = VTOI(vp)->i_ffs1_size;
+#else
afile->size = VTOI(vp)->i_ffs_size;
+#endif
afile->offset = 0;
afile->proc = NULL;
- afile->inum = ainode; /* for hint validity checking */
- VOP_UNLOCK(vp, 0, curproc);
return (void *)afile;
}
struct vattr tvattr;
AFS_STATCNT(osi_Stat);
- MObtainWriteLock(&afs_xosi, 320);
+ ObtainWriteLock(&afs_xosi, 320);
AFS_GUNLOCK();
code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curproc);
AFS_GLOCK();
if (code == 0) {
astat->size = afile->size = tvattr.va_size;
- astat->blksize = tvattr.va_blocksize;
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();
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)
afile->offset += code;
osi_DisableAtimes(afile->vnode);
} else {
- afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
- ICL_TYPE_INT32, code);
- code = -1;
+ afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32,
+ (unsigned int) resid, ICL_TYPE_INT32, code);
+ 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 += 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);