#ifdef KERNEL
extern int (**afs_vnodeop_p)();
-extern struct simplelock afs_global_lock;
-#ifndef AFS_GLOBAL_SUNLOCK
-#define AFS_ASSERT_GLOCK()
-#endif
+#ifdef AFS_GLOBAL_SUNLOCK
+extern struct proc * afs_global_owner;
+extern struct lock afs_global_lock;
+#define AFS_GLOCK() \
+ do { \
+ osi_Assert(curproc); \
+ lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, curproc); \
+ osi_Assert(afs_global_owner == NULL); \
+ afs_global_owner = curproc; \
+ } while (0)
+#define AFS_GUNLOCK() \
+ do { \
+ osi_Assert(curproc); \
+ osi_Assert(afs_global_owner == curproc); \
+ afs_global_owner = NULL; \
+ lockmgr(&afs_global_lock, LK_RELEASE, 0, curproc); \
+ } while(0)
+#define ISAFS_GLOCK() (afs_global_owner == curproc && curproc)
+#else
+extern struct simplelock afs_global_lock;
#define AFS_GLOCK()
#define AFS_GUNLOCK()
+#define AFS_ASSERT_GLOCK()
+#define ISAFS_GLOCK() 1
+#endif
#define AFS_RXGLOCK()
#define AFS_RXGUNLOCK()
#define ISAFS_RXGLOCK() 1
-#define ISAFS_GLOCK() 1
#undef SPLVAR
-#define SPLVAR
+#define SPLVAR int splvar
#undef NETPRI
-#define NETPRI
+#define NETPRI splvar=splnet()
#undef USERPRI
-#define USERPRI
+#define USERPRI splx(splvar)
#endif /* KERNEL */
#endif /* _OSI_MACHDEP_H_ */
endTime = osi_Time() + (ams / 1000);
if (ahandle)
ahandle->proc = (caddr_t) curproc;
+ AFS_ASSERT_GLOCK();
+ AFS_GUNLOCK();
do {
if (aintok) {
code = tsleep(&waitV, PCATCH | (PZERO+8), "afs_osi_Wait", timo);
break;
}
} while (osi_Time() < endTime);
+ AFS_GLOCK();
return code;
}
void afs_osi_Sleep(void *event)
{
+ AFS_ASSERT_GLOCK();
+ AFS_GUNLOCK();
tsleep(event, PVFS, "afs", 0);
+ AFS_GLOCK();
}
int afs_osi_SleepSig(void *event)
{
+ AFS_ASSERT_GLOCK();
+ AFS_GUNLOCK();
tsleep(event, PVFS, "afs", 0);
+ AFS_GLOCK();
return 0;
}
return EBUSY;
}
- AFS_GLOCK();
AFS_STATCNT(afs_mount);
#ifdef AFS_DISCON_ENV
mp->osi_vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */
mp->osi_vfs_fsid.val[1] = (int) AFS_VFSFSID;
- AFS_GUNLOCK();
-
(void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN-1, &size);
bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
vflush(afsp, NULLVP, 0); /* don't support forced */
afsp->mnt_data = NULL;
-#ifdef AFS_GLOBAL_SUNLOCK
- mutex_enter(&afs_global_lock);
-#endif
+ AFS_GLOCK();
afs_globalVFS = 0;
afs_cold_shutdown = 1;
afs_shutdown(); /* XXX */
-#ifdef AFS_GLOBAL_SUNLOCK
- mutex_exit(&afs_global_lock);
-#endif
+ AFS_GUNLOCK();
/* give up syscall entries for ioctl & setgroups, which we've stolen */
sysent[SYS_ioctl].sy_call = sys_ioctl;
AFS_STATCNT(afs_root);
-#ifdef AFS_GLOBAL_SUNLOCK
- mutex_enter(&afs_global_lock);
-#endif
+ AFS_GLOCK();
if (!(code = afs_InitReq(&treq, osi_curcred())) &&
!(code = afs_CheckInit())) {
tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
} else
code = ENOENT;
}
-#ifdef AFS_GLOBAL_SUNLOCK
- mutex_exit(&afs_global_lock);
-#endif
+ AFS_GUNLOCK();
if (!code)
vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curproc); /* return it locked */
afs_statfs(struct osi_vfs *afsp, struct statfs *abp)
{
AFS_STATCNT(afs_statfs);
-#ifdef AFS_GLOBAL_SUNLOCK
- mutex_enter(&afs_global_lock);
-#endif
abp->f_bsize = afsp->osi_vfs_bsize;
- /* Fake a high number below to satisfy programs that use the ustat (for AIX), or statfs (for the rest) call to make sure that there's enough space in the device partition before storing something there (like ed(1)) */
- abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = abp->f_ffree = 9000000; /* XXX */
+
+ /*
+ * Fake a high number below to satisfy programs that use the ustat (for
+ * * AIX), or statfs (for the rest) call to make sure that there's
+ * enough * space in the device partition before storing something there
+ * (like * ed(1))
+ */
+ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = abp->f_ffree = 9000000;
abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */
abp->f_fsid.val[1] = (int) AFS_VFSFSID;
-#ifdef AFS_GLOBAL_SUNLOCK
- mutex_exit(&afs_global_lock);
-#endif
return 0;
}
struct componentname *a_cnp;
} */ *ap;
{
- int error;
+ int code;
struct vcache *vcp;
struct vnode *vp, *dvp;
int flags = ap->a_cnp->cn_flags;
dvp = ap->a_dvp;
if (afs_debug & AFSDEB_VNLAYER && !(dvp->v_flag & VROOT))
printf("nbsd_lookup dvp %p flags %x name %s cnt %d\n", dvp, flags, name, dvp->v_usecount);
- error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
- if (error) {
+ AFS_GLOCK();
+ code = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
+ AFS_GUNLOCK();
+ if (code) {
if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) &&
- (flags & ISLASTCN) && error == ENOENT)
- error = EJUSTRETURN;
+ (flags & ISLASTCN) && code == ENOENT)
+ code = EJUSTRETURN;
if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
cnp->cn_flags |= SAVENAME;
DROPNAME();
*ap->a_vpp = 0;
- return (error);
+ return (code);
}
vp = AFSTOV(vcp); /* always get a node if no error */
DROPNAME();
if (afs_debug & AFSDEB_VNLAYER && !(dvp->v_flag & VROOT))
printf("nbsd_lookup done dvp %p cnt %d\n", dvp, dvp->v_usecount);
- return error;
+ return code;
}
int
struct vattr *a_vap;
} */ *ap;
{
- int error = 0;
+ int code = 0;
struct vcache *vcp;
struct vnode *dvp = ap->a_dvp;
GETNAME();
/* vnode layer handles excl/nonexcl */
- error = afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL,
+ AFS_GLOCK();
+ code = afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL,
ap->a_vap->va_mode, &vcp,
cnp->cn_cred);
- if (error) {
+ AFS_GUNLOCK();
+ if (code) {
VOP_ABORTOP(dvp, cnp);
vput(dvp);
DROPNAME();
- return(error);
+ return(code);
}
if (vcp) {
DROPNAME();
if (afs_debug & AFSDEB_VNLAYER)
printf("nbsd_create done dvp %p cnt %d\n", dvp, dvp->v_usecount);
- return error;
+ return code;
}
int
struct proc *a_p;
} */ *ap;
{
- int error;
+ int code;
struct vcache *vc = VTOAFS(ap->a_vp);
- error = afs_open(&vc, ap->a_mode, ap->a_cred);
+ AFS_GLOCK();
+ code = afs_open(&vc, ap->a_mode, ap->a_cred);
#ifdef DIAGNOSTIC
if (AFSTOV(vc) != ap->a_vp)
panic("AFS open changed vnode!");
#endif
- return error;
+ AFS_GUNLOCK();
+ return code;
}
int
struct proc *a_p;
} */ *ap;
{
- return afs_close(VTOAFS(ap->a_vp), ap->a_fflag, ap->a_cred);
+ int code;
+
+ AFS_GLOCK();
+ code = afs_close(VTOAFS(ap->a_vp), ap->a_fflag, ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
}
int
struct proc *a_p;
} */ *ap;
{
- return afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
+ int code;
+
+ AFS_GLOCK();
+ code = afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
}
+
int
afs_nbsd_getattr(ap)
struct vop_getattr_args /* {
struct proc *a_p;
} */ *ap;
{
- return afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
+ int code;
+
+ AFS_GLOCK();
+ code = afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
}
+
int
afs_nbsd_setattr(ap)
struct vop_setattr_args /* {
struct proc *a_p;
} */ *ap;
{
- return afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
+ int code;
+
+ AFS_GLOCK();
+ code = afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
}
+
int
afs_nbsd_read(ap)
struct vop_read_args /* {
struct ucred *a_cred;
} */ *ap;
{
- return afs_read(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, 0, 0, 0);
+ int code;
+
+ AFS_GLOCK();
+ code = afs_read(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, 0, 0, 0);
+ AFS_GUNLOCK();
+ return code;
}
+
int
afs_nbsd_write(ap)
struct vop_write_args /* {
struct ucred *a_cred;
} */ *ap;
{
+ int code;
+
#ifdef UVM
(void) uvm_vnp_uncache(ap->a_vp); /* toss stale pages */
#else
vnode_pager_uncache(ap->a_vp);
#endif
- return afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
+ AFS_GLOCK();
+ code = afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
+ AFS_GUNLOCK();
+ return code;
}
+
int
afs_nbsd_ioctl(ap)
struct vop_ioctl_args /* {
struct proc *a_p;
} */ *ap;
{
+ int code;
+
/* in case we ever get in here... */
AFS_STATCNT(afs_ioctl);
+ AFS_GLOCK();
if (((ap->a_command >> 8) & 0xff) == 'V')
/* This is a VICEIOCTL call */
- return HandleIoctl(VTOAFS(ap->a_vp), ap->a_command, (struct afs_ioctl *) ap->a_data);
+ code = HandleIoctl(VTOAFS(ap->a_vp), ap->a_command, (struct afs_ioctl *) ap->a_data);
else
/* No-op call; just return. */
- return ENOTTY;
+ code = ENOTTY;
+ AFS_GUNLOCK();
+ return code;
}
/* ARGSUSED */
{
int wait = ap->a_waitfor == MNT_WAIT;
struct vnode *vp = ap->a_vp;
+ int code;
+ AFS_GLOCK();
vflushbuf(vp, wait);
- return afs_fsync(VTOAFS(vp), ap->a_cred);
+ code = afs_fsync(VTOAFS(vp), ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
}
int
struct componentname *a_cnp;
} */ *ap;
{
- int error = 0;
+ int code;
struct vnode *vp = ap->a_vp;
struct vnode *dvp = ap->a_dvp;
GETNAME();
- error = afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
+ AFS_GLOCK();
+ code = afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
+ AFS_GUNLOCK();
if (dvp == vp)
vrele(vp);
else
vput(dvp);
FREE(cnp->cn_pnbuf, M_NAMEI);
DROPNAME();
- return error;
+ return code;
}
int
struct componentname *a_cnp;
} */ *ap;
{
- int error = 0;
+ int code;
struct vnode *dvp = ap->a_dvp;
struct vnode *vp = ap->a_vp;
GETNAME();
if (dvp->v_mount != vp->v_mount) {
VOP_ABORTOP(vp, cnp);
- error = EXDEV;
+ code = EXDEV;
goto out;
}
if (vp->v_type == VDIR) {
VOP_ABORTOP(vp, cnp);
- error = EISDIR;
+ code = EISDIR;
goto out;
}
- if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curproc))) {
+ if ((code = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curproc))) {
VOP_ABORTOP(dvp, cnp);
goto out;
}
- error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
+ AFS_GLOCK();
+ code = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
+ AFS_GUNLOCK();
FREE(cnp->cn_pnbuf, M_NAMEI);
if (dvp != vp)
VOP_UNLOCK(vp, 0, curproc);
out:
vput(dvp);
DROPNAME();
- return error;
+ return code;
}
int
struct componentname *a_tcnp;
} */ *ap;
{
- int error = 0;
+ int code = 0;
struct componentname *fcnp = ap->a_fcnp;
char *fname;
struct componentname *tcnp = ap->a_tcnp;
*/
if ((fvp->v_mount != tdvp->v_mount) ||
(tvp && (fvp->v_mount != tvp->v_mount))) {
- error = EXDEV;
+ code = EXDEV;
abortit:
VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */
if (tdvp == tvp)
VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */
vrele(fdvp);
vrele(fvp);
- return (error);
+ return (code);
}
/*
* if fvp == tvp, we're just removing one name of a pair of
*/
if (fvp == tvp) {
if (fvp->v_type == VDIR) {
- error = EINVAL;
+ code = EINVAL;
goto abortit;
}
return (VOP_REMOVE(fdvp, fvp, fcnp));
}
- if ((error = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, curproc)))
+ if ((code = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, curproc)))
goto abortit;
MALLOC(fname, char *, fcnp->cn_namelen+1, M_TEMP, M_WAITOK);
tname[tcnp->cn_namelen] = '\0';
+ AFS_GLOCK();
/* XXX use "from" or "to" creds? NFS uses "to" creds */
- error = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
+ code = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
+ AFS_GUNLOCK();
VOP_UNLOCK(fvp, 0, curproc);
FREE(fname, M_TEMP);
FREE(tname, M_TEMP);
- if (error)
+ if (code)
goto abortit; /* XXX */
if (tdvp == tvp)
vrele(tdvp);
vput(tvp);
vrele(fdvp);
vrele(fvp);
- return error;
+ return code;
}
int
{
struct vnode *dvp = ap->a_dvp;
struct vattr *vap = ap->a_vap;
- int error = 0;
+ int code;
struct vcache *vcp;
GETNAME();
if ((cnp->cn_flags & HASBUF) == 0)
panic("afs_nbsd_mkdir: no name");
#endif
- error = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
- if (error) {
+ AFS_GLOCK();
+ code = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
+ AFS_GUNLOCK();
+ if (code) {
VOP_ABORTOP(dvp, cnp);
vput(dvp);
DROPNAME();
- return(error);
+ return(code);
}
if (vcp) {
*ap->a_vpp = AFSTOV(vcp);
DROPNAME();
FREE(cnp->cn_pnbuf, M_NAMEI);
vput(dvp);
- return error;
+ return code;
}
int
struct componentname *a_cnp;
} */ *ap;
{
- int error = 0;
+ int code;
struct vnode *vp = ap->a_vp;
struct vnode *dvp = ap->a_dvp;
return (EINVAL);
}
- error = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
+ AFS_GLOCK();
+ code = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
+ AFS_GUNLOCK();
DROPNAME();
vput(dvp);
vput(vp);
- return error;
+ return code;
}
int
} */ *ap;
{
struct vnode *dvp = ap->a_dvp;
- int error = 0;
+ int code;
/* NFS ignores a_vpp; so do we. */
GETNAME();
- error = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target,
+ AFS_GLOCK();
+ code = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target,
cnp->cn_cred);
+ AFS_GUNLOCK();
DROPNAME();
FREE(cnp->cn_pnbuf, M_NAMEI);
vput(dvp);
- return error;
+ return code;
}
int
u_long **a_cookies;
} */ *ap;
{
+ int code;
+
+ AFS_GLOCK();
#ifdef AFS_HAVE_COOKIES
printf("readdir %p cookies %p ncookies %d\n", ap->a_vp, ap->a_cookies,
ap->a_ncookies);
- return afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred,
+ code = afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred,
ap->a_eofflag, ap->a_ncookies, ap->a_cookies);
#else
- return afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag);
+ code = afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag);
#endif
+ AFS_GUNLOCK();
+ return code;
}
int
struct ucred *a_cred;
} */ *ap;
{
-/* printf("readlink %p\n", ap->a_vp);*/
- return afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
+ int code;
+
+ AFS_GLOCK();
+ code = afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
}
extern int prtactive;
struct vnode *a_vp;
} */ *ap;
{
- int error, slept;
+ int code, slept;
struct vnode *vp = ap->a_vp;
struct vcache *avc = VTOAFS(vp);
vnode_pager_uncache(vp);
#endif
+ AFS_GLOCK();
#ifndef AFS_DISCON_ENV
- error = afs_FlushVCache(avc, &slept); /* tosses our stuff from vnode */
+ code = afs_FlushVCache(avc, &slept); /* tosses our stuff from vnode */
#else
/* reclaim the vnode and the in-memory vcache, but keep the on-disk vcache */
- error = afs_FlushVS(avc);
+ code = afs_FlushVS(avc);
#endif
- if (!error && vp->v_data)
+ AFS_GUNLOCK();
+ if (!code && vp->v_data)
panic("afs_reclaim: vnode not cleaned");
- return error;
+ return code;
}
int
tiovec[0].iov_base = abp->b_un.b_addr;
tiovec[0].iov_len = len;
+ AFS_GLOCK();
if ((abp->b_flags & B_READ) == B_READ) {
code = afs_rdwr(tvc, &tuio, UIO_READ, 0, credp);
if (code == 0 && tuio.afsio_resid > 0)
bzero(abp->b_un.b_addr + len - tuio.afsio_resid, tuio.afsio_resid);
} else
code = afs_rdwr(tvc, &tuio, UIO_WRITE, 0, credp);
+ AFS_GUNLOCK();
ReleaseWriteLock(&tvc->lock);
AFS_RELE(AFSTOV(tvc));
int a_flags;
} */ *ap;
{
- return afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, osi_curcred(),
+ int code;
+
+ AFS_GLOCK();
+ code = afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, osi_curcred(),
(int) ap->a_id);
+ AFS_GUNLOCK();
+ return code;
}
/* don't set CDirty in here because RPC is called synchronously */
+int
afs_symlink
#ifdef AFS_OSF_ENV
(ndp, attrs, atargetName)
struct vattr *attrs;
struct AFS_UCRED *acred; {
#endif
- afs_uint32 now;
+ afs_uint32 now = 0;
struct vrequest treq;
afs_int32 code;
struct conn *tc;
return 0;
}
+int
afs_readlink(OSI_VC_ARG(avc), auio, acred)
OSI_VC_DECL(avc);
struct uio *auio;
struct lock__bsd__ afs_global_lock;
#endif
-#if defined(AFS_FBSD_ENV)
+#if defined(AFS_XBSD_ENV)
struct lock afs_global_lock;
struct proc *afs_global_owner;
#endif
#endif
#if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
afs_warn("RxEvent... ");
- /* cancel rx event deamon */
+ /* cancel rx event daemon */
while (afs_termState == AFSOP_STOP_RXEVENT)
afs_osi_Sleep(&afs_termState);
#if defined(RXK_LISTENER_ENV)
static struct osi_packet {
struct osi_packet *next;
-} *freePacketList = 0, *freeSmallList, *freeMediumList;
+} *freePacketList = NULL, *freeSmallList;
afs_lock_t osi_flplock;
}
#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
+static struct osi_packet *freeMediumList;
+
osi_AllocMoreMSpace(register afs_int32 preallocs)
{
register int i;
struct cell *tcell = NULL;
AFS_STATCNT(PGetWSCell);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
tcell = afs_GetPrimaryCell(READ_LOCK);
register struct cell *tcell;
AFS_STATCNT(PGetUserCell);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
/* return the cell name of the primary cell for this user */
int newStyle;
AFS_STATCNT(PGetTokens);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
/* weird interface. If input parameter is present, it is an integer and
register struct unixuser *tu;
AFS_STATCNT(PUnlog);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
i = UHash(areq->uid);
AFS_STATCNT(PCheckServers);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (*lp == 0x12345678) { /* For afs3.3 version */
DECL_PIOCTL(PCheckVolNames)
{
AFS_STATCNT(PCheckVolNames);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
afs_CheckRootVolume();
afs_int32 retValue;
AFS_STATCNT(PCheckAuth);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
retValue = 0;
afs_int32 scount;
AFS_STATCNT(PNewCell);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (!afs_osi_suser(*acred))
register afs_int32 code;
char *realName, *aliasName;
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (!afs_osi_suser(*acred))
register char *cp, *tp = ain;
AFS_STATCNT(PListCells);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
memcpy((char *)&whichCell, tp, sizeof(afs_int32));
register struct cell_alias *tcalias=0;
register char *cp, *tp = ain;
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (ainSize < sizeof(afs_int32))
return EINVAL;
afs_int32 temp;
AFS_STATCNT(PGetCellStatus);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
tcell = afs_GetCellByName(ain, READ_LOCK);
if (!afs_osi_suser(*acred))
return EACCES;
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
tcell = afs_GetCellByName(ain+2*sizeof(afs_int32), WRITE_LOCK);
AFS_STATCNT(PFlushVolumeData);
if (!avc)
return EINVAL;
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
volume = avc->fid.Fid.Volume; /* who to zap */
struct setspref *ssp;
AFS_STATCNT(PSetSPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (!afs_osi_suser(*acred))
{
struct spref *sp;
AFS_STATCNT(PSetSPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
int isfs;
AFS_STATCNT(PGetSPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
int i,j;
AFS_STATCNT(PGetCPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if ( ainSize < sizeof (struct sprefrequest ))
int i;
AFS_STATCNT(PSetCPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
sin = (struct setspref *)ain;
/* Extra kernel definitions (from kdefs file) */
#ifdef _KERNEL
+#define AFS_GLOBAL_SUNLOCK 1
#define AFS_SHORTGID 0 /* are group id's short? */
#if !defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__)
# include "afsint.h"
#endif /* KERNEL */
-#define MAXBS 2048 /* try to avoid horrible allocs */
-static afs_int32 bslosers = 0;
-
#ifdef KERNEL
#define NVALLOC(a) osi_Alloc(a)
#define NVFREE(a,b) osi_Free(a,b)
#else /* KERNEL */
+#define MAXBS 2048 /* try to avoid horrible allocs */
+static afs_int32 bslosers = 0;
#define NVALLOC(a) malloc(a)
#define NVFREE(a,b) free(a)
#endif /* KERNEL */
#include <sys/lock.h>
-/* Remind me to fix this later... */
+/* You can't have AFS_GLOBAL_SUNLOCK and not RX_ENABLE_LOCKS */
+#define RX_ENABLE_LOCKS 1
+#define AFS_GLOBAL_RXLOCK_KERNEL
-#define MUTEX_ISMINE(a)
-#define osirx_AssertMine(addr, msg)
+/* This is incomplete and probably wouldn't work with NCPUS > 1 */
+typedef int afs_kcondvar_t;
+
+#define CV_WAIT(cv, lck) { \
+ int isGlockOwner = ISAFS_GLOCK(); \
+ if (isGlockOwner) AFS_GUNLOCK(); \
+ MUTEX_EXIT(lck); \
+ tsleep(cv, PSOCK, "afs_rx_cv_wait", 0); \
+ if (isGlockOwner) AFS_GLOCK(); \
+ MUTEX_ENTER(lck); \
+ }
+#define CV_SIGNAL(cv) wakeup_one(cv)
+#define CV_BROADCAST(cv) wakeup(cv)
+
+typedef struct {
+ struct lock lock;
+ struct proc *owner;
+} afs_kmutex_t;
+
+#define MUTEX_DEFAULT 0
+
+#ifdef USE_REAL_MUTEX
+/* This doesn't seem to work yet */
+#define MUTEX_ISMINE(a) (((afs_kmutex_t *)(a))->owner == curproc)
+#define MUTEX_INIT(a,b,c,d) \
+ do { \
+ lockinit(&(a)->lock,PSOCK, "afs rx mutex", 0, 0); \
+ (a)->owner = 0; \
+ } while(0);
+#define MUTEX_DESTROY(a) \
+ do { \
+ (a)->owner = (struct proc *)-1; \
+ } while(0);
+#define MUTEX_ENTER(a) \
+ do { \
+ lockmgr(&(a)->lock, LK_EXCLUSIVE, 0, curproc); \
+ osi_Assert((a)->owner == 0); \
+ (a)->owner = curproc; \
+ } while(0);
+#define MUTEX_TRYENTER(a) \
+ ( lockmgr(&(a)->lock, LK_EXCLUSIVE|LK_NOWAIT, 0, curproc) ? 0 : ((a)->owner = curproc, 1) )
+#define MUTEX_EXIT(a) \
+ do { \
+ osi_Assert((a)->owner == curproc); \
+ (a)->owner = 0; \
+ lockmgr(&(a)->lock, LK_RELEASE, 0, curproc); \
+ } while(0);
+#else /* USE_REAL_MUTEX */
+#define MUTEX_ISMINE(a) 1
+#define MUTEX_INIT(a,b,c,d)
#define MUTEX_DESTROY(a)
#define MUTEX_ENTER(a)
#define MUTEX_TRYENTER(a) 1
-#define MUTEX_EXIT(a)
-#define MUTEX_INIT(a,b,c,d)
+#define MUTEX_EXIT(a)
+#endif /* USE_REAL_MUTEX */
+
#define CV_INIT(a,b,c,d)
#define CV_DESTROY(a)
+#ifndef AFS_GLOBAL_SUNLOCK
#define AFS_ASSERT_RXGLOCK()
+#endif
#endif /* _RX_KMUTEX_H_ */
rx_sleepLock = alloc_spinlock(LAST_HELD_ORDER-10, "rx_sleepLock");
#endif /* KERNEL && AFS_HPUX110_ENV */
#else /* RX_ENABLE_LOCKS */
-#if defined(KERNEL) && defined(AFS_GLOBAL_SUNLOCK) && !defined(AFS_HPUX_ENV)
+#if defined(KERNEL) && defined(AFS_GLOBAL_SUNLOCK) && !defined(AFS_HPUX_ENV) && !defined(AFS_OBSD_ENV)
mutex_init(&afs_rxglobal_lock, "afs_rxglobal_lock", MUTEX_DEFAULT, NULL);
#endif /* AFS_GLOBAL_SUNLOCK */
#endif /* RX_ENABLE_LOCKS */
{
struct rx_serverQueueEntry *np;
register int i, j;
+#ifndef KERNEL
register struct rx_call *call;
register struct rx_serverQueueEntry *sq;
+#endif /* KERNEL */
LOCK_RX_INIT
if (rxinit_status == 1) {
#endif
extern void *osi_Alloc();
#endif
+#if defined(AFS_OBSD_ENV)
+#include "h/proc.h"
+#endif
#else /* KERNEL */
#include <stdio.h>
#include "rx_clock.h"