Add trailing semicolons to more macros and re-indent.
int
idbg_prafsnode(OSI_VC_DECL(avc))
{
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- AFS_GLOCK();
+ AFS_GLOCK();
qprintf(" Len %d DV %d Date %d Own %d Grp %d Mode 0%o Lnk %d\n",
avc->m.Length, avc->m.DataVersion, avc->m.Date, avc->m.Owner,
avc->m.Group, avc->m.Mode, avc->m.LinkCount);
#undef OSI_VN_DECL
#define OSI_VN_DECL(V) bhv_desc_t *bhv_##V
#undef OSI_VN_CONVERT
-#define OSI_VN_CONVERT(V) struct vnode * V = (struct vnode*)BHV_TO_VNODE(bhv_##V);
+#define OSI_VN_CONVERT(V) struct vnode * V = (struct vnode*)BHV_TO_VNODE(bhv_##V)
#undef OSI_VC_ARG
#define OSI_VC_ARG(V) bhv_##V
#undef OSI_VC_DECL
#define OSI_VC_DECL(V) bhv_desc_t *bhv_##V
#undef OSI_VC_CONVERT
-#define OSI_VC_CONVERT(V) struct vcache * V = VTOAFS(BHV_TO_VNODE(bhv_##V));
+#define OSI_VC_CONVERT(V) struct vcache * V = VTOAFS(BHV_TO_VNODE(bhv_##V))
#undef OSI_VFS_ARG
#define OSI_VFS_ARG(V) bhv_##V
#undef OSI_VFS_DECL
#define OSI_VFS_DECL(V) bhv_desc_t *bhv_##V
#undef OSI_VFS_CONVERT
-#define OSI_VFS_CONVERT(V) struct vfs * V = (struct vfs*)bhvtovfs(bhv_##V);
+#define OSI_VFS_CONVERT(V) struct vfs * V = (struct vfs*)bhvtovfs(bhv_##V)
#endif /* AFS_SGI64_ENV */
register struct afs_q *tq;
struct afs_q *uq;
int error, fv_slept;
- OSI_VFS_CONVERT(afsp)
+ OSI_VFS_CONVERT(afsp);
- AFS_STATCNT(afs_unmount);
+ AFS_STATCNT(afs_unmount);
if (!suser())
return EPERM;
register afs_int32 code = 0;
struct vrequest treq;
register struct vcache *tvp = 0;
- OSI_VFS_CONVERT(afsp)
+ OSI_VFS_CONVERT(afsp);
- AFS_STATCNT(afs_root);
+ AFS_STATCNT(afs_root);
if (afs_globalVp && (afs_globalVp->states & CStatd)) {
tvp = afs_globalVp;
} else {
struct statvfs *abp;
struct vnode *avp; /* unused */
{
- OSI_VFS_CONVERT(afsp)
+ OSI_VFS_CONVERT(afsp);
- AFS_STATCNT(afs_statfs);
+ AFS_STATCNT(afs_statfs);
abp->f_bsize = afsp->vfs_bsize;
abp->f_frsize = afsp->vfs_bsize;
/* Fake a high number below to satisfy programs that use the statfs
register struct afs_q *tq;
struct afs_q *uq;
int s;
- OSI_VFS_CONVERT(afsp)
+ OSI_VFS_CONVERT(afsp);
- error = lasterr = 0;
+ error = lasterr = 0;
/*
* if not interested in vnodes, skip all this
*/
afs_fid2_t *afid2;
#endif
- OSI_VFS_CONVERT(afsp)
+ OSI_VFS_CONVERT(afsp);
- AFS_STATCNT(afs_vget);
+ AFS_STATCNT(afs_vget);
*avcp = NULL;
cred_t * cr)
{
int error;
- OSI_VN_CONVERT(vp)
+ OSI_VN_CONVERT(vp);
#ifdef AFS_SGI65_ENV
struct flid flid;
int pid;
struct cred *cr;
{
int code;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- osi_Assert(avc->v.v_count > 0);
+ osi_Assert(avc->v.v_count > 0);
if (avc->v.v_type != VREG)
return EISDIR;
struct cred *cr;
{
int code;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- osi_Assert(avc->v.v_count > 0);
+ osi_Assert(avc->v.v_count > 0);
if (avc->v.v_type != VREG)
return EISDIR;
int bsize; /* server's block size in bytes */
off_t off;
size_t rem, cnt;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- bsize = AFSBSIZE;
+ bsize = AFSBSIZE;
off = offset % bsize; /* offset into block */
bmv->bn = BTOBBT(offset - off);
bmv->offset = bmv->bn;
iovec_t aiovec;
int error;
struct cred *cr;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
vnode_t *vp = (vnode_t *) avc;
/*
u_int flags;
struct cred *cr;
{
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
struct vnode *vp = AFSTOV(avc);
if (vp->v_flag & VNOMAP)
u_int flags;
struct cred *acred;
{
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
struct vnode *vp = AFSTOV(avc);
register struct brequest *tb;
struct vrequest treq;
struct cred *cr;
#endif
{
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
struct vnode *vp = AFSTOV(avc);
struct vrequest treq;
int error;
struct ucred *acred;
{
int s;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
vnode_t *vp = (vnode_t *) avc;
int mapcnt = avc->mapcnt; /* We just clear off this many. */
void
afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag)
{
- OSI_VN_CONVERT(vp)
+ OSI_VN_CONVERT(vp);
struct vcache *avc = VTOAFS(vp);
if (OSI_GET_LOCKID() == avc->vc_rwlockid) {
void
afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag)
{
- OSI_VN_CONVERT(vp)
+ OSI_VN_CONVERT(vp);
struct vcache *avc = VTOAFS(vp);
AFS_ASSERT_GLOCK();
{
struct cell *tcell;
afs_fid2_t *afid = (afs_fid2_t *) fidp;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- osi_Assert(sizeof(fid_t) >= sizeof(afs_fid2_t));
+ osi_Assert(sizeof(fid_t) >= sizeof(afs_fid2_t));
afid->af_len = sizeof(afs_fid2_t) - sizeof(afid->af_len);
tcell = afs_GetCell(avc->fid.Cell, READ_LOCK);
register afs_int32 code = 0;
struct vrequest treq;
register struct vcache *tvp = 0;
- OSI_VFS_CONVERT(afsp)
+ OSI_VFS_CONVERT(afsp);
- AFS_STATCNT(afs_root);
+ AFS_STATCNT(afs_root);
if (afs_globalVp && (afs_globalVp->states & CStatd)) {
tvp = afs_globalVp;
} else {
register afs_int32 code;
struct vrequest treq;
struct afs_fakestat_state fakestate;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- AFS_STATCNT(afs_access);
+ AFS_STATCNT(afs_access);
afs_Trace3(afs_iclSetp, CM_TRACE_ACCESS, ICL_TYPE_POINTER, avc,
ICL_TYPE_INT32, amode, ICL_TYPE_OFFSET,
ICL_HANDLE_OFFSET(avc->m.Length));
{
register afs_int32 code;
struct vrequest treq;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- if (code = afs_InitReq(&treq, acred))
+ if (code = afs_InitReq(&treq, acred))
return code;
code = afs_VerifyVCache(avc, &treq);
}
#if defined(AFS_DARWIN_ENV)
{
- extern u_int32_t afs_darwin_realmodes;
+ extern u_int32_t afs_darwin_realmodes;
if (!afs_darwin_realmodes) {
/* Mac OS X uses the mode bits to determine whether a file or
* directory is accessible, and believes them, even though under
* conservatively.
*/
if (S_ISDIR(attrs->va_mode)) {
- /* all access bits need to be set for directories, since even
+ /* all access bits need to be set for directories, since even
* a mode 0 directory can still be used normally.
*/
- attrs->va_mode |= ACCESSPERMS;
+ attrs->va_mode |= ACCESSPERMS;
} else {
- /* for other files, replicate the user bits to group and other */
- mode_t ubits = (attrs->va_mode & S_IRWXU) >> 6;
+ /* for other files, replicate the user bits to group and other */
+ mode_t ubits = (attrs->va_mode & S_IRWXU) >> 6;
attrs->va_mode |= ubits | (ubits << 3);
}
}
attrs->va_fsid = avc->v.v_mount->m_stat.f_fsid.val[0];
#else
#ifdef AFS_DARWIN70_ENV
- attrs->va_fsid = avc->v.v_mount->mnt_stat.f_fsid.val[0];
+ attrs->va_fsid = avc->v.v_mount->mnt_stat.f_fsid.val[0];
#else /* ! AFS_DARWIN70_ENV */
attrs->va_fsid = 1;
#endif /* AFS_DARWIN70_ENV */
extern struct unixuser *afs_FindUser();
struct unixuser *au;
int inited = 0;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- AFS_STATCNT(afs_getattr);
+ AFS_STATCNT(afs_getattr);
afs_Trace2(afs_iclSetp, CM_TRACE_GETATTR, ICL_TYPE_POINTER, avc,
ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
struct AFSStoreStatus astat;
register afs_int32 code;
struct afs_fakestat_state fakestate;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- AFS_STATCNT(afs_setattr);
+ AFS_STATCNT(afs_setattr);
#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
afs_Trace4(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc,
ICL_TYPE_INT32, attrs->va_mask, ICL_TYPE_OFFSET,
struct vcache *tvc;
struct volume *volp = 0;
struct afs_fakestat_state fakestate;
- XSTATS_DECLS OSI_VC_CONVERT(adp)
+ XSTATS_DECLS;
+ OSI_VC_CONVERT(adp);
- AFS_STATCNT(afs_create);
+ AFS_STATCNT(afs_create);
if ((code = afs_InitReq(&treq, acred)))
goto done2;
struct ucred *acred = ndp->ni_cred;
#else /* AFS_OSF_ENV */
afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred)
- OSI_VC_DECL(adp);
+ OSI_VC_DECL(adp);
register struct vcache **avcp;
char *aname;
struct vattr *attrs;
struct AFSVolSync tsync;
afs_int32 now;
struct afs_fakestat_state fakestate;
- XSTATS_DECLS OSI_VC_CONVERT(adp)
+ XSTATS_DECLS;
+ OSI_VC_CONVERT(adp);
- AFS_STATCNT(afs_mkdir);
+ AFS_STATCNT(afs_mkdir);
afs_Trace2(afs_iclSetp, CM_TRACE_MKDIR, ICL_TYPE_POINTER, adp,
ICL_TYPE_STRING, aname);
#else
afs_rmdir(adp, aname, acred)
#endif
- OSI_VC_DECL(adp);
+ OSI_VC_DECL(adp);
char *aname;
struct AFS_UCRED *acred;
{
struct AFSFetchStatus OutDirStatus;
struct AFSVolSync tsync;
struct afs_fakestat_state fakestate;
- XSTATS_DECLS OSI_VC_CONVERT(adp)
+ XSTATS_DECLS;
+ OSI_VC_CONVERT(adp);
- AFS_STATCNT(afs_rmdir);
+ AFS_STATCNT(afs_rmdir);
afs_Trace2(afs_iclSetp, CM_TRACE_RMDIR, ICL_TYPE_POINTER, adp,
ICL_TYPE_STRING, aname);
#else
afs_fid(OSI_VC_ARG(avc), fidpp)
#endif /* AFS_AIX41_ENV */
-OSI_VC_DECL(avc);
+ OSI_VC_DECL(avc);
#if defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN54_ENV)
struct fid *fidpp;
#else
extern struct vcache *afs_globalVp;
int SizeOfSmallFid = SIZEOF_SMALLFID;
int rootvp = 0;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- AFS_STATCNT(afs_fid);
+ AFS_STATCNT(afs_fid);
if (afs_shuttingdown)
return EIO;
struct AFSVolSync tsync;
afs_int32 lockType;
struct AFS_FLOCK flock;
- XSTATS_DECLS AFS_STATCNT(HandleFlock);
+ XSTATS_DECLS;
+ AFS_STATCNT(HandleFlock);
code = 0; /* default when we don't make any network calls */
lockIdSet(&flock, NULL, clid);
struct AFSCallBack CallBack;
struct AFSVolSync tsync;
int temp;
- XSTATS_DECLS temp = areq->flags & O_NONBLOCK;
+ XSTATS_DECLS;
+ temp = areq->flags & O_NONBLOCK;
areq->flags |= O_NONBLOCK;
do {
#else
afs_link(avc, OSI_VC_ARG(adp), aname, acred)
#endif
- OSI_VC_DECL(adp);
+ OSI_VC_DECL(adp);
struct vcache *avc;
char *aname;
struct AFS_UCRED *acred;
struct AFSFetchStatus OutFidStatus, OutDirStatus;
struct AFSVolSync tsync;
struct afs_fakestat_state vfakestate, dfakestate;
- XSTATS_DECLS OSI_VC_CONVERT(adp)
+ XSTATS_DECLS;
+ OSI_VC_CONVERT(adp);
- AFS_STATCNT(afs_link);
+ AFS_STATCNT(afs_link);
afs_Trace3(afs_iclSetp, CM_TRACE_LINK, ICL_TYPE_POINTER, adp,
ICL_TYPE_POINTER, avc, ICL_TYPE_STRING, aname);
/* create a hard link; new entry is aname in dir adp */
static int
afs_getsysname(register struct vrequest *areq, register struct vcache *adp,
- register char *bufp, int *num, char **sysnamelist[])
+ register char *bufp, int *num, char **sysnamelist[])
{
register struct unixuser *au;
register afs_int32 error;
*sysnamelist = afs_sysnamelist;
- if (!afs_nfsexporter)
- strcpy(bufp, (*sysnamelist)[0]);
+ if (!afs_nfsexporter)
+ strcpy(bufp, (*sysnamelist)[0]);
else {
- au = afs_GetUser(areq->uid, adp->fid.Cell, 0);
- if (au->exporter) {
- error = EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num);
- if (error) {
- strcpy(bufp, "@sys");
- afs_PutUser(au, 0);
- return -1;
- } else {
- strcpy(bufp, (*sysnamelist)[0]);
- }
- } else
- strcpy(bufp, afs_sysname);
- afs_PutUser(au, 0);
+ au = afs_GetUser(areq->uid, adp->fid.Cell, 0);
+ if (au->exporter) {
+ error = EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num);
+ if (error) {
+ strcpy(bufp, "@sys");
+ afs_PutUser(au, 0);
+ return -1;
+ } else {
+ strcpy(bufp, (*sysnamelist)[0]);
+ }
+ } else
+ strcpy(bufp, afs_sysname);
+ afs_PutUser(au, 0);
}
return 0;
}
void
-Check_AtSys(register struct vcache *avc, char *aname,
- struct sysname_info *state, struct vrequest *areq)
+Check_AtSys(register struct vcache *avc, char *aname,
+ struct sysname_info *state, struct vrequest *areq)
{
int num = 0;
char **sysnamelist[MAXSYSNAME];
state->offset = 0;
state->name = (char *)osi_AllocLargeSpace(AFS_SMALLOCSIZ);
state->allocked = 1;
- state->index = afs_getsysname(areq, avc, state->name, &num, sysnamelist);
+ state->index =
+ afs_getsysname(areq, avc, state->name, &num, sysnamelist);
} else {
state->offset = -1;
state->allocked = 0;
int
Next_AtSys(register struct vcache *avc, struct vrequest *areq,
- struct sysname_info *state)
+ struct sysname_info *state)
{
int num = afs_sysnamecount;
char **sysnamelist[MAXSYSNAME];
if (state->index == -1)
- return 0; /* No list */
+ return 0; /* No list */
- /* Check for the initial state of aname != "@sys" in Check_AtSys*/
+ /* Check for the initial state of aname != "@sys" in Check_AtSys */
if (state->offset == -1 && state->allocked == 0) {
- register char *tname;
-
- /* Check for .*@sys */
- for (tname=state->name; *tname; tname++)
- /*Move to the end of the string*/;
-
- if ((tname > state->name + 4) && (AFS_EQ_ATSYS(tname-4))) {
- state->offset = (tname - 4) - state->name;
- tname = (char *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
- strncpy(tname, state->name, state->offset);
- state->name = tname;
- state->allocked = 1;
- num = 0;
- state->index = afs_getsysname(areq, avc, state->name+state->offset,
- &num, sysnamelist);
- return 1;
- } else
- return 0; /* .*@sys doesn't match either */
+ register char *tname;
+
+ /* Check for .*@sys */
+ for (tname = state->name; *tname; tname++)
+ /*Move to the end of the string */ ;
+
+ if ((tname > state->name + 4) && (AFS_EQ_ATSYS(tname - 4))) {
+ state->offset = (tname - 4) - state->name;
+ tname = (char *)osi_AllocLargeSpace(AFS_LRALLOCSIZ);
+ strncpy(tname, state->name, state->offset);
+ state->name = tname;
+ state->allocked = 1;
+ num = 0;
+ state->index =
+ afs_getsysname(areq, avc, state->name + state->offset, &num,
+ sysnamelist);
+ return 1;
+ } else
+ return 0; /* .*@sys doesn't match either */
} else {
- register struct unixuser *au;
- register afs_int32 error;
-
- *sysnamelist = afs_sysnamelist;
-
- if (afs_nfsexporter) {
- au = afs_GetUser(areq->uid, avc->fid.Cell, 0);
- if (au->exporter) {
- error = EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num);
- if (error) {
- return 0;
- }
- }
- afs_PutUser(au, 0);
- }
- if (++(state->index) >= num || !(*sysnamelist)[state->index])
- return 0; /* end of list */
+ register struct unixuser *au;
+ register afs_int32 error;
+
+ *sysnamelist = afs_sysnamelist;
+
+ if (afs_nfsexporter) {
+ au = afs_GetUser(areq->uid, avc->fid.Cell, 0);
+ if (au->exporter) {
+ error =
+ EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num);
+ if (error) {
+ return 0;
+ }
+ }
+ afs_PutUser(au, 0);
+ }
+ if (++(state->index) >= num || !(*sysnamelist)[state->index])
+ return 0; /* end of list */
}
- strcpy(state->name+state->offset, (*sysnamelist)[state->index]);
+ strcpy(state->name + state->offset, (*sysnamelist)[state->index]);
return 1;
}
#else
#if defined(AFS_HPUX1123_ENV)
/* DEE should use the new afs_inode_t for all */
-extern int BlobScan(ino_t *afile, afs_int32 ablob);
+extern int BlobScan(ino_t * afile, afs_int32 ablob);
#else
#if defined AFS_LINUX_64BIT_KERNEL
extern int BlobScan(long *afile, afs_int32 ablob);
struct VenusFid dotdot;
int flagIndex; /* First file with bulk fetch flag set */
int inlinebulk = 0; /* Did we use InlineBulk RPC or not? */
- XSTATS_DECLS
- /* first compute some basic parameters. We dont want to prefetch more
- * than a fraction of the cache in any given call, and we want to preserve
- * a portion of the LRU queue in any event, so as to avoid thrashing
- * the entire stat cache (we will at least leave some of it alone).
- * presently dont stat more than 1/8 the cache in any one call. */
- nentries = afs_cacheStats / 8;
+ XSTATS_DECLS;
+ /* first compute some basic parameters. We dont want to prefetch more
+ * than a fraction of the cache in any given call, and we want to preserve
+ * a portion of the LRU queue in any event, so as to avoid thrashing
+ * the entire stat cache (we will at least leave some of it alone).
+ * presently dont stat more than 1/8 the cache in any one call. */
+ nentries = afs_cacheStats / 8;
/* dont bother prefetching more than one calls worth of info */
if (nentries > AFSCBMAX)
afs_lookup(adp, aname, avcp, acred)
#endif /* UKERNEL */
#endif /* SUN5 || SGI */
-OSI_VC_DECL(adp);
+ OSI_VC_DECL(adp);
struct vcache **avcp;
char *aname;
struct AFS_UCRED *acred;
int pass = 0, hit = 0;
long dirCookie;
extern afs_int32 afs_mariner; /*Writing activity to log? */
- OSI_VC_CONVERT(adp)
+ OSI_VC_CONVERT(adp);
afs_hyper_t versionNo;
int no_read_access = 0;
struct sysname_info sysState; /* used only for @sys checking */
#else
#if defined(AFS_HPUX1123_ENV)
/*DEE should use afs_inode_t for all */
-int
-BlobScan(ino_t *afile, afs_int32 ablob)
+int
+BlobScan(ino_t * afile, afs_int32 ablob)
#else
#ifdef AFS_LINUX_64BIT_KERNEL
int
afs_readdir(OSI_VC_ARG(avc), auio, acred)
#endif
#endif
- OSI_VC_DECL(avc);
+ OSI_VC_DECL(avc);
struct uio *auio;
struct AFS_UCRED *acred;
{
#if defined(AFS_SGI53_ENV)
afs_int32 use64BitDirent, dirsiz;
#endif /* defined(AFS_SGI53_ENV) */
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
#ifdef AFS_HPUX_ENV
- /*
- * XXX All the hacks for alloced sdirEntry and inlining of afs_readdir_move instead of calling
- * it is necessary for hpux due to stack problems that seem to occur when coming thru the nfs
- * translator side XXX
- */
+ /*
+ * XXX All the hacks for alloced sdirEntry and inlining of afs_readdir_move instead of calling
+ * it is necessary for hpux due to stack problems that seem to occur when coming thru the nfs
+ * translator side XXX
+ */
struct min_direct *sdirEntry =
(struct min_direct *)osi_AllocSmallSpace(sizeof(struct min_direct));
afs_int32 rlen;
register struct conn *tc;
struct AFSFetchStatus OutDirStatus;
struct AFSVolSync tsync;
- XSTATS_DECLS
+ XSTATS_DECLS;
do {
tc = afs_Conn(&adp->fid, treqp, SHARED_LOCK);
if (tc) {
struct ucred *acred = ndp->ni_cred;
#else /* AFS_OSF_ENV */
afs_remove(OSI_VC_ARG(adp), aname, acred)
-OSI_VC_DECL(adp);
+ OSI_VC_DECL(adp);
char *aname;
struct AFS_UCRED *acred;
{
register struct vcache *tvc;
afs_size_t offset, len;
struct afs_fakestat_state fakestate;
- OSI_VC_CONVERT(adp)
+ OSI_VC_CONVERT(adp);
- AFS_STATCNT(afs_remove);
+ AFS_STATCNT(afs_remove);
afs_Trace2(afs_iclSetp, CM_TRACE_REMOVE, ICL_TYPE_POINTER, adp,
ICL_TYPE_STRING, aname);
#endif
return code;
}
-
#if 0
if (adp->mvstat == 2) {
afs_PutFakeStat(&fakestate);
#ifdef AFS_OSF_ENV
- afs_PutVCache(adp);
+ afs_PutVCache(adp);
afs_PutVCache(tvc);
#endif
return EISDIR;
Ttvcr = VREFCOUNT(tvc);
#ifdef AFS_AIX_ENV
if (tvc && (VREFCOUNT(tvc) > 2) && tvc->opens > 0
- && !(tvc->states & CUnlinked))
+ && !(tvc->states & CUnlinked))
#else
#ifdef AFS_DARWIN14_ENV
- if (tvc && (VREFCOUNT(tvc) > 1 + DARWIN_REFBASE) && tvc->opens > 0 && !(tvc->states & CUnlinked))
+ if (tvc && (VREFCOUNT(tvc) > 1 + DARWIN_REFBASE) && tvc->opens > 0
+ && !(tvc->states & CUnlinked))
#else
if (tvc && (VREFCOUNT(tvc) > 1) && tvc->opens > 0
- && !(tvc->states & CUnlinked))
+ && !(tvc->states & CUnlinked))
#endif
#endif
{
avc->states &= ~(CUnlinked | CUnlinkedDel);
#ifdef AFS_DARWIN14_ENV
- if (VREFCOUNT(avc) < 4) {
- oldref = 4 - VREFCOUNT(avc);
- VREFCOUNT_SET(avc, 4);
- }
+ if (VREFCOUNT(avc) < 4) {
+ oldref = 4 - VREFCOUNT(avc);
+ VREFCOUNT_SET(avc, 4);
+ }
#endif
ReleaseWriteLock(&avc->lock);
VREFCOUNT_SET(avc, 0);
#else
if (oldref) {
- int newref = VREFCOUNT(avc) - oldref;
+ int newref = VREFCOUNT(avc) - oldref;
VREFCOUNT_SET(avc, newref);
}
#endif
struct dcache *tdc1, *tdc2;
struct AFSFetchStatus OutOldDirStatus, OutNewDirStatus;
struct AFSVolSync tsync;
- XSTATS_DECLS AFS_STATCNT(afs_rename);
+ XSTATS_DECLS;
+ AFS_STATCNT(afs_rename);
afs_Trace4(afs_iclSetp, CM_TRACE_RENAME, ICL_TYPE_POINTER, aodp,
ICL_TYPE_STRING, aname1, ICL_TYPE_POINTER, andp,
ICL_TYPE_STRING, aname2);
#else /* AFS_OSF_ENV */
#if defined(AFS_SGI_ENV)
afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, npnp, acred)
- struct pathname *npnp;
+ struct pathname *npnp;
#else
afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, acred)
#endif
- OSI_VC_DECL(aodp);
+ OSI_VC_DECL(aodp);
struct vcache *andp;
char *aname1, *aname2;
struct AFS_UCRED *acred;
struct afs_fakestat_state ofakestate;
struct afs_fakestat_state nfakestate;
struct vrequest treq;
- OSI_VC_CONVERT(aodp)
+ OSI_VC_CONVERT(aodp);
- code = afs_InitReq(&treq, acred);
+ code = afs_InitReq(&treq, acred);
if (code)
return code;
afs_InitFakeStat(&ofakestate);
/* don't set CDirty in here because RPC is called synchronously */
-int
-afs_symlink
+int afs_symlink
#ifdef AFS_OSF_ENV
(ndp, attrs, atargetName)
struct nameidata *ndp;
struct AFSVolSync tsync;
struct volume *volp = 0;
struct afs_fakestat_state fakestate;
- XSTATS_DECLS OSI_VC_CONVERT(adp)
+ XSTATS_DECLS;
+ OSI_VC_CONVERT(adp);
AFS_STATCNT(afs_symlink);
afs_Trace2(afs_iclSetp, CM_TRACE_SYMLINK, ICL_TYPE_POINTER, adp,
struct vrequest treq;
register char *tp;
struct afs_fakestat_state fakestat;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
AFS_STATCNT(afs_readlink);
afs_Trace1(afs_iclSetp, CM_TRACE_READLINK, ICL_TYPE_POINTER, avc);
#else
afs_close(OSI_VC_ARG(avc), aflags, acred)
#endif
-OSI_VC_DECL(avc);
+ OSI_VC_DECL(avc);
afs_int32 aflags;
struct AFS_UCRED *acred;
{
struct flid flid;
#endif
struct afs_fakestat_state fakestat;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- AFS_STATCNT(afs_close);
+ AFS_STATCNT(afs_close);
afs_Trace2(afs_iclSetp, CM_TRACE_CLOSE, ICL_TYPE_POINTER, avc,
ICL_TYPE_INT32, aflags);
code = afs_InitReq(&treq, acred);
{
register afs_int32 code;
struct vrequest treq;
- OSI_VC_CONVERT(avc)
+ OSI_VC_CONVERT(avc);
- if (avc->vc_error)
+ if (avc->vc_error)
return avc->vc_error;
#if defined(AFS_SUN5_ENV)
int doReallyAdjustSize = 0;
int overWriteWholeChunk = 0;
- XSTATS_DECLS
+ XSTATS_DECLS;
#ifndef AFS_NOSTATS
struct afs_stats_xferData *xferP; /* Ptr to this op's xfer struct */
osi_timeval_t xferStartTime, /*FS xfer start time */
#define DQTODC(q) ((struct dcache *)(((char *) (q)) - sizeof(struct afs_q)))
for (tq = DirtyQ.prev; tq != &DirtyQ; tq = QPrev(tq)) {
- tdc = DQTODC(tq);
+ tdc = DQTODC(tq);
if (tdc->dflags & DFEntryMod) {
int wrLock;
register afs_int32 code;
register struct rx_call *tcall;
afs_size_t tlen, xlen = 0;
- XSTATS_DECLS AFS_STATCNT(afs_StoreMini);
+ XSTATS_DECLS;
+ AFS_STATCNT(afs_StoreMini);
afs_Trace2(afs_iclSetp, CM_TRACE_STOREMINI, ICL_TYPE_POINTER, avc,
ICL_TYPE_INT32, avc->m.Length);
tlen = avc->m.Length;
struct conn *tc;
struct osi_file *tfile;
struct rx_call *tcall;
- XSTATS_DECLS for (bytes = 0, j = 0; !code && j <= high; j++) {
+ XSTATS_DECLS;
+ for (bytes = 0, j = 0; !code && j <= high; j++) {
if (dcList[j]) {
ObtainSharedLock(&(dcList[j]->lock), 629);
if (!bytes)
* Generate an index into the hash table for a given Fid.
*/
static int
-afs_HashCBRFid(struct AFSFid *fid) {
+afs_HashCBRFid(struct AFSFid *fid)
+{
return (fid->Volume + fid->Vnode + fid->Unique) % CBRSIZE;
}
* Must be called with afs_xvcb held.
*/
static void
-afs_InsertHashCBR(struct afs_cbr *cbr) {
+afs_InsertHashCBR(struct afs_cbr *cbr)
+{
int slot = afs_HashCBRFid(&cbr->fid);
cbr->hash_next = afs_cbrHashT[slot];
struct vrequest treq;
struct conn *tc;
int safety1, safety2, safety3;
- XSTATS_DECLS if ((code = afs_InitReq(&treq, afs_osi_credp)))
+ XSTATS_DECLS;
+ if ((code = afs_InitReq(&treq, afs_osi_credp)))
return code;
treq.flags |= O_NONBLOCK;
tfids = afs_osi_Alloc(sizeof(struct AFSFid) * AFS_MAXCBRSCALL);
ncbr = cbr->hash_next;
if (afid->Fid.Volume == cbr->fid.Volume &&
- afid->Fid.Vnode == cbr->fid.Vnode &&
+ afid->Fid.Vnode == cbr->fid.Vnode &&
afid->Fid.Unique == cbr->fid.Unique) {
afs_FreeCBR(cbr);
}
refpanic("VLRU inconsistent");
}
#ifdef AFS_DARWIN_ENV
- if ((VREFCOUNT(tvc) < DARWIN_REFBASE) ||
- (VREFCOUNT(tvc) < 1+DARWIN_REFBASE &&
+ if ((VREFCOUNT(tvc) < DARWIN_REFBASE) ||
+ (VREFCOUNT(tvc) < 1 + DARWIN_REFBASE &&
UBCINFOEXISTS(&tvc->v))) {
- VREFCOUNT_SET(tvc,
- DARWIN_REFBASE + (UBCINFOEXISTS(&tvc->v) ? 1 : 0));
+ VREFCOUNT_SET(tvc,
+ DARWIN_REFBASE +
+ (UBCINFOEXISTS(&tvc->v) ? 1 : 0));
}
if (tvc->opens == 0 && ((tvc->states & CUnlinkedDel) == 0)
- && VREFCOUNT(tvc) == DARWIN_REFBASE+1
+ && VREFCOUNT(tvc) == DARWIN_REFBASE + 1
&& UBCINFOEXISTS(&tvc->v)) {
osi_VM_TryReclaim(tvc, &fv_slept);
if (fv_slept) {
}
#endif
- if (VREFCOUNT(tvc) ==
+ if (VREFCOUNT(tvc) ==
#ifdef AFS_DARWIN_ENV
DARWIN_REFBASE
#else
- 0
+ 0
#endif
- && tvc->opens == 0
- && (tvc->states & CUnlinkedDel) == 0) {
+ && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) {
#if defined(AFS_XBSD_ENV)
/*
* vgone() reclaims the vnode, which calls afs_FlushVCache(),
AFS_GLOCK();
if (tvc->v != NULL) {
/* I'd like to know if this ever happens...
- We don't drop global for the rest of this function,
- so if we do lose the race, the other thread should
- have found the same vnode and finished initializing
- the vcache entry. Is it conceivable that this vcache
- entry could be recycled during this interval? If so,
- then there probably needs to be some sort of additional
- mutual exclusion (an Embryonic flag would suffice).
- -GAW */
+ * We don't drop global for the rest of this function,
+ * so if we do lose the race, the other thread should
+ * have found the same vnode and finished initializing
+ * the vcache entry. Is it conceivable that this vcache
+ * entry could be recycled during this interval? If so,
+ * then there probably needs to be some sort of additional
+ * mutual exclusion (an Embryonic flag would suffice).
+ * -GAW */
printf("afs_NewVCache: lost the race\n");
return (tvc);
}
tvc->truncPos = AFS_NOTRUNC; /* don't truncate until we need to */
hzero(tvc->m.DataVersion); /* in case we copy it into flushDV */
#if defined(AFS_LINUX22_ENV)
-{
- struct inode *ip = AFSTOI(tvc);
- struct address_space *mapping = &ip->i_data;
+ {
+ struct inode *ip = AFSTOI(tvc);
+ struct address_space *mapping = &ip->i_data;
#if defined(AFS_LINUX26_ENV)
- inode_init_once(ip);
+ inode_init_once(ip);
#else
- sema_init(&ip->i_sem, 1);
- INIT_LIST_HEAD(&ip->i_hash);
- INIT_LIST_HEAD(&ip->i_dentry);
+ sema_init(&ip->i_sem, 1);
+ INIT_LIST_HEAD(&ip->i_hash);
+ INIT_LIST_HEAD(&ip->i_dentry);
#if defined(AFS_LINUX24_ENV)
- sema_init(&ip->i_zombie, 1);
- init_waitqueue_head(&ip->i_wait);
- spin_lock_init(&ip->i_data.i_shared_lock);
+ sema_init(&ip->i_zombie, 1);
+ init_waitqueue_head(&ip->i_wait);
+ spin_lock_init(&ip->i_data.i_shared_lock);
#ifdef STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
- spin_lock_init(&ip->i_data.page_lock);
+ spin_lock_init(&ip->i_data.page_lock);
#endif
- INIT_LIST_HEAD(&ip->i_data.clean_pages);
- INIT_LIST_HEAD(&ip->i_data.dirty_pages);
- INIT_LIST_HEAD(&ip->i_data.locked_pages);
- INIT_LIST_HEAD(&ip->i_dirty_buffers);
+ INIT_LIST_HEAD(&ip->i_data.clean_pages);
+ INIT_LIST_HEAD(&ip->i_data.dirty_pages);
+ INIT_LIST_HEAD(&ip->i_data.locked_pages);
+ INIT_LIST_HEAD(&ip->i_dirty_buffers);
#ifdef STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS
- INIT_LIST_HEAD(&ip->i_dirty_data_buffers);
+ INIT_LIST_HEAD(&ip->i_dirty_data_buffers);
#endif
#ifdef STRUCT_INODE_HAS_I_DEVICES
- INIT_LIST_HEAD(&ip->i_devices);
+ INIT_LIST_HEAD(&ip->i_devices);
#endif
#ifdef STRUCT_INODE_HAS_I_TRUNCATE_SEM
- init_rwsem(&ip->i_truncate_sem);
+ init_rwsem(&ip->i_truncate_sem);
#endif
#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
- init_rwsem(&ip->i_alloc_sem);
-#endif
+ init_rwsem(&ip->i_alloc_sem);
+#endif
#else /* AFS_LINUX22_ENV */
- sema_init(&ip->i_atomic_write, 1);
- init_waitqueue(&ip->i_wait);
+ sema_init(&ip->i_atomic_write, 1);
+ init_waitqueue(&ip->i_wait);
#endif
#endif
#if defined(AFS_LINUX24_ENV)
- mapping->host = ip;
- ip->i_mapping = mapping;
+ mapping->host = ip;
+ ip->i_mapping = mapping;
#ifdef STRUCT_ADDRESS_SPACE_HAS_GFP_MASK
- ip->i_data.gfp_mask = GFP_HIGHUSER;
+ ip->i_data.gfp_mask = GFP_HIGHUSER;
#endif
#if defined(AFS_LINUX26_ENV)
- mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
-{
- extern struct backing_dev_info afs_backing_dev_info;
+ mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
+ {
+ extern struct backing_dev_info afs_backing_dev_info;
- mapping->backing_dev_info = &afs_backing_dev_info;
-}
+ mapping->backing_dev_info = &afs_backing_dev_info;
+ }
#endif
#endif
#if !defined(AFS_LINUX26_ENV)
- if (afs_globalVFS)
- ip->i_dev = afs_globalVFS->s_dev;
+ if (afs_globalVFS)
+ ip->i_dev = afs_globalVFS->s_dev;
#else
#ifdef STRUCT_INODE_HAS_I_SECURITY
- ip->i_security = NULL;
- if (security_inode_alloc(ip))
- panic("Cannot allocate inode security");
+ ip->i_security = NULL;
+ if (security_inode_alloc(ip))
+ panic("Cannot allocate inode security");
#endif
#endif
- ip->i_sb = afs_globalVFS;
- put_inode_on_dummy_list(ip);
-}
+ ip->i_sb = afs_globalVFS;
+ put_inode_on_dummy_list(ip);
+ }
#endif
#ifdef AFS_OSF_ENV
/* VLISTNONE(&tvc->v); */
tvc->v.v_freelist.tqe_next = 0;
tvc->v.v_freelist.tqe_prev = (struct vnode **)0xdeadb;
- tvc->vrefCount+=DARWIN_REFBASE;
+ tvc->vrefCount += DARWIN_REFBASE;
#endif
/*
* The proper value for mvstat (for root fids) is setup by the caller.
struct vrequest treq, ureq;
struct AFSVolSync tsync;
int didCore;
- XSTATS_DECLS AFS_STATCNT(afs_FlushActiveVcaches);
+ XSTATS_DECLS;
+ AFS_STATCNT(afs_FlushActiveVcaches);
ObtainReadLock(&afs_xvcache);
for (i = 0; i < VCSIZE; i++) {
for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
}
}
#ifdef AFS_DARWIN_ENV
- if (VREFCOUNT(tvc) == 1+DARWIN_REFBASE
+ if (VREFCOUNT(tvc) == 1 + DARWIN_REFBASE
&& UBCINFOEXISTS(&tvc->v)) {
if (tvc->opens)
panic("flushactive open, hasubc, but refcnt 1");
struct conn *tc;
struct AFSFetchStatus OutStatus;
struct AFSVolSync tsync;
- XSTATS_DECLS AFS_STATCNT(afs_WriteVCache);
+ XSTATS_DECLS;
+ AFS_STATCNT(afs_WriteVCache);
afs_Trace2(afs_iclSetp, CM_TRACE_WVCACHE, ICL_TYPE_POINTER, avc,
ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
afs_uint32 start;
register struct conn *tc;
struct AFSFetchStatus OutDirStatus;
- XSTATS_DECLS if (!name)
- name = ""; /* XXX */
+ XSTATS_DECLS;
+ if (!name)
+ name = ""; /* XXX */
do {
tc = afs_Conn(afid, areq, SHARED_LOCK);
if (tc) {
#endif /* AFS_OSF_ENV */
#ifdef AFS_DARWIN14_ENV
/* It'd really suck if we allowed duplicate vcaches for the
- same fid to happen. Wonder if this will work? */
+ * same fid to happen. Wonder if this will work? */
struct vnode *vp = AFSTOV(tvc);
- if (vp->v_flag & (VXLOCK|VORECLAIM|VTERMINATE)) {
- printf("precluded FindVCache on %x (%d:%d:%d)\n",
+ if (vp->v_flag & (VXLOCK | VORECLAIM | VTERMINATE)) {
+ printf("precluded FindVCache on %x (%d:%d:%d)\n",
vp, tvc->fid.Fid.Volume, tvc->fid.Fid.Vnode,
tvc->fid.Fid.Unique);
simple_lock(&vp->v_interlock);
SET(vp->v_flag, VTERMWANT);
simple_unlock(&vp->v_interlock);
- (void)tsleep((caddr_t)&vp->v_ubcinfo, PINOD, "vget1", 0);
+ (void)tsleep((caddr_t) & vp->v_ubcinfo, PINOD, "vget1", 0);
printf("VTERMWANT ended on %x\n", vp);
continue;
}
struct AFSCallBack CallBack;
struct AFSVolSync tsync;
struct volume *volp;
- XSTATS_DECLS
+ XSTATS_DECLS;
do {
tc = afs_Conn(afid, areq, SHARED_LOCK);
avc->quick.stamp = 0;
{
register struct rx_securityClass *tclass;
- LOCK_GLOBAL_MUTEX tclass = (struct rx_securityClass *)
+ LOCK_GLOBAL_MUTEX;
+ tclass = (struct rx_securityClass *)
rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, NULL);
if (tclass) {
*astr = tclass;
*aindex = 2; /* kerberos security index */
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
} else {
- UNLOCK_GLOBAL_MUTEX return 2;
+ UNLOCK_GLOBAL_MUTEX;
+ return 2;
}
}
#endif /* !defined(UKERNEL) */
{
afs_int32 rc;
- LOCK_GLOBAL_MUTEX rc = GenericAuth(adir, astr, aindex, rxkad_clear);
- UNLOCK_GLOBAL_MUTEX return rc;
+ LOCK_GLOBAL_MUTEX;
+ rc = GenericAuth(adir, astr, aindex, rxkad_clear);
+ UNLOCK_GLOBAL_MUTEX;
+ return rc;
}
/* build a fake ticket for 'afs' using keys from adir, returning an
{
afs_int32 rc;
- LOCK_GLOBAL_MUTEX rc = GenericAuth(adir, astr, aindex, rxkad_crypt);
- UNLOCK_GLOBAL_MUTEX return rc;
+ LOCK_GLOBAL_MUTEX;
+ rc = GenericAuth(adir, astr, aindex, rxkad_crypt);
+ UNLOCK_GLOBAL_MUTEX;
+ return rc;
}
#ifdef AFS_NT40_ENV
/* NT client CellServDB has different file name than NT server or Unix */
if (IsClientConfigDirectory(adir->name)) {
- if ( !afssw_GetClientCellServDBDir(&p) ) {
- strcompose(tbuffer, sizeof(tbuffer), p, "/",
- AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
- free(p);
- } else {
- int len;
- strncpy(tbuffer, adir->name, sizeof(tbuffer));
- len = strlen(tbuffer);
- if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) {
- strncat(tbuffer, "\\", sizeof(tbuffer));
- }
- strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer));
- tbuffer[sizeof(tbuffer)-1] = '\0';
- }
+ if (!afssw_GetClientCellServDBDir(&p)) {
+ strcompose(tbuffer, sizeof(tbuffer), p, "/",
+ AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
+ free(p);
+ } else {
+ int len;
+ strncpy(tbuffer, adir->name, sizeof(tbuffer));
+ len = strlen(tbuffer);
+ if (tbuffer[len - 1] != '\\' && tbuffer[len - 1] != '/') {
+ strncat(tbuffer, "\\", sizeof(tbuffer));
+ }
+ strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT,
+ sizeof(tbuffer));
+ tbuffer[sizeof(tbuffer) - 1] = '\0';
+ }
} else {
strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
NULL);
/* NT client CellServDB has different file name than NT server or Unix */
if (IsClientConfigDirectory(adir->name)) {
- if ( !afssw_GetClientCellServDBDir(&p) ) {
- strcompose(tbuffer, sizeof(tbuffer), p, "/",
- AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
- free(p);
- } else {
- int len = strlen(tbuffer);
- if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) {
- strncat(tbuffer, "\\", sizeof(tbuffer));
- }
- strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer));
- tbuffer[sizeof(tbuffer)-1] = '\0';
- }
+ if (!afssw_GetClientCellServDBDir(&p)) {
+ strcompose(tbuffer, sizeof(tbuffer), p, "/",
+ AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
+ free(p);
+ } else {
+ int len = strlen(tbuffer);
+ if (tbuffer[len - 1] != '\\' && tbuffer[len - 1] != '/') {
+ strncat(tbuffer, "\\", sizeof(tbuffer));
+ }
+ strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT,
+ sizeof(tbuffer));
+ tbuffer[sizeof(tbuffer) - 1] = '\0';
+ }
} else {
strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
NULL);
register struct afsconf_dir *tdir;
register afs_int32 code;
- LOCK_GLOBAL_MUTEX
- /* zero structure and fill in name; rest is done by internal routine */
- tdir = (struct afsconf_dir *)malloc(sizeof(struct afsconf_dir));
+ LOCK_GLOBAL_MUTEX;
+ /* zero structure and fill in name; rest is done by internal routine */
+ tdir = (struct afsconf_dir *)malloc(sizeof(struct afsconf_dir));
memset(tdir, 0, sizeof(struct afsconf_dir));
tdir->name = (char *)malloc(strlen(adir) + 1);
strcpy(tdir->name, adir);
fp = fopen("/.AFSCONF", "r");
if (fp == 0) {
free(tdir);
- UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0;
+ UNLOCK_GLOBAL_MUTEX;
+ return (struct afsconf_dir *)0;
}
fgets(afs_confdir, 128, fp);
fclose(fp);
fp = fopen("/.AFSCONF", "r");
if (fp == 0) {
free(tdir);
- UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0;
+ UNLOCK_GLOBAL_MUTEX;
+ return (struct afsconf_dir *)0;
}
}
fgets(afs_confdir, 128, fp);
len = strlen(afs_confdir);
if (len == 0) {
free(tdir);
- UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0;
+ UNLOCK_GLOBAL_MUTEX;
+ return (struct afsconf_dir *)0;
}
if (afs_confdir[len - 1] == '\n') {
afs_confdir[len - 1] = 0;
if (code) {
free(tdir->name);
free(tdir);
- UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0;
+ UNLOCK_GLOBAL_MUTEX;
+ return (struct afsconf_dir *)0;
}
}
- UNLOCK_GLOBAL_MUTEX return tdir;
+ UNLOCK_GLOBAL_MUTEX;
+ return tdir;
}
*/
if (IsClientConfigDirectory(adir->name)) {
/* NT client config dir */
- char * p;
- if ( !afssw_GetClientCellServDBDir(&p) ) {
- strcompose(tbuffer, sizeof(tbuffer), p, "/",
- AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
- free(p);
- } else {
- int len;
- strncpy(tbuffer, adir->name, sizeof(tbuffer));
- len = strlen(tbuffer);
- if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) {
- strncat(tbuffer, "\\", sizeof(tbuffer));
- }
- strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer));
- tbuffer[sizeof(tbuffer)-1] = '\0';
- }
+ char *p;
+ if (!afssw_GetClientCellServDBDir(&p)) {
+ strcompose(tbuffer, sizeof(tbuffer), p, "/",
+ AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
+ free(p);
+ } else {
+ int len;
+ strncpy(tbuffer, adir->name, sizeof(tbuffer));
+ len = strlen(tbuffer);
+ if (tbuffer[len - 1] != '\\' && tbuffer[len - 1] != '/') {
+ strncat(tbuffer, "\\", sizeof(tbuffer));
+ }
+ strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT,
+ sizeof(tbuffer));
+ tbuffer[sizeof(tbuffer) - 1] = '\0';
+ }
} else {
/* NT server config dir */
strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE,
{
register struct afsconf_entry *tde;
register afs_int32 code;
- LOCK_GLOBAL_MUTEX for (tde = adir->entries; tde; tde = tde->next) {
+ LOCK_GLOBAL_MUTEX;
+ for (tde = adir->entries; tde; tde = tde->next) {
code = (*aproc) (&tde->cellInfo, arock, adir);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* call aproc(entry, arock, adir) for all cell aliases.
{
register struct afsconf_aliasentry *tde;
register afs_int32 code;
- LOCK_GLOBAL_MUTEX for (tde = adir->alias_entries; tde; tde = tde->next) {
+ LOCK_GLOBAL_MUTEX;
+ for (tde = adir->alias_entries; tde; tde = tde->next) {
code = (*aproc) (&tde->aliasInfo, arock, adir);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
afs_int32 afsconf_SawCell = 0;
* replaced with a more fine-grained lock just for the resolver
* operations.
*/
- LOCK_GLOBAL_MUTEX len =
- res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer));
- UNLOCK_GLOBAL_MUTEX if (len < 0)
- return AFSCONF_NOTFOUND;
+ LOCK_GLOBAL_MUTEX;
+ len = res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer));
+ UNLOCK_GLOBAL_MUTEX;
+ if (len < 0)
+ return AFSCONF_NOTFOUND;
p = answer + sizeof(HEADER); /* Skip header */
code = dn_expand(answer, answer + len, p, host, sizeof(host));
int tservice;
struct afsconf_entry DNSce;
afs_int32 cellHostAddrs[AFSMAXCELLHOSTS];
- char cellHostNames[AFSMAXCELLHOSTS][MAXHOSTCHARS];
+ char cellHostNames[AFSMAXCELLHOSTS][MAXHOSTCHARS];
int numServers;
int rc;
int ttl;
DNSce.cellInfo.numServers = 0;
DNSce.next = NULL;
- rc = getAFSServer(acellName, cellHostAddrs, cellHostNames, &numServers, &ttl);
+ rc = getAFSServer(acellName, cellHostAddrs, cellHostNames, &numServers,
+ &ttl);
/* ignore the ttl here since this code is only called by transitory programs
* like klog, etc. */
if (rc < 0)
acellInfo->numServers = numServers;
strcpy(acellInfo->name, acellName);
if (aservice) {
- LOCK_GLOBAL_MUTEX tservice = afsconf_FindService(aservice);
- UNLOCK_GLOBAL_MUTEX if (tservice < 0) {
+ LOCK_GLOBAL_MUTEX;
+ tservice = afsconf_FindService(aservice);
+ UNLOCK_GLOBAL_MUTEX;
+ if (tservice < 0) {
return AFSCONF_NOTFOUND; /* service not found */
}
for (i = 0; i < acellInfo->numServers; i++) {
int ambig;
char tbuffer[64];
- LOCK_GLOBAL_MUTEX if (adir)
- afsconf_Check(adir);
+ LOCK_GLOBAL_MUTEX;
+ if (adir)
+ afsconf_Check(adir);
if (acellName) {
tcell = acellName;
cnLen = strlen(tcell) + 1;
} else {
i = afsconf_GetLocalCell(adir, tbuffer, sizeof(tbuffer));
if (i) {
- UNLOCK_GLOBAL_MUTEX return i;
+ UNLOCK_GLOBAL_MUTEX;
+ return i;
}
tcell = tbuffer;
}
bestce = (struct afsconf_entry *)0;
ambig = 0;
if (!adir) {
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* Look through the list of aliases */
if (aservice) {
tservice = afsconf_FindService(aservice);
if (tservice < 0) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; /* service not found */
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_NOTFOUND; /* service not found */
}
for (i = 0; i < acellInfo->numServers; i++) {
acellInfo->hostAddr[i].sin_port = tservice;
}
}
acellInfo->timeout = 0;
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
} else {
- UNLOCK_GLOBAL_MUTEX
+ UNLOCK_GLOBAL_MUTEX;
#ifdef AFS_AFSDB_ENV
- return afsconf_GetAfsdbInfo(tcell, aservice, acellInfo);
+ return afsconf_GetAfsdbInfo(tcell, aservice, acellInfo);
#else
- return AFSCONF_NOTFOUND;
+ return AFSCONF_NOTFOUND;
#endif /* AFS_AFSDB_ENV */
}
}
char *afscell_path;
afs_int32 code = 0;
- LOCK_GLOBAL_MUTEX
- /*
- * If a cell switch was specified in a command, then it should override the
- * AFSCELL variable. If a cell was specified, then the afsconf_SawCell flag
- * is set and the cell name in the adir structure is used.
- * Read the AFSCELL var each time: in case it changes (unsetenv AFSCELL).
- */
- if (!afsconf_SawCell && (afscell_path = getenv("AFSCELL"))) {
+ LOCK_GLOBAL_MUTEX;
+ /*
+ * If a cell switch was specified in a command, then it should override the
+ * AFSCELL variable. If a cell was specified, then the afsconf_SawCell flag
+ * is set and the cell name in the adir structure is used.
+ * Read the AFSCELL var each time: in case it changes (unsetenv AFSCELL).
+ */
+ if (!afsconf_SawCell && (afscell_path = getenv("AFSCELL"))) {
if (!afsconf_showcell) {
fprintf(stderr, "Note: Operation is performed on cell %s\n",
afscell_path);
code = AFSCONF_UNKNOWN;
}
- UNLOCK_GLOBAL_MUTEX return (code);
+ UNLOCK_GLOBAL_MUTEX;
+ return (code);
}
int
afsconf_Close(struct afsconf_dir *adir)
{
- LOCK_GLOBAL_MUTEX afsconf_CloseInternal(adir);
+ LOCK_GLOBAL_MUTEX;
+ afsconf_CloseInternal(adir);
if (adir->name)
free(adir->name);
free(adir);
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
static int
}
#endif /* AFS_NT40_ENV */
- LOCK_GLOBAL_MUTEX
- /* compute the key name and other setup */
- strcompose(tbuffer, 256, adir->name, "/", AFSDIR_KEY_FILE, NULL);
+ LOCK_GLOBAL_MUTEX;
+ /* compute the key name and other setup */
+ strcompose(tbuffer, 256, adir->name, "/", AFSDIR_KEY_FILE, NULL);
tstr = (struct afsconf_keys *)malloc(sizeof(struct afsconf_keys));
adir->keystr = tstr;
fd = open(tbuffer, O_RDONLY);
if (fd < 0) {
tstr->nkeys = 0;
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
code = read(fd, tstr, sizeof(struct afsconf_keys));
close(fd);
if (code < sizeof(afs_int32)) {
tstr->nkeys = 0;
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* convert key structure to host order */
for (fd = 0; fd < tstr->nkeys; fd++)
tstr->key[fd].kvno = ntohl(tstr->key[fd].kvno);
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* get keys structure */
{
register afs_int32 code;
- LOCK_GLOBAL_MUTEX code = afsconf_Check(adir);
+ LOCK_GLOBAL_MUTEX;
+ code = afsconf_Check(adir);
if (code) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_FAILURE;
}
memcpy(astr, adir->keystr, sizeof(struct afsconf_keys));
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* get latest key */
struct afsconf_key *bestk;
register afs_int32 code;
- LOCK_GLOBAL_MUTEX code = afsconf_Check(adir);
+ LOCK_GLOBAL_MUTEX;
+ code = afsconf_Check(adir);
if (code) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_FAILURE;
}
maxa = adir->keystr->nkeys;
memcpy(akey, bestk->key, 8); /* copy out latest key */
if (avno)
*avno = bestk->kvno; /* and kvno to caller */
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
- UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; /* didn't find any keys */
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_NOTFOUND; /* didn't find any keys */
}
/* get a particular key */
register struct afsconf_key *tk;
register afs_int32 code;
- LOCK_GLOBAL_MUTEX code = afsconf_Check(adir);
+ LOCK_GLOBAL_MUTEX;
+ code = afsconf_Check(adir);
if (code) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_FAILURE;
}
maxa = adir->keystr->nkeys;
for (tk = adir->keystr->key, i = 0; i < maxa; i++, tk++) {
if (tk->kvno == avno) {
memcpy(akey, tk->key, 8);
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
}
- UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_NOTFOUND;
}
/* save the key structure in the appropriate file */
register afs_int32 i;
int foundSlot;
- LOCK_GLOBAL_MUTEX tk = adir->keystr;
+ LOCK_GLOBAL_MUTEX;
+ tk = adir->keystr;
if (akvno != 999) {
if (akvno < 0 || akvno > 255) {
- UNLOCK_GLOBAL_MUTEX return ERANGE;
+ UNLOCK_GLOBAL_MUTEX;
+ return ERANGE;
}
}
foundSlot = 0;
for (i = 0, tkey = tk->key; i < tk->nkeys; i++, tkey++) {
if (tkey->kvno == akvno) {
if (!overwrite) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_KEYINUSE;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_KEYINUSE;
}
foundSlot = 1;
break;
}
if (!foundSlot) {
if (tk->nkeys >= AFSCONF_MAXKEYS) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_FULL;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_FULL;
}
tkey = &tk->key[tk->nkeys++];
}
memcpy(tkey->key, akey, 8);
i = SaveKeys(adir);
afsconf_Touch(adir);
- UNLOCK_GLOBAL_MUTEX return i;
+ UNLOCK_GLOBAL_MUTEX;
+ return i;
}
/* this proc works by sliding the other guys down, rather than using a funny
register int i;
int foundFlag = 0;
- LOCK_GLOBAL_MUTEX tk = adir->keystr;
+ LOCK_GLOBAL_MUTEX;
+ tk = adir->keystr;
for (i = 0, tkey = tk->key; i < tk->nkeys; i++, tkey++) {
if (tkey->kvno == akvno) {
}
}
if (!foundFlag) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_NOTFOUND;
}
/* otherwise slide the others down. i and tkey point at the guy to delete */
tk->nkeys--;
i = SaveKeys(adir);
afsconf_Touch(adir);
- UNLOCK_GLOBAL_MUTEX return i;
+ UNLOCK_GLOBAL_MUTEX;
+ return i;
}
{
int ncode, ocode;
- LOCK_GLOBAL_MUTEX
+ LOCK_GLOBAL_MUTEX;
#ifdef AFS_KERBEROS_ENV
- if (!lcell[0])
+ if (!lcell[0])
ktc_LocalCell();
if ( /*!strcmp(aclient->cell, lcell) && this would only store local creds */
}
afs_tf_close();
#ifdef NO_AFS_CLIENT
- UNLOCK_GLOBAL_MUTEX return ncode;
+ UNLOCK_GLOBAL_MUTEX;
+ return ncode;
#endif /* NO_AFS_CLIENT */
}
#endif
} else
ocode = 0;
if (ncode && ocode) {
- UNLOCK_GLOBAL_MUTEX if (ocode == -1)
+ UNLOCK_GLOBAL_MUTEX;
+ if (ocode == -1)
ocode = errno;
else if (ocode == KTC_PIOCTLFAIL)
ocode = errno;
return KTC_PIOCTLFAIL;
}
#endif /* NO_AFS_CLIENT */
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* get token, given server we need and token buffer. aclient will eventually
int tktLen; /* server ticket length */
char found = 0;
- LOCK_GLOBAL_MUTEX
+ LOCK_GLOBAL_MUTEX;
#ifndef NO_AFS_CLIENT
- TRY_KERNEL(KTC_GETTOKEN_OP, aserver, aclient, atoken, atokenLen);
+ TRY_KERNEL(KTC_GETTOKEN_OP, aserver, aclient, atoken, atokenLen);
#endif /* NO_AFS_CLIENT */
#ifdef AFS_KERBEROS_ENV
min(atokenLen, sizeof(struct ktc_token)));
if (aclient)
*aclient = local_tokens[i].client;
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
#ifdef AFS_KERBEROS_ENV
if (!afs_tf_init(ktc_tkt_string(), R_TKT_FIL)) {
min(atokenLen, sizeof(struct ktc_token)));
afs_tf_close();
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
}
}
afs_tf_close();
#endif
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
#ifndef NO_AFS_CLIENT
for (index = 0; index < 200; index++) { /* sanity check in case pioctl fails */
if (code) {
/* failed to retrieve specified token */
if (code < 0 && errno == EDOM) {
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
} else {
/* token retrieved; parse buffer */
/* get size of clear token and verify */
memcpy(&temp, tp, sizeof(afs_int32));
if (temp != sizeof(struct ClearToken)) {
- UNLOCK_GLOBAL_MUTEX return KTC_ERROR;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_ERROR;
}
tp += sizeof(afs_int32);
maxLen =
atokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN;
if (maxLen < tktLen) {
- UNLOCK_GLOBAL_MUTEX return KTC_TOOBIG;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_TOOBIG;
}
/* set return values */
sprintf(aclient->name, "Unix UID %d", ct.ViceId);
}
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
}
}
#endif /* NO_AFS_CLIENT */
- UNLOCK_GLOBAL_MUTEX if ((code < 0) && (errno == EINVAL))
+ UNLOCK_GLOBAL_MUTEX;
+ if ((code < 0) && (errno == EINVAL))
return KTC_NOPIOCTL;
return KTC_PIOCTLFAIL; /* probable cause */
}
{
int rc;
- LOCK_GLOBAL_MUTEX TRY_KERNEL(KTC_FORGETTOKEN_OP, aserver, 0, 0, 0);
+ LOCK_GLOBAL_MUTEX;
+ TRY_KERNEL(KTC_FORGETTOKEN_OP, aserver, 0, 0, 0);
rc = ktc_ForgetAllTokens(); /* bogus, but better */
- UNLOCK_GLOBAL_MUTEX return rc;
+ UNLOCK_GLOBAL_MUTEX;
+ return rc;
}
#endif /* NO_AFS_CLIENT */
memset(tbuffer, 0, sizeof(tbuffer));
- LOCK_GLOBAL_MUTEX
+ LOCK_GLOBAL_MUTEX;
#ifndef NO_AFS_CLIENT
- TRY_KERNEL(KTC_LISTTOKENS_OP, aserver, aprevIndex, aindex, 0);
+ TRY_KERNEL(KTC_LISTTOKENS_OP, aserver, aprevIndex, aindex, 0);
#endif /* NO_AFS_CLIENT */
index = aprevIndex;
if (afs_tf_init(ktc_tkt_string(), R_TKT_FIL)
|| afs_tf_get_pname(tbuffer) || afs_tf_get_pinst(tbuffer)) {
afs_tf_close();
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
for (i = 214; i < index; i++) {
if (afs_tf_get_cred(&cprincipal, &ctoken)) {
afs_tf_close();
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
}
again:
if (afs_tf_get_cred(&cprincipal, &ctoken)) {
afs_tf_close();
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
index++;
*aserver = cprincipal;
*aindex = index;
afs_tf_close();
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
#endif
if (local_tokens[index - 123].valid) {
*aserver = local_tokens[index - 123].server;
*aindex = index + 1;
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
index++;
}
- UNLOCK_GLOBAL_MUTEX
+ UNLOCK_GLOBAL_MUTEX;
#ifdef AFS_KERBEROS_ENV
- return ktc_ListTokens(214, aindex, aserver);
+ return ktc_ListTokens(214, aindex, aserver);
#else
- return KTC_NOENT;
+ return KTC_NOENT;
#endif
}
if (index < 123) {
int rc;
rc = ktc_ListTokens(123, aindex, aserver);
- UNLOCK_GLOBAL_MUTEX return rc;
+ UNLOCK_GLOBAL_MUTEX;
+ return rc;
} else {
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
}
if (code == 0)
index++;
}
if (code < 0) {
- UNLOCK_GLOBAL_MUTEX if (errno == EINVAL)
+ UNLOCK_GLOBAL_MUTEX;
+ if (errno == EINVAL)
return KTC_NOPIOCTL;
return KTC_PIOCTLFAIL;
}
tp += temp; /* skip ticket for now */
memcpy(&temp, tp, sizeof(afs_int32)); /* get size of clear token */
if (temp != sizeof(struct ClearToken)) {
- UNLOCK_GLOBAL_MUTEX return KTC_ERROR;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_ERROR;
}
tp += sizeof(afs_int32); /* skip length */
tp += temp; /* skip clear token itself */
aserver->instance[0] = 0;
strcpy(aserver->name, "afs");
#endif /* NO_AFS_CLIENT */
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* discard all tokens from this user's cache */
{
int ncode, ocode;
- LOCK_GLOBAL_MUTEX
+ LOCK_GLOBAL_MUTEX;
#ifdef AFS_KERBEROS_ENV
- (void) afs_tf_dest_tkt();
+ (void)afs_tf_dest_tkt();
#endif
ncode = NewForgetAll();
ocode = errno;
else if (ocode == KTC_PIOCTLFAIL)
ocode = errno;
- UNLOCK_GLOBAL_MUTEX if (ocode == EINVAL)
+ UNLOCK_GLOBAL_MUTEX;
+ if (ocode == EINVAL)
return KTC_NOPIOCTL;
return KTC_PIOCTLFAIL;
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* ktc_OldPioctl - returns a boolean true if the kernel supports only the old
ktc_OldPioctl()
{
int rc;
- LOCK_GLOBAL_MUTEX
+ LOCK_GLOBAL_MUTEX;
#ifdef KERNEL_KTC_COMPAT
- CHECK_KERNEL;
+ CHECK_KERNEL;
rc = (kernelKTC != 1); /* old style interface */
#else
- rc = 1;
+ rc = 1;
#endif
- UNLOCK_GLOBAL_MUTEX return rc;
+ UNLOCK_GLOBAL_MUTEX;
+ return rc;
}
{
char *env;
- LOCK_GLOBAL_MUTEX if (!*krb_ticket_string) {
+ LOCK_GLOBAL_MUTEX;
+ if (!*krb_ticket_string) {
if (env = getenv("KRBTKFILE")) {
(void)strncpy(krb_ticket_string, env,
sizeof(krb_ticket_string) - 1);
(void)sprintf(krb_ticket_string, "%s%d", TKT_ROOT, getuid());
}
}
- UNLOCK_GLOBAL_MUTEX return krb_ticket_string;
+ UNLOCK_GLOBAL_MUTEX;
+ return krb_ticket_string;
}
/*
char *val;
{
- LOCK_GLOBAL_MUTEX(void) strncpy(krb_ticket_string, val,
- sizeof(krb_ticket_string) - 1);
+ LOCK_GLOBAL_MUTEX;
+ (void)strncpy(krb_ticket_string, val, sizeof(krb_ticket_string) - 1);
krb_ticket_string[sizeof(krb_ticket_string) - 1] = '\0';
- UNLOCK_GLOBAL_MUTEX return;
+ UNLOCK_GLOBAL_MUTEX;
+ return;
}
/*
int numenv;
char **newenv, **senv, **denv;
- LOCK_GLOBAL_MUTEX if (stat("/ticket", &sbuf) == -1) {
+ LOCK_GLOBAL_MUTEX;
+ if (stat("/ticket", &sbuf) == -1) {
prefix = "/tmp/tkt";
}
strcat(*denv, fname);
*++denv = 0;
environ = newenv;
-UNLOCK_GLOBAL_MUTEX}
+ UNLOCK_GLOBAL_MUTEX;
+}
/*
* BLETCH! We have to invoke the entire afsconf package just to
"SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters";
static char AFSGlobalKTCMutexName[] = "Global\\AFS_KTC_Mutex";
-static char AFSKTCMutexName[] = "AFS_KTC_Mutex";
+static char AFSKTCMutexName[] = "AFS_KTC_Mutex";
/*
* Support for RPC's to send and receive session keys
#ifndef AFS_WIN95_ENV
ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName);
- if ( ktcMutex == NULL )
- return KTC_PIOCTLFAIL;
- if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
- if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) {
- CloseHandle(ktcMutex);
- return KTC_PIOCTLFAIL;
- }
+ if (ktcMutex == NULL)
+ return KTC_PIOCTLFAIL;
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) {
+ CloseHandle(ktcMutex);
+ return KTC_PIOCTLFAIL;
+ }
}
/* RPC to send session key */
status = send_key(uuid, token->sessionKey.data);
if (status != RPC_S_OK) {
- if (status == 1)
- strcpy(rpcErr, "RPC failure in AFS gateway");
- else
- DceErrorInqText(status, rpcErr);
- if (status == RPC_S_SERVER_UNAVAILABLE ||
- status == EPT_S_NOT_REGISTERED)
- {
- ReleaseMutex(ktcMutex);
- CloseHandle(ktcMutex);
- return KTC_NOCMRPC;
- }
- else
- {
- ReleaseMutex(ktcMutex);
- CloseHandle(ktcMutex);
- return KTC_RPC;
- }
+ if (status == 1)
+ strcpy(rpcErr, "RPC failure in AFS gateway");
+ else
+ DceErrorInqText(status, rpcErr);
+ if (status == RPC_S_SERVER_UNAVAILABLE ||
+ status == EPT_S_NOT_REGISTERED) {
+ ReleaseMutex(ktcMutex);
+ CloseHandle(ktcMutex);
+ return KTC_NOCMRPC;
+ } else {
+ ReleaseMutex(ktcMutex);
+ CloseHandle(ktcMutex);
+ return KTC_RPC;
+ }
}
#endif /* AFS_WIN95_ENV */
#endif /* AFS_WIN95_ENV */
if (code) {
- if (code == -1) {
- if (errno == ESRCH)
- return KTC_NOCELL;
- else if (errno == ENODEV)
- return KTC_NOCM;
- else if (errno == EINVAL)
- return KTC_INVAL;
- else
- return KTC_PIOCTLFAIL;
- } else
- return KTC_PIOCTLFAIL;
+ if (code == -1) {
+ if (errno == ESRCH)
+ return KTC_NOCELL;
+ else if (errno == ENODEV)
+ return KTC_NOCM;
+ else if (errno == EINVAL)
+ return KTC_INVAL;
+ else
+ return KTC_PIOCTLFAIL;
+ } else
+ return KTC_PIOCTLFAIL;
}
return 0;
iob.out = tbuffer;
iob.out_size = sizeof(tbuffer);
-#ifndef AFS_WIN95_ENV
+#ifndef AFS_WIN95_ENV
ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName);
- if ( ktcMutex == NULL )
- return KTC_PIOCTLFAIL;
- if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
- if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) {
- CloseHandle(ktcMutex);
- return KTC_PIOCTLFAIL;
- }
+ if (ktcMutex == NULL)
+ return KTC_PIOCTLFAIL;
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) {
+ CloseHandle(ktcMutex);
+ return KTC_PIOCTLFAIL;
+ }
}
#endif /* AFS_WIN95_ENV */
code = pioctl(0, VIOCNEWGETTOK, &iob, 0);
if (code) {
#ifndef AFS_WIN95_ENV
- ReleaseMutex(ktcMutex);
- CloseHandle(ktcMutex);
+ ReleaseMutex(ktcMutex);
+ CloseHandle(ktcMutex);
#endif /* AFS_WIN95_ENV */
- if (code == -1) {
- if (errno == ESRCH)
- return KTC_NOCELL;
- else if (errno == ENODEV)
- return KTC_NOCM;
- else if (errno == EINVAL)
- return KTC_INVAL;
- else if (errno == EDOM)
- return KTC_NOENT;
- else
- return KTC_PIOCTLFAIL;
- } else
- return KTC_PIOCTLFAIL;
- }
-
-#ifndef AFS_WIN95_ENV
+ if (code == -1) {
+ if (errno == ESRCH)
+ return KTC_NOCELL;
+ else if (errno == ENODEV)
+ return KTC_NOCM;
+ else if (errno == EINVAL)
+ return KTC_INVAL;
+ else if (errno == EDOM)
+ return KTC_NOENT;
+ else
+ return KTC_PIOCTLFAIL;
+ } else
+ return KTC_PIOCTLFAIL;
+ }
+#ifndef AFS_WIN95_ENV
/* get rid of RPC for win95 build */
/* RPC to receive session key */
status = receive_key(uuid, token->sessionKey.data);
CloseHandle(ktcMutex);
if (status != RPC_S_OK) {
- if (status == 1)
- strcpy(rpcErr, "RPC failure in AFS gateway");
- else
- DceErrorInqText(status, rpcErr);
- if (status == RPC_S_SERVER_UNAVAILABLE
- || status == EPT_S_NOT_REGISTERED)
- return KTC_NOCMRPC;
- else
- return KTC_RPC;
+ if (status == 1)
+ strcpy(rpcErr, "RPC failure in AFS gateway");
+ else
+ DceErrorInqText(status, rpcErr);
+ if (status == RPC_S_SERVER_UNAVAILABLE
+ || status == EPT_S_NOT_REGISTERED)
+ return KTC_NOCMRPC;
+ else
+ return KTC_RPC;
}
#endif /* AFS_WIN95_ENV */
/* user name is here */
/* check that ticket will fit
- * this compares the size of the ktc_token allocated by the app
- * which might be smaller than the current definition of MAXKTCTICKETLEN
- */
- maxLen = tokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN;
- if (maxLen < ticketLen)
- return KTC_TOOBIG;
+ * this compares the size of the ktc_token allocated by the app
+ * which might be smaller than the current definition of MAXKTCTICKETLEN
+ */
+ maxLen = tokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN;
+ if (maxLen < ticketLen)
+ return KTC_TOOBIG;
/* set return values */
memcpy(token->ticket, ticketP, ticketLen);
int code;
HANDLE ktcMutex = NULL;
-#ifndef AFS_WIN95_ENV
+#ifndef AFS_WIN95_ENV
ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName);
- if ( ktcMutex == NULL )
- return KTC_PIOCTLFAIL;
- if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
- if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) {
- CloseHandle(ktcMutex);
- return KTC_PIOCTLFAIL;
- }
+ if (ktcMutex == NULL)
+ return KTC_PIOCTLFAIL;
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) {
+ CloseHandle(ktcMutex);
+ return KTC_PIOCTLFAIL;
+ }
}
#endif /* AFS_WIN95_ENV */
code = pioctl(0, VIOCGETTOK, &iob, 0);
#ifndef AFS_WIN95_ENV
- ReleaseMutex(ktcMutex);
- CloseHandle(ktcMutex);
+ ReleaseMutex(ktcMutex);
+ CloseHandle(ktcMutex);
#endif /* AFS_WIN95_ENV */
if (code) {
if (strcmp(server->name, "afs")) {
return ForgetOneLocalToken(server);
}
-
-#ifndef AFS_WIN95_ENV
+#ifndef AFS_WIN95_ENV
ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName);
- if ( ktcMutex == NULL )
- return KTC_PIOCTLFAIL;
- if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
- if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) {
- CloseHandle(ktcMutex);
- return KTC_PIOCTLFAIL;
- }
+ if (ktcMutex == NULL)
+ return KTC_PIOCTLFAIL;
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) {
+ CloseHandle(ktcMutex);
+ return KTC_PIOCTLFAIL;
+ }
}
#endif /* AFS_WIN95_ENV */
(void)ForgetLocalTokens();
-#ifndef AFS_WIN95_ENV
+#ifndef AFS_WIN95_ENV
ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName);
- if ( ktcMutex == NULL )
- return KTC_PIOCTLFAIL;
- if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
- if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) {
- CloseHandle(ktcMutex);
- return KTC_PIOCTLFAIL;
- }
+ if (ktcMutex == NULL)
+ return KTC_PIOCTLFAIL;
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) {
+ CloseHandle(ktcMutex);
+ return KTC_PIOCTLFAIL;
+ }
}
#endif /* AFS_WIN95_ENV */
int found = -1;
int i;
- LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++)
+ LOCK_GLOBAL_MUTEX;
+ for (i = 0; i < MAXLOCALTOKENS; i++)
if (local_tokens[i].valid) {
if ((strcmp(local_tokens[i].server.name, aserver->name) == 0)
&& (strcmp(local_tokens[i].server.instance, aserver->instance)
} else if (found == -1)
found = i; /* remember empty slot but keep looking for a match */
if (found == -1) {
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
memcpy(&local_tokens[found].token, atoken, sizeof(struct ktc_token));
memcpy(&local_tokens[found].server, aserver,
memcpy(&local_tokens[found].client, aclient,
sizeof(struct ktc_principal));
local_tokens[found].valid = 1;
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
{
int i;
- LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++)
+ LOCK_GLOBAL_MUTEX;
+ for (i = 0; i < MAXLOCALTOKENS; i++)
if (local_tokens[i].valid
&& (strcmp(local_tokens[i].server.name, aserver->name) == 0)
&& (strcmp(local_tokens[i].server.instance, aserver->instance) ==
min(atokenLen, sizeof(struct ktc_token)));
memcpy(aclient, &local_tokens[i].client,
sizeof(struct ktc_principal));
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
{
int i;
- LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) {
+ LOCK_GLOBAL_MUTEX;
+ for (i = 0; i < MAXLOCALTOKENS; i++) {
local_tokens[i].valid = 0;
memset(&local_tokens[i].token.sessionKey, 0,
sizeof(struct ktc_encryptionKey));
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
{
int i;
- LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) {
+ LOCK_GLOBAL_MUTEX;
+ for (i = 0; i < MAXLOCALTOKENS; i++) {
if (local_tokens[i].valid
&& (strcmp(local_tokens[i].server.name, aserver->name) == 0)
&& (strcmp(local_tokens[i].server.instance, aserver->instance) ==
local_tokens[i].valid = 0;
memset(&local_tokens[i].token.sessionKey, 0,
sizeof(struct ktc_encryptionKey));
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
}
- UNLOCK_GLOBAL_MUTEX return KTC_NOENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KTC_NOENT;
}
register struct rx_call *acall;
register struct afsconf_dir *adir;
{
- LOCK_GLOBAL_MUTEX return ((afsconf_SuperUser(adir, acall, NULL) == 0) ?
- 10029 : 0);
-UNLOCK_GLOBAL_MUTEX}
+ LOCK_GLOBAL_MUTEX;
+ return ((afsconf_SuperUser(adir, acall, NULL) == 0) ? 10029 : 0);
+ UNLOCK_GLOBAL_MUTEX;
+}
#endif /* !defined(UKERNEL) */
static int
{
int rc;
- LOCK_GLOBAL_MUTEX rc = GetNoAuthFlag(adir);
- UNLOCK_GLOBAL_MUTEX return rc;
+ LOCK_GLOBAL_MUTEX;
+ rc = GetNoAuthFlag(adir);
+ UNLOCK_GLOBAL_MUTEX;
+ return rc;
}
void
{
register afs_int32 code;
- LOCK_GLOBAL_MUTEX if (aflag == 0) {
+ LOCK_GLOBAL_MUTEX;
+ if (aflag == 0) {
/* turn off noauth flag */
code = (unlink(AFSDIR_SERVER_NOAUTH_FILEPATH) ? errno : 0);
osi_audit(NoAuthDisableEvent, code, AUD_END);
} else
osi_audit(NoAuthEnableEvent, errno, AUD_END);
}
-UNLOCK_GLOBAL_MUTEX}
+ UNLOCK_GLOBAL_MUTEX;
+}
/* deletes a user from the UserList file */
int
struct stat tstat;
register afs_int32 code;
- LOCK_GLOBAL_MUTEX strcompose(tbuffer, sizeof tbuffer, adir->name, "/",
- AFSDIR_ULIST_FILE, NULL);
+ LOCK_GLOBAL_MUTEX;
+ strcompose(tbuffer, sizeof tbuffer, adir->name, "/",
+ AFSDIR_ULIST_FILE, NULL);
#ifndef AFS_NT40_ENV
{
/*
#endif /* AFS_NT40_ENV */
tf = fopen(tbuffer, "r");
if (!tf) {
- UNLOCK_GLOBAL_MUTEX return -1;
+ UNLOCK_GLOBAL_MUTEX;
+ return -1;
}
code = stat(tbuffer, &tstat);
if (code < 0) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
strcpy(nbuffer, tbuffer);
strcat(nbuffer, ".NXX");
nf = fopen(nbuffer, "w+");
if (!nf) {
fclose(tf);
- UNLOCK_GLOBAL_MUTEX return EIO;
+ UNLOCK_GLOBAL_MUTEX;
+ return EIO;
}
flag = 0;
found = 0;
unlink(nbuffer);
/* finally, decide what to return to the caller */
- UNLOCK_GLOBAL_MUTEX if (flag)
- return EIO; /* something mysterious went wrong */
+ UNLOCK_GLOBAL_MUTEX;
+ if (flag)
+ return EIO; /* something mysterious went wrong */
if (!found)
return ENOENT; /* entry wasn't found, no changes made */
return 0; /* everything was fine */
register int flag;
register afs_int32 code;
- LOCK_GLOBAL_MUTEX strcompose(tbuffer, sizeof tbuffer, adir->name, "/",
- AFSDIR_ULIST_FILE, NULL);
+ LOCK_GLOBAL_MUTEX;
+ strcompose(tbuffer, sizeof tbuffer, adir->name, "/",
+ AFSDIR_ULIST_FILE, NULL);
tf = fopen(tbuffer, "r");
if (!tf) {
- UNLOCK_GLOBAL_MUTEX return 1;
+ UNLOCK_GLOBAL_MUTEX;
+ return 1;
}
flag = 1;
while (1) {
if (flag == 0)
strcpy(abuffer, tname);
fclose(tf);
- UNLOCK_GLOBAL_MUTEX return flag;
+ UNLOCK_GLOBAL_MUTEX;
+ return flag;
}
/* returns true iff user is in the UserList file */
register afs_int32 code;
char tbuffer[256];
- LOCK_GLOBAL_MUTEX if (FindUser(adir, aname)) {
- UNLOCK_GLOBAL_MUTEX return EEXIST; /* already in the list */
+ LOCK_GLOBAL_MUTEX;
+ if (FindUser(adir, aname)) {
+ UNLOCK_GLOBAL_MUTEX;
+ return EEXIST; /* already in the list */
}
strcompose(tbuffer, sizeof tbuffer, adir->name, "/", AFSDIR_ULIST_FILE,
NULL);
tf = fopen(tbuffer, "a+");
if (!tf) {
- UNLOCK_GLOBAL_MUTEX return EIO;
+ UNLOCK_GLOBAL_MUTEX;
+ return EIO;
}
fprintf(tf, "%s\n", aname);
code = 0;
code = EIO;
if (fclose(tf))
code = EIO;
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
/* special CompFindUser routine that builds up a princ and then
register afs_int32 code;
int flag;
- LOCK_GLOBAL_MUTEX if (!adir) {
- UNLOCK_GLOBAL_MUTEX return 0;
+ LOCK_GLOBAL_MUTEX;
+ if (!adir) {
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
if (afsconf_GetNoAuthFlag(adir)) {
if (namep)
strcpy(namep, "<NoAuth>");
- UNLOCK_GLOBAL_MUTEX return 1;
+ UNLOCK_GLOBAL_MUTEX;
+ return 1;
}
tconn = rx_ConnectionOf(acall);
code = rx_SecurityClassOf(tconn);
if (code == 0) {
- UNLOCK_GLOBAL_MUTEX return 0; /* not authenticated at all, answer is no */
+ UNLOCK_GLOBAL_MUTEX;
+ return 0; /* not authenticated at all, answer is no */
} else if (code == 1) {
/* bcrypt tokens */
- UNLOCK_GLOBAL_MUTEX return 0; /* not supported any longer */
+ UNLOCK_GLOBAL_MUTEX;
+ return 0; /* not supported any longer */
} else if (code == 2) {
char tname[MAXKTCNAMELEN]; /* authentication from ticket */
char tinst[MAXKTCNAMELEN];
rxkad_GetServerInfo(acall->conn, NULL, &exp, tname, tinst, tcell,
NULL);
if (code) {
- UNLOCK_GLOBAL_MUTEX return 0; /* bogus connection/other error */
+ UNLOCK_GLOBAL_MUTEX;
+ return 0; /* bogus connection/other error */
}
/* don't bother checking anything else if tix have expired */
#else
if (exp < FT_ApproxTime()) {
#endif
- UNLOCK_GLOBAL_MUTEX return 0; /* expired tix */
+ UNLOCK_GLOBAL_MUTEX;
+ return 0; /* expired tix */
}
/* generate lowercased version of cell name */
if (namep)
strcpy(namep, uname);
- UNLOCK_GLOBAL_MUTEX return flag;
+ UNLOCK_GLOBAL_MUTEX;
+ return flag;
} else { /* some other auth type */
- UNLOCK_GLOBAL_MUTEX return 0; /* mysterious, just say no */
+ UNLOCK_GLOBAL_MUTEX;
+ return 0; /* mysterious, just say no */
}
}
register FILE *tf;
register afs_int32 i;
- LOCK_GLOBAL_MUTEX
- /* write ThisCell file */
- strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, NULL);
+ LOCK_GLOBAL_MUTEX;
+ /* write ThisCell file */
+ strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, NULL);
fd = open(tbuffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
- UNLOCK_GLOBAL_MUTEX return errno;
+ UNLOCK_GLOBAL_MUTEX;
+ return errno;
}
i = strlen(acellInfo->name);
code = write(fd, acellInfo->name, i);
if (code != i) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_FAILURE;
}
if (close(fd) < 0) {
- UNLOCK_GLOBAL_MUTEX return errno;
+ UNLOCK_GLOBAL_MUTEX;
+ return errno;
}
/* make sure we have both name and address for each host, looking up other
* if need be */
code = VerifyEntries(acellInfo);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
/* write CellServDB */
strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, NULL);
tf = fopen(tbuffer, "w");
if (!tf) {
- UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_NOTFOUND;
}
fprintf(tf, ">%s #Cell name\n", acellInfo->name);
for (i = 0; i < acellInfo->numServers; i++) {
}
if (ferror(tf)) {
fclose(tf);
- UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE;
+ UNLOCK_GLOBAL_MUTEX;
+ return AFSCONF_FAILURE;
}
code = fclose(tf);
if (adir)
adir->timeRead = 0;
- UNLOCK_GLOBAL_MUTEX if (code == EOF)
+ UNLOCK_GLOBAL_MUTEX;
+ if (code == EOF)
return AFSCONF_FAILURE;
return 0;
}
}
#define LOCK_ET_LIST \
- (et_list_done || pthread_once(&et_list_once, et_mutex_once)); \
- assert(pthread_mutex_lock(&et_list_mutex)==0);
-#define UNLOCK_ET_LIST assert(pthread_mutex_unlock(&et_list_mutex)==0);
+ do { \
+ (et_list_done || pthread_once(&et_list_once, et_mutex_once)); \
+ assert(pthread_mutex_lock(&et_list_mutex)==0); \
+ } while (0)
+#define UNLOCK_ET_LIST assert(pthread_mutex_unlock(&et_list_mutex)==0)
#else
#define LOCK_ET_LIST
#define UNLOCK_ET_LIST
else
goto oops;
}
- LOCK_ET_LIST for (et = _et_list; et; et = et->next) {
+ LOCK_ET_LIST;
+ for (et = _et_list; et; et = et->next) {
if (et->table->base == table_num) {
/* This is the right table */
if (et->table->n_msgs <= offset)
goto oops;
- UNLOCK_ET_LIST return (et->table->msgs[offset]);
+ UNLOCK_ET_LIST;
+ return (et->table->msgs[offset]);
}
}
oops:
- UNLOCK_ET_LIST strcpy(buffer, "Unknown code ");
+ UNLOCK_ET_LIST;
+ strcpy(buffer, "Unknown code ");
if (table_num) {
strcat(buffer, error_table_name(table_num));
strcat(buffer, " ");
{
struct et_list *et;
- LOCK_ET_LIST
- /*
- * Protect against adding the same error table twice
- */
- for (et = _et_list; et; et = et->next) {
+ LOCK_ET_LIST;
+ /*
+ * Protect against adding the same error table twice
+ */
+ for (et = _et_list; et; et = et->next) {
if (et->table->base == new_table->table->base) {
- UNLOCK_ET_LIST return;
+ UNLOCK_ET_LIST;
+ return;
}
}
new_table->next = _et_list;
_et_list = new_table;
-UNLOCK_ET_LIST}
+ UNLOCK_ET_LIST;
+}
#ifdef DEBUG
afs_uint32 dbg_tmp[2];
#endif
- LOCK_RXKAD_STATS if (encrypt)
- rxkad_stats.des_encrypts[DES_ENCRYPT]++;
+ LOCK_RXKAD_STATS;
+ if (encrypt)
+ rxkad_stats.des_encrypts[DES_ENCRYPT]++;
else
rxkad_stats.des_encrypts[DES_DECRYPT]++;
- UNLOCK_RXKAD_STATS
- /*
- * Use L1,R1 and L2,R2 as two sets of "64-bit" registers always
- * work from L1,R1 input to L2,R2 output; initialize the cleartext
- * into registers.
- */
+ UNLOCK_RXKAD_STATS;
+ /*
+ * Use L1,R1 and L2,R2 as two sets of "64-bit" registers always
+ * work from L1,R1 input to L2,R2 output; initialize the cleartext
+ * into registers.
+ */
#ifdef MUSTALIGN
#ifdef DEBUG
- /*
- * If the alignment is wrong, the programmer really screwed up --
- * we aren't even getting the right data type. His problem. Keep
- * this code for debugging.
- */
- /* Make sure schedule is ok */
- if ((afs_int32) schedule & 3) {
+ /*
+ * If the alignment is wrong, the programmer really screwed up --
+ * we aren't even getting the right data type. His problem. Keep
+ * this code for debugging.
+ */
+ /* Make sure schedule is ok */
+ if ((afs_int32) schedule & 3) {
fprintf(stderr, "des.c schedule arg pointer not aligned\n");
abort();
}
n = 0;
p_char = k_char;
- LOCK_RXKAD_STATS rxkad_stats.des_key_scheds++;
- UNLOCK_RXKAD_STATS
+ LOCK_RXKAD_STATS;
+ rxkad_stats.des_key_scheds++;
+ UNLOCK_RXKAD_STATS;
#ifdef lint
- n = n; /* fool it in case of VAXASM */
+ n = n; /* fool it in case of VAXASM */
#endif
#ifdef DEBUG
if (des_debug)
#include <assert.h>
pthread_mutex_t des_init_mutex;
-#define LOCK_INIT assert(pthread_mutex_lock(&des_init_mutex)==0);
-#define UNLOCK_INIT assert(pthread_mutex_unlock(&des_init_mutex)==0);
+#define LOCK_INIT assert(pthread_mutex_lock(&des_init_mutex)==0)
+#define UNLOCK_INIT assert(pthread_mutex_unlock(&des_init_mutex)==0)
#else
#define LOCK_INIT
#define UNLOCK_INIT
int
des_random_key(des_cblock key)
{
- LOCK_INIT if (!is_inited) {
+ LOCK_INIT;
+ if (!is_inited) {
des_init_random_number_generator(key);
}
- UNLOCK_INIT
+ UNLOCK_INIT;
do {
des_generate_random_block(key);
des_fixup_key_parity(key);
#include <assert.h>
pthread_mutex_t des_random_mutex;
-#define LOCK_RANDOM assert(pthread_mutex_lock(&des_random_mutex)==0);
-#define UNLOCK_RANDOM assert(pthread_mutex_unlock(&des_random_mutex)==0);
+#define LOCK_RANDOM assert(pthread_mutex_lock(&des_random_mutex)==0)
+#define UNLOCK_RANDOM assert(pthread_mutex_unlock(&des_random_mutex)==0)
#else
#define LOCK_RANDOM
#define UNLOCK_RANDOM
register int i;
/* select the new stream: (note errors are not possible here...) */
- LOCK_RANDOM des_key_sched(key, random_sequence_key.d);
+ LOCK_RANDOM;
+ des_key_sched(key, random_sequence_key.d);
/* "seek" to the start of the stream: */
for (i = 0; i < 8; i++)
sequence_number[i] = 0;
-UNLOCK_RANDOM}
+ UNLOCK_RANDOM;
+}
/*
* des_set_sequence_number: this routine is used to set the sequence number
static afs_int32
des_set_sequence_number(des_cblock new_sequence_number)
{
- LOCK_RANDOM memcpy((char *)sequence_number, (char *)new_sequence_number,
- sizeof(sequence_number));
- UNLOCK_RANDOM return 0;
+ LOCK_RANDOM;
+ memcpy((char *)sequence_number, (char *)new_sequence_number,
+ sizeof(sequence_number));
+ UNLOCK_RANDOM;
+ return 0;
}
/*
{
int i;
- LOCK_RXKAD_STATS rxkad_stats.des_randoms++;
- UNLOCK_RXKAD_STATS
- /*
- * Encrypt the sequence number to get the new random block:
- */
- LOCK_RANDOM des_ecb_encrypt(sequence_number, block,
- random_sequence_key.d, 1);
+ LOCK_RXKAD_STATS;
+ rxkad_stats.des_randoms++;
+ UNLOCK_RXKAD_STATS;
+ /*
+ * Encrypt the sequence number to get the new random block:
+ */
+ LOCK_RANDOM;
+ des_ecb_encrypt(sequence_number, block, random_sequence_key.d, 1);
/*
* Increment the sequence number as an 8 byte unsigned number with wrap:
if (sequence_number[i])
break;
}
- UNLOCK_RANDOM return 0;
+ UNLOCK_RANDOM;
+ return 0;
}
#include <pthread.h>
#include <assert.h>
extern pthread_mutex_t rxkad_stats_mutex;
-#define LOCK_RXKAD_STATS assert(pthread_mutex_lock(&rxkad_stats_mutex)==0);
-#define UNLOCK_RXKAD_STATS assert(pthread_mutex_unlock(&rxkad_stats_mutex)==0);
+#define LOCK_RXKAD_STATS assert(pthread_mutex_lock(&rxkad_stats_mutex)==0)
+#define UNLOCK_RXKAD_STATS assert(pthread_mutex_unlock(&rxkad_stats_mutex)==0)
#else
#define LOCK_RXKAD_STATS
#define UNLOCK_RXKAD_STATS
{
int i;
- LOCK_GLOBAL_MUTEX ka_ExpandCell(cell, explicit_cell_server_list.name, 0);
+ LOCK_GLOBAL_MUTEX;
+ ka_ExpandCell(cell, explicit_cell_server_list.name, 0);
for (i = 0; i < MAXHOSTSPERCELL; i++)
if (serverList[i]) {
explicit_cell_server_list.numServers = i + 1;
explicit = 1;
} else
break;
-UNLOCK_GLOBAL_MUTEX}
+ UNLOCK_GLOBAL_MUTEX;
+}
static int
myCellLookup(struct afsconf_dir *conf, char *cell, char *service,
afs_int32 code;
char cellname[MAXKTCREALMLEN];
- LOCK_GLOBAL_MUTEX if (cell && !strlen(cell))
- cell = 0;
+ LOCK_GLOBAL_MUTEX;
+ if (cell && !strlen(cell))
+ cell = 0;
else
cell = lcstring(cellname, cell, sizeof(cellname));
conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
#endif /* UKERNEL */
if (!conf) {
- UNLOCK_GLOBAL_MUTEX return KANOCELLS;
+ UNLOCK_GLOBAL_MUTEX;
+ return KANOCELLS;
}
}
code = myCellLookup(conf, cell, AFSCONF_KAUTHSERVICE, cellinfo);
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
afs_int32
ka_GetSecurity(int service, struct ktc_token * token,
struct rx_securityClass ** scP, int *siP)
{ /* security class index */
- LOCK_GLOBAL_MUTEX *scP = 0;
+ LOCK_GLOBAL_MUTEX;
+ *scP = 0;
switch (service) {
case KA_AUTHENTICATION_SERVICE:
case KA_TICKET_GRANTING_SERVICE:
*siP = RX_SCINDEX_KAD;
break;
default:
- UNLOCK_GLOBAL_MUTEX return KABADARGUMENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADARGUMENT;
}
if (*scP == 0) {
printf("Failed gettting security object\n");
- UNLOCK_GLOBAL_MUTEX return KARXFAIL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KARXFAIL;
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
afs_int32
char sname[MAXHOSTCHARS];
int snamel;
- LOCK_GLOBAL_MUTEX code = ka_GetServers(cell, &cellinfo);
+ LOCK_GLOBAL_MUTEX;
+ code = ka_GetServers(cell, &cellinfo);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
lcstring(sname, server, sizeof(sname));
for (i = 0; i < cellinfo.numServers; i++) {
if (strncmp(cellinfo.hostName[i], sname, snamel) == 0) {
if (match >= 0) {
- UNLOCK_GLOBAL_MUTEX return KANOCELLS;
+ UNLOCK_GLOBAL_MUTEX;
+ return KANOCELLS;
} else
match = i;
}
}
if (match < 0) {
- UNLOCK_GLOBAL_MUTEX return KANOCELLS;
+ UNLOCK_GLOBAL_MUTEX;
+ return KANOCELLS;
}
code = rx_Init(0);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = ka_GetSecurity(service, token, &sc, &si);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
#ifdef AFS_PTHREAD_ENV
serverconns[0] =
*conn = 0;
code = ubik_ClientInit(serverconns, conn);
rxs_Release(sc);
- UNLOCK_GLOBAL_MUTEX if (code)
- return KAUBIKINIT;
+ UNLOCK_GLOBAL_MUTEX;
+ if (code)
+ return KAUBIKINIT;
return 0;
}
int si; /* security class index */
int i;
- LOCK_GLOBAL_MUTEX code = rx_Init(0);
+ LOCK_GLOBAL_MUTEX;
+ code = rx_Init(0);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = ka_GetSecurity(service, token, &sc, &si);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
for (i = 0; i < cellinfo->numServers; i++)
*conn = 0;
code = ubik_ClientInit(serverconns, conn);
rxs_Release(sc);
- UNLOCK_GLOBAL_MUTEX if (code)
- return KAUBIKINIT;
+ UNLOCK_GLOBAL_MUTEX;
+ if (code)
+ return KAUBIKINIT;
return 0;
}
int i;
struct afsconf_cell cellinfo; /* for cell auth server list */
- LOCK_GLOBAL_MUTEX code = ka_GetServers(cell, &cellinfo);
+ LOCK_GLOBAL_MUTEX;
+ code = ka_GetServers(cell, &cellinfo);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = rx_Init(0);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = ka_GetSecurity(service, token, &sc, &si);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
for (i = 0; i < cellinfo.numServers; i++)
*conn = 0;
code = ubik_ClientInit(serverconns, conn);
rxs_Release(sc);
- UNLOCK_GLOBAL_MUTEX if (code)
- return KAUBIKINIT;
+ UNLOCK_GLOBAL_MUTEX;
+ if (code)
+ return KAUBIKINIT;
return 0;
}
char *ans_label;
int version;
- LOCK_GLOBAL_MUTEX if ((code = des_key_sched(key, schedule))) {
- UNLOCK_GLOBAL_MUTEX return KABADKEY;
+ LOCK_GLOBAL_MUTEX;
+ if ((code = des_key_sched(key, schedule))) {
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADKEY;
}
if (service == KA_MAINTENANCE_SERVICE) {
req_label = KA_GETTGT_REQ_LABEL;
ans_label = KA_GETTGT_ANS_LABEL;
} else {
- UNLOCK_GLOBAL_MUTEX return KABADARGUMENT;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADARGUMENT;
}
request_time = time(0);
}
}
if (code) {
- UNLOCK_GLOBAL_MUTEX if ((code >= KAMINERROR) && (code <= KAMAXERROR))
- return code;
+ UNLOCK_GLOBAL_MUTEX;
+ if ((code >= KAMINERROR) && (code <= KAMAXERROR))
+ return code;
return KAUBIKCALL;
}
des_pcbc_encrypt(oanswer.SeqBody, oanswer.SeqBody, oanswer.SeqLen,
CheckTicketAnswer(&oanswer, request_time + 1, token, &caller,
0, ans_label, pwexpires);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
}
break;
if ((answer_old.time != request_time + 1)
|| (answer_old.ticket_len < MINKTCTICKETLEN)
|| (answer_old.ticket_len > MAXKTCTICKETLEN)) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
{
char *label = ((char *)answer_old.ticket) + answer_old.ticket_len;
if (strncmp(label, ans_label, sizeof(answer_old.label))) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
token->startTime = start;
token->endTime = end;
}
break;
default:
- UNLOCK_GLOBAL_MUTEX return KAINTERNALERROR;
+ UNLOCK_GLOBAL_MUTEX;
+ return KAINTERNALERROR;
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
afs_int32
int version;
afs_int32 pwexpires;
- LOCK_GLOBAL_MUTEX aticket.SeqLen = auth_token->ticketLen;
+ LOCK_GLOBAL_MUTEX;
+ aticket.SeqLen = auth_token->ticketLen;
aticket.SeqBody = auth_token->ticket;
code = des_key_sched(&auth_token->sessionKey, schedule);
if (code) {
- UNLOCK_GLOBAL_MUTEX return KABADKEY;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADKEY;
}
times.start = htonl(start);
}
}
if (code) {
- UNLOCK_GLOBAL_MUTEX if ((code >= KAMINERROR) && (code <= KAMAXERROR))
- return code;
+ UNLOCK_GLOBAL_MUTEX;
+ if ((code >= KAMINERROR) && (code <= KAMAXERROR))
+ return code;
return KAUBIKCALL;
}
CheckTicketAnswer(&oanswer, 0, token, 0, &server,
KA_GETTICKET_ANS_LABEL, &pwexpires);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
}
break;
sizeof(token->sessionKey));
if (tkt_CheckTimes(token->startTime, token->endTime, time(0)) < 0) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
if ((token->ticketLen < MINKTCTICKETLEN)
|| (token->ticketLen > MAXKTCTICKETLEN)) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
strings = answer_old.name;
len = strlen(strings); /* check client name */
if ((len < 1) || (len > MAXKTCNAMELEN)) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
strings += len + 1; /* check client instance */
len = strlen(strings);
if ((len < 0) || (len > MAXKTCNAMELEN)) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
strings += len + 1;
len = strlen(strings); /* check client cell */
if ((len < 0) || (len > MAXKTCNAMELEN)) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
strings += len + 1;
len = strlen(strings); /* check server name */
if ((len < 1) || (len > MAXKTCNAMELEN) || strcmp(name, strings)) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
strings += len + 1;
len = strlen(strings); /* check server instance */
if ((len < 0) || (len > MAXKTCNAMELEN) || strcmp(instance, strings)) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
strings += len + 1;
if ((strings - oanswer.SeqBody + token->ticketLen) - oanswer.SeqLen >=
ENCRYPTIONBLOCKSIZE) {
- UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KABADPROTOCOL;
}
memcpy(token->ticket, strings, token->ticketLen);
break;
default:
- UNLOCK_GLOBAL_MUTEX return KAINTERNALERROR;
+ UNLOCK_GLOBAL_MUTEX;
+ return KAINTERNALERROR;
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
afs_int32
{
afs_int32 code;
- LOCK_GLOBAL_MUTEX
+ LOCK_GLOBAL_MUTEX;
#if defined(AFS_S390_LINUX20_ENV) && !defined(AFS_S390X_LINUX20_ENV)
- code =
+ code =
ubik_Call_New(KAM_SetPassword, conn, 0, name, instance, 0, 0,
*newkey);
#else
- code =
+ code =
ubik_Call_New(KAM_SetPassword, conn, 0, name, instance, 0, *newkey);
#endif
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
char realm[MAXKTCREALMLEN];
afs_int32 code;
- LOCK_GLOBAL_MUTEX code = ka_CellToRealm(cell, realm, 0 /*local */ );
+ LOCK_GLOBAL_MUTEX;
+ code = ka_CellToRealm(cell, realm, 0 /*local */ );
if (code) /* just take his word for it */
strncpy(realm, cell, sizeof(realm));
else /* for backward compatibility */
StringToKey(str, realm, key);
else
Andrew_StringToKey(str, realm, key);
-UNLOCK_GLOBAL_MUTEX}
+ UNLOCK_GLOBAL_MUTEX;
+}
/* This prints out a prompt and reads a string from the terminal, turning off
echoing. If verify is requested it requests that the string be entered
char password[BUFSIZ];
afs_int32 code;
- LOCK_GLOBAL_MUTEX memset(key, 0, sizeof(struct ktc_encryptionKey));
+ LOCK_GLOBAL_MUTEX;
+ memset(key, 0, sizeof(struct ktc_encryptionKey));
code = read_pw_string(password, sizeof(password), prompt, verify);
if (code) {
- UNLOCK_GLOBAL_MUTEX return KAREADPW;
+ UNLOCK_GLOBAL_MUTEX;
+ return KAREADPW;
}
if (strlen(password) == 0) {
- UNLOCK_GLOBAL_MUTEX return KANULLPASSWORD;
+ UNLOCK_GLOBAL_MUTEX;
+ return KANULLPASSWORD;
}
ka_StringToKey(password, cell, key);
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
/* This performs the backslash quoting defined by AC_ParseLoginName. */
afs_int32 code;
static int inited = 0;
- LOCK_GLOBAL_MUTEX if (inited) {
- UNLOCK_GLOBAL_MUTEX return 0;
+ LOCK_GLOBAL_MUTEX;
+ if (inited) {
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
inited++;
initialize_U_error_table();
initialize_KTC_error_table();
initialize_ACFG_error_table();
code = ka_CellConfig(AFSDIR_CLIENT_ETC_DIRPATH);
- UNLOCK_GLOBAL_MUTEX if (code)
- return code;
+ UNLOCK_GLOBAL_MUTEX;
+ if (code)
+ return code;
return 0;
}
(keyCache[i].superseded == NEVERDATE);
info->kcInfo[j].keycksum = 0;
#if DEBUG_KEY_CACHE
- {
- int k;
- for (k = 0; k < sizeof(struct ktc_encryptionKey); k++)
- info->kcInfo[j].keycksum += ((char *)&keyCache[i].key)[k];
- }
+ {
+ int k;
+ for (k = 0; k < sizeof(struct ktc_encryptionKey); k++)
+ info->kcInfo[j].keycksum +=
+ ((char *)&keyCache[i].key)[k];
+ }
#endif
strcpy(principal, keyCache[i].name);
strcat(principal, ".");
strcpy(cell_name, afs_LclCellName);
return 0;
#else /* UKERNEL */
- LOCK_GLOBAL_MUTEX if (conf)
- afsconf_Close(conf);
+ LOCK_GLOBAL_MUTEX;
+ if (conf)
+ afsconf_Close(conf);
conf = afsconf_Open(dir);
if (!conf) {
- UNLOCK_GLOBAL_MUTEX return KANOCELLS;
+ UNLOCK_GLOBAL_MUTEX;
+ return KANOCELLS;
}
code = afsconf_GetLocalCell(conf, cell_name, sizeof(cell_name));
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
#endif /* UKERNEL */
}
{
int code;
- LOCK_GLOBAL_MUTEX if (conf) {
- UNLOCK_GLOBAL_MUTEX return cell_name;
+ LOCK_GLOBAL_MUTEX;
+ if (conf) {
+ UNLOCK_GLOBAL_MUTEX;
+ return cell_name;
}
#ifdef UKERNEL
conf = afs_cdir;
if (!conf || code) {
printf("** Can't determine local cell name!\n");
conf = 0;
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
#endif /* UKERNEL */
- UNLOCK_GLOBAL_MUTEX return cell_name;
+ UNLOCK_GLOBAL_MUTEX;
+ return cell_name;
}
int
char cellname[MAXKTCREALMLEN];
struct afsconf_cell cellinfo; /* storage for cell info */
- LOCK_GLOBAL_MUTEX ka_LocalCell(); /* initialize things */
+ LOCK_GLOBAL_MUTEX;
+ ka_LocalCell(); /* initialize things */
if (!conf) {
- UNLOCK_GLOBAL_MUTEX return KANOCELLS;
+ UNLOCK_GLOBAL_MUTEX;
+ return KANOCELLS;
}
if ((cell == 0) || (strlen(cell) == 0)) {
cell = lcstring(cellname, cell, sizeof(cellname));
code = afsconf_GetCellInfo(conf, cell, 0, &cellinfo);
if (code) {
- UNLOCK_GLOBAL_MUTEX return KANOCELL;
+ UNLOCK_GLOBAL_MUTEX;
+ return KANOCELL;
}
cell = cellinfo.name;
}
strcpy(fullCell, cell);
if (alocal)
*alocal = local;
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
int
{
int code;
- LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, realm, local);
+ LOCK_GLOBAL_MUTEX;
+ code = ka_ExpandCell(cell, realm, local);
ucstring(realm, realm, MAXKTCREALMLEN);
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = KAANSWERTOOLONG;
if (oanswer->MaxSeqLen <
- sizeof(struct ka_ticketAnswer) - 5 * MAXKTCNAMELEN - MAXKTCTICKETLEN + ticketLen)
+ sizeof(struct ka_ticketAnswer) - 5 * MAXKTCNAMELEN - MAXKTCTICKETLEN +
+ ticketLen)
return code;
answer = (struct ka_ticketAnswer *)oanswer->SeqBody;
case 0:
code = KAANSWERTOOLONG;
if (oanswer->MaxSeqLen <
- sizeof(struct ka_getTicketAnswer) - 5 * MAXKTCNAMELEN - MAXKTCTICKETLEN + ticketLen)
+ sizeof(struct ka_getTicketAnswer) - 5 * MAXKTCNAMELEN -
+ MAXKTCTICKETLEN + ticketLen)
goto abort;
answer = (struct ka_getTicketAnswer *)oanswer->SeqBody;
char *arock;
struct cmd_syndesc *as;
{
- char name[MAXKTCNAMELEN]="";
- char instance[MAXKTCNAMELEN]="";
- char cell[MAXKTCREALMLEN]="";
- char realm[MAXKTCREALMLEN]="";
+ char name[MAXKTCNAMELEN] = "";
+ char instance[MAXKTCNAMELEN] = "";
+ char cell[MAXKTCREALMLEN] = "";
+ char realm[MAXKTCREALMLEN] = "";
afs_int32 serverList[MAXSERVERS];
char *lcell; /* local cellname */
int code;
#include <mit-cpyright.h>
- /* #include <krb_conf.h> *//* removed 890221 */
+ /* #include <krb_conf.h> *//* removed 890221 */
#ifndef PROT_DEFS
#define PROT_DEFS
/* Routines to create and read packets may be found in prot.c */
- /* KTEXT create_auth_reply(); *//* removed 890221 */
- /* KTEXT create_death_packet(); *//* removed 890221 */
- /* KTEXT pkt_cipher(); *//* removed 890221 */
+ /* KTEXT create_auth_reply(); *//* removed 890221 */
+ /* KTEXT create_death_packet(); *//* removed 890221 */
+ /* KTEXT pkt_cipher(); *//* removed 890221 */
/* Message types , always leave lsb for byte order */
afs_int32
ka_GetAuthToken(char *name, char *instance, char *cell,
- struct ktc_encryptionKey *key, afs_int32 lifetime,
+ struct ktc_encryptionKey * key, afs_int32 lifetime,
afs_int32 * pwexpires)
{
afs_int32 code;
char realm[MAXKTCREALMLEN];
struct ktc_principal client, server;
- LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, cellname, 0 /*local */ );
+ LOCK_GLOBAL_MUTEX;
+ code = ka_ExpandCell(cell, cellname, 0 /*local */ );
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
cell = cellname;
/* get an unauthenticated connection to desired cell */
code = ka_AuthServerConn(cell, KA_AUTHENTICATION_SERVICE, 0, &conn);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code =
ka_Authenticate(name, instance, cell, conn,
KA_TICKET_GRANTING_SERVICE, key, now, now + lifetime,
&token, pwexpires);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = ubik_ClientDestroy(conn);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = ka_CellToRealm(cell, realm, 0 /*local */ );
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
strcpy(client.name, name);
strcpy(client.instance, instance);
strcpy(server.instance, realm);
strcpy(server.cell, cell);
code = ktc_SetToken(&server, &token, &client, 0);
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
afs_int32
char authDomain[MAXKTCREALMLEN];
int local;
- LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, cellname, 0 /*local */ );
+ LOCK_GLOBAL_MUTEX;
+ code = ka_ExpandCell(cell, cellname, 0 /*local */ );
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
cell = cellname;
code =
ktc_GetToken(&server, token, sizeof(struct ktc_token), &client);
if (!code) {
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
}
code = ka_CellToRealm(cell, realm, &local);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
/* get TGS ticket for proper realm */
}
if (code && local) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
} else if (code) {
/* here we invoke the inter-cell mechanism */
ktc_GetToken(&auth_server, &cell_token, sizeof(cell_token),
&client);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
/* get a connection to the local cell */
if ((code =
ka_AuthServerConn(localCell, KA_TICKET_GRANTING_SERVICE, 0,
&conn))) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
/* get foreign auth ticket */
if ((code =
client.instance, conn, now, now + lifetime,
&cell_token, "" /* local auth domain */ ,
&auth_token))) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = ubik_ClientDestroy(conn);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
conn = 0;
lcstring(auth_server.cell, localCell, sizeof(auth_server.cell));
ucstring(authDomain, localCell, sizeof(authDomain));
if ((code = ktc_SetToken(&auth_server, &auth_token, &client, 0))) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
}
if ((code =
ka_AuthServerConn(cell, KA_TICKET_GRANTING_SERVICE, 0, &conn))) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
if ((code =
ka_GetToken(name, instance, cell, client.name, client.instance, conn,
now, now + lifetime, &auth_token, authDomain, token))) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = ubik_ClientDestroy(conn);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
if ((code =
ktc_SetToken(&server, token, &client,
dosetpag ? AFS_SETTOK_SETPAG : 0))) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
afs_int32
struct ktc_token localToken;
char cellname[MAXKTCREALMLEN];
- LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, cellname, 0 /*local */ );
+ LOCK_GLOBAL_MUTEX;
+ code = ka_ExpandCell(cell, cellname, 0 /*local */ );
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
cell = cellname;
code =
ktc_GetToken(&server, token, sizeof(struct ktc_token), &client);
if (code == 0) {
- UNLOCK_GLOBAL_MUTEX return 0;
+ UNLOCK_GLOBAL_MUTEX;
+ return 0;
}
}
if ((name == 0) || (key == 0)) {
/* just lookup in cache don't get new one */
- UNLOCK_GLOBAL_MUTEX return KANOTICKET;
+ UNLOCK_GLOBAL_MUTEX;
+ return KANOTICKET;
}
/* get an unauthenticated connection to desired cell */
code = ka_AuthServerConn(cell, KA_AUTHENTICATION_SERVICE, 0, &conn);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code =
ka_Authenticate(name, instance, cell, conn, KA_MAINTENANCE_SERVICE,
key, now, now + lifetime, token, 0);
(void)ubik_ClientDestroy(conn);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
strcpy(client.name, name);
strcpy(client.instance, instance);
strncpy(client.cell, cell, sizeof(client.cell));
code = ktc_SetToken(&server, token, &client, 0);
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
char cellname[MAXKTCREALMLEN];
afs_int32 pwexpires;
- LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, cellname, 0 /*local */ );
+ LOCK_GLOBAL_MUTEX;
+ code = ka_ExpandCell(cell, cellname, 0 /*local */ );
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
cell = cellname;
/* get an unauthenticated connection to desired cell */
code = ka_AuthServerConn(cell, KA_AUTHENTICATION_SERVICE, 0, &conn);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code =
KA_TICKET_GRANTING_SERVICE, key, now,
now + MAXKTCTICKETLIFETIME, &token, &pwexpires);
if (code) {
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
code = ubik_ClientDestroy(conn);
- UNLOCK_GLOBAL_MUTEX return code;
+ UNLOCK_GLOBAL_MUTEX;
+ return code;
}
afs_int32
GetTickets(char *name, char *instance, char *realm,
- struct ktc_encryptionKey *key, Date lifetime,
+ struct ktc_encryptionKey * key, Date lifetime,
afs_int32 * pwexpires, afs_int32 flags)
{
afs_int32 code;
(void)fflush(stdout);
}
FD_ZERO(&readfds);
- FD_SET(f,&readfds);
+ FD_SET(f, &readfds);
errno = 0;
/* select - either recv is ready, or timeout */
/* see if timeout or error or wrong descriptor */
if (num_converted == 4) {
*serverAddress = (part1 << 24) | (part2 << 16) | (part3 << 8) | part4;
} else {
- LOCK_GLOBAL_MUTEX server = gethostbyname(serverName);
+ LOCK_GLOBAL_MUTEX;
+ server = gethostbyname(serverName);
if (server != NULL) {
memcpy((void *)serverAddress, (const void *)server->h_addr,
sizeof(serverAddress));
UNLOCK_GLOBAL_MUTEX;
goto fail_util_AdminServerAddressGetFromName;
}
- UNLOCK_GLOBAL_MUTEX}
+ UNLOCK_GLOBAL_MUTEX;
+ }
rc = 1;
fail_util_AdminServerAddressGetFromName:
* Iterate over the list and fill in the hostname of each of the servers
*/
- LOCK_GLOBAL_MUTEX for (iserv = 0; iserv < serv->total; iserv++) {
+ LOCK_GLOBAL_MUTEX;
+ for (iserv = 0; iserv < serv->total; iserv++) {
int addr = htonl(serv->server[iserv].serverAddress[0]);
host = gethostbyaddr((const char *)&addr, sizeof(int), AF_INET);
if (host != NULL) {
AFS_MAX_SERVER_NAME_LEN);
}
}
- UNLOCK_GLOBAL_MUTEX
- if (IteratorInit
+ UNLOCK_GLOBAL_MUTEX;
+ if (IteratorInit
(iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL, NULL,
&tst)) {
*iterationIdP = (void *)iter;
#ifdef AFS_PTHREAD_ENV
#include <assert.h>
#include <pthread.h>
-#define LOCK_LOCK(A) assert(pthread_mutex_lock(&(A)->mutex) == 0);
-#define LOCK_UNLOCK(A) assert(pthread_mutex_unlock(&(A)->mutex) == 0);
+#define LOCK_LOCK(A) assert(pthread_mutex_lock(&(A)->mutex) == 0)
+#define LOCK_UNLOCK(A) assert(pthread_mutex_unlock(&(A)->mutex) == 0)
#else /* AFS_PTHREAD_ENV */
#define LOCK_LOCK(A)
#define LOCK_UNLOCK(A)
#define ObtainReadLock(lock)\
BEGINMAC \
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
if (!((lock)->excl_locked & WRITE_LOCK) && !(lock)->wait_states)\
(lock) -> readers_reading++;\
else\
Afs_Lock_Obtain(lock, READ_LOCK); \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#define ObtainReadLockNoBlock(lock, code)\
BEGINMAC \
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
if (!((lock)->excl_locked & WRITE_LOCK) && !(lock)->wait_states) {\
(lock) -> readers_reading++;\
code = 0;\
}\
else\
code = -1; \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#define ObtainWriteLock(lock)\
BEGINMAC \
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
if (!(lock)->excl_locked && !(lock)->readers_reading)\
(lock) -> excl_locked = WRITE_LOCK;\
else\
Afs_Lock_Obtain(lock, WRITE_LOCK); \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#define ObtainWriteLockNoBlock(lock, code)\
BEGINMAC \
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
if (!(lock)->excl_locked && !(lock)->readers_reading) {\
(lock) -> excl_locked = WRITE_LOCK;\
code = 0;\
}\
else\
code = -1; \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#define ObtainSharedLock(lock)\
BEGINMAC \
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
if (!(lock)->excl_locked && !(lock)->wait_states)\
(lock) -> excl_locked = SHARED_LOCK;\
else\
Afs_Lock_Obtain(lock, SHARED_LOCK); \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#define ObtainSharedLockNoBlock(lock, code)\
BEGINMAC \
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
if (!(lock)->excl_locked && !(lock)->wait_states) {\
(lock) -> excl_locked = SHARED_LOCK;\
code = 0;\
}\
else\
code = -1; \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#define BoostSharedLock(lock)\
BEGINMAC \
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
if (!(lock)->readers_reading)\
(lock)->excl_locked = WRITE_LOCK;\
else\
Afs_Lock_Obtain(lock, BOOSTED_LOCK); \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
/* this must only be called with a WRITE or boosted SHARED lock! */
#define UnboostSharedLock(lock)\
BEGINMAC\
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
(lock)->excl_locked = SHARED_LOCK; \
if((lock)->wait_states) \
Afs_Lock_ReleaseR(lock); \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#ifdef notdef
#define ReleaseReadLock(lock)\
BEGINMAC\
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
if (!--(lock)->readers_reading && (lock)->wait_states)\
Afs_Lock_ReleaseW(lock) ; \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#define ReleaseWriteLock(lock)\
BEGINMAC\
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
(lock)->excl_locked &= ~WRITE_LOCK;\
if ((lock)->wait_states) Afs_Lock_ReleaseR(lock);\
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#ifdef notdef
/* can be used on shared or boosted (write) locks */
#define ReleaseSharedLock(lock)\
BEGINMAC\
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
(lock)->excl_locked &= ~(SHARED_LOCK | WRITE_LOCK);\
if ((lock)->wait_states) Afs_Lock_ReleaseR(lock);\
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
#ifdef notdef
/* convert a write lock to a read lock */
#define ConvertWriteToReadLock(lock)\
BEGINMAC\
- LOCK_LOCK(lock) \
+ LOCK_LOCK(lock); \
(lock)->excl_locked &= ~WRITE_LOCK;\
(lock)->readers_reading++;\
if ((lock)->wait_states & READ_LOCK) \
Afs_Lock_WakeupR(lock) ; \
- LOCK_UNLOCK(lock) \
+ LOCK_UNLOCK(lock); \
ENDMAC
/* I added this next macro to make sure it is safe to nuke a lock -- Mike K. */
pthread_once_t rx_once_init = PTHREAD_ONCE_INIT;
#define INIT_PTHREAD_LOCKS \
-assert(pthread_once(&rx_once_init, rxi_InitPthread)==0);
+assert(pthread_once(&rx_once_init, rxi_InitPthread)==0)
/*
* The rx_stats_mutex mutex protects the following global variables:
* rxi_dataQuota
* rx_epoch
*/
-#define LOCK_EPOCH assert(pthread_mutex_lock(&epoch_mutex)==0);
-#define UNLOCK_EPOCH assert(pthread_mutex_unlock(&epoch_mutex)==0);
+#define LOCK_EPOCH assert(pthread_mutex_lock(&epoch_mutex)==0)
+#define UNLOCK_EPOCH assert(pthread_mutex_unlock(&epoch_mutex)==0)
#else
#define LOCK_EPOCH
#define UNLOCK_EPOCH
void
rx_SetEpoch(afs_uint32 epoch)
{
- LOCK_EPOCH rx_epoch = epoch;
-UNLOCK_EPOCH}
+ LOCK_EPOCH;
+ rx_epoch = epoch;
+ UNLOCK_EPOCH;
+}
/* Initialize rx. A port number may be mentioned, in which case this
* becomes the default port number for any service installed later.
* rxinit_status
*/
-#define LOCK_RX_INIT assert(pthread_mutex_lock(&rx_init_mutex)==0);
-#define UNLOCK_RX_INIT assert(pthread_mutex_unlock(&rx_init_mutex)==0);
+#define LOCK_RX_INIT assert(pthread_mutex_lock(&rx_init_mutex)==0)
+#define UNLOCK_RX_INIT assert(pthread_mutex_unlock(&rx_init_mutex)==0)
#else
#define LOCK_RX_INIT
#define UNLOCK_RX_INIT
#endif
-int
+int
rx_InitHost(u_int host, u_int port)
{
#ifdef KERNEL
SPLVAR;
- INIT_PTHREAD_LOCKS LOCK_RX_INIT if (rxinit_status == 0) {
+ INIT_PTHREAD_LOCKS;
+ LOCK_RX_INIT;
+ if (rxinit_status == 0) {
tmp_status = rxinit_status;
- UNLOCK_RX_INIT return tmp_status; /* Already started; return previous error code. */
+ UNLOCK_RX_INIT;
+ return tmp_status; /* Already started; return previous error code. */
}
#ifdef AFS_NT40_ENV
if (afs_winsockInit() < 0)
rx_socket = rxi_GetHostUDPSocket(host, (u_short) port);
if (rx_socket == OSI_NULLSOCKET) {
- UNLOCK_RX_INIT return RX_ADDRINUSE;
+ UNLOCK_RX_INIT;
+ return RX_ADDRINUSE;
}
#ifdef RX_ENABLE_LOCKS
#ifdef RX_LOCKS_DB
AFS_RXGUNLOCK();
USERPRI;
tmp_status = rxinit_status = 0;
- UNLOCK_RX_INIT return tmp_status;
+ UNLOCK_RX_INIT;
+ return tmp_status;
}
-int rx_Init(u_int port)
+int
+rx_Init(u_int port)
{
return rx_InitHost(htonl(INADDR_ANY), port);
}
{
register struct rx_connection **conn_ptr, **conn_end;
- INIT_PTHREAD_LOCKS LOCK_RX_INIT if (rxinit_status == 1) {
- UNLOCK_RX_INIT return; /* Already shutdown. */
+ INIT_PTHREAD_LOCKS;
+ LOCK_RX_INIT;
+ if (rxinit_status == 1) {
+ UNLOCK_RX_INIT;
+ return; /* Already shutdown. */
}
rxi_DeleteCachedConnections();
if (rx_connHashTable) {
rxi_flushtrace();
rxinit_status = 1;
-UNLOCK_RX_INIT}
+ UNLOCK_RX_INIT;
+}
#endif
/* if we wakeup packet waiter too often, can get in loop with two
if (type == RX_CLIENT_CONNECTION && pp->port == port)
break;
/* So what happens when it's a callback connection? */
- if (/*type == RX_CLIENT_CONNECTION &&*/ (conn->epoch & 0x80000000))
+ if ( /*type == RX_CLIENT_CONNECTION && */
+ (conn->epoch & 0x80000000))
break;
}
if (!flag) {
* counter
*/
-#define LOCK_RX_DEBUG assert(pthread_mutex_lock(&rx_debug_mutex)==0);
-#define UNLOCK_RX_DEBUG assert(pthread_mutex_unlock(&rx_debug_mutex)==0);
+#define LOCK_RX_DEBUG assert(pthread_mutex_lock(&rx_debug_mutex)==0)
+#define UNLOCK_RX_DEBUG assert(pthread_mutex_unlock(&rx_debug_mutex)==0)
#else
#define LOCK_RX_DEBUG
#define UNLOCK_RX_DEBUG
register char *tp;
endTime = time(0) + 20; /* try for 20 seconds */
- LOCK_RX_DEBUG counter++;
- UNLOCK_RX_DEBUG tp = &tbuffer[sizeof(struct rx_header)];
+ LOCK_RX_DEBUG;
+ counter++;
+ UNLOCK_RX_DEBUG;
+ tp = &tbuffer[sizeof(struct rx_header)];
taddr.sin_family = AF_INET;
taddr.sin_port = remotePort;
taddr.sin_addr.s_addr = remoteAddr;
tv.tv_sec = 1;
tv.tv_usec = 0;
code = select(socket + 1, &imask, 0, 0, &tv);
- if (code == 1 && FD_ISSET(socket,&imask)) {
+ if (code == 1 && FD_ISSET(socket, &imask)) {
/* now receive a packet */
faddrLen = sizeof(struct sockaddr_in);
code =
recvfrom(socket, tbuffer, sizeof(tbuffer), 0,
(struct sockaddr *)&faddr, &faddrLen);
- if (code > 0) {
- memcpy(&theader, tbuffer, sizeof(struct rx_header));
- if (counter == ntohl(theader.callNumber))
- break;
- }
+ if (code > 0) {
+ memcpy(&theader, tbuffer, sizeof(struct rx_header));
+ if (counter == ntohl(theader.callNumber))
+ break;
+ }
}
/* see if we've timed out */
register struct rx_serverQueueEntry *sq;
#endif /* KERNEL */
- LOCK_RX_INIT if (rxinit_status == 1) {
- UNLOCK_RX_INIT return; /* Already shutdown. */
+ LOCK_RX_INIT;
+ if (rxinit_status == 1) {
+ UNLOCK_RX_INIT;
+ return; /* Already shutdown. */
}
#ifndef KERNEL
rx_port = 0;
MUTEX_EXIT(&rx_stats_mutex);
rxinit_status = 1;
-UNLOCK_RX_INIT}
+ UNLOCK_RX_INIT;
+}
#ifdef RX_ENABLE_LOCKS
void
#include <winbase.h>
#include "rx_clock.h"
-void clock_UpdateTime(void); /* forward reference */
+void clock_UpdateTime(void); /* forward reference */
struct clock clock_now; /* The last elapsed time ready by clock_GetTimer */
clock_UnInit(void)
{
clockInitialized = 0;
- return 0;
+ return 0;
}
#endif
*/
pthread_mutex_t rxi_connCacheMutex;
-#define LOCK_CONN_CACHE assert(pthread_mutex_lock(&rxi_connCacheMutex)==0);
-#define UNLOCK_CONN_CACHE assert(pthread_mutex_unlock(&rxi_connCacheMutex)==0);
+#define LOCK_CONN_CACHE assert(pthread_mutex_lock(&rxi_connCacheMutex)==0)
+#define UNLOCK_CONN_CACHE assert(pthread_mutex_unlock(&rxi_connCacheMutex)==0)
#else
#define LOCK_CONN_CACHE
#define UNLOCK_CONN_CACHE
* increase the frequency of cache hits.
*/
- LOCK_CONN_CACHE if (!rxi_FindCachedConnection(parts, conn)) {
+ LOCK_CONN_CACHE;
+ if (!rxi_FindCachedConnection(parts, conn)) {
/*
* Create a new connection and enter it in the cache
*/
error = 1;
}
}
- UNLOCK_CONN_CACHE return error;
+ UNLOCK_CONN_CACHE;
+ return error;
}
/*
{
cache_entry_p cacheConn, nCacheConn;
- LOCK_CONN_CACHE
- for (queue_Scan
- (&rxi_connectionCache, cacheConn, nCacheConn, cache_entry)) {
+ LOCK_CONN_CACHE;
+ for (queue_Scan(&rxi_connectionCache, cacheConn, nCacheConn, cache_entry)) {
if (!cacheConn)
break;
queue_Remove(cacheConn);
rxi_DestroyConnection(cacheConn->conn);
free(cacheConn);
}
-UNLOCK_CONN_CACHE}
+ UNLOCK_CONN_CACHE;
+}
/*
* External functions
{
cache_entry_p cacheConn, nCacheConn;
- LOCK_CONN_CACHE
- for (queue_Scan
- (&rxi_connectionCache, cacheConn, nCacheConn, cache_entry)) {
+ LOCK_CONN_CACHE;
+ for (queue_Scan(&rxi_connectionCache, cacheConn, nCacheConn, cache_entry)) {
if (conn == cacheConn->conn) {
cacheConn->inUse--;
/*
break;
}
}
-UNLOCK_CONN_CACHE}
+ UNLOCK_CONN_CACHE;
+}
#include <assert.h>
pthread_mutex_t rx_event_mutex;
-#define LOCK_EV_INIT assert(pthread_mutex_lock(&rx_event_mutex)==0);
-#define UNLOCK_EV_INIT assert(pthread_mutex_unlock(&rx_event_mutex)==0);
+#define LOCK_EV_INIT assert(pthread_mutex_lock(&rx_event_mutex)==0)
+#define UNLOCK_EV_INIT assert(pthread_mutex_unlock(&rx_event_mutex)==0)
#else
#define LOCK_EV_INIT
#define UNLOCK_EV_INIT
void
rxevent_Init(int nEvents, void (*scheduler) (void))
{
- LOCK_EV_INIT if (rxevent_initialized) {
- UNLOCK_EV_INIT return;
+ LOCK_EV_INIT;
+ if (rxevent_initialized) {
+ UNLOCK_EV_INIT;
+ return;
}
MUTEX_INIT(&rxevent_lock, "rxevent_lock", MUTEX_DEFAULT, 0);
clock_Init();
rxevent_initialized = 1;
clock_Zero(&rxevent_nextRaiseEvents);
rxevent_raiseScheduled = 0;
-UNLOCK_EV_INIT}
+ UNLOCK_EV_INIT;
+}
/* Create and initialize new epoch structure */
struct rxepoch *
{
struct xfreelist *xp, *nxp;
- LOCK_EV_INIT if (!rxevent_initialized) {
- UNLOCK_EV_INIT return;
+ LOCK_EV_INIT;
+ if (!rxevent_initialized) {
+ UNLOCK_EV_INIT;
+ return;
}
rxevent_initialized = 0;
- UNLOCK_EV_INIT MUTEX_DESTROY(&rxevent_lock);
+ UNLOCK_EV_INIT;
+ MUTEX_DESTROY(&rxevent_lock);
#if defined(AFS_AIX32_ENV) && defined(KERNEL)
/* Everything is freed in afs_osinet.c */
#else
memset((void *)mtus, 0, sizeof(mtus));
for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) {
- if (!afs_cb_interface.mtu[i])
+ if (!afs_cb_interface.mtu[i])
afs_cb_interface.mtu[i] = htonl(1500);
rxmtu = (ntohl(afs_cb_interface.mtu[i]) - RX_IPUDP_SIZE);
ifinaddr = ntohl(afs_cb_interface.addr_in[i]);
#if defined(AFS_HPUX102_ENV)
#if defined(AFS_HPUX110_ENV)
/* we need a file associated with the socket so sosend in NetSend
- will not fail */
+ * will not fail */
/* blocking socket */
code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0, 0);
fp = falloc();
- if (!fp) goto bad;
+ if (!fp)
+ goto bad;
fp->f_flag = FREAD | FWRITE;
fp->f_type = DTYPE_SOCKET;
- fp->f_ops = &socketops;
+ fp->f_ops = &socketops;
- fp->f_data = (void *) newSocket;
+ fp->f_data = (void *)newSocket;
newSocket->so_fp = (void *)fp;
#else /* AFS_HPUX110_ENV */
#endif
#ifdef AFS_HPUX110_ENV
if (asocket->so_fp) {
- struct file * fp = asocket->so_fp;
+ struct file *fp = asocket->so_fp;
#if !defined(AFS_HPUX1123_ENV)
/* 11.23 still has falloc, but not FPENTRYFREE !
- so for now if we shutdown, we will waist a file
- structure */
+ * so for now if we shutdown, we will waist a file
+ * structure */
FPENTRYFREE(fp);
asocket->so_fp = NULL;
#endif
#include <assert.h>
pthread_mutex_t osi_malloc_mutex;
-#define LOCK_MALLOC_STATS assert(pthread_mutex_lock(&osi_malloc_mutex)==0);
-#define UNLOCK_MALLOC_STATS assert(pthread_mutex_unlock(&osi_malloc_mutex)==0);
+#define LOCK_MALLOC_STATS assert(pthread_mutex_lock(&osi_malloc_mutex)==0)
+#define UNLOCK_MALLOC_STATS assert(pthread_mutex_unlock(&osi_malloc_mutex)==0)
#else
#define LOCK_MALLOC_STATS
#define UNLOCK_MALLOC_STATS
*/
if (x == 0)
return (char *)&memZero;
- LOCK_MALLOC_STATS osi_alloccnt++;
+ LOCK_MALLOC_STATS;
+ osi_alloccnt++;
osi_allocsize += x;
- UNLOCK_MALLOC_STATS return (char *)(mem_alloc(x));
+ UNLOCK_MALLOC_STATS;
+ return (char *)(mem_alloc(x));
}
int
{
if ((x == &memZero) || !x)
return 0;
- LOCK_MALLOC_STATS osi_alloccnt--;
+ LOCK_MALLOC_STATS;
+ osi_alloccnt--;
osi_allocsize -= size;
- UNLOCK_MALLOC_STATS mem_free(x, size);
+ UNLOCK_MALLOC_STATS;
+ mem_free(x, size);
return 0;
}
#endif
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.noPacketOnRead++;
MUTEX_EXIT(&rx_stats_mutex);
- }
- else {
+ } else {
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.bogusPacketOnRead++;
rx_stats.bogusHost = from.sin_addr.s_addr;
assert(p != NULL);
- dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d",
- deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1],
- peer->host, peer->port, p->header.serial, p->header.epoch,
- p->header.cid, p->header.callNumber, p->header.seq, p->header.flags,
- (int)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
+ dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (int)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
#endif
MUTEX_ENTER(&rx_stats_mutex);
next.sec = 30; /* Time to sleep if there are no events scheduled */
next.usec = 0;
clock_GetTime(&cv);
- rxevent_RaiseEvents(&next);
+ rxevent_RaiseEvents(&next);
assert(pthread_mutex_lock(&event_handler_mutex) == 0);
if (rx_pthread_event_rescheduled) {
*/
pthread_mutex_t rx_if_init_mutex;
-#define LOCK_IF_INIT assert(pthread_mutex_lock(&rx_if_init_mutex)==0);
-#define UNLOCK_IF_INIT assert(pthread_mutex_unlock(&rx_if_init_mutex)==0);
+#define LOCK_IF_INIT assert(pthread_mutex_lock(&rx_if_init_mutex)==0)
+#define UNLOCK_IF_INIT assert(pthread_mutex_unlock(&rx_if_init_mutex)==0)
/*
* The rx_if_mutex mutex protects the following global variables:
*/
pthread_mutex_t rx_if_mutex;
-#define LOCK_IF assert(pthread_mutex_lock(&rx_if_mutex)==0);
-#define UNLOCK_IF assert(pthread_mutex_unlock(&rx_if_mutex)==0);
+#define LOCK_IF assert(pthread_mutex_lock(&rx_if_mutex)==0)
+#define UNLOCK_IF assert(pthread_mutex_unlock(&rx_if_mutex)==0)
#else
#define LOCK_IF_INIT
#define UNLOCK_IF_INIT
void
rx_GetIFInfo(void)
{
- LOCK_IF_INIT if (Inited) {
- UNLOCK_IF_INIT return;
+ LOCK_IF_INIT;
+ if (Inited) {
+ UNLOCK_IF_INIT;
+ return;
} else {
u_int maxsize;
u_int rxsize;
afs_uint32 i;
Inited = 1;
- UNLOCK_IF_INIT rxi_numNetAddrs = ADDRSPERSITE;
+ UNLOCK_IF_INIT;
+ rxi_numNetAddrs = ADDRSPERSITE;
- LOCK_IF(void) syscfg_GetIFInfo(&rxi_numNetAddrs, rxi_NetAddrs,
- myNetMasks, myNetMTUs, myNetFlags);
+ LOCK_IF;
+ (void)syscfg_GetIFInfo(&rxi_numNetAddrs, rxi_NetAddrs,
+ myNetMasks, myNetMTUs, myNetFlags);
for (i = 0; i < rxi_numNetAddrs; i++) {
rxsize = rxi_AdjustIfMTU(myNetMTUs[i] - RX_IPUDP_SIZE);
}
}
- UNLOCK_IF ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
+ UNLOCK_IF;
+ ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
if (ncbufs > 0) {
ncbufs = ncbufs / RX_CBUFFERSIZE;
npackets = rx_initSendWindow - 1;
struct sockaddr_in *a;
#endif /* AFS_DJGPP_ENV */
- LOCK_IF_INIT if (Inited) {
- UNLOCK_IF_INIT return;
+ LOCK_IF_INIT;
+ if (Inited) {
+ UNLOCK_IF_INIT;
+ return;
}
Inited = 1;
- UNLOCK_IF_INIT LOCK_IF rxi_numNetAddrs = 0;
+ UNLOCK_IF_INIT;
+ LOCK_IF;
+ rxi_numNetAddrs = 0;
memset(rxi_NetAddrs, 0, sizeof(rxi_NetAddrs));
memset(myNetFlags, 0, sizeof(myNetFlags));
memset(myNetMTUs, 0, sizeof(myNetMTUs));
memset(myNetMasks, 0, sizeof(myNetMasks));
- UNLOCK_IF s = socket(AF_INET, SOCK_DGRAM, 0);
+ UNLOCK_IF;
+ s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
return;
return;
}
- LOCK_IF
+ LOCK_IF;
#ifdef AFS_AIX41_ENV
#define size(p) MAX((p).sa_len, sizeof(p))
- cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
+ cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
for (cp = buf; cp < cplim;
cp += sizeof(ifr->ifr_name) + MAX(a->sin_len, sizeof(*a))) {
if (rxi_numNetAddrs >= ADDRSPERSITE)
ifr = (struct ifreq *)cp;
#else
- len = ifc.ifc_len / sizeof(struct ifreq);
+ len = ifc.ifc_len / sizeof(struct ifreq);
if (len > ADDRSPERSITE)
len = ADDRSPERSITE;
++rxi_numNetAddrs;
}
}
- UNLOCK_IF close(s);
+ UNLOCK_IF;
+ close(s);
/* have to allocate at least enough to allow a single packet to reach its
* maximum size, so ReadPacket will work. Allocate enough for a couple
- LOCK_IF_INIT if (!Inited) {
- UNLOCK_IF_INIT
- /*
- * there's a race here since more than one thread could call
- * rx_GetIFInfo. The race stops in rx_GetIFInfo.
- */
- rx_GetIFInfo();
+ LOCK_IF_INIT;
+ if (!Inited) {
+ UNLOCK_IF_INIT;
+ /*
+ * there's a race here since more than one thread could call
+ * rx_GetIFInfo. The race stops in rx_GetIFInfo.
+ */
+ rx_GetIFInfo();
} else {
- UNLOCK_IF_INIT}
+ UNLOCK_IF_INIT;
+ }
#ifdef ADAPT_MTU
/* try to second-guess IP, and identify which link is most likely to
* pp->burstSize pp->burst pp->burstWait.sec pp->burstWait.usec
* pp->timeout.usec */
- LOCK_IF for (ix = 0; ix < rxi_numNetAddrs; ++ix) {
+ LOCK_IF;
+ for (ix = 0; ix < rxi_numNetAddrs; ++ix) {
if ((rxi_NetAddrs[ix] & myNetMasks[ix]) == (ppaddr & myNetMasks[ix])) {
#ifdef IFF_POINTOPOINT
if (myNetFlags[ix] & IFF_POINTOPOINT)
pp->ifMTU = MIN(rx_MyMaxSendSize, rxmtu);
}
}
- UNLOCK_IF if (!pp->ifMTU) { /* not local */
+ UNLOCK_IF;
+ if (!pp->ifMTU) { /* not local */
pp->timeout.sec = 3;
pp->ifMTU = MIN(rx_MyMaxSendSize, RX_REMOTE_PACKET_SIZE);
}
/* Override max MTU. If rx_SetNoJumbo is called, it must be
called before calling rx_SetMaxMTU since SetNoJumbo clobbers rx_maxReceiveSize */
-void rx_SetMaxMTU(int mtu)
+void
+rx_SetMaxMTU(int mtu)
{
- rx_MyMaxSendSize = rx_maxReceiveSizeUser = rx_maxReceiveSize = mtu;
+ rx_MyMaxSendSize = rx_maxReceiveSizeUser = rx_maxReceiveSize = mtu;
}
-
#define AFS_RXGUNLOCK()
#ifndef UKERNEL
/* Defined in rx/UKERNEL/rx_kmutex.h */
-#define ISAFS_GLOCK()
-#define ISAFS_RXGLOCK()
+#define ISAFS_GLOCK()
+#define ISAFS_RXGLOCK()
#endif
#define AFS_ASSERT_RXGLOCK()
/* Some "operating-system independent" stuff, for the user mode implementation */
code -= size;
} else {
#ifdef AFS_NT40_ENV
- if (code == SOCKET_ERROR)
- code = WSAGetLastError();
- if (code == WSAEWOULDBLOCK)
- errno = WSAEWOULDBLOCK;
- else
- errno = EIO;
+ if (code == SOCKET_ERROR)
+ code = WSAGetLastError();
+ if (code == WSAEWOULDBLOCK)
+ errno = WSAEWOULDBLOCK;
+ else
+ errno = EIO;
#endif /* AFS_NT40_ENV */
code = -1;
}
case WSAENOBUFS:
errno = 0;
break;
- case WSAEWOULDBLOCK:
- errno = WSAEWOULDBLOCK;
- break;
+ case WSAEWOULDBLOCK:
+ errno = WSAEWOULDBLOCK;
+ break;
default:
errno = EIO;
break;
printf("getconn call failed with code %d\n", code);
break;
}
- if (tconn.cid == (afs_int32)0xffffffff) {
+ if (tconn.cid == (afs_int32) 0xffffffff) {
printf("Done.\n");
break;
}
return (TRUE);
}
if (xdrs->x_op == XDR_ENCODE) {
- high = (afs_int32)(*ulp >> 32);
- low = (afs_uint32)(*ulp & 0xFFFFFFFFL);
+ high = (afs_int32) (*ulp >> 32);
+ low = (afs_uint32) (*ulp & 0xFFFFFFFFL);
if (!XDR_PUTINT32(xdrs, (afs_int32 *) & high))
return (FALSE);
return (XDR_PUTINT32(xdrs, (afs_int32 *) & low));
return (TRUE);
}
if (xdrs->x_op == XDR_ENCODE) {
- high = (afs_uint32)(*ulp >> 32);
- low = (afs_uint32)(*ulp & 0xFFFFFFFFL);
+ high = (afs_uint32) (*ulp >> 32);
+ low = (afs_uint32) (*ulp & 0xFFFFFFFFL);
if (!XDR_PUTINT32(xdrs, (afs_uint32 *) & high))
return (FALSE);
return (XDR_PUTINT32(xdrs, (afs_uint32 *) & low));
fc_ecb_encrypt(afs_uint32 * in, afs_uint32 * out, fc_KeySchedule sched,
int encrypt)
{
- LOCK_RXKAD_STATS rxkad_stats.fc_encrypts[encrypt]++;
- UNLOCK_RXKAD_STATS if (encrypt)
- fc_ecb_enc(in[0], in[1], out, sched);
+ LOCK_RXKAD_STATS;
+ rxkad_stats.fc_encrypts[encrypt]++;
+ UNLOCK_RXKAD_STATS;
+ if (encrypt)
+ fc_ecb_enc(in[0], in[1], out, sched);
else
fc_ecb_dec(in[0], in[1], out, sched);
return 0;
ROT56R(hi, lo, 11);
*sched++ = EFF_NTOHL(lo);
#endif
- LOCK_RXKAD_STATS rxkad_stats.fc_key_scheds++;
- UNLOCK_RXKAD_STATS return 0;
+ LOCK_RXKAD_STATS;
+ rxkad_stats.fc_key_scheds++;
+ UNLOCK_RXKAD_STATS;
+ return 0;
}
/*
obj = rx_SecurityObjectOf(rx_connection_not_used);
tp = (struct rxkad_cprivate *)obj->privateData;
- LOCK_RXKAD_STATS rxkad_stats.bytesEncrypted[rxkad_TypeIndex(tp->type)] +=
- len;
- UNLOCK_RXKAD_STATS {
+ LOCK_RXKAD_STATS;
+ rxkad_stats.bytesEncrypted[rxkad_TypeIndex(tp->type)] += len;
+ UNLOCK_RXKAD_STATS;
+ {
/* What is this good for?
* It turns out that the security header for auth_enc is of
* size 8 bytes and the last 4 bytes are defined to be 0!
obj = rx_SecurityObjectOf(rx_connection_not_used);
tp = (struct rxkad_cprivate *)obj->privateData;
- LOCK_RXKAD_STATS rxkad_stats.bytesDecrypted[rxkad_TypeIndex(tp->type)] +=
- len;
- UNLOCK_RXKAD_STATS memcpy(ivec, iv, sizeof(ivec)); /* Must use copy of iv */
+ LOCK_RXKAD_STATS;
+ rxkad_stats.bytesDecrypted[rxkad_TypeIndex(tp->type)] += len;
+ UNLOCK_RXKAD_STATS;
+ memcpy(ivec, iv, sizeof(ivec)); /* Must use copy of iv */
for (frag = &packet->wirevec[1]; len > 0; frag++) {
int iov_len = frag->iov_len;
afs_uint32 *iov_bas = (afs_uint32 *) frag->iov_base;
#endif
static inline afs_uint32
-cshift (afs_uint32 x, unsigned int n)
+cshift(afs_uint32 x, unsigned int n)
{
x = CRAYFIX(x);
return CRAYFIX((x << n) | (x >> (32 - n)));
#define X data
void
-MD4_Init (struct md4 *m)
+MD4_Init(struct md4 *m)
{
- m->sz[0] = 0;
- m->sz[1] = 0;
- D = 0x10325476;
- C = 0x98badcfe;
- B = 0xefcdab89;
- A = 0x67452301;
+ m->sz[0] = 0;
+ m->sz[1] = 0;
+ D = 0x10325476;
+ C = 0x98badcfe;
+ B = 0xefcdab89;
+ A = 0x67452301;
}
#define F(x,y,z) CRAYFIX((x & y) | (~x & z))
#define DO3(a,b,c,d,k,s,i) DOIT(a,b,c,d,k,s,i,H)
static inline void
-calc (struct md4 *m, afs_uint32 *data)
+calc(struct md4 *m, afs_uint32 * data)
{
- afs_uint32 AA, BB, CC, DD;
-
- AA = A;
- BB = B;
- CC = C;
- DD = D;
-
- /* Round 1 */
-
- DO1(A,B,C,D,0,3,0);
- DO1(D,A,B,C,1,7,0);
- DO1(C,D,A,B,2,11,0);
- DO1(B,C,D,A,3,19,0);
-
- DO1(A,B,C,D,4,3,0);
- DO1(D,A,B,C,5,7,0);
- DO1(C,D,A,B,6,11,0);
- DO1(B,C,D,A,7,19,0);
-
- DO1(A,B,C,D,8,3,0);
- DO1(D,A,B,C,9,7,0);
- DO1(C,D,A,B,10,11,0);
- DO1(B,C,D,A,11,19,0);
-
- DO1(A,B,C,D,12,3,0);
- DO1(D,A,B,C,13,7,0);
- DO1(C,D,A,B,14,11,0);
- DO1(B,C,D,A,15,19,0);
-
- /* Round 2 */
-
- DO2(A,B,C,D,0,3,0x5A827999);
- DO2(D,A,B,C,4,5,0x5A827999);
- DO2(C,D,A,B,8,9,0x5A827999);
- DO2(B,C,D,A,12,13,0x5A827999);
-
- DO2(A,B,C,D,1,3,0x5A827999);
- DO2(D,A,B,C,5,5,0x5A827999);
- DO2(C,D,A,B,9,9,0x5A827999);
- DO2(B,C,D,A,13,13,0x5A827999);
-
- DO2(A,B,C,D,2,3,0x5A827999);
- DO2(D,A,B,C,6,5,0x5A827999);
- DO2(C,D,A,B,10,9,0x5A827999);
- DO2(B,C,D,A,14,13,0x5A827999);
-
- DO2(A,B,C,D,3,3,0x5A827999);
- DO2(D,A,B,C,7,5,0x5A827999);
- DO2(C,D,A,B,11,9,0x5A827999);
- DO2(B,C,D,A,15,13,0x5A827999);
-
- /* Round 3 */
-
- DO3(A,B,C,D,0,3,0x6ED9EBA1);
- DO3(D,A,B,C,8,9,0x6ED9EBA1);
- DO3(C,D,A,B,4,11,0x6ED9EBA1);
- DO3(B,C,D,A,12,15,0x6ED9EBA1);
-
- DO3(A,B,C,D,2,3,0x6ED9EBA1);
- DO3(D,A,B,C,10,9,0x6ED9EBA1);
- DO3(C,D,A,B,6,11,0x6ED9EBA1);
- DO3(B,C,D,A,14,15,0x6ED9EBA1);
-
- DO3(A,B,C,D,1,3,0x6ED9EBA1);
- DO3(D,A,B,C,9,9,0x6ED9EBA1);
- DO3(C,D,A,B,5,11,0x6ED9EBA1);
- DO3(B,C,D,A,13,15,0x6ED9EBA1);
-
- DO3(A,B,C,D,3,3,0x6ED9EBA1);
- DO3(D,A,B,C,11,9,0x6ED9EBA1);
- DO3(C,D,A,B,7,11,0x6ED9EBA1);
- DO3(B,C,D,A,15,15,0x6ED9EBA1);
-
- A += AA;
- B += BB;
- C += CC;
- D += DD;
+ afs_uint32 AA, BB, CC, DD;
+
+ AA = A;
+ BB = B;
+ CC = C;
+ DD = D;
+
+ /* Round 1 */
+
+ DO1(A, B, C, D, 0, 3, 0);
+ DO1(D, A, B, C, 1, 7, 0);
+ DO1(C, D, A, B, 2, 11, 0);
+ DO1(B, C, D, A, 3, 19, 0);
+
+ DO1(A, B, C, D, 4, 3, 0);
+ DO1(D, A, B, C, 5, 7, 0);
+ DO1(C, D, A, B, 6, 11, 0);
+ DO1(B, C, D, A, 7, 19, 0);
+
+ DO1(A, B, C, D, 8, 3, 0);
+ DO1(D, A, B, C, 9, 7, 0);
+ DO1(C, D, A, B, 10, 11, 0);
+ DO1(B, C, D, A, 11, 19, 0);
+
+ DO1(A, B, C, D, 12, 3, 0);
+ DO1(D, A, B, C, 13, 7, 0);
+ DO1(C, D, A, B, 14, 11, 0);
+ DO1(B, C, D, A, 15, 19, 0);
+
+ /* Round 2 */
+
+ DO2(A, B, C, D, 0, 3, 0x5A827999);
+ DO2(D, A, B, C, 4, 5, 0x5A827999);
+ DO2(C, D, A, B, 8, 9, 0x5A827999);
+ DO2(B, C, D, A, 12, 13, 0x5A827999);
+
+ DO2(A, B, C, D, 1, 3, 0x5A827999);
+ DO2(D, A, B, C, 5, 5, 0x5A827999);
+ DO2(C, D, A, B, 9, 9, 0x5A827999);
+ DO2(B, C, D, A, 13, 13, 0x5A827999);
+
+ DO2(A, B, C, D, 2, 3, 0x5A827999);
+ DO2(D, A, B, C, 6, 5, 0x5A827999);
+ DO2(C, D, A, B, 10, 9, 0x5A827999);
+ DO2(B, C, D, A, 14, 13, 0x5A827999);
+
+ DO2(A, B, C, D, 3, 3, 0x5A827999);
+ DO2(D, A, B, C, 7, 5, 0x5A827999);
+ DO2(C, D, A, B, 11, 9, 0x5A827999);
+ DO2(B, C, D, A, 15, 13, 0x5A827999);
+
+ /* Round 3 */
+
+ DO3(A, B, C, D, 0, 3, 0x6ED9EBA1);
+ DO3(D, A, B, C, 8, 9, 0x6ED9EBA1);
+ DO3(C, D, A, B, 4, 11, 0x6ED9EBA1);
+ DO3(B, C, D, A, 12, 15, 0x6ED9EBA1);
+
+ DO3(A, B, C, D, 2, 3, 0x6ED9EBA1);
+ DO3(D, A, B, C, 10, 9, 0x6ED9EBA1);
+ DO3(C, D, A, B, 6, 11, 0x6ED9EBA1);
+ DO3(B, C, D, A, 14, 15, 0x6ED9EBA1);
+
+ DO3(A, B, C, D, 1, 3, 0x6ED9EBA1);
+ DO3(D, A, B, C, 9, 9, 0x6ED9EBA1);
+ DO3(C, D, A, B, 5, 11, 0x6ED9EBA1);
+ DO3(B, C, D, A, 13, 15, 0x6ED9EBA1);
+
+ DO3(A, B, C, D, 3, 3, 0x6ED9EBA1);
+ DO3(D, A, B, C, 11, 9, 0x6ED9EBA1);
+ DO3(C, D, A, B, 7, 11, 0x6ED9EBA1);
+ DO3(B, C, D, A, 15, 15, 0x6ED9EBA1);
+
+ A += AA;
+ B += BB;
+ C += CC;
+ D += DD;
}
/*
#if defined(WORDS_BIGENDIAN)
static inline afs_uint32
-swap_afs_uint32 (afs_uint32 t)
+swap_afs_uint32(afs_uint32 t)
{
- afs_uint32 temp1, temp2;
-
- temp1 = cshift(t, 16);
- temp2 = temp1 >> 8;
- temp1 &= 0x00ff00ff;
- temp2 &= 0x00ff00ff;
- temp1 <<= 8;
- return temp1 | temp2;
+ afs_uint32 temp1, temp2;
+
+ temp1 = cshift(t, 16);
+ temp2 = temp1 >> 8;
+ temp1 &= 0x00ff00ff;
+ temp2 &= 0x00ff00ff;
+ temp1 <<= 8;
+ return temp1 | temp2;
}
#endif
-struct x32{
- unsigned int a:32;
- unsigned int b:32;
+struct x32 {
+ unsigned int a:32;
+ unsigned int b:32;
};
void
-MD4_Update (struct md4 *m, const void *v, size_t len)
+MD4_Update(struct md4 *m, const void *v, size_t len)
{
const unsigned char *p = v;
size_t old_sz = m->sz[0];
m->sz[0] += len * 8;
if (m->sz[0] < old_sz)
++m->sz[1];
- offset = (old_sz / 8) % 64;
- while(len > 0) {
+ offset = (old_sz / 8) % 64;
+ while (len > 0) {
size_t l = min(len, 64 - offset);
memcpy(m->save + offset, p, l);
offset += l;
p += l;
len -= l;
- if(offset == 64) {
+ if (offset == 64) {
#if defined(WORDS_BIGENDIAN)
int i;
afs_uint32 current[16];
- struct x32 *u = (struct x32*)m->save;
- for(i = 0; i < 8; i++){
- current[2*i+0] = swap_afs_uint32(u[i].a);
- current[2*i+1] = swap_afs_uint32(u[i].b);
+ struct x32 *u = (struct x32 *)m->save;
+ for (i = 0; i < 8; i++) {
+ current[2 * i + 0] = swap_afs_uint32(u[i].a);
+ current[2 * i + 1] = swap_afs_uint32(u[i].b);
}
calc(m, current);
#else
- calc(m, (afs_uint32*)m->save);
+ calc(m, (afs_uint32 *) m->save);
#endif
offset = 0;
}
}
void
-MD4_Final (void *res, struct md4 *m)
+MD4_Final(void *res, struct md4 *m)
{
- static unsigned char zeros[72];
- unsigned offset = (m->sz[0] / 8) % 64;
- unsigned int dstart = (120 - offset - 1) % 64 + 1;
-
- *zeros = 0x80;
- memset (zeros + 1, 0, sizeof(zeros) - 1);
- zeros[dstart+0] = (m->sz[0] >> 0) & 0xff;
- zeros[dstart+1] = (m->sz[0] >> 8) & 0xff;
- zeros[dstart+2] = (m->sz[0] >> 16) & 0xff;
- zeros[dstart+3] = (m->sz[0] >> 24) & 0xff;
- zeros[dstart+4] = (m->sz[1] >> 0) & 0xff;
- zeros[dstart+5] = (m->sz[1] >> 8) & 0xff;
- zeros[dstart+6] = (m->sz[1] >> 16) & 0xff;
- zeros[dstart+7] = (m->sz[1] >> 24) & 0xff;
- MD4_Update (m, zeros, dstart + 8);
- {
- int i;
- unsigned char *r = (unsigned char *)res;
-
- for (i = 0; i < 4; ++i) {
- r[4*i] = m->counter[i] & 0xFF;
- r[4*i+1] = (m->counter[i] >> 8) & 0xFF;
- r[4*i+2] = (m->counter[i] >> 16) & 0xFF;
- r[4*i+3] = (m->counter[i] >> 24) & 0xFF;
- }
- }
+ static unsigned char zeros[72];
+ unsigned offset = (m->sz[0] / 8) % 64;
+ unsigned int dstart = (120 - offset - 1) % 64 + 1;
+
+ *zeros = 0x80;
+ memset(zeros + 1, 0, sizeof(zeros) - 1);
+ zeros[dstart + 0] = (m->sz[0] >> 0) & 0xff;
+ zeros[dstart + 1] = (m->sz[0] >> 8) & 0xff;
+ zeros[dstart + 2] = (m->sz[0] >> 16) & 0xff;
+ zeros[dstart + 3] = (m->sz[0] >> 24) & 0xff;
+ zeros[dstart + 4] = (m->sz[1] >> 0) & 0xff;
+ zeros[dstart + 5] = (m->sz[1] >> 8) & 0xff;
+ zeros[dstart + 6] = (m->sz[1] >> 16) & 0xff;
+ zeros[dstart + 7] = (m->sz[1] >> 24) & 0xff;
+ MD4_Update(m, zeros, dstart + 8);
+ {
+ int i;
+ unsigned char *r = (unsigned char *)res;
+
+ for (i = 0; i < 4; ++i) {
+ r[4 * i] = m->counter[i] & 0xFF;
+ r[4 * i + 1] = (m->counter[i] >> 8) & 0xFF;
+ r[4 * i + 2] = (m->counter[i] >> 16) & 0xFF;
+ r[4 * i + 3] = (m->counter[i] >> 24) & 0xFF;
+ }
+ }
#if 0
- {
- int i;
- afs_uint32 *r = (afs_uint32 *)res;
+ {
+ int i;
+ afs_uint32 *r = (afs_uint32 *) res;
- for (i = 0; i < 4; ++i)
- r[i] = swap_afs_uint32 (m->counter[i]);
- }
+ for (i = 0; i < 4; ++i)
+ r[i] = swap_afs_uint32(m->counter[i]);
+ }
#endif
}
#endif
struct md4 {
- unsigned int sz[2];
- afs_uint32 counter[4];
- unsigned char save[64];
+ unsigned int sz[2];
+ afs_uint32 counter[4];
+ unsigned char save[64];
};
typedef struct md4 MD4_CTX;
-void MD4_Init (struct md4 *m);
-void MD4_Update (struct md4 *m, const void *p, size_t len);
-void MD4_Final (void *res, struct md4 *m);
+void MD4_Init(struct md4 *m);
+void MD4_Update(struct md4 *m, const void *p, size_t len);
+void MD4_Final(void *res, struct md4 *m);
#define X data
void
-MD5_Init (struct md5 *m)
+MD5_Init(struct md5 *m)
{
- m->sz[0] = 0;
- m->sz[1] = 0;
- D = 0x10325476;
- C = 0x98badcfe;
- B = 0xefcdab89;
- A = 0x67452301;
+ m->sz[0] = 0;
+ m->sz[1] = 0;
+ D = 0x10325476;
+ C = 0x98badcfe;
+ B = 0xefcdab89;
+ A = 0x67452301;
}
#define F(x,y,z) CRAYFIX((x & y) | (~x & z))
#define DO4(a,b,c,d,k,s,i) DOIT(a,b,c,d,k,s,i,I)
static inline void
-calc (struct md5 *m, afs_uint32 *data)
+calc(struct md5 *m, afs_uint32 * data)
{
- afs_uint32 AA, BB, CC, DD;
-
- AA = A;
- BB = B;
- CC = C;
- DD = D;
-
- /* Round 1 */
-
- DO1(A,B,C,D,0,7,0xd76aa478);
- DO1(D,A,B,C,1,12,0xe8c7b756);
- DO1(C,D,A,B,2,17,0x242070db);
- DO1(B,C,D,A,3,22,0xc1bdceee);
-
- DO1(A,B,C,D,4,7,0xf57c0faf);
- DO1(D,A,B,C,5,12,0x4787c62a);
- DO1(C,D,A,B,6,17,0xa8304613);
- DO1(B,C,D,A,7,22,0xfd469501);
-
- DO1(A,B,C,D,8,7,0x698098d8);
- DO1(D,A,B,C,9,12,0x8b44f7af);
- DO1(C,D,A,B,10,17,0xffff5bb1);
- DO1(B,C,D,A,11,22,0x895cd7be);
-
- DO1(A,B,C,D,12,7,0x6b901122);
- DO1(D,A,B,C,13,12,0xfd987193);
- DO1(C,D,A,B,14,17,0xa679438e);
- DO1(B,C,D,A,15,22,0x49b40821);
-
- /* Round 2 */
-
- DO2(A,B,C,D,1,5,0xf61e2562);
- DO2(D,A,B,C,6,9,0xc040b340);
- DO2(C,D,A,B,11,14,0x265e5a51);
- DO2(B,C,D,A,0,20,0xe9b6c7aa);
-
- DO2(A,B,C,D,5,5,0xd62f105d);
- DO2(D,A,B,C,10,9,0x2441453);
- DO2(C,D,A,B,15,14,0xd8a1e681);
- DO2(B,C,D,A,4,20,0xe7d3fbc8);
-
- DO2(A,B,C,D,9,5,0x21e1cde6);
- DO2(D,A,B,C,14,9,0xc33707d6);
- DO2(C,D,A,B,3,14,0xf4d50d87);
- DO2(B,C,D,A,8,20,0x455a14ed);
-
- DO2(A,B,C,D,13,5,0xa9e3e905);
- DO2(D,A,B,C,2,9,0xfcefa3f8);
- DO2(C,D,A,B,7,14,0x676f02d9);
- DO2(B,C,D,A,12,20,0x8d2a4c8a);
-
- /* Round 3 */
-
- DO3(A,B,C,D,5,4,0xfffa3942);
- DO3(D,A,B,C,8,11,0x8771f681);
- DO3(C,D,A,B,11,16,0x6d9d6122);
- DO3(B,C,D,A,14,23,0xfde5380c);
-
- DO3(A,B,C,D,1,4,0xa4beea44);
- DO3(D,A,B,C,4,11,0x4bdecfa9);
- DO3(C,D,A,B,7,16,0xf6bb4b60);
- DO3(B,C,D,A,10,23,0xbebfbc70);
-
- DO3(A,B,C,D,13,4,0x289b7ec6);
- DO3(D,A,B,C,0,11,0xeaa127fa);
- DO3(C,D,A,B,3,16,0xd4ef3085);
- DO3(B,C,D,A,6,23,0x4881d05);
-
- DO3(A,B,C,D,9,4,0xd9d4d039);
- DO3(D,A,B,C,12,11,0xe6db99e5);
- DO3(C,D,A,B,15,16,0x1fa27cf8);
- DO3(B,C,D,A,2,23,0xc4ac5665);
-
- /* Round 4 */
-
- DO4(A,B,C,D,0,6,0xf4292244);
- DO4(D,A,B,C,7,10,0x432aff97);
- DO4(C,D,A,B,14,15,0xab9423a7);
- DO4(B,C,D,A,5,21,0xfc93a039);
-
- DO4(A,B,C,D,12,6,0x655b59c3);
- DO4(D,A,B,C,3,10,0x8f0ccc92);
- DO4(C,D,A,B,10,15,0xffeff47d);
- DO4(B,C,D,A,1,21,0x85845dd1);
-
- DO4(A,B,C,D,8,6,0x6fa87e4f);
- DO4(D,A,B,C,15,10,0xfe2ce6e0);
- DO4(C,D,A,B,6,15,0xa3014314);
- DO4(B,C,D,A,13,21,0x4e0811a1);
-
- DO4(A,B,C,D,4,6,0xf7537e82);
- DO4(D,A,B,C,11,10,0xbd3af235);
- DO4(C,D,A,B,2,15,0x2ad7d2bb);
- DO4(B,C,D,A,9,21,0xeb86d391);
-
- A += AA;
- B += BB;
- C += CC;
- D += DD;
+ afs_uint32 AA, BB, CC, DD;
+
+ AA = A;
+ BB = B;
+ CC = C;
+ DD = D;
+
+ /* Round 1 */
+
+ DO1(A, B, C, D, 0, 7, 0xd76aa478);
+ DO1(D, A, B, C, 1, 12, 0xe8c7b756);
+ DO1(C, D, A, B, 2, 17, 0x242070db);
+ DO1(B, C, D, A, 3, 22, 0xc1bdceee);
+
+ DO1(A, B, C, D, 4, 7, 0xf57c0faf);
+ DO1(D, A, B, C, 5, 12, 0x4787c62a);
+ DO1(C, D, A, B, 6, 17, 0xa8304613);
+ DO1(B, C, D, A, 7, 22, 0xfd469501);
+
+ DO1(A, B, C, D, 8, 7, 0x698098d8);
+ DO1(D, A, B, C, 9, 12, 0x8b44f7af);
+ DO1(C, D, A, B, 10, 17, 0xffff5bb1);
+ DO1(B, C, D, A, 11, 22, 0x895cd7be);
+
+ DO1(A, B, C, D, 12, 7, 0x6b901122);
+ DO1(D, A, B, C, 13, 12, 0xfd987193);
+ DO1(C, D, A, B, 14, 17, 0xa679438e);
+ DO1(B, C, D, A, 15, 22, 0x49b40821);
+
+ /* Round 2 */
+
+ DO2(A, B, C, D, 1, 5, 0xf61e2562);
+ DO2(D, A, B, C, 6, 9, 0xc040b340);
+ DO2(C, D, A, B, 11, 14, 0x265e5a51);
+ DO2(B, C, D, A, 0, 20, 0xe9b6c7aa);
+
+ DO2(A, B, C, D, 5, 5, 0xd62f105d);
+ DO2(D, A, B, C, 10, 9, 0x2441453);
+ DO2(C, D, A, B, 15, 14, 0xd8a1e681);
+ DO2(B, C, D, A, 4, 20, 0xe7d3fbc8);
+
+ DO2(A, B, C, D, 9, 5, 0x21e1cde6);
+ DO2(D, A, B, C, 14, 9, 0xc33707d6);
+ DO2(C, D, A, B, 3, 14, 0xf4d50d87);
+ DO2(B, C, D, A, 8, 20, 0x455a14ed);
+
+ DO2(A, B, C, D, 13, 5, 0xa9e3e905);
+ DO2(D, A, B, C, 2, 9, 0xfcefa3f8);
+ DO2(C, D, A, B, 7, 14, 0x676f02d9);
+ DO2(B, C, D, A, 12, 20, 0x8d2a4c8a);
+
+ /* Round 3 */
+
+ DO3(A, B, C, D, 5, 4, 0xfffa3942);
+ DO3(D, A, B, C, 8, 11, 0x8771f681);
+ DO3(C, D, A, B, 11, 16, 0x6d9d6122);
+ DO3(B, C, D, A, 14, 23, 0xfde5380c);
+
+ DO3(A, B, C, D, 1, 4, 0xa4beea44);
+ DO3(D, A, B, C, 4, 11, 0x4bdecfa9);
+ DO3(C, D, A, B, 7, 16, 0xf6bb4b60);
+ DO3(B, C, D, A, 10, 23, 0xbebfbc70);
+
+ DO3(A, B, C, D, 13, 4, 0x289b7ec6);
+ DO3(D, A, B, C, 0, 11, 0xeaa127fa);
+ DO3(C, D, A, B, 3, 16, 0xd4ef3085);
+ DO3(B, C, D, A, 6, 23, 0x4881d05);
+
+ DO3(A, B, C, D, 9, 4, 0xd9d4d039);
+ DO3(D, A, B, C, 12, 11, 0xe6db99e5);
+ DO3(C, D, A, B, 15, 16, 0x1fa27cf8);
+ DO3(B, C, D, A, 2, 23, 0xc4ac5665);
+
+ /* Round 4 */
+
+ DO4(A, B, C, D, 0, 6, 0xf4292244);
+ DO4(D, A, B, C, 7, 10, 0x432aff97);
+ DO4(C, D, A, B, 14, 15, 0xab9423a7);
+ DO4(B, C, D, A, 5, 21, 0xfc93a039);
+
+ DO4(A, B, C, D, 12, 6, 0x655b59c3);
+ DO4(D, A, B, C, 3, 10, 0x8f0ccc92);
+ DO4(C, D, A, B, 10, 15, 0xffeff47d);
+ DO4(B, C, D, A, 1, 21, 0x85845dd1);
+
+ DO4(A, B, C, D, 8, 6, 0x6fa87e4f);
+ DO4(D, A, B, C, 15, 10, 0xfe2ce6e0);
+ DO4(C, D, A, B, 6, 15, 0xa3014314);
+ DO4(B, C, D, A, 13, 21, 0x4e0811a1);
+
+ DO4(A, B, C, D, 4, 6, 0xf7537e82);
+ DO4(D, A, B, C, 11, 10, 0xbd3af235);
+ DO4(C, D, A, B, 2, 15, 0x2ad7d2bb);
+ DO4(B, C, D, A, 9, 21, 0xeb86d391);
+
+ A += AA;
+ B += BB;
+ C += CC;
+ D += DD;
}
/*
#if defined(WORDS_BIGENDIAN)
static inline afs_uint32
-swap_afs_uint32 (afs_uint32 t)
+swap_afs_uint32(afs_uint32 t)
{
- afs_uint32 temp1, temp2;
-
- temp1 = cshift(t, 16);
- temp2 = temp1 >> 8;
- temp1 &= 0x00ff00ff;
- temp2 &= 0x00ff00ff;
- temp1 <<= 8;
- return temp1 | temp2;
+ afs_uint32 temp1, temp2;
+
+ temp1 = cshift(t, 16);
+ temp2 = temp1 >> 8;
+ temp1 &= 0x00ff00ff;
+ temp2 &= 0x00ff00ff;
+ temp1 <<= 8;
+ return temp1 | temp2;
}
#endif
-struct x32{
- unsigned int a:32;
- unsigned int b:32;
+struct x32 {
+ unsigned int a:32;
+ unsigned int b:32;
};
void
-MD5_Update (struct md5 *m, const void *v, size_t len)
+MD5_Update(struct md5 *m, const void *v, size_t len)
{
- const unsigned char *p = v;
- size_t old_sz = m->sz[0];
- size_t offset;
-
- m->sz[0] += len * 8;
- if (m->sz[0] < old_sz)
- ++m->sz[1];
- offset = (old_sz / 8) % 64;
- while(len > 0){
- size_t l = min(len, 64 - offset);
- memcpy(m->save + offset, p, l);
- offset += l;
- p += l;
- len -= l;
- if(offset == 64){
+ const unsigned char *p = v;
+ size_t old_sz = m->sz[0];
+ size_t offset;
+
+ m->sz[0] += len * 8;
+ if (m->sz[0] < old_sz)
+ ++m->sz[1];
+ offset = (old_sz / 8) % 64;
+ while (len > 0) {
+ size_t l = min(len, 64 - offset);
+ memcpy(m->save + offset, p, l);
+ offset += l;
+ p += l;
+ len -= l;
+ if (offset == 64) {
#if defined(WORDS_BIGENDIAN)
- int i;
- afs_uint32 current[16];
- struct x32 *u = (struct x32*)m->save;
- for(i = 0; i < 8; i++){
- current[2*i+0] = swap_afs_uint32(u[i].a);
- current[2*i+1] = swap_afs_uint32(u[i].b);
- }
- calc(m, current);
+ int i;
+ afs_uint32 current[16];
+ struct x32 *u = (struct x32 *)m->save;
+ for (i = 0; i < 8; i++) {
+ current[2 * i + 0] = swap_afs_uint32(u[i].a);
+ current[2 * i + 1] = swap_afs_uint32(u[i].b);
+ }
+ calc(m, current);
#else
- calc(m, (afs_uint32*)m->save);
+ calc(m, (afs_uint32 *) m->save);
#endif
- offset = 0;
+ offset = 0;
+ }
}
- }
}
void
-MD5_Final (void *res, struct md5 *m)
+MD5_Final(void *res, struct md5 *m)
{
- static unsigned char zeros[72];
- unsigned offset = (m->sz[0] / 8) % 64;
- unsigned int dstart = (120 - offset - 1) % 64 + 1;
-
- *zeros = 0x80;
- memset (zeros + 1, 0, sizeof(zeros) - 1);
- zeros[dstart+0] = (m->sz[0] >> 0) & 0xff;
- zeros[dstart+1] = (m->sz[0] >> 8) & 0xff;
- zeros[dstart+2] = (m->sz[0] >> 16) & 0xff;
- zeros[dstart+3] = (m->sz[0] >> 24) & 0xff;
- zeros[dstart+4] = (m->sz[1] >> 0) & 0xff;
- zeros[dstart+5] = (m->sz[1] >> 8) & 0xff;
- zeros[dstart+6] = (m->sz[1] >> 16) & 0xff;
- zeros[dstart+7] = (m->sz[1] >> 24) & 0xff;
- MD5_Update (m, zeros, dstart + 8);
- {
- int i;
- unsigned char *r = (unsigned char *)res;
-
- for (i = 0; i < 4; ++i) {
- r[4*i] = m->counter[i] & 0xFF;
- r[4*i+1] = (m->counter[i] >> 8) & 0xFF;
- r[4*i+2] = (m->counter[i] >> 16) & 0xFF;
- r[4*i+3] = (m->counter[i] >> 24) & 0xFF;
- }
- }
+ static unsigned char zeros[72];
+ unsigned offset = (m->sz[0] / 8) % 64;
+ unsigned int dstart = (120 - offset - 1) % 64 + 1;
+
+ *zeros = 0x80;
+ memset(zeros + 1, 0, sizeof(zeros) - 1);
+ zeros[dstart + 0] = (m->sz[0] >> 0) & 0xff;
+ zeros[dstart + 1] = (m->sz[0] >> 8) & 0xff;
+ zeros[dstart + 2] = (m->sz[0] >> 16) & 0xff;
+ zeros[dstart + 3] = (m->sz[0] >> 24) & 0xff;
+ zeros[dstart + 4] = (m->sz[1] >> 0) & 0xff;
+ zeros[dstart + 5] = (m->sz[1] >> 8) & 0xff;
+ zeros[dstart + 6] = (m->sz[1] >> 16) & 0xff;
+ zeros[dstart + 7] = (m->sz[1] >> 24) & 0xff;
+ MD5_Update(m, zeros, dstart + 8);
+ {
+ int i;
+ unsigned char *r = (unsigned char *)res;
+
+ for (i = 0; i < 4; ++i) {
+ r[4 * i] = m->counter[i] & 0xFF;
+ r[4 * i + 1] = (m->counter[i] >> 8) & 0xFF;
+ r[4 * i + 2] = (m->counter[i] >> 16) & 0xFF;
+ r[4 * i + 3] = (m->counter[i] >> 24) & 0xFF;
+ }
+ }
#if 0
- {
- int i;
- afs_uint32 *r = (afs_uint32 *)res;
+ {
+ int i;
+ afs_uint32 *r = (afs_uint32 *) res;
- for (i = 0; i < 4; ++i)
- r[i] = swap_afs_uint32 (m->counter[i]);
- }
+ for (i = 0; i < 4; ++i)
+ r[i] = swap_afs_uint32(m->counter[i]);
+ }
#endif
}
#endif
struct md5 {
- unsigned int sz[2];
- afs_uint32 counter[4];
- unsigned char save[64];
+ unsigned int sz[2];
+ afs_uint32 counter[4];
+ unsigned char save[64];
};
typedef struct md5 MD5_CTX;
-void MD5_Init (struct md5 *m);
-void MD5_Update (struct md5 *m, const void *p, size_t len);
-void MD5_Final (void *res, struct md5 *m); /* afs_uint32 res[4] */
+void MD5_Init(struct md5 *m);
+void MD5_Update(struct md5 *m, const void *p, size_t len);
+void MD5_Final(void *res, struct md5 *m); /* afs_uint32 res[4] */
/* no ticket good for longer than 30 days */
#define MAXKTCTICKETLIFETIME (30*24*3600)
#define MINKTCTICKETLEN 32
-#define MAXKTCTICKETLEN 12000 /* was 344 */
+#define MAXKTCTICKETLEN 12000 /* was 344 */
#define MAXKTCNAMELEN 64 /* name & inst should be 256 */
#define MAXKTCREALMLEN 64 /* should be 256 */
#define KTC_TIME_UNCERTAINTY (15*60) /* max skew bet. machines' clocks */
#define MAXRANDOMNAMELEN 16 /* length of random generated
- * usernames used by afslog for high
- * security must be < MAXKTCNAMELEN && < MAXSMBNAMELEN */
-#define MAXSMBNAMELEN 256 /* max length of an SMB name */
+ * usernames used by afslog for high
+ * security must be < MAXKTCNAMELEN && < MAXSMBNAMELEN */
+#define MAXSMBNAMELEN 256 /* max length of an SMB name */
#define LOGON_OPTION_INTEGRATED 1
#define LOGON_OPTION_HIGHSECURITY 2
#include <pthread.h>
#include <assert.h>
extern pthread_mutex_t rxkad_stats_mutex;
-#define LOCK_RXKAD_STATS assert(pthread_mutex_lock(&rxkad_stats_mutex)==0);
-#define UNLOCK_RXKAD_STATS assert(pthread_mutex_unlock(&rxkad_stats_mutex)==0);
+#define LOCK_RXKAD_STATS assert(pthread_mutex_lock(&rxkad_stats_mutex)==0)
+#define UNLOCK_RXKAD_STATS assert(pthread_mutex_unlock(&rxkad_stats_mutex)==0)
#else
#define LOCK_RXKAD_STATS
#define UNLOCK_RXKAD_STATS
*/
#include <assert.h>
pthread_mutex_t rxkad_client_uid_mutex;
-#define LOCK_CUID assert(pthread_mutex_lock(&rxkad_client_uid_mutex)==0);
-#define UNLOCK_CUID assert(pthread_mutex_unlock(&rxkad_client_uid_mutex)==0);
+#define LOCK_CUID assert(pthread_mutex_lock(&rxkad_client_uid_mutex)==0)
+#define UNLOCK_CUID assert(pthread_mutex_unlock(&rxkad_client_uid_mutex)==0)
#else
#define LOCK_CUID
#define UNLOCK_CUID
struct rxkad_cidgen tgen;
static afs_int32 counter = 0; /* not used anymore */
- LOCK_CUID if (Cuid[0] == 0) {
+ LOCK_CUID;
+ if (Cuid[0] == 0) {
afs_uint32 xor[2];
tgen.ipAddr = rxi_getaddr(); /* comes back in net order */
clock_GetTime(&tgen.time); /* changes time1 and time2 */
}
if (!aconn) {
- UNLOCK_CUID return 0;
+ UNLOCK_CUID;
+ return 0;
}
aconn->epoch = Cuid[0];
aconn->cid = Cuid[1];
Cuid[1] += 1 << RX_CIDSHIFT;
- UNLOCK_CUID return 0;
+ UNLOCK_CUID;
+ return 0;
}
/* Allocate a new client security object. Called with the encryption level,
}
memcpy(tcp->ticket, ticket, ticketLen);
- LOCK_RXKAD_STATS rxkad_stats_clientObjects++;
- UNLOCK_RXKAD_STATS return tsc;
+ LOCK_RXKAD_STATS;
+ rxkad_stats_clientObjects++;
+ UNLOCK_RXKAD_STATS;
+ return tsc;
}
/* client: respond to a challenge packet */
if (level > tcp->level)
return RXKADLEVELFAIL;
- LOCK_RXKAD_STATS rxkad_stats.challenges[rxkad_LevelIndex(tcp->level)]++;
- UNLOCK_RXKAD_STATS if (v2) {
+ LOCK_RXKAD_STATS;
+ rxkad_stats.challenges[rxkad_LevelIndex(tcp->level)]++;
+ UNLOCK_RXKAD_STATS;
+ if (v2) {
int i;
afs_uint32 xor[2];
memset((void *)&r_v2, 0, sizeof(r_v2));
void
rxkad_ResetState(void)
{
- LOCK_CUID Cuid[0] = 0;
+ LOCK_CUID;
+ Cuid[0] = 0;
rxkad_EpochWasSet = 0;
-UNLOCK_CUID}
+ UNLOCK_CUID;
+}
#endif
/* variable initialization for the benefit of darwin compiler; if it causes
problems elsewhere, conditionalize for darwin or fc_test compile breaks */
-struct rxkad_stats rxkad_stats = {0};
+struct rxkad_stats rxkad_stats = { 0 };
/* static prototypes */
static afs_int32 ComputeSum(struct rx_packet *apacket,
} else {
return RXKADINCONSISTENCY;
} /* unknown type */
- LOCK_RXKAD_STATS rxkad_stats.destroyObject++;
- UNLOCK_RXKAD_STATS return 0;
+ LOCK_RXKAD_STATS;
+ rxkad_stats.destroyObject++;
+ UNLOCK_RXKAD_STATS;
+ return 0;
}
/* rxkad_Close - called by rx with the security class object as a parameter
rxkad_SetLevel(aconn, tcp->level); /* set header and trailer sizes */
rxkad_AllocCID(aobj, aconn); /* CHANGES cid AND epoch!!!! */
rxkad_DeriveXORInfo(aconn, tcp->keysched, tcp->ivec, tccp->preSeq);
- LOCK_RXKAD_STATS rxkad_stats.
- connections[rxkad_LevelIndex(tcp->level)]++;
- UNLOCK_RXKAD_STATS}
+ LOCK_RXKAD_STATS;
+ rxkad_stats.connections[rxkad_LevelIndex(tcp->level)]++;
+ UNLOCK_RXKAD_STATS;
+ }
aobj->refCount++; /* attached connection */
return 0;
sconn = (struct rxkad_sconn *)aconn->securityData;
if (sconn) {
aconn->securityData = 0;
- LOCK_RXKAD_STATS if (sconn->authenticated)
- rxkad_stats.destroyConn[rxkad_LevelIndex(sconn->level)]++;
+ LOCK_RXKAD_STATS;
+ if (sconn->authenticated)
+ rxkad_stats.destroyConn[rxkad_LevelIndex(sconn->level)]++;
else
rxkad_stats.destroyUnauth++;
- UNLOCK_RXKAD_STATS rock = sconn->rock;
+ UNLOCK_RXKAD_STATS;
+ rock = sconn->rock;
if (rock)
rxi_Free(rock, sizeof(struct rxkad_serverinfo));
rxi_Free(sconn, sizeof(struct rxkad_sconn));
} else {
- LOCK_RXKAD_STATS rxkad_stats.destroyUnused++;
- UNLOCK_RXKAD_STATS}
+ LOCK_RXKAD_STATS;
+ rxkad_stats.destroyUnused++;
+ UNLOCK_RXKAD_STATS;
+ }
} else { /* client */
struct rxkad_cconn *cconn;
struct rxkad_cprivate *tcp;
aconn->securityData = 0;
rxi_Free(cconn, sizeof(struct rxkad_cconn));
}
- LOCK_RXKAD_STATS rxkad_stats.destroyClient++;
- UNLOCK_RXKAD_STATS}
+ LOCK_RXKAD_STATS;
+ rxkad_stats.destroyClient++;
+ UNLOCK_RXKAD_STATS;
+ }
aobj->refCount--; /* decrement connection counter */
if (aobj->refCount <= 0) {
afs_int32 code;
if (sconn && sconn->authenticated
&& (osi_Time() < sconn->expirationTime)) {
level = sconn->level;
- LOCK_RXKAD_STATS rxkad_stats.
- checkPackets[rxkad_StatIndex(rxkad_server, level)]++;
- UNLOCK_RXKAD_STATS sconn->stats.packetsReceived++;
+ LOCK_RXKAD_STATS;
+ rxkad_stats.checkPackets[rxkad_StatIndex(rxkad_server, level)]++;
+ UNLOCK_RXKAD_STATS;
+ sconn->stats.packetsReceived++;
sconn->stats.bytesReceived += len;
schedule = (fc_KeySchedule *) sconn->keysched;
ivec = (fc_InitializationVector *) sconn->ivec;
} else {
- LOCK_RXKAD_STATS rxkad_stats.expired++;
- UNLOCK_RXKAD_STATS return RXKADEXPIRED;
+ LOCK_RXKAD_STATS;
+ rxkad_stats.expired++;
+ UNLOCK_RXKAD_STATS;
+ return RXKADEXPIRED;
}
preSeq = sconn->preSeq;
} else { /* client connection */
if (!(tcp->type & rxkad_client))
return RXKADINCONSISTENCY;
level = tcp->level;
- LOCK_RXKAD_STATS rxkad_stats.
- checkPackets[rxkad_StatIndex(rxkad_client, level)]++;
- UNLOCK_RXKAD_STATS cconn->stats.packetsReceived++;
+ LOCK_RXKAD_STATS;
+ rxkad_stats.checkPackets[rxkad_StatIndex(rxkad_client, level)]++;
+ UNLOCK_RXKAD_STATS;
+ cconn->stats.packetsReceived++;
cconn->stats.bytesReceived += len;
preSeq = cconn->preSeq;
schedule = (fc_KeySchedule *) tcp->keysched;
if (sconn && sconn->authenticated
&& (osi_Time() < sconn->expirationTime)) {
level = sconn->level;
- LOCK_RXKAD_STATS rxkad_stats.
+ LOCK_RXKAD_STATS;
+ rxkad_stats.
preparePackets[rxkad_StatIndex(rxkad_server, level)]++;
- UNLOCK_RXKAD_STATS sconn->stats.packetsSent++;
+ UNLOCK_RXKAD_STATS;
+ sconn->stats.packetsSent++;
sconn->stats.bytesSent += len;
schedule = (fc_KeySchedule *) sconn->keysched;
ivec = (fc_InitializationVector *) sconn->ivec;
} else {
- LOCK_RXKAD_STATS rxkad_stats.expired++; /* this is a pretty unlikely path... */
- UNLOCK_RXKAD_STATS return RXKADEXPIRED;
+ LOCK_RXKAD_STATS;
+ rxkad_stats.expired++; /* this is a pretty unlikely path... */
+ UNLOCK_RXKAD_STATS;
+ return RXKADEXPIRED;
}
preSeq = sconn->preSeq;
} else { /* client connection */
if (!(tcp->type & rxkad_client))
return RXKADINCONSISTENCY;
level = tcp->level;
- LOCK_RXKAD_STATS rxkad_stats.
- preparePackets[rxkad_StatIndex(rxkad_client, level)]++;
- UNLOCK_RXKAD_STATS cconn->stats.packetsSent++;
+ LOCK_RXKAD_STATS;
+ rxkad_stats.preparePackets[rxkad_StatIndex(rxkad_client, level)]++;
+ UNLOCK_RXKAD_STATS;
+ cconn->stats.packetsSent++;
cconn->stats.bytesSent += len;
preSeq = cconn->preSeq;
schedule = (fc_KeySchedule *) tcp->keysched;
rxkad_level
rxkad_StringToLevel(char *name)
{
- if (strcmp(name, "clear") == 0)
- return rxkad_clear;
- if (strcmp(name, "auth") == 0)
- return rxkad_auth;
- if (strcmp(name, "crypt") == 0)
- return rxkad_crypt;
- return -1;
+ if (strcmp(name, "clear") == 0)
+ return rxkad_clear;
+ if (strcmp(name, "auth") == 0)
+ return rxkad_auth;
+ if (strcmp(name, "crypt") == 0)
+ return rxkad_crypt;
+ return -1;
}
char *
rxkad_LevelToString(rxkad_level level)
{
- if (level == rxkad_clear)
- return "clear";
- if (level == rxkad_auth)
- return "auth";
- if (level == rxkad_crypt)
- return "crypt";
- return "unknown";
+ if (level == rxkad_clear)
+ return "clear";
+ if (level == rxkad_auth)
+ return "auth";
+ if (level == rxkad_crypt)
+ return "crypt";
+ return "unknown";
}
level, char
*get_key_rock,
int (*get_key)
- (char
- *get_key_rock,
- int kvno,
- struct
- ktc_encryptionKey
- * serverKey),
+
+
+
+ (char
+ *get_key_rock,
+ int kvno,
+ struct
+ ktc_encryptionKey
+ * serverKey),
int (*user_ok)
- (char *name,
- char
- *instance,
- char *cell,
- afs_int32
- kvno));
+
+
+
+ (char *name,
+ char
+ *instance,
+ char *cell,
+ afs_int32
+ kvno));
extern int rxkad_CheckAuthentication(struct rx_securityClass *aobj,
struct rx_connection *aconn);
extern int rxkad_CreateChallenge(struct rx_securityClass *aobj,
rxkad_CheckPacket, /* check data packet */
rxkad_DestroyConnection,
rxkad_GetStats,
- 0, /* spare 1 */
- 0, /* spare 2 */
- 0, /* spare 3 */
+ 0, /* spare 1 */
+ 0, /* spare 2 */
+ 0, /* spare 3 */
};
extern afs_uint32 rx_MyMaxSendSize;
#include <assert.h>
pthread_mutex_t rxkad_random_mutex;
-#define LOCK_RM assert(pthread_mutex_lock(&rxkad_random_mutex)==0);
-#define UNLOCK_RM assert(pthread_mutex_unlock(&rxkad_random_mutex)==0);
+#define LOCK_RM assert(pthread_mutex_lock(&rxkad_random_mutex)==0)
+#define UNLOCK_RM assert(pthread_mutex_unlock(&rxkad_random_mutex)==0)
#else
#define LOCK_RM
#define UNLOCK_RM
struct timeval key;
gettimeofday(&key, NULL);
- LOCK_RM fc_keysched(&key, random_int32_schedule);
-UNLOCK_RM}
+ LOCK_RM;
+ fc_keysched(&key, random_int32_schedule);
+ UNLOCK_RM;
+}
static afs_int32
get_random_int32(void)
static struct timeval seed;
afs_int32 rc;
- LOCK_RM fc_ecb_encrypt(&seed, &seed, random_int32_schedule, ENCRYPT);
+ LOCK_RM;
+ fc_ecb_encrypt(&seed, &seed, random_int32_schedule, ENCRYPT);
rc = seed.tv_sec;
- UNLOCK_RM return rc;
+ UNLOCK_RM;
+ return rc;
}
/* Called with four parameters. The first is the level of encryption, as
tsp->user_ok = user_ok; /* to inform server of client id. */
init_random_int32();
- LOCK_RXKAD_STATS rxkad_stats_serverObjects++;
- UNLOCK_RXKAD_STATS return tsc;
+ LOCK_RXKAD_STATS;
+ rxkad_stats_serverObjects++;
+ UNLOCK_RXKAD_STATS;
+ return tsc;
}
/* server: called to tell if a connection authenticated properly */
rx_packetwrite(apacket, 0, challengeSize, challenge);
rx_SetDataSize(apacket, challengeSize);
sconn->tried = 1;
- LOCK_RXKAD_STATS rxkad_stats.challengesSent++;
- UNLOCK_RXKAD_STATS return 0;
+ LOCK_RXKAD_STATS;
+ rxkad_stats.challengesSent++;
+ UNLOCK_RXKAD_STATS;
+ return 0;
}
/* server: process a response to a challenge packet */
return RXKADLEVELFAIL;
sconn->level = level;
rxkad_SetLevel(aconn, sconn->level);
- LOCK_RXKAD_STATS rxkad_stats.responses[rxkad_LevelIndex(sconn->level)]++;
- UNLOCK_RXKAD_STATS
- /* now compute endpoint-specific info used for computing 16 bit checksum */
- rxkad_DeriveXORInfo(aconn, sconn->keysched, sconn->ivec,
- sconn->preSeq);
+ LOCK_RXKAD_STATS;
+ rxkad_stats.responses[rxkad_LevelIndex(sconn->level)]++;
+ UNLOCK_RXKAD_STATS;
+ /* now compute endpoint-specific info used for computing 16 bit checksum */
+ rxkad_DeriveXORInfo(aconn, sconn->keysched, sconn->ivec, sconn->preSeq);
/* otherwise things are ok */
sconn->expirationTime = end;
static int
verify_checksum_md4(void *data, size_t len,
- void *cksum, size_t cksumsz,
- struct ktc_encryptionKey *key)
+ void *cksum, size_t cksumsz,
+ struct ktc_encryptionKey *key)
{
- MD4_CTX md4;
- unsigned char tmp[16];
+ MD4_CTX md4;
+ unsigned char tmp[16];
- MD4_Init(&md4);
- MD4_Update(&md4, data, len);
- MD4_Final (tmp, &md4);
+ MD4_Init(&md4);
+ MD4_Update(&md4, data, len);
+ MD4_Final(tmp, &md4);
- if (memcmp(tmp, cksum, cksumsz) != 0)
- return 1;
- return 0;
+ if (memcmp(tmp, cksum, cksumsz) != 0)
+ return 1;
+ return 0;
}
static int
verify_checksum_md5(void *data, size_t len,
- void *cksum, size_t cksumsz,
- struct ktc_encryptionKey *key)
+ void *cksum, size_t cksumsz,
+ struct ktc_encryptionKey *key)
{
- MD5_CTX md5;
- unsigned char tmp[16];
+ MD5_CTX md5;
+ unsigned char tmp[16];
- MD5_Init(&md5);
- MD5_Update(&md5, data, len);
- MD5_Final (tmp, &md5);
+ MD5_Init(&md5);
+ MD5_Update(&md5, data, len);
+ MD5_Final(tmp, &md5);
- if (memcmp(tmp, cksum, cksumsz) != 0)
- return 1;
- return 0;
+ if (memcmp(tmp, cksum, cksumsz) != 0)
+ return 1;
+ return 0;
}
static int
des_key_schedule s;
char cksum[24];
size_t cksumsz;
- int ret = 1; /* failure */
+ int ret = 1; /* failure */
cksum_func = NULL;
}
#ifdef AFS_NT40_ENV
- /* get all my interface addresses in net byte order */
- count = rx_getAllAddr(myAddr, UBIK_MAX_INTERFACE_ADDR);
+ /* get all my interface addresses in net byte order */
+ count = rx_getAllAddr(myAddr, UBIK_MAX_INTERFACE_ADDR);
#else
if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) {
/*
for (j = 0, found = 0; j < count; j++) {
for (i = 0; i < totalServers; i++) {
if (info)
- tmpAddr =
- (afs_uint32) info->hostAddr[i].sin_addr.s_addr;
+ tmpAddr = (afs_uint32) info->hostAddr[i].sin_addr.s_addr;
else
tmpAddr = aservers[i];
if (myAddr[j] == tmpAddr) {
(*dbase->truncate) (dbase, file, 0); /* truncate first */
tversion.epoch = 0; /* start off by labelling in-transit db as invalid */
tversion.counter = 0;
- (*dbase->setlabel) (dbase, file, &tversion);/* setlabel does sync */
+ (*dbase->setlabel) (dbase, file, &tversion); /* setlabel does sync */
memcpy(&ubik_dbase->version, &tversion, sizeof(struct ubik_version));
while (length > 0) {
tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length);
};
#ifdef AFS_PTHREAD_ENV
-#define LOCK_UBIK_CLIENT(client) assert(pthread_mutex_lock(&client->cm)==0);
-#define UNLOCK_UBIK_CLIENT(client) assert(pthread_mutex_unlock(&client->cm)==0);
+#define LOCK_UBIK_CLIENT(client) assert(pthread_mutex_lock(&client->cm)==0)
+#define UNLOCK_UBIK_CLIENT(client) assert(pthread_mutex_unlock(&client->cm)==0)
#else
#define LOCK_UBIK_CLIENT(client)
#define UNLOCK_UBIK_CLIENT(client)
extern afs_int32 ubik_ClientDestroy(struct ubik_client *aclient);
/* ubik.c */
-extern int ubik_BeginTrans(register struct ubik_dbase *dbase, afs_int32 transMode, struct ubik_trans **transPtr);
+extern int ubik_BeginTrans(register struct ubik_dbase *dbase,
+ afs_int32 transMode, struct ubik_trans **transPtr);
extern int ubik_EndTrans(register struct ubik_trans *transPtr);
#endif /* UBIK_H */
if (*tp == '-')
break; /* done */
/* otherwise this is a new host name */
- LOCK_GLOBAL_MUTEX th = gethostbyname(tp);
+ LOCK_GLOBAL_MUTEX;
+ th = gethostbyname(tp);
if (!th) {
- UNLOCK_GLOBAL_MUTEX return UBADHOST;
+ UNLOCK_GLOBAL_MUTEX;
+ return UBADHOST;
}
memmove((void *)&temp, (const void *)th->h_addr,
sizeof(afs_int32));
- UNLOCK_GLOBAL_MUTEX if (counter++ >= MAXSERVERS)
- return UNHOSTS;
+ UNLOCK_GLOBAL_MUTEX;
+ if (counter++ >= MAXSERVERS)
+ return UNHOSTS;
*aothers++ = temp;
} else {
/* haven't seen a -server yet */
initialize_U_error_table();
if (*aclient) { /* the application is doing a re-initialization */
- LOCK_UBIK_CLIENT((*aclient))
- /* this is an important defensive check */
- if (!((*aclient)->initializationState)) {
- UNLOCK_UBIK_CLIENT((*aclient))
- return UREINITIALIZE;
+ LOCK_UBIK_CLIENT((*aclient));
+ /* this is an important defensive check */
+ if (!((*aclient)->initializationState)) {
+ UNLOCK_UBIK_CLIENT((*aclient));
+ return UREINITIALIZE;
}
/* release all existing connections */
rx_DestroyConnection(rxConn);
#endif
}
- UNLOCK_UBIK_CLIENT((*aclient))
+ UNLOCK_UBIK_CLIENT((*aclient));
#ifdef AFS_PTHREAD_ENV
- if (pthread_mutex_destroy(&((*aclient)->cm)))
+ if (pthread_mutex_destroy(&((*aclient)->cm)))
return UMUTEXDESTROY;
#endif
} else {
pthread_mutex_t ubik_client_mutex;
#define LOCK_UCLNT_CACHE \
assert(pthread_once(&ubik_client_once, ubik_client_init_mutex) == 0 && \
- pthread_mutex_lock(&ubik_client_mutex)==0);
-#define UNLOCK_UCLNT_CACHE assert(pthread_mutex_unlock(&ubik_client_mutex)==0);
+ pthread_mutex_lock(&ubik_client_mutex)==0)
+#define UNLOCK_UCLNT_CACHE assert(pthread_mutex_unlock(&ubik_client_mutex)==0)
void
ubik_client_init_mutex()
rcode = UNOSERVERS;
chaseCount = inlist = needsync = 0;
- LOCK_UCLNT_CACHE for (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {
+ LOCK_UCLNT_CACHE;
+ for (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {
if (calls_needsync[j] == (int *)aproc) {
inlist = needsync = 1;
break;
}
}
- UNLOCK_UCLNT_CACHE
- /*
- * First pass, we try all servers that are up.
- * Second pass, we try all servers.
- */
- for (pass = 0; pass < 2; pass++) { /*p */
+ UNLOCK_UCLNT_CACHE;
+ /*
+ * First pass, we try all servers that are up.
+ * Second pass, we try all servers.
+ */
+ for (pass = 0; pass < 2; pass++) { /*p */
/* For each entry in our servers list */
for (count = 0;; count++) { /*s */
done:
if (needsync) {
if (!inlist) { /* Remember proc call that needs sync site */
- LOCK_UCLNT_CACHE calls_needsync[synccount % SYNCCOUNT] =
- (int *)aproc;
+ LOCK_UCLNT_CACHE;
+ calls_needsync[synccount % SYNCCOUNT] = (int *)aproc;
synccount++;
- UNLOCK_UCLNT_CACHE inlist = 1;
+ UNLOCK_UCLNT_CACHE;
+ inlist = 1;
}
if (!rcode) { /* Remember the sync site - cmd successful */
rxp = rx_PeerOf(aclient->conns[count]);
short origLevel;
if (needlock) {
- LOCK_UBIK_CLIENT(aclient)
+ LOCK_UBIK_CLIENT(aclient);
}
origLevel = aclient->initializationState;
tc = aclient->conns[*apos];
if (!tc) {
if (needlock) {
- UNLOCK_UBIK_CLIENT(aclient)
+ UNLOCK_UBIK_CLIENT(aclient);
}
return UNOSERVERS;
}
}
if (*apos >= MAXSERVERS) {
if (needlock) {
- UNLOCK_UBIK_CLIENT(aclient)
+ UNLOCK_UBIK_CLIENT(aclient);
}
return UNOSERVERS;
}
p14, p15, p16);
if (aclient->initializationState != origLevel) {
if (needlock) {
- UNLOCK_UBIK_CLIENT(aclient)
+ UNLOCK_UBIK_CLIENT(aclient);
}
return code; /* somebody did a ubik_ClientInit */
}
(*apos)++;
if (needlock) {
- UNLOCK_UBIK_CLIENT(aclient)
+ UNLOCK_UBIK_CLIENT(aclient);
}
return code;
}
int stepBack;
short origLevel;
- LOCK_UBIK_CLIENT(aclient)
+ LOCK_UBIK_CLIENT(aclient);
restart:
rcode = UNOSERVERS;
origLevel = aclient->initializationState;
}
}
} else if ((code >= 0) && (code != UNOQUORUM)) {
- UNLOCK_UBIK_CLIENT(aclient)
- return code; /* success or global error condition */
+ UNLOCK_UBIK_CLIENT(aclient);
+ return code; /* success or global error condition */
}
}
}
- UNLOCK_UBIK_CLIENT(aclient)
- return rcode;
+ UNLOCK_UBIK_CLIENT(aclient);
+ return rcode;
}
/*
extern int pthread_recursive_mutex_unlock(pthread_recursive_mutex_p);
#define LOCK_GLOBAL_MUTEX \
- assert(pthread_recursive_mutex_lock(&grmutex)==0);
+ assert(pthread_recursive_mutex_lock(&grmutex)==0)
#define UNLOCK_GLOBAL_MUTEX \
- assert(pthread_recursive_mutex_unlock(&grmutex)==0);
+ assert(pthread_recursive_mutex_unlock(&grmutex)==0)
#else