/*
* osi_misc.c
*
- * Implements:
- * afs_suser
*/
#include <afsconfig.h>
#include "afs/param.h"
-RCSID("$Header$");
#include "afs/sysincludes.h" /* Standard vendor system headers */
#include "afsincludes.h" /* Afs-based standard headers */
#include <sys/namei.h>
-#ifdef AFS_FBSD50_ENV
-/* serious cheating */
-#undef curproc
-#define curproc curthread
-#endif
-
-#ifndef AFS_FBSD50_ENV
-/*
- * afs_suser() returns true if the caller is superuser, false otherwise.
- *
- * Note that it must NOT set errno.
- */
-
-afs_suser()
-{
- int error;
-
- if (suser(curproc) == 0) {
- return (1);
- }
- return (0);
-}
-#endif
-
int
osi_lookupname(char *aname, enum uio_seg seg, int followlink,
- struct vnode **dirvpp, struct vnode **vpp)
+ struct vnode **vpp)
{
struct nameidata n;
- int flags, error;
- flags = 0;
- flags = LOCKLEAF;
+ int flags, error, glocked;
+
+ glocked = ISAFS_GLOCK();
+ if (glocked)
+ AFS_GUNLOCK();
+
+ flags = LOCKLEAF | MPSAFE; /* namei must take Giant if needed */
if (followlink)
flags |= FOLLOW;
else
flags |= NOFOLLOW;
- /* if (dirvpp) flags|=WANTPARENT;*//* XXX LOCKPARENT? */
- NDINIT(&n, LOOKUP, flags, seg, aname, curproc);
- if (error = namei(&n))
+ NDINIT(&n, LOOKUP, flags, seg, aname, curthread);
+ if ((error = namei(&n)) != 0) {
+ if (glocked)
+ AFS_GLOCK();
return error;
+ }
*vpp = n.ni_vp;
-/*
- if (dirvpp)
- *dirvpp = n.ni_dvp;
-*/
- /* should we do this? */
- VOP_UNLOCK(n.ni_vp, 0, curproc);
+ /* XXX should we do this? Usually NOT (matt) */
+#if defined(AFS_FBSD80_ENV)
+ /*VOP_UNLOCK(n.ni_vp, 0);*/
+#else
+ VOP_UNLOCK(n.ni_vp, 0, curthread);
+#endif
NDFREE(&n, NDF_ONLY_PNBUF);
+ if (glocked)
+ AFS_GLOCK();
return 0;
}
void
afs_osi_SetTime(osi_timeval_t * atv)
{
-#ifdef AFS_FBSD50_ENV
printf("afs attempted to set clock; use \"afsd -nosettime\"\n");
-#else
- struct timespec ts;
- struct timeval tv, delta;
- int s;
+}
- AFS_GUNLOCK();
- s = splclock();
- microtime(&tv);
- delta = *atv;
- timevalsub(&delta, &tv);
- ts.tv_sec = atv->tv_sec;
- ts.tv_nsec = atv->tv_usec * 1000;
- set_timecounter(&ts);
- (void)splsoftclock();
- lease_updatetime(delta.tv_sec);
- splx(s);
- resettodr();
- AFS_GLOCK();
-#endif
+/*
+ * Replace all of the bogus special-purpose memory allocators...
+ */
+void *
+osi_fbsd_alloc(size_t size, int dropglobal)
+{
+ void *rv;
+ int glocked;
+
+ if (dropglobal) {
+ glocked = ISAFS_GLOCK();
+ if (glocked)
+ AFS_GUNLOCK();
+ rv = malloc(size, M_AFS, M_WAITOK);
+ if (glocked)
+ AFS_GLOCK();
+ } else
+ rv = malloc(size, M_AFS, M_NOWAIT);
+
+ return (rv);
+}
+
+void
+osi_fbsd_free(void *p)
+{
+ free(p, M_AFS);
}