int afs_osicred_initialized = 0;
-afs_ucred_t afs_osi_cred;
extern struct osi_dev cacheDev;
extern struct mount *afs_cacheVfsp;
int afs_CacheFSType = -1;
ret = va.va_fileid;
#elif !defined(VTOH)
struct vattr va;
- if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
+ if (VOP_GETATTR(avp, &va, afs_osi_credp, current_proc()))
osi_Panic("VOP_GETATTR failed in VnodeToIno\n");
ret = va.va_fileid;
#else
return va.va_fsid; /* XXX they say it's the dev.... */
#elif !defined(VTOH)
struct vattr va;
- if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
+ if (VOP_GETATTR(avp, &va, afs_osi_credp, current_proc()))
osi_Panic("VOP_GETATTR failed in VnodeToDev\n");
return va.va_fsid; /* XXX they say it's the dev.... */
#else
osi_Panic("UFSOpen called for non-UFS cache\n");
}
if (!afs_osicred_initialized) {
- memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
- afs_osi_cred.cr_ref++;
+ afs_osi_credp = afs_osi_Alloc(sizeof(*afs_osi_credp));
+ osi_Assert(afs_osi_credp != NULL);
+ memset(afs_osi_credp, 0, sizeof(*afs_osi_credp));
+ afs_osi_credp->cr_ref++;
#ifndef AFS_DARWIN110_ENV
- afs_osi_cred.cr_ngroups = 1;
+ afs_osi_credp->cr_ngroups = 1;
#endif
afs_osicred_initialized = 1;
}
if (code == 0 && !VATTR_ALL_SUPPORTED(&tvattr))
code = EINVAL;
#else
- code = VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
+ code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, current_proc());
#endif
AFS_GLOCK();
if (code == 0) {
#else
VATTR_NULL(&tvattr);
tvattr.va_size = asize;
- code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
+ code = VOP_SETATTR(afile->vnode, &tvattr, afs_osi_credp, current_proc());
#endif
AFS_GLOCK();
return code;
#else
code =
gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
- AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
+ AFS_UIOSYS, IO_UNIT, afs_osi_credp, &resid);
#endif
AFS_GLOCK();
if (code == 0) {
#else
code =
gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize,
- afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred,
+ afile->offset, AFS_UIOSYS, IO_UNIT, afs_osi_credp,
&resid);
#endif
AFS_GLOCK();
{
AFS_STATCNT(shutdown_osifile);
if (afs_cold_shutdown) {
+ if (afs_osi_credp != NULL) {
+ afs_osi_Free(afs_osi_credp, sizeof(*afs_osi_credp));
+ afs_osi_credp = NULL;
+ }
afs_osicred_initialized = 0;
}
}
if (vop_cred)
code = afs_close(avc, ap->a_fflag, vop_cred);
else
- code = afs_close(avc, ap->a_fflag, &afs_osi_cred);
+ code = afs_close(avc, ap->a_fflag, afs_osi_credp);
osi_FlushPages(avc, vop_cred); /* hold GLOCK, but not basic vnode lock */
/* This is legit; it just forces the fstrace event to happen */
code = afs_CheckCode(code, NULL, 60);
if (vop_cred)
error = afs_fsync(VTOAFS(vp), vop_cred);
else
- error = afs_fsync(VTOAFS(vp), &afs_osi_cred);
+ error = afs_fsync(VTOAFS(vp), afs_osi_credp);
if (!haveGlock) AFS_GUNLOCK();
return error;
}
crdup(osi_curcred());
#elif defined(AFS_SUN5_ENV)
afs_osi_credp = kcred;
+#elif defined(AFS_DARWIN_ENV)
+ afs_osi_credp = afs_osi_Alloc(sizeof(*afs_osi_credp));
+ osi_Assert(afs_osi_credp != NULL);
+ memset(afs_osi_credp, 0, sizeof(*afs_osi_credp));
+# if defined(AFS_DARWIN80_ENV)
+ afs_osi_credp->cr_ref = 1; /* kauth_cred_get_ref needs 1 existing ref */
+# endif
#else
memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
#if defined(AFS_LINUX_ENV)
afs_set_cr_group_info(&afs_osi_cred, groups_alloc(0));
#endif
-#if defined(AFS_DARWIN80_ENV)
- afs_osi_cred.cr_ref = 1; /* kauth_cred_get_ref needs 1 existing ref */
-#else
-# if !(defined(AFS_LINUX_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED))
+#if !(defined(AFS_LINUX_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED))
crhold(&afs_osi_cred); /* don't let it evaporate */
-# endif
#endif
afs_osi_credp = &afs_osi_cred;