/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#endif
#endif /* AFS_HPUX_ENV */
- if ( !afs_osicred_initialized )
- {
- memset((char *)&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
- crhold(&afs_osi_cred); /* don't let it evaporate */
- afs_osicred_initialized = 1;
- }
+ if ( !afs_osicred_initialized ) {
+ memset((char *)&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
+ crhold(&afs_osi_cred); /* don't let it evaporate */
+ afs_osicred_initialized = 1;
+ }
#ifdef AFS_SGI64_ENV
- osi_flid.fl_pid = osi_flid.fl_sysid = 0;
+ osi_flid.fl_pid = osi_flid.fl_sysid = 0;
#endif
}
/* If we've already purged this version, or if we're the ones
writing this version, don't flush it (could lose the
data we're writing). */
- if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) ||
+ if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) ||
((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
ReleaseReadLock(&avc->lock);
return;
ReleaseReadLock(&avc->lock);
ObtainWriteLock(&avc->lock,10);
/* Check again */
- if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) ||
+ if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) ||
((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) {
ReleaseWriteLock(&avc->lock);
return;
/* see if we've already flushed this data version */
if (hcmp(vp->m.DataVersion, vp->flushDV) <= 0) return;
-#ifdef AFS_DEC_ENV
+#ifdef AFS_DEC_ENV
{
void afs_gfs_FlushText();
afs_gfs_FlushText(vp);
MObtainWriteLock(&afs_ftf,317);
hset(fdv, vp->m.DataVersion);
- /* why this disgusting code below?
- * xuntext, called by xrele, doesn't notice when it is called
+ /* why this disgusting code below?
+ * xuntext, called by xrele, doesn't notice when it is called
* with a freed text object. Sun continually calls xrele or xuntext
* without any locking, as long as VTEXT is set on the
- * corresponding vnode.
+ * corresponding vnode.
* But, if the text object is locked when you check the VTEXT
* flag, several processes can wait in xuntext, waiting for the
* text lock; when the second one finally enters xuntext's
#if defined (AFS_HPUX_ENV)
if (vp->v.v_flag & VTEXT) {
- xrele(vp);
+ xrele(vp);
if (vp->v.v_flag & VTEXT) { /* still has a text object? */
MReleaseWriteLock(&afs_ftf);
*/
static void afs_gfs_FlushText(register struct vcache *vp)
{
- afs_hyper_t fdv; /* version before which we'll flush */
+ afs_hyper_t fdv; /* version before which we'll flush */
register struct text *xp;
struct gnode * gp;
gp = afs_vntogn(vp);
if (!gp) {
- /* this happens frequently after cores are created. */
- MReleaseWriteLock(&afs_ftf);
- return;
+ /* this happens frequently after cores are created. */
+ MReleaseWriteLock(&afs_ftf);
+ return;
}
if (gp->g_flag & GTEXT) {
if (gp->g_textp) {
- xp = (struct text *) gp->g_textp ;
- /* if text object is locked, give up */
- if (xp && (xp->x_flag & XLOCK)) {
- MReleaseWriteLock(&afs_ftf);
- return;
- }
+ xp = (struct text *) gp->g_textp ;
+ /* if text object is locked, give up */
+ if (xp && (xp->x_flag & XLOCK)) {
+ MReleaseWriteLock(&afs_ftf);
+ return;
+ }
}
else xp = NULL;
- if (gp->g_flag & GTEXT) {/* still has a text object? */
- xinval(gp);
- }
+ if (gp->g_flag & GTEXT) { /* still has a text object? */
+ xinval(gp);
+ }
}
/* next do the stuff that need not check for deadlock problems */
osi_linux_mask();
#endif
}
-
+
/* unmask signals in rxk listener */
void afs_osi_UnmaskRxkSignals(void)
{
osi_linux_unmask();
#endif
}
-
+
/* register rxk listener proc info */
void afs_osi_RxkRegister(void)
{
{
#ifdef AFS_LINUX22_ENV
afs_osi_MaskSignals();
-#endif
+#endif
#ifdef AFS_DEC_ENV
u.u_procp->p_type |= SSYS;
-#endif
+#endif
#if AFS_SUN5_ENV
curproc->p_flag |= SSYS;
#endif
afs_osi_Free(x, strlen(x) + 1);
}
-/* ? is it moderately likely that there are dirty VM pages associated with
+/* ? is it moderately likely that there are dirty VM pages associated with
* this vnode?
*
* Prereqs: avc must be write-locked
*
- * System Dependencies: - *must* support each type of system for which
- * memory mapped files are supported, even if all
+ * System Dependencies: - *must* support each type of system for which
+ * memory mapped files are supported, even if all
* it does is return TRUE;
*
* NB: this routine should err on the side of caution for ProcessFS to work
if (avc->execsOrWriters <= 0)
return 0; /* can't be many dirty pages here, I guess */
-
-#if defined (AFS_AIX32_ENV)
+
+#if defined (AFS_AIX32_ENV)
#ifdef notdef
/* because of the level of hardware involvment with VM and all the
* warnings about "This routine must be called at VMM interrupt
* level", I thought it would be safest to disable interrupts while
* looking at the software page fault table. */
- /* convert vm handle into index into array: I think that stoinio is
+ /* convert vm handle into index into array: I think that stoinio is
* always zero... Look into this XXX */
#define VMHASH(handle) ( \
( ((handle) & ~vmker.stoinio) \
^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
- ) & 0x000fffff)
+ ) & 0x000fffff)
if (avc->vmh) {
unsigned int pagef, pri, index, next;
}
}
#endif
-return 0;
+ return 0;
}
#endif /* notdef */
{
AFS_STATCNT(shutdown_osi);
if (afs_cold_shutdown) {
- LOCK_INIT(&afs_ftf, "afs_ftf");
- }
+ LOCK_INIT(&afs_ftf, "afs_ftf");
+ }
}
-int afs_osi_suser(void *credp)
+#ifndef AFS_OBSD_ENV
+int afs_osi_suser(void *credp)
{
-#ifdef AFS_SUN5_ENV
- return afs_suser(credp);
+#if defined(AFS_SUN5_ENV)
+ return afs_suser(credp);
#else
- return afs_suser();
+ return afs_suser();
#endif
}
+#endif
#if AFS_GCPAGS
return 0;
}
#else /* AFS_SGI65_ENV */
-static int SGI_ProcScanFunc(proc_t *p, void *arg, int mode)
+static int SGI_ProcScanFunc(proc_t *p, void *arg, int mode)
{
afs_int32 (*perproc_func)(struct proc *) = arg;
int code=0;
/* we pass in the function pointer for arg,
- * mode ==0 for startup call, ==1 for each valid proc,
+ * mode ==0 for startup call, ==1 for each valid proc,
* and ==2 for terminate call.
*/
if(mode == 1) {
#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
void afs_osi_TraverseProcTable(void)
-{
+{
struct proc *p;
LIST_FOREACH(p, &allproc, p_list) {
if (p->p_stat == SIDL)
continue;
afs_GCPAGs_perproc_func(p);
}
-}
+}
#endif
#if defined(AFS_LINUX22_ENV)
void afs_osi_TraverseProcTable()
-{
+{
struct task_struct *p;
#ifdef EXPORTED_TASKLIST_LOCK
#ifdef EXPORTED_TASKLIST_LOCK
read_unlock(&tasklist_lock);
#endif
-}
+}
#endif
/* return a pointer (sometimes a static copy ) to the cred for a
if((pr->p_stat == SSLEEP) ||
(pr->p_stat == SRUN) ||
- (pr->p_stat == SSTOP))
+ (pr->p_stat == SSTOP))
rv = pr->p_rcred;
return rv;
}
#elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
-{
+{
struct AFS_UCRED *rv=NULL;
static struct AFS_UCRED cr;
if(pr == NULL) {
return NULL;
}
-
+
if((pr->p_stat == SSLEEP) ||
(pr->p_stat == SRUN) ||
(pr->p_stat == SSTOP)) {
pcred_unlock(pr);
rv = &cr;
}
-
+
return rv;
-}
+}
#elif defined(AFS_LINUX22_ENV)
const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
-{
+{
struct AFS_UCRED *rv=NULL;
static struct AFS_UCRED cr;
if(pr == NULL) {
return NULL;
}
-
+
if ((pr->state == TASK_RUNNING) ||
(pr->state == TASK_INTERRUPTIBLE) ||
(pr->state == TASK_UNINTERRUPTIBLE) ||
memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
rv = &cr;
}
-
+
return rv;
-}
+}
#else
const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
{
if(pr == NULL) {
return NULL;
}
- rv = pr->p_cred;
+ rv = pr->p_cred;
return rv;
}
#endif
#endif
char *path;
- unsigned int com;
+ unsigned int com;
caddr_t cmarg;
int follow;
{
struct ucred *credp = crref(); /* don't free until done! */
#endif
#ifdef AFS_LINUX22_ENV
- cred_t *credp = crref(); /* don't free until done! */
+ cred_t *credp = crref(); /* don't free until done! */
struct dentry *dp;
#endif
setuerror(code);
#endif
return (code);
- }
+ }
if ((com & 0xff) == PSetClientContext) {
#if defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
- return EINVAL; /* Not handling these yet. */
-#else
-#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV)
+ return EINVAL; /* Not handling these yet. */
+#elif defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV)
code = HandleClientContext(&data, &com, &foreigncreds, credp);
#else
-#if defined(AFS_HPUX101_ENV)
- code=HandleClientContext(&data, &com, &foreigncreds, p_cred(u.u_procp));
-#else
-#ifdef AFS_SGI_ENV
- code = HandleClientContext(&data, &com, &foreigncreds, OSI_GET_CURRENT_CRED());
-#else
-#ifdef AFS_OBSD_ENV
code = HandleClientContext(&data, &com, &foreigncreds, osi_curcred());
-#else
- code = HandleClientContext(&data, &com, &foreigncreds, u.u_cred);
-#endif /* AFS_SGI_ENV */
-#endif
#endif
-#endif
-#endif
- if (code) {
- if (foreigncreds) {
- crfree(foreigncreds);
- }
- PIOCTL_FREE_CRED();
+ if (code) {
+ if (foreigncreds) {
+ crfree(foreigncreds);
+ }
+ PIOCTL_FREE_CRED();
#if defined(KERNEL_HAVE_UERROR)
- return (setuerror(code), code);
+ return (setuerror(code), code);
#else
- return (code);
+ return (code);
#endif
- }
+ }
}
#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
if (foreigncreds) {
- /*
- * We could have done without temporary setting the u.u_cred below
- * (foreigncreds could be passed as param the pioctl modules)
- * but calls such as afs_osi_suser() doesn't allow that since it
- * references u.u_cred directly. We could, of course, do something
- * like afs_osi_suser(cred) which, I think, is better since it
- * generalizes and supports multi cred environments...
- */
+ /*
+ * We could have done without temporary setting the u.u_cred below
+ * (foreigncreds could be passed as param the pioctl modules)
+ * but calls such as afs_osi_suser() doesn't allow that since it
+ * references u.u_cred directly. We could, of course, do something
+ * like afs_osi_suser(cred) which, I think, is better since it
+ * generalizes and supports multi cred environments...
+ */
#ifdef AFS_SUN5_ENV
tmpcred = credp;
credp = foreigncreds;
}
#endif
if ((com & 0xff) == 15) {
- /* special case prefetch so entire pathname eval occurs in helper process.
- otherwise, the pioctl call is essentially useless */
+ /* special case prefetch so entire pathname eval occurs in helper process.
+ otherwise, the pioctl call is essentially useless */
#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
code = Prefetch(path, &data, follow,
foreigncreds ? foreigncreds : credp);
#else
-#if defined(AFS_HPUX101_ENV)
- code = Prefetch(path, &data, follow, p_cred(u.u_procp));
-#else
-#ifdef AFS_SGI_ENV
- code = Prefetch(path, &data, follow, OSI_GET_CURRENT_CRED());
-#else
-#ifdef AFS_OBSD_ENV
code = Prefetch(path, &data, follow, osi_curcred());
-#else
- code = Prefetch(path, &data, follow, u.u_cred);
-#endif /* AFS_SGI64_ENV */
-#endif /* AFS_HPUX101_ENV */
-#endif
#endif
#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
if (foreigncreds) {
crset(tmpcred); /* restore original credentials */
#else
#if defined(AFS_HPUX101_ENV)
- set_p_cred(u.u_procp, tmpcred); /* restore original credentials */
+ set_p_cred(u.u_procp, tmpcred); /* restore original credentials */
#else
#ifndef AFS_SUN5_ENV
#ifdef AFS_SGI_ENV
- OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
+ OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
#else
- u.u_cred = tmpcred; /* restore original credentials */
+ u.u_cred = tmpcred; /* restore original credentials */
#endif
#endif
#endif /* AFS_HPUX101_ENV */
AFS_GUNLOCK();
#ifdef AFS_AIX41_ENV
code = lookupname(path, USR, follow, NULL, &vp,
- foreigncreds ? foreigncreds : credp);
+ foreigncreds ? foreigncreds : credp);
#else
#ifdef AFS_LINUX22_ENV
code = gop_lookupname(path, AFS_UIOUSER, follow, NULL, &dp);
crset(tmpcred); /* restore original credentials */
#else
#if defined(AFS_HPUX101_ENV)
- set_p_cred(u.u_procp, tmpcred); /* restore original credentials */
+ set_p_cred(u.u_procp, tmpcred); /* restore original credentials */
#else
#if !defined(AFS_SUN5_ENV)
#ifdef AFS_SGI_ENV
- OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
+ OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
#else
- u.u_cred = tmpcred; /* restore original credentials */
+ u.u_cred = tmpcred; /* restore original credentials */
#endif /* AFS_SGI64_ENV */
#endif
#endif /* AFS_HPUX101_ENV */
/* now make the call if we were passed no file, or were passed an AFS file */
if (!vp || IsAfsVnode(vp)) {
#ifdef AFS_DEC_ENV
- /* Ultrix 4.0: can't get vcache entry unless we've got an AFS gnode.
- * So, we must test in this part of the code. Also, must arrange to
- * GRELE the original gnode pointer when we're done, since in Ultrix 4.0,
- * we hold gnodes, whose references hold our vcache entries.
- */
- if (vp) {
- gp = vp; /* remember for "put" */
- vp = (struct vnode *) afs_gntovn(vp); /* get vcache from gp */
- }
- else gp = NULL;
+ /* Ultrix 4.0: can't get vcache entry unless we've got an AFS gnode.
+ * So, we must test in this part of the code. Also, must arrange to
+ * GRELE the original gnode pointer when we're done, since in Ultrix 4.0,
+ * we hold gnodes, whose references hold our vcache entries.
+ */
+ if (vp) {
+ gp = vp; /* remember for "put" */
+ vp = (struct vnode *) afs_gntovn(vp); /* get vcache from gp */
+ }
+ else gp = NULL;
#endif
#ifdef AFS_SUN5_ENV
- code = afs_HandlePioctl(vp, com, &data, follow, &credp);
+ code = afs_HandlePioctl(vp, com, &data, follow, &credp);
#else
#ifdef AFS_AIX41_ENV
- {
- struct ucred *cred1, *cred2;
+ {
+ struct ucred *cred1, *cred2;
- if (foreigncreds) {
- cred1 = cred2 = foreigncreds;
- } else {
- cred1 = cred2 = credp;
- }
- code = afs_HandlePioctl(vp, com, &data, follow, &cred1);
- if (cred1 != cred2) {
- /* something changed the creds */
- crset(cred1);
- }
- }
+ if (foreigncreds) {
+ cred1 = cred2 = foreigncreds;
+ } else {
+ cred1 = cred2 = credp;
+ }
+ code = afs_HandlePioctl(vp, com, &data, follow, &cred1);
+ if (cred1 != cred2) {
+ /* something changed the creds */
+ crset(cred1);
+ }
+ }
#else
#if defined(AFS_HPUX101_ENV)
- {
- struct ucred *cred = p_cred(u.u_procp);
- code = afs_HandlePioctl(vp, com, &data, follow, &cred);
- }
+ {
+ struct ucred *cred = p_cred(u.u_procp);
+ code = afs_HandlePioctl(vp, com, &data, follow, &cred);
+ }
#else
#ifdef AFS_SGI_ENV
- {
- struct cred *credp;
- credp = OSI_GET_CURRENT_CRED();
- code = afs_HandlePioctl(vp, com, &data, follow, &credp);
- }
+ {
+ struct cred *credp;
+ credp = OSI_GET_CURRENT_CRED();
+ code = afs_HandlePioctl(vp, com, &data, follow, &credp);
+ }
#else
#if defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
- code = afs_HandlePioctl(vp, com, &data, follow, &credp);
+ code = afs_HandlePioctl(vp, com, &data, follow, &credp);
#else
- code = afs_HandlePioctl(vp, com, &data, follow, &u.u_cred);
+ code = afs_HandlePioctl(vp, com, &data, follow, &u.u_cred);
#endif
#endif /* AFS_SGI_ENV */
#endif /* AFS_HPUX101_ENV */
#if defined(KERNEL_HAVE_UERROR)
setuerror(EINVAL);
#else
- code = EINVAL; /* not in /afs */
+ code = EINVAL; /* not in /afs */
#endif
#ifdef AFS_DEC_ENV
if (vp) {
#else
#ifndef AFS_SUN5_ENV
#ifdef AFS_SGI_ENV
- OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
+ OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
#else
- u.u_cred = tmpcred; /* restore original credentials */
+ u.u_cred = tmpcred; /* restore original credentials */
#endif /* ASF_SGI64_ENV */
#endif
#endif /* AFS_HPUX101_ENV */
#ifdef AFS_LINUX22_ENV
dput(dp);
#else
- AFS_RELE(vp); /* put vnode back */
+ AFS_RELE(vp); /* put vnode back */
#endif
}
PIOCTL_FREE_CRED();