#include <afsconfig.h>
#include "afs/param.h"
-RCSID("$Header$");
+RCSID
+ ("$Header$");
-#include "afs/sysincludes.h" /* Standard vendor system headers */
-#include "afsincludes.h" /* Afs-based standard headers */
-#include "afs/afs_stats.h" /* afs statistics */
+#include "afs/sysincludes.h" /* Standard vendor system headers */
+#include "afsincludes.h" /* Afs-based standard headers */
+#include "afs/afs_stats.h" /* afs statistics */
#include "afs/osi_inode.h"
-int afs_osicred_initialized=0;
-struct AFS_UCRED afs_osi_cred;
-afs_lock_t afs_xosi; /* lock is for tvattr */
+int afs_osicred_initialized = 0;
+struct AFS_UCRED afs_osi_cred;
+afs_lock_t afs_xosi; /* lock is for tvattr */
extern struct osi_dev cacheDev;
extern struct mount *afs_cacheVfsp;
int afs_CacheFSType = -1;
/* Initialize the cache operations. Called while initializing cache files. */
-void afs_InitDualFSCacheOps(struct vnode *vp)
+void
+afs_InitDualFSCacheOps(struct vnode *vp)
{
int code;
static int inited = 0;
if (inited)
- return;
+ return;
inited = 1;
if (vp == NULL)
- return;
+ return;
if (strncmp("hfs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
- afs_CacheFSType = AFS_APPL_HFS_CACHE;
- else
- if (strncmp("ufs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
- afs_CacheFSType = AFS_APPL_UFS_CACHE;
+ afs_CacheFSType = AFS_APPL_HFS_CACHE;
+ else if (strncmp("ufs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
+ afs_CacheFSType = AFS_APPL_UFS_CACHE;
else
- osi_Panic("Unknown cache vnode type\n");
+ osi_Panic("Unknown cache vnode type\n");
}
-ino_t VnodeToIno(vnode_t *avp)
+ino_t
+VnodeToIno(vnode_t * avp)
{
- unsigned long ret;
+ unsigned long ret;
- if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
- struct inode *ip = VTOI(avp);
- ret=ip->i_number;
- } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
+ if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
+ struct inode *ip = VTOI(avp);
+ ret = ip->i_number;
+ } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
#ifndef VTOH
- struct vattr va;
- if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
- osi_Panic("VOP_GETATTR failed in VnodeToIno\n");
- ret=va.va_fileid;
+ struct vattr va;
+ if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
+ osi_Panic("VOP_GETATTR failed in VnodeToIno\n");
+ ret = va.va_fileid;
#else
- struct hfsnode *hp = VTOH(avp);
- ret=H_FILEID(hp);
+ struct hfsnode *hp = VTOH(avp);
+ ret = H_FILEID(hp);
#endif
- } else
- osi_Panic("VnodeToIno called before cacheops initialized\n");
- return ret;
+ } else
+ osi_Panic("VnodeToIno called before cacheops initialized\n");
+ return ret;
}
-dev_t VnodeToDev(vnode_t *avp)
+dev_t
+VnodeToDev(vnode_t * avp)
{
-
- if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
- struct inode *ip = VTOI(avp);
- return ip->i_dev;
- } else
- if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
-#ifndef VTOH /* slow, but works */
- struct vattr va;
- if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
- osi_Panic("VOP_GETATTR failed in VnodeToDev\n");
- return va.va_fsid; /* XXX they say it's the dev.... */
+
+ if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
+ struct inode *ip = VTOI(avp);
+ return ip->i_dev;
+ } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
+#ifndef VTOH /* slow, but works */
+ struct vattr va;
+ if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
+ osi_Panic("VOP_GETATTR failed in VnodeToDev\n");
+ return va.va_fsid; /* XXX they say it's the dev.... */
#else
- struct hfsnode *hp = VTOH(avp);
- return H_DEV(hp);
+ struct hfsnode *hp = VTOH(avp);
+ return H_DEV(hp);
#endif
- } else
- osi_Panic("VnodeToDev called before cacheops initialized\n");
+ } else
+ osi_Panic("VnodeToDev called before cacheops initialized\n");
}
-void *osi_UFSOpen(afs_int32 ainode)
+void *
+osi_UFSOpen(afs_int32 ainode)
{
struct vnode *vp;
struct vattr va;
afs_int32 code = 0;
int dummy;
AFS_STATCNT(osi_UFSOpen);
- if(cacheDiskType != AFS_FCACHE_TYPE_UFS) {
+ if (cacheDiskType != AFS_FCACHE_TYPE_UFS) {
osi_Panic("UFSOpen called for non-UFS cache\n");
}
if (!afs_osicred_initialized) {
/* valid for alpha_osf, SunOS, Ultrix */
memset((char *)&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
afs_osi_cred.cr_ref++;
- afs_osi_cred.cr_ngroups=1;
+ afs_osi_cred.cr_ngroups = 1;
afs_osicred_initialized = 1;
}
- afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file));
+ afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
AFS_GUNLOCK();
- if (afs_CacheFSType == AFS_APPL_HFS_CACHE)
- code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, &ainode, &vp, &va, &dummy); /* XXX hfs is broken */
+ if (afs_CacheFSType == AFS_APPL_HFS_CACHE)
+ code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, &ainode, &vp, &va, &dummy); /* XXX hfs is broken */
+ else if (afs_CacheFSType == AFS_APPL_UFS_CACHE)
+ code =
+ igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode,
+ &vp, &va, &dummy);
else
- if (afs_CacheFSType == AFS_APPL_UFS_CACHE)
- code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &vp, &va, &dummy);
- else
- panic("osi_UFSOpen called before cacheops initialized\n");
+ panic("osi_UFSOpen called before cacheops initialized\n");
AFS_GLOCK();
if (code) {
osi_FreeSmallSpace(afile);
afile->vnode = vp;
afile->size = va.va_size;
afile->offset = 0;
- afile->proc = (int (*)()) 0;
- afile->inum = ainode; /* for hint validity checking */
+ afile->proc = (int (*)())0;
+ afile->inum = ainode; /* for hint validity checking */
return (void *)afile;
}
-int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
+int
+afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
{
register afs_int32 code;
struct vattr tvattr;
AFS_STATCNT(osi_Stat);
- MObtainWriteLock(&afs_xosi,320);
+ MObtainWriteLock(&afs_xosi, 320);
AFS_GUNLOCK();
- code=VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
+ code = VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
AFS_GLOCK();
if (code == 0) {
astat->size = tvattr.va_size;
return code;
}
-int osi_UFSClose(register struct osi_file *afile)
+int
+osi_UFSClose(register struct osi_file *afile)
{
- AFS_STATCNT(osi_Close);
- if(afile->vnode) {
+ AFS_STATCNT(osi_Close);
+ if (afile->vnode) {
AFS_RELE(afile->vnode);
- }
-
- osi_FreeSmallSpace(afile);
- return 0;
+ }
+
+ osi_FreeSmallSpace(afile);
+ return 0;
}
-int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
+int
+osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
{
struct AFS_UCRED *oldCred;
struct vattr tvattr;
* small enough. Check now and save some time.
*/
code = afs_osi_Stat(afile, &tstat);
- if (code || tstat.size <= asize) return code;
- MObtainWriteLock(&afs_xosi,321);
+ if (code || tstat.size <= asize)
+ return code;
+ MObtainWriteLock(&afs_xosi, 321);
VATTR_NULL(&tvattr);
tvattr.va_size = asize;
AFS_GUNLOCK();
- code=VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
+ code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
AFS_GLOCK();
MReleaseWriteLock(&afs_xosi);
return code;
}
-void osi_DisableAtimes(struct vnode *avp)
+void
+osi_DisableAtimes(struct vnode *avp)
{
- if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
- struct inode *ip = VTOI(avp);
- ip->i_flag &= ~IN_ACCESS;
- }
-#ifdef VTOH /* can't do this without internals */
- else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
- struct hfsnode *hp = VTOH(avp);
- hp->h_nodeflags &= ~IN_ACCESS;
- }
+ if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
+ struct inode *ip = VTOI(avp);
+ ip->i_flag &= ~IN_ACCESS;
+ }
+#ifdef VTOH /* can't do this without internals */
+ else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
+ struct hfsnode *hp = VTOH(avp);
+ hp->h_nodeflags &= ~IN_ACCESS;
+ }
#endif
}
/* Generic read interface */
-int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize)
+int
+afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
+ afs_int32 asize)
{
struct AFS_UCRED *oldCred;
unsigned int resid;
* 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 )
+ if (!afile) {
+ if (!afs_shuttingdown)
osi_Panic("osi_Read called with null param");
else
return EIO;
}
- if (offset != -1) afile->offset = offset;
+ if (offset != -1)
+ afile->offset = offset;
AFS_GUNLOCK();
- code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
- AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
+ code =
+ gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
+ AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
AFS_GLOCK();
if (code == 0) {
code = asize - resid;
afile->offset += code;
osi_DisableAtimes(afile->vnode);
- }
- else {
+ } else {
afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
- ICL_TYPE_INT32, code);
+ ICL_TYPE_INT32, code);
code = -1;
}
return code;
}
/* Generic write interface */
-int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize)
+int
+afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
+ afs_int32 asize)
{
struct AFS_UCRED *oldCred;
unsigned int resid;
register afs_int32 code;
AFS_STATCNT(osi_Write);
- if ( !afile )
+ if (!afile)
osi_Panic("afs_osi_Write called with null param");
- if (offset != -1) afile->offset = offset;
+ 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_cred, &resid);
+ code =
+ gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize,
+ afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred,
+ &resid);
AFS_GLOCK();
}
if (code == 0) {
code = asize - resid;
afile->offset += code;
- }
- else {
+ } else {
code = -1;
}
if (afile->proc) {
- (*afile->proc)(afile, code);
+ (*afile->proc) (afile, code);
}
return code;
}
-void shutdown_osifile(void)
+void
+shutdown_osifile(void)
{
- extern int afs_cold_shutdown;
+ extern int afs_cold_shutdown;
- AFS_STATCNT(shutdown_osifile);
- if (afs_cold_shutdown) {
- afs_osicred_initialized = 0;
- }
+ AFS_STATCNT(shutdown_osifile);
+ if (afs_cold_shutdown) {
+ afs_osicred_initialized = 0;
+ }
}
-