From 72d2ef7fa25a09c8f71b57c4969549eff20ce69e Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 2 Feb 2012 17:35:52 -0600 Subject: [PATCH] SOLARIS: Use kcred instead of afs_osi_cred For many vfs ops to the cache, we currently pass &afs_osi_cred for our credentials, which is a mostly zeroed-out credential structure. In some modern versions of Solaris (Solaris 11), at least some parts of this structure need to not be NULL (cr_zone), or we will panic. The Solaris kernel provides a 'kcred' credentials structure for the purpose of using "kernel" credentials for i/o. So just use that instead for Solaris 8 and beyond, since kcred has existed at least since Solaris 8. Reviewed-on: http://gerrit.openafs.org/6669 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit dc6beb3ea29a64bcf59807fd451a573aa54e1122) Change-Id: I6fd0ce4a890c2e6d9377cad39f47303aa1687a6b Reviewed-on: http://gerrit.openafs.org/6682 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/SOLARIS/osi_file.c | 37 ++++++++++++++++++++++--------------- src/afs/afs_osi.c | 2 ++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/afs/SOLARIS/osi_file.c b/src/afs/SOLARIS/osi_file.c index d6985f185..a9e97ed66 100644 --- a/src/afs/SOLARIS/osi_file.c +++ b/src/afs/SOLARIS/osi_file.c @@ -18,7 +18,9 @@ int afs_osicred_initialized = 0; +#ifndef AFS_SUN58_ENV afs_ucred_t afs_osi_cred; +#endif afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct vfs *afs_cacheVfsp; @@ -85,9 +87,9 @@ VnodeToIno(vnode_t * vp) vattr.va_mask = AT_FSID | AT_NODEID; /* quick return using this mask. */ #ifdef AFS_SUN511_ENV - code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred, NULL); + code = VOP_GETATTR(vp, &vattr, 0, afs_osi_credp, NULL); #else - code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred); + code = VOP_GETATTR(vp, &vattr, 0, afs_osi_credp); #endif if (code) { osi_Panic("VnodeToIno"); @@ -104,9 +106,9 @@ VnodeToDev(vnode_t * vp) vattr.va_mask = AT_FSID | AT_NODEID; /* quick return using this mask. */ AFS_GUNLOCK(); #ifdef AFS_SUN511_ENV - code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred, NULL); + code = VOP_GETATTR(vp, &vattr, 0, afs_osi_credp, NULL); #else - code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred); + code = VOP_GETATTR(vp, &vattr, 0, afs_osi_credp); #endif AFS_GLOCK(); if (code) { @@ -129,9 +131,9 @@ VnodeToSize(vnode_t * vp) vattr.va_mask = AT_SIZE; AFS_GUNLOCK(); #ifdef AFS_SUN511_ENV - code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred, NULL); + code = VOP_GETATTR(vp, &vattr, 0, afs_osi_credp, NULL); #else - code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred); + code = VOP_GETATTR(vp, &vattr, 0, afs_osi_credp); #endif AFS_GLOCK(); if (code) { @@ -199,14 +201,14 @@ osi_UfsOpen(afs_dcache_id_t *ainode) VN_HOLD(rootdir); /* released in loopuppnvp */ code = lookuppnvp(&lookpn, NULL, FOLLOW, NULL, &vp, - rootdir, rootdir, &afs_osi_cred); + rootdir, rootdir, afs_osi_credp); if (code != 0) osi_Panic("UfsOpen: lookuppnvp failed %ld %s", code, ainode->ufs); #ifdef AFS_SUN511_ENV - code = VOP_OPEN(&vp, FREAD|FWRITE, &afs_osi_cred, NULL); + code = VOP_OPEN(&vp, FREAD|FWRITE, afs_osi_credp, NULL); #else - code = VOP_OPEN(&vp, FREAD|FWRITE, &afs_osi_cred); + code = VOP_OPEN(&vp, FREAD|FWRITE, afs_osi_credp); #endif if (code != 0) @@ -247,9 +249,14 @@ osi_UFSOpen(afs_dcache_id_t *ainode) osi_Panic("UFSOpen called for non-UFS cache\n"); } if (!afs_osicred_initialized) { +#ifdef AFS_SUN58_ENV + afs_osi_credp = kcred; +#else /* valid for alpha_osf, SunOS, Ultrix */ memset(&afs_osi_cred, 0, sizeof(afs_ucred_t)); crhold(&afs_osi_cred); /* don't let it evaporate, since it is static */ + afs_osi_credp = &afs_osi_cred; +#endif afs_osicred_initialized = 1; } #ifdef AFS_HAVE_VXFS @@ -270,9 +277,9 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat) tvattr.va_mask = AT_ALL; AFS_GUNLOCK(); #ifdef AFS_SUN511_ENV - code = VOP_GETATTR(afile->vnode, &tvattr, 0, &afs_osi_cred, NULL); + code = VOP_GETATTR(afile->vnode, &tvattr, 0, afs_osi_credp, NULL); #else - code = VOP_GETATTR(afile->vnode, &tvattr, 0, &afs_osi_cred); + code = VOP_GETATTR(afile->vnode, &tvattr, 0, afs_osi_credp); #endif AFS_GLOCK(); if (code == 0) { @@ -323,10 +330,10 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) { caller_context_t ct; - code = VOP_SETATTR(afile->vnode, &tvattr, 0, &afs_osi_cred, &ct); + code = VOP_SETATTR(afile->vnode, &tvattr, 0, afs_osi_credp, &ct); } #else - code = VOP_SETATTR(afile->vnode, &tvattr, 0, &afs_osi_cred); + code = VOP_SETATTR(afile->vnode, &tvattr, 0, afs_osi_credp); #endif AFS_GLOCK(); ReleaseWriteLock(&afs_xosi); @@ -380,7 +387,7 @@ afs_osi_Read(struct osi_file *afile, int offset, void *aptr, AFS_GUNLOCK(); code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, 0, 0, &afs_osi_cred, &resid); + AFS_UIOSYS, 0, 0, afs_osi_credp, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; @@ -414,7 +421,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, AFS_GUNLOCK(); code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, - afile->offset, AFS_UIOSYS, 0, RLIM64_INFINITY, &afs_osi_cred, + afile->offset, AFS_UIOSYS, 0, RLIM64_INFINITY, afs_osi_credp, &resid); AFS_GLOCK(); if (code == 0) { diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index 4cece9823..ce0a14c08 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -84,6 +84,8 @@ osi_Init(void) /* Can't just invent one, must use crget() because of mutex */ afs_osi_credp = crdup(osi_curcred()); +#elif defined(AFS_SUN58_ENV) + afs_osi_credp = kcred; #else memset(&afs_osi_cred, 0, sizeof(afs_ucred_t)); #if defined(AFS_LINUX26_ENV) -- 2.39.5