gtx: project null auth # kauth rxkad ?
case ${SYS_NAME} in \
- rs_aix* | sun4x_5? | sgi_6? | *linux*) \
+ rs_aix* | sun4x_5? | sgi_6? | *linux* | ppc_darwin*) \
rm -f ${DESTDIR}lib/afs/libtermlib.a; \
ln -s libnull.a ${DESTDIR}lib/afs/libtermlib.a; \
${COMPILE_PART1} gtx ${COMPILE_PART2};; \
case ${SYS_NAME} in \
sun4x_58 ) echo skipping ntp for ${SYS_NAME} ;; \
*linux* ) echo skipping ntp for ${SYS_NAME} ;; \
+ ppc_darwin* ) echo skipping ntp for ${SYS_NAME} ;; \
* ) ${COMPILE_PART1} ntp ${COMPILE_PART2} ;; \
esac
vfsck: minproject vol
set -x; \
case ${SYS_NAME} in \
- sgi_* | *linux*) \
- echo skip vfsck for ${SYS_NAME} ;; \
- rs_aix42) \
+ sgi_* | *linux* | rs_aix42 | ppc_darwin* ) \
echo skip vfsck for ${SYS_NAME} ;; \
* ) \
${COMPILE_PART1} vfsck ${COMPILE_PART2} ;; \
${COMPILE_PART1} login ${COMPILE_PART2} ;; \
sun4x_* | hp_ux11* | *linux* ) \
${COMPILE_PART1} pam ${COMPILE_PART2} ;; \
+ ppc_darwin* ) \
+ echo Skipping login for ${SYS_NAME} ;; \
* ) \
${COMPILE_PART1} login ${COMPILE_PART2} ;; \
esac
# pthread based user space RX library
libafsrpc: rx rxkad des
- ${COMPILE_PART1} libafsrpc ${COMPILE_PART2}
+ case ${SYS_NAME} in \
+ alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux*) \
+ ${COMPILE_PART1} libafsrpc ${COMPILE_PART2} ;; \
+ *) \
+ echo Not building MT libafsrpc for ${SYS_NAME} ;; \
+ esac
libafsauthent: ubik auth kauth libafsrpc
- ${COMPILE_PART1} libafsauthent ${COMPILE_PART2}
+ case ${SYS_NAME} in \
+ alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux*) \
+ ${COMPILE_PART1} libafsauthent ${COMPILE_PART2} ;; \
+ *) \
+ echo Not building MT libafsrpc for ${SYS_NAME} ;; \
+ esac
-libadmin: libafsauthent bozo
+libadmin_real: libafsauthent bozo
${COMPILE_PART1} libadmin ${COMPILE_PART2}
${COMPILE_PART1} libadmin/adminutil ${COMPILE_PART2}
${COMPILE_PART1} libadmin/vos ${COMPILE_PART2}
${COMPILE_PART1} libadmin/test ${COMPILE_PART2}
${COMPILE_PART1} libadmin/samples ${COMPILE_PART2}
+libadmin: libafsauthent bozo
+ case ${SYS_NAME} in \
+ alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux*) \
+ $(MAKE) libadmin_real SYS_NAME=$(SYS_NAME) \
+ WASHTOOL="$(WASHTOOL)" \
+ COMPILE_PART1="$(COMPILE_PART1)" \
+ COMPILE_PART2="$(COMPILE_PART2)" \
+ SRCDIR=$(SRCDIR) DESTDIR=$(DESTDIR) \
+ DBG_DEFS=$(DBG_DEFS) ;; \
+ *) \
+ echo Not building MT libadmin for ${SYS_NAME} ;; \
+ esac
+
finale: project cmd comerr afsd allrcmds butc tbutc libafs libuafs audit kauth log package \
ptserver scout bu_utils ubik uss bozo vfsck volser \
venus update xstat afsmonitor dauth tests libafsrpc \
MKAFS_OSTYPE=IRIX;; \
sun4x_5* ) \
MKAFS_OSTYPE=SOLARIS;; \
+ ppc_darwin* ) \
+ MKAFS_OSTYPE=DARWIN;; \
* ) \
echo WARNING: No MakefileProto for sys ${SYS_NAME} ; \
esac; \
MKAFS_OSTYPE=DUX;; \
sgi_6* ) \
MKAFS_OSTYPE=IRIX;; \
+ ppc_darwin* ) \
+ MKAFS_OSTYPE=DARWIN;; \
* ) \
echo WARNING: No MakefileProto for sys ${SYS_NAME} ; \
esac; \
sun4x_56/
sun4x_57/
sun4x_58/
+ ppc_darwin_13/
alpha_linux_2216_22/ (DES does not work, will require one more change to
compile)
--- /dev/null
+/*
+ * 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
+ */
+
+#include "../afs/param.h" /* Should be always first */
+#include "../afs/sysincludes.h" /* Standard vendor system headers */
+#include "../afs/afsincludes.h" /* Afs-based standard headers */
+#include "../afs/afs_stats.h" /* afs statistics */
+#include "../afs/osi_inode.h"
+
+
+int afs_osicred_initialized=0;
+struct AFS_UCRED afs_osi_cred;
+afs_lock_t afs_xosi; /* lock is for tvattr */
+extern struct osi_dev cacheDev;
+extern struct mount *afs_cacheVfsp;
+int afs_CacheFSType = -1;
+
+/* Initialize the cache operations. Called while initializing cache files. */
+void afs_InitDualFSCacheOps(struct vnode *vp)
+{
+ int code;
+ static int inited = 0;
+
+ if (inited)
+ return;
+ inited = 1;
+
+ if (vp == NULL)
+ return;
+ if (strncmp("hfs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
+ afs_CacheFSType = AFS_APPL_HFS_CACHE;
+ else
+ if (strncmp("ufs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0)
+ afs_CacheFSType = AFS_APPL_UFS_CACHE;
+ else
+ osi_Panic("Unknown cache vnode type\n");
+}
+
+ino_t VnodeToIno(vnode_t *avp)
+{
+ unsigned long ret;
+
+ if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
+ struct inode *ip = VTOI(avp);
+ ret=ip->i_number;
+ }
+ if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
+#ifndef VTOH
+ struct vattr va;
+ if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
+ osi_Panic("VOP_GETATTR failed in VnodeToIno\n");
+ ret=va.va_fileid;
+#else
+ struct hfsnode *hp = VTOH(avp);
+ ret=H_FILEID(hp);
+#endif
+ }
+ return ret;
+}
+
+
+dev_t VnodeToDev(vnode_t *avp)
+{
+
+
+ if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
+ struct inode *ip = VTOI(avp);
+ return ip->i_dev;
+ }
+ if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
+#ifndef VTOH /* slow, but works */
+ struct vattr va;
+ if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc()))
+ osi_Panic("VOP_GETATTR failed in VnodeToDev\n");
+ return va.va_fsid; /* XXX they say it's the dev.... */
+#else
+ struct hfsnode *hp = VTOH(avp);
+ return H_DEV(hp);
+#endif
+ }
+}
+
+void *osi_UFSOpen(ainode)
+ afs_int32 ainode;
+{
+ struct vnode *vp;
+ struct vattr va;
+ register struct osi_file *afile = NULL;
+ extern int cacheDiskType;
+ afs_int32 code = 0;
+ int dummy;
+ AFS_STATCNT(osi_UFSOpen);
+ if(cacheDiskType != AFS_FCACHE_TYPE_UFS) {
+ osi_Panic("UFSOpen called for non-UFS cache\n");
+ }
+ if (!afs_osicred_initialized) {
+ /* valid for alpha_osf, SunOS, Ultrix */
+ bzero((char *)&afs_osi_cred, sizeof(struct AFS_UCRED));
+ afs_osi_cred.cr_ref++;
+ afs_osi_cred.cr_ngroups=1;
+ afs_osicred_initialized = 1;
+ }
+ afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file));
+ AFS_GUNLOCK();
+ if (afs_CacheFSType == AFS_APPL_HFS_CACHE)
+ code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, &ainode, &vp, &va, &dummy); /* XXX hfs is broken */
+ else
+ code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &vp, &va, &dummy);
+ AFS_GLOCK();
+ if (code) {
+ osi_FreeSmallSpace(afile);
+ osi_Panic("UFSOpen: igetinode failed");
+ }
+ afile->vnode = vp;
+ afile->size = va.va_size;
+ afile->offset = 0;
+ afile->proc = (int (*)()) 0;
+ afile->inum = ainode; /* for hint validity checking */
+ return (void *)afile;
+}
+
+afs_osi_Stat(afile, astat)
+ register struct osi_file *afile;
+ register struct osi_stat *astat; {
+ register afs_int32 code;
+ struct vattr tvattr;
+ AFS_STATCNT(osi_Stat);
+ MObtainWriteLock(&afs_xosi,320);
+ AFS_GUNLOCK();
+ code=VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
+ AFS_GLOCK();
+ if (code == 0) {
+ astat->size = tvattr.va_size;
+ astat->blksize = tvattr.va_blocksize;
+ astat->mtime = tvattr.va_mtime.tv_sec;
+ astat->atime = tvattr.va_atime.tv_sec;
+ }
+ MReleaseWriteLock(&afs_xosi);
+ return code;
+}
+
+osi_UFSClose(afile)
+ register struct osi_file *afile;
+ {
+ AFS_STATCNT(osi_Close);
+ if(afile->vnode) {
+ AFS_RELE(afile->vnode);
+ }
+
+ osi_FreeSmallSpace(afile);
+ return 0;
+ }
+
+osi_UFSTruncate(afile, asize)
+ register struct osi_file *afile;
+ afs_int32 asize; {
+ struct AFS_UCRED *oldCred;
+ struct vattr tvattr;
+ register afs_int32 code;
+ struct osi_stat tstat;
+ AFS_STATCNT(osi_Truncate);
+
+ /* This routine only shrinks files, and most systems
+ * have very slow truncates, even when the file is already
+ * small enough. Check now and save some time.
+ */
+ code = afs_osi_Stat(afile, &tstat);
+ if (code || tstat.size <= asize) return code;
+ MObtainWriteLock(&afs_xosi,321);
+ VATTR_NULL(&tvattr);
+ tvattr.va_size = asize;
+ AFS_GUNLOCK();
+ code=VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
+ AFS_GLOCK();
+ MReleaseWriteLock(&afs_xosi);
+ return code;
+}
+
+void osi_DisableAtimes(avp)
+struct vnode *avp;
+{
+
+
+ if (afs_CacheFSType == AFS_APPL_UFS_CACHE) {
+ struct inode *ip = VTOI(avp);
+ ip->i_flag &= ~IN_ACCESS;
+ }
+#ifdef VTOH /* can't do this without internals */
+ else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) {
+ struct hfsnode *hp = VTOH(avp);
+ hp->h_nodeflags &= ~IN_ACCESS;
+ }
+#endif
+}
+
+
+/* Generic read interface */
+afs_osi_Read(afile, offset, aptr, asize)
+ register struct osi_file *afile;
+ int offset;
+ char *aptr;
+ afs_int32 asize; {
+ struct AFS_UCRED *oldCred;
+ unsigned int resid;
+ register afs_int32 code;
+ AFS_STATCNT(osi_Read);
+
+ /**
+ * If the osi_file passed in is NULL, panic only if AFS is not shutting
+ * down. No point in crashing when we are already shutting down
+ */
+ if ( !afile ) {
+ if ( !afs_shuttingdown )
+ osi_Panic("osi_Read called with null param");
+ else
+ return EIO;
+ }
+
+ if (offset != -1) afile->offset = offset;
+ AFS_GUNLOCK();
+ code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
+ AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
+ AFS_GLOCK();
+ if (code == 0) {
+ code = asize - resid;
+ afile->offset += code;
+ osi_DisableAtimes(afile->vnode);
+ }
+ else {
+ afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
+ ICL_TYPE_INT32, code);
+ code = -1;
+ }
+ return code;
+}
+
+/* Generic write interface */
+afs_osi_Write(afile, offset, aptr, asize)
+ register struct osi_file *afile;
+ char *aptr;
+ afs_int32 offset;
+ afs_int32 asize; {
+ struct AFS_UCRED *oldCred;
+ unsigned int resid;
+ register afs_int32 code;
+ AFS_STATCNT(osi_Write);
+ if ( !afile )
+ osi_Panic("afs_osi_Write called with null param");
+ if (offset != -1) afile->offset = offset;
+ {
+ AFS_GUNLOCK();
+ code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset,
+ AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
+ AFS_GLOCK();
+ }
+ if (code == 0) {
+ code = asize - resid;
+ afile->offset += code;
+ }
+ else {
+ code = -1;
+ }
+ if (afile->proc) {
+ (*afile->proc)(afile, code);
+ }
+ return code;
+}
+
+
+
+
+
+void
+shutdown_osifile()
+{
+ extern int afs_cold_shutdown;
+
+ AFS_STATCNT(shutdown_osifile);
+ if (afs_cold_shutdown) {
+ afs_osicred_initialized = 0;
+ }
+}
+
--- /dev/null
+/*
+ * 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
+ */
+/*
+ * osi_groups.c
+ *
+ * Implements:
+ * Afs_xsetgroups (syscall)
+ * setpag
+ *
+ */
+#include "../afs/param.h"
+#include "../afs/sysincludes.h"
+#include "../afs/afsincludes.h"
+#include "../afs/afs_stats.h" /* statistics */
+
+static int
+afs_getgroups(
+ struct ucred *cred,
+ int ngroups,
+ gid_t *gidset);
+
+static int
+afs_setgroups(
+ struct proc *proc,
+ struct ucred **cred,
+ int ngroups,
+ gid_t *gidset,
+ int change_parent);
+
+int
+Afs_xsetgroups(p, args, retval)
+ struct proc *p;
+ void *args;
+ int *retval;
+{
+ int code = 0;
+ struct vrequest treq;
+ struct ucred *cr;
+
+ pcred_readlock(p);
+ cr=crdup(p->p_cred->pc_ucred);
+ pcred_unlock(p);
+
+ AFS_STATCNT(afs_xsetgroups);
+ AFS_GLOCK();
+
+ code = afs_InitReq(&treq, cr);
+ AFS_GUNLOCK();
+ crfree(cr);
+ if (code) return setgroups(p, args, retval); /* afs has shut down */
+
+ code = setgroups(p, args, retval);
+ /* Note that if there is a pag already in the new groups we don't
+ * overwrite it with the old pag.
+ */
+ pcred_readlock(p);
+ cr=crdup(p->p_cred->pc_ucred);
+ pcred_unlock(p);
+
+ if (PagInCred(cr) == NOPAG) {
+ if (((treq.uid >> 24) & 0xff) == 'A') {
+ AFS_GLOCK();
+ /* we've already done a setpag, so now we redo it */
+ AddPag(p, treq.uid, &cr );
+ AFS_GUNLOCK();
+ }
+ }
+ crfree(cr);
+ return code;
+}
+
+
+int
+setpag(proc, cred, pagvalue, newpag, change_parent)
+ struct proc *proc;
+ struct ucred **cred;
+ afs_uint32 pagvalue;
+ afs_uint32 *newpag;
+ afs_uint32 change_parent;
+{
+ gid_t gidset[NGROUPS];
+ int ngroups, code;
+ int j;
+
+ AFS_STATCNT(setpag);
+ ngroups = afs_getgroups(*cred, NGROUPS, gidset);
+ if (afs_get_pag_from_groups(gidset[1], gidset[2]) == NOPAG) {
+ /* We will have to shift grouplist to make room for pag */
+ if (ngroups + 2 > NGROUPS) {
+ return (E2BIG);
+ }
+ for (j = ngroups -1; j >= 1; j--) {
+ gidset[j+2] = gidset[j];
+ }
+ ngroups += 2;
+ }
+ *newpag = (pagvalue == -1 ? genpag(): pagvalue);
+ afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]);
+ code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
+ return code;
+}
+
+
+static int
+afs_getgroups(
+ struct ucred *cred,
+ int ngroups,
+ gid_t *gidset)
+{
+ int ngrps, savengrps;
+ gid_t *gp;
+
+ AFS_STATCNT(afs_getgroups);
+ savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
+ gp = cred->cr_groups;
+ while (ngrps--)
+ *gidset++ = *gp++;
+ return savengrps;
+}
+
+
+
+static int
+afs_setgroups(
+ struct proc *proc,
+ struct ucred **cred,
+ int ngroups,
+ gid_t *gidset,
+ int change_parent)
+{
+ int ngrps;
+ int i;
+ gid_t *gp;
+ struct ucred *oldcr, *cr;
+
+ AFS_STATCNT(afs_setgroups);
+ /*
+ * The real setgroups() call does this, so maybe we should too.
+ *
+ */
+ if (ngroups > NGROUPS)
+ return EINVAL;
+ cr = *cred;
+ cr->cr_ngroups = ngroups;
+ gp = cr->cr_groups;
+ while (ngroups--)
+ *gp++ = *gidset++;
+ if (change_parent) {
+ crhold(cr);
+ pcred_writelock(proc->p_pptr);
+ oldcr=proc->p_pptr->p_cred->pc_ucred;
+ proc->p_pptr->p_cred->pc_ucred=cr;
+ pcred_unlock(proc->p_pptr);
+ crfree(oldcr);
+ }
+ crhold(cr);
+ pcred_writelock(proc);
+ oldcr=proc->p_cred->pc_ucred;
+ proc->p_cred->pc_ucred=cr;
+ pcred_unlock(proc);
+ crfree(oldcr);
+ return(0);
+}
--- /dev/null
+/*
+ * 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
+ */
+/*
+ * MACOS inode operations
+ *
+ * Implements:
+ *
+ */
+#include "../afs/param.h" /* Should be always first */
+#include "../afs/sysincludes.h" /* Standard vendor system headers */
+#include "../afs/afsincludes.h" /* Afs-based standard headers */
+#include "../afs/osi_inode.h"
+#include "../afs/afs_stats.h" /* statistics stuff */
+#include <ufs/ufs/ufsmount.h>
+extern struct ucred afs_osi_cred;
+
+getinode(fs, dev, inode, vpp, perror)
+ struct mount *fs;
+ struct vnode **vpp;
+ dev_t dev;
+ ino_t inode;
+ int *perror;
+{
+ struct vnode *vp;
+ int code;
+
+ *vpp = 0;
+ *perror = 0;
+ if (!fs) {
+ register struct ufsmount *ump;
+#ifdef VFSTOHFS
+ register struct hfsmount *hmp;
+#endif
+ register struct vnode *vp;
+ register struct mount *mp;
+ extern struct mount *rootfs;
+ if (mp = rootfs) do {
+ /*
+ * XXX Also do the test for MFS
+ */
+ if (!strcmp(mp->mnt_vfc->vfc_name, "ufs")) {
+ ump = VFSTOUFS(mp);
+ if (ump->um_fs == NULL)
+ break;
+ if (ump->um_dev == dev) {
+ fs = ump->um_mountp;
+ }
+ }
+#ifdef VFSTOHFS
+ if (!strcmp(mp->mnt_vfc->vfc_name, "hfs")) {
+ hmp = VFSTOHFS(mp);
+#if 0
+ if (hmp->hfs_mp == NULL)
+ break;
+#endif
+ if (hmp->hfs_raw_dev == dev) {
+ fs = hmp->hfs_mp;
+ }
+ }
+#endif
+
+ mp = CIRCLEQ_NEXT(mp, mnt_list);
+ } while (mp != rootfs);
+ if (!fs)
+ return(ENXIO);
+ }
+ code=VFS_VGET(fs, (void *)inode, &vp);
+ if (code) {
+ *perror = BAD_IGET;
+ return code;
+ } else {
+ *vpp = vp;
+ return(0);
+ }
+}
+extern int afs_CacheFSType;
+igetinode(vfsp, dev, inode, vpp, va, perror)
+ struct vnode **vpp;
+ struct mount *vfsp;
+ dev_t dev;
+ ino_t inode;
+ struct vattr *va;
+ int *perror;
+{
+ struct vnode *pvp, *vp;
+ extern struct osi_dev cacheDev;
+ register int code = 0;
+
+ *perror = 0;
+
+ AFS_STATCNT(igetinode);
+ if ((code = getinode(vfsp, dev, inode, &vp, perror)) != 0) {
+ return(code);
+ }
+ if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK) {
+ printf("igetinode: bad type %d\n", vp->v_type);
+ iforget(vp);
+ return(ENOENT);
+ }
+ VOP_GETATTR(vp, va, &afs_osi_cred, current_proc());
+ if (va->va_mode == 0) {
+ /* Not an allocated inode */
+ iforget(vp);
+ return(ENOENT);
+ }
+ if (vfsp && afs_CacheFSType == AFS_APPL_HFS_CACHE && va->va_nlink == 0) {
+ printf("igetinode: hfs nlink 0\n");
+ }
+ if (va->va_nlink == 0) {
+ vput(vp);
+ return(ENOENT);
+ }
+
+ VOP_UNLOCK(vp, 0, current_proc());
+ *vpp = vp;
+ return(0);
+}
+
+iforget(vp)
+struct vnode *vp;
+{
+
+ AFS_STATCNT(iforget);
+ /* XXX could sleep */
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, current_proc());
+ /* this whole thing is too wierd. Why??? XXX */
+ if (vp->v_usecount == 1) {
+ vp->v_usecount=0;
+ VOP_UNLOCK(vp,0, current_proc());
+#if 0
+ simple_lock(&vnode_free_list_slock);
+ TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
+ freevnodes++;
+ simple_unlock(&vnode_free_list_slock);
+#else
+ printf("iforget: leaking vnode\n");
+#endif
+ } else {
+ vput(vp);
+ }
+}
+
+#if 0
+/*
+ * icreate system call -- create an inode
+ */
+afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
+ long *retval;
+ long dev, near_inode, param1, param2, param3, param4;
+{
+ int dummy, err=0;
+ struct inode *ip, *newip;
+ register int code;
+ struct vnode *vp;
+
+ AFS_STATCNT(afs_syscall_icreate);
+
+ if (!afs_suser())
+ return(EPERM);
+
+ code = getinode(0, (dev_t)dev, 2, &ip, &dummy);
+ if (code) {
+ return(ENOENT);
+ }
+ code = ialloc(ip, (ino_t)near_inode, 0, &newip);
+ iput(ip);
+ if (code) {
+ return(code);
+ }
+ IN_LOCK(newip);
+ newip->i_flag |= IACC|IUPD|ICHG;
+
+ newip->i_nlink = 1;
+
+ newip->i_mode = IFREG;
+
+ IN_UNLOCK(newip);
+ vp = ITOV(newip);
+ VN_LOCK(vp);
+ vp->v_type = VREG;
+ VN_UNLOCK(vp);
+
+ if ( !vp->v_object)
+ {
+ extern struct vfs_ubcops ufs_ubcops;
+ extern struct vm_ubc_object* ubc_object_allocate();
+ struct vm_ubc_object* vop;
+ vop = ubc_object_allocate(&vp, &ufs_ubcops,
+ vp->v_mount->m_funnel);
+ VN_LOCK(vp);
+ vp->v_object = vop;
+ VN_UNLOCK(vp);
+ }
+
+
+ IN_LOCK(newip);
+ newip->i_flags |= IC_XUID|IC_XGID;
+ newip->i_flags &= ~IC_PROPLIST;
+ newip->i_vicep1 = param1;
+ if (param2 == 0x1fffffff/*INODESPECIAL*/) {
+ newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3));
+ newip->i_vicep3a = (u_short)(param3 >> 16);
+ newip->i_vicep3b = (u_short)param3;
+ } else {
+ newip->i_vicep2 = (((param2 >> 16) & 0x1f) << 27) +
+ (((param4 >> 16) & 0x1f) << 22) +
+ (param3 & 0x3fffff);
+ newip->i_vicep3a = (u_short)param4;
+ newip->i_vicep3b = (u_short)param2;
+ }
+ newip->i_vicemagic = VICEMAGIC;
+
+ *retval = newip->i_number;
+ IN_UNLOCK(newip);
+ iput(newip);
+ return(code);
+}
+
+
+afs_syscall_iopen(dev, inode, usrmod, retval)
+ long *retval;
+ int dev, inode, usrmod;
+{
+ struct file *fp;
+ struct inode *ip;
+ struct vnode *vp = (struct vnode *)0;
+ int dummy;
+ int fd;
+ extern struct fileops vnops;
+ register int code;
+
+ AFS_STATCNT(afs_syscall_iopen);
+
+ if (!afs_suser())
+ return(EPERM);
+
+ code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy);
+ if (code) {
+ return(code);
+ }
+ if ((code = falloc(&fp, &fd)) != 0) {
+ iput(ip);
+ return(code);
+ }
+ IN_UNLOCK(ip);
+
+ FP_LOCK(fp);
+ fp->f_flag = (usrmod-FOPEN) & FMASK;
+ fp->f_type = DTYPE_VNODE;
+ fp->f_ops = &vnops;
+ fp->f_data = (caddr_t)ITOV(ip);
+
+ FP_UNLOCK(fp);
+ U_FD_SET(fd, fp, &u.u_file_state);
+ *retval = fd;
+ return(0);
+}
+
+
+/*
+ * Support for iinc() and idec() system calls--increment or decrement
+ * count on inode.
+ * Restricted to super user.
+ * Only VICEMAGIC type inodes.
+ */
+afs_syscall_iincdec(dev, inode, inode_p1, amount)
+ int dev, inode, inode_p1, amount;
+{
+ int dummy;
+ struct inode *ip;
+ register int code;
+
+ if (!afs_suser())
+ return(EPERM);
+
+ code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy);
+ if (code) {
+ return(code);
+ }
+ if (!IS_VICEMAGIC(ip)) {
+ return(EPERM);
+ } else if (ip->i_vicep1 != inode_p1) {
+ return(ENXIO);
+ }
+ ip->i_nlink += amount;
+ if (ip->i_nlink == 0) {
+ CLEAR_VICEMAGIC(ip);
+ }
+ ip->i_flag |= ICHG;
+ iput(ip);
+ return(0);
+}
+#else
+afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
+ long *retval;
+ long dev, near_inode, param1, param2, param3, param4;
+{
+ return EOPNOTSUPP;
+}
+afs_syscall_iopen(dev, inode, usrmod, retval)
+ long *retval;
+ int dev, inode, usrmod;
+{
+ return EOPNOTSUPP;
+}
+afs_syscall_iincdec(dev, inode, inode_p1, amount)
+ int dev, inode, inode_p1, amount;
+{
+ return EOPNOTSUPP;
+}
+#endif
--- /dev/null
+/*
+ * 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
+ */
+/*
+ * osi_inode.h
+ *
+ * Inode information required for MACOS servers and salvager.
+ */
+#ifndef _OSI_INODE_H_
+#define _OSI_INODE_H_
+
+#define BAD_IGET -1000
+
+#define VICEMAGIC 0x84fa1cb6
+
+#define DI_VICEP3(p) ((p)->di_vicep3)
+#define I_VICEP3(p) ((p)->i_vicep3)
+
+#define i_vicemagic i_din.di_flags
+#define i_vicep1 i_din.di_gen
+#define i_vicep2 i_din.di_uid
+#define i_vicep3 i_din.di_gid
+#define i_vicep4 i_din.di_spare[0] /* not used */
+
+#define di_vicemagic di_flags
+#define di_vicep1 di_gen
+#define di_vicep2 di_uid
+#define di_vicep3 di_gid
+#define di_vicep4 di_spare[0] /* not used */
+
+#define IS_VICEMAGIC(ip) ((ip)->i_vicemagic == VICEMAGIC)
+#define IS_DVICEMAGIC(dp) ((dp)->di_vicemagic == VICEMAGIC)
+
+#define CLEAR_VICEMAGIC(ip) (ip)->i_vicemagic = 0
+#define CLEAR_DVICEMAGIC(dp) (dp)->di_vicemagic = 0
+
+#endif /* _OSI_INODE_H_ */
--- /dev/null
+/*
+ * 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
+ */
+/*
+ *
+ * MACOS OSI header file. Extends afs_osi.h.
+ *
+ * afs_osi.h includes this file, which is the only way this file should
+ * be included in a source file. This file can redefine macros declared in
+ * afs_osi.h.
+ */
+
+#ifndef _OSI_MACHDEP_H_
+#define _OSI_MACHDEP_H_
+
+#ifdef XAFS_DARWIN_ENV
+#ifndef _MACH_ETAP_H_
+#define _MACH_ETAP_H_
+typedef unsigned short etap_event_t;
+#endif
+#endif
+
+#include <sys/lock.h>
+#include <kern/thread.h>
+#include <sys/user.h>
+
+#define getpid() current_proc()->p_pid
+#define getppid() current_proc()->p_pptr->p_pid
+#undef gop_lookupname
+#define gop_lookupname osi_lookupname
+
+#define FTRUNC 0
+
+/* vcexcl - used only by afs_create */
+enum vcexcl { EXCL, NONEXCL } ;
+
+/*
+ * Time related macros
+ */
+extern struct timeval time;
+#define osi_Time() (time.tv_sec)
+#define afs_hz hz
+
+#define PAGESIZE 8192
+
+#define AFS_UCRED ucred
+
+#define AFS_PROC struct proc
+
+#define osi_vnhold(avc,r) do { \
+ if ((avc)->vrefCount) { VN_HOLD(&((avc)->v)); } \
+ else (avc)->vrefCount = 1; } while(0)
+
+#define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
+ vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid),current_proc())
+
+#undef afs_suser
+
+#ifdef KERNEL
+extern thread_t afs_global_owner;
+/* simple locks cannot be used since sleep can happen at any time */
+/* Should probably use mach locks rather than bsd locks, since we use the
+ mach thread control api's elsewhere (mach locks not used for consistency
+ with rx, since rx needs lock_write_try() in order to use mach locks
+ */
+extern struct lock__bsd__ afs_global_lock;
+#define AFS_GLOCK() \
+ do { \
+ lockmgr(&afs_global_lock, LK_EXCLUSIVE, 0, current_proc()); \
+ osi_Assert(afs_global_owner == 0); \
+ afs_global_owner = current_thread(); \
+ } while (0)
+#define AFS_GUNLOCK() \
+ do { \
+ osi_Assert(afs_global_owner == current_thread()); \
+ afs_global_owner = 0; \
+ lockmgr(&afs_global_lock, LK_RELEASE, 0, current_proc()); \
+ } while(0)
+#define ISAFS_GLOCK() (afs_global_owner == current_thread())
+#define AFS_RXGLOCK()
+#define AFS_RXGUNLOCK()
+#define ISAFS_RXGLOCK() 1
+
+#define SPLVAR
+#define NETPRI
+#define USERPRI
+#if 0
+#undef SPLVAR
+#define SPLVAR int x;
+#undef NETPRI
+#define NETPRI x=splnet();
+#undef USERPRI
+#define USERPRI splx(x);
+#endif
+
+#define AFS_APPL_UFS_CACHE 1
+#define AFS_APPL_HFS_CACHE 2
+
+extern ino_t VnodeToIno(vnode_t *vp);
+extern dev_t VnodeToDev(vnode_t *vp);
+
+#endif /* KERNEL */
+
+#endif /* _OSI_MACHDEP_H_ */
--- /dev/null
+/*
+ * 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
+ */
+
+#include "../afs/param.h"
+#include "../afs/sysincludes.h"
+#include "../afs/afsincludes.h"
+#include <sys/namei.h>
+
+int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
+ struct vnode **dirvpp, struct vnode **vpp)
+{
+ struct nameidata n;
+ int flags,error;
+ flags=0;
+ flags=LOCKLEAF;
+ if (followlink)
+ flags|=FOLLOW;
+ else
+ flags|=NOFOLLOW;
+/* if (dirvpp) flags|=WANTPARENT;*/ /* XXX LOCKPARENT? */
+ NDINIT(&n, LOOKUP, flags, seg, aname, current_proc());
+ if (error=namei(&n))
+ return error;
+ *vpp=n.ni_vp;
+/*
+ if (dirvpp)
+ *dirvpp = n.ni_dvp;
+#/
+ /* should we do this? */
+ VOP_UNLOCK(n.ni_vp, 0, current_proc());
+ return 0;
+}
+
+/*
+ * afs_suser() returns true if the caller is superuser, false otherwise.
+ *
+ * Note that it must NOT set errno.
+ */
+
+afs_suser() {
+ int error;
+ struct proc *p=current_proc();
+
+ if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) {
+ return(1);
+ }
+ return(0);
+}
--- /dev/null
+#include "../afs/param.h"
+#include "../afs/sysincludes.h"
+#include "../afs/afsincludes.h"
+#include "../sys/syscall.h"
+#include <mach/kmod.h>
+#define VERSION "1.0.3"
+
+
+struct vfsconf afs_vfsconf;
+extern struct vfsops afs_vfsops;
+extern struct mount *afs_globalVFS;
+extern int Afs_xsetgroups();
+extern int afs_xioctl();
+extern int afs3_syscall();
+
+extern int ioctl();
+extern int setgroups();
+kern_return_t afs_modload(struct kmod_info *ki, void *data)
+{
+ if (sysent[AFS_SYSCALL].sy_call != nosys) {
+ printf("AFS_SYSCALL in use. aborting\n");
+ return KERN_FAILURE;
+ }
+ bzero(&afs_vfsconf, sizeof(struct vfsconf));
+ strcpy(afs_vfsconf.vfc_name, "afs");
+ afs_vfsconf.vfc_vfsops=&afs_vfsops;
+ afs_vfsconf.vfc_typenum=VT_AFS;
+ afs_vfsconf.vfc_flags=MNT_NODEV;
+ if (vfsconf_add(&afs_vfsconf)) {
+ printf("AFS: vfsconf_add failed. aborting\n");
+ return KERN_FAILURE;
+ }
+ sysent[SYS_setgroups].sy_call=Afs_xsetgroups;
+ sysent[SYS_ioctl].sy_call=afs_xioctl;
+ sysent[AFS_SYSCALL].sy_call=afs3_syscall;
+ sysent[AFS_SYSCALL].sy_narg = 5;
+ sysent[AFS_SYSCALL].sy_parallel = 0;
+#ifdef KERNEL_FUNNEL
+ sysent[AFS_SYSCALL].sy_funnel=KERNEL_FUNNEL;
+#endif
+ return KERN_SUCCESS;
+}
+kern_return_t afs_modunload(struct kmod_info *ki, void *data)
+{
+ if (afs_globalVFS)
+ return KERN_FAILURE;
+ if (vfsconf_del("afs"))
+ return KERN_FAILURE;
+ /* give up syscall entries for ioctl & setgroups, which we've stolen */
+ sysent[SYS_ioctl].sy_call = ioctl;
+ sysent[SYS_setgroups].sy_call = setgroups;
+ /* give up the stolen syscall entry */
+ sysent[AFS_SYSCALL].sy_narg = 0;
+ sysent[AFS_SYSCALL].sy_call = nosys;
+ return KERN_SUCCESS;
+ }
+
+KMOD_EXPLICIT_DECL(openafs, VERSION, afs_modload, afs_modunload)
--- /dev/null
+/*
+ * 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
+ */
+/*
+ * osi_prototypes.h
+ *
+ * Exported macos support routines.
+ */
+#ifndef _OSI_PROTO_H_
+#define _OSI_PROTO_H_
+
+/* osi_misc.c */
+extern int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
+ struct vnode **dirvpp, struct vnode **vpp);
+/* osi_vm.c */
+extern void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size);
+extern int osi_VM_Setup(struct vcache *avc);
+#endif /* _OSI_PROTO_H_ */
--- /dev/null
+/*
+ * 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
+ */
+
+#include "../afs/param.h" /* Should be always first */
+#include "../afs/sysincludes.h" /* Standard vendor system headers */
+#include "../afs/afsincludes.h" /* Afs-based standard headers */
+#include "../afs/afs_stats.h" /* afs statistics */
+
+
+static int osi_TimedSleep(char *event, afs_int32 ams, int aintok);
+void afs_osi_Wakeup(char *event);
+void afs_osi_Sleep(char *event);
+
+static char waitV;
+
+
+void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle)
+{
+ AFS_STATCNT(osi_InitWaitHandle);
+ achandle->proc = (caddr_t) 0;
+}
+
+/* cancel osi_Wait */
+void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle)
+{
+ caddr_t proc;
+
+ AFS_STATCNT(osi_CancelWait);
+ proc = achandle->proc;
+ if (proc == 0) return;
+ achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */
+ afs_osi_Wakeup(&waitV);
+}
+
+/* afs_osi_Wait
+ * Waits for data on ahandle, or ams ms later. ahandle may be null.
+ * Returns 0 if timeout and EINTR if signalled.
+ */
+int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok)
+{
+ int code;
+ afs_int32 endTime, tid;
+ struct proc *p=current_proc();
+
+ AFS_STATCNT(osi_Wait);
+ endTime = osi_Time() + (ams/1000);
+ if (ahandle)
+ ahandle->proc = (caddr_t)p;
+ do {
+ AFS_ASSERT_GLOCK();
+ code = 0;
+ code = osi_TimedSleep(&waitV, ams, aintok);
+
+ if (code) break; /* if something happened, quit now */
+ /* if we we're cancelled, quit now */
+ if (ahandle && (ahandle->proc == (caddr_t) 0)) {
+ /* we've been signalled */
+ break;
+ }
+ } while (osi_Time() < endTime);
+ return code;
+}
+
+
+
+typedef struct afs_event {
+ struct afs_event *next; /* next in hash chain */
+ char *event; /* lwp event: an address */
+ int refcount; /* Is it in use? */
+ int seq; /* Sequence number: this is incremented
+ by wakeup calls; wait will not return until
+ it changes */
+} afs_event_t;
+
+#define HASHSIZE 128
+afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */
+#define afs_evhash(event) (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1));
+int afs_evhashcnt = 0;
+
+/* Get and initialize event structure corresponding to lwp event (i.e. address)
+ * */
+static afs_event_t *afs_getevent(char *event)
+{
+ afs_event_t *evp, *newp = 0;
+ int hashcode;
+
+ AFS_ASSERT_GLOCK();
+ hashcode = afs_evhash(event);
+ evp = afs_evhasht[hashcode];
+ while (evp) {
+ if (evp->event == event) {
+ evp->refcount++;
+ return evp;
+ }
+ if (evp->refcount == 0)
+ newp = evp;
+ evp = evp->next;
+ }
+ if (!newp) {
+ newp = (afs_event_t *) osi_AllocSmallSpace(sizeof (afs_event_t));
+ afs_evhashcnt++;
+ newp->next = afs_evhasht[hashcode];
+ afs_evhasht[hashcode] = newp;
+ newp->seq = 0;
+ }
+ newp->event = event;
+ newp->refcount = 1;
+ return newp;
+}
+
+/* Release the specified event */
+#define relevent(evp) ((evp)->refcount--)
+
+
+void afs_osi_Sleep(char *event)
+{
+ struct afs_event *evp;
+ int seq;
+
+ evp = afs_getevent(event);
+ seq = evp->seq;
+ while (seq == evp->seq) {
+ AFS_ASSERT_GLOCK();
+ assert_wait((event_t)event, 0);
+ AFS_GUNLOCK();
+ thread_block(0);
+ AFS_GLOCK();
+ }
+ relevent(evp);
+}
+
+/* osi_TimedSleep
+ *
+ * Arguments:
+ * event - event to sleep on
+ * ams --- max sleep time in milliseconds
+ * aintok - 1 if should sleep interruptibly
+ *
+ * Returns 0 if timeout and EINTR if signalled.
+ */
+static int osi_TimedSleep(char *event, afs_int32 ams, int aintok)
+{
+ int code = 0;
+ struct afs_event *evp;
+ int ticks,seq;
+
+ ticks = ( ams * afs_hz )/1000;
+
+
+ evp = afs_getevent(event);
+ seq=evp->seq;
+ assert_wait((event_t)event, aintok ? THREAD_ABORTSAFE : 0);
+ AFS_GUNLOCK();
+ thread_set_timer(ticks, NSEC_PER_SEC / hz);
+ thread_block(0);
+ AFS_GLOCK();
+#if 0 /* thread_t structure only available if MACH_KERNEL_PRIVATE */
+ if (current_thread()->wait_result != THREAD_AWAKENED)
+ code = EINTR;
+#else
+ if (seq == evp->seq)
+ code = EINTR;
+#endif
+
+ relevent(evp);
+ return code;
+}
+
+
+void afs_osi_Wakeup(char *event)
+{
+ struct afs_event *evp;
+
+ evp = afs_getevent(event);
+ if (evp->refcount > 1) {
+ evp->seq++;
+ thread_wakeup((event_t)event);
+ }
+ relevent(evp);
+}
--- /dev/null
+#include <afs/param.h> /* Should be always first */
+#include <afs/sysincludes.h> /* Standard vendor system headers */
+#include <afs/afsincludes.h> /* Afs-based standard headers */
+#include <afs/afs_stats.h> /* statistics */
+#include <sys/malloc.h>
+#include <sys/namei.h>
+#include <sys/conf.h>
+#include <sys/syscall.h>
+
+struct vcache *afs_globalVp = 0;
+struct mount *afs_globalVFS = 0;
+
+int
+afs_quotactl()
+{
+ return EOPNOTSUPP;
+}
+
+int
+afs_fhtovp(mp, fhp, vpp)
+struct mount *mp;
+struct fid *fhp;
+struct vnode **vpp;
+{
+
+ return (EINVAL);
+}
+
+int
+afs_vptofh(vp, fhp)
+struct vnode *vp;
+struct fid *fhp;
+{
+
+ return (EINVAL);
+}
+
+int
+afs_start(mp, flags, p)
+struct mount *mp;
+int flags;
+struct proc *p;
+{
+ return (0); /* nothing to do. ? */
+}
+
+int
+afs_mount(mp, path, data, ndp, p)
+register struct mount *mp;
+char *path;
+caddr_t data;
+struct nameidata *ndp;
+struct proc *p;
+{
+ /* ndp contains the mounted-from device. Just ignore it.
+ we also don't care about our proc struct. */
+ size_t size;
+ int error;
+
+ if (mp->mnt_flag & MNT_UPDATE)
+ return EINVAL;
+
+ AFS_GLOCK();
+ AFS_STATCNT(afs_mount);
+
+ if (afs_globalVFS) { /* Don't allow remounts. */
+ AFS_GUNLOCK();
+ return (EBUSY);
+ }
+
+ afs_globalVFS = mp;
+ mp->vfs_bsize = 8192;
+ vfs_getnewfsid(mp);
+ mp->mnt_stat.f_iosize=8192;
+
+ (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN-1, &size);
+ bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
+ bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
+ strcpy(mp->mnt_stat.f_mntfromname, "AFS");
+ /* null terminated string "AFS" will fit, just leave it be. */
+ strcpy(mp->mnt_stat.f_fstypename, "afs");
+ AFS_GUNLOCK();
+ (void) afs_statfs(mp, &mp->mnt_stat, p);
+ return 0;
+}
+
+int
+afs_unmount(mp, flags, p)
+struct mount *mp;
+int flags;
+struct proc *p;
+{
+
+ AFS_GLOCK();
+ AFS_STATCNT(afs_unmount);
+ afs_globalVFS = 0;
+ afs_shutdown();
+ AFS_GUNLOCK();
+
+ return 0;
+}
+
+int
+afs_root(struct mount *mp,
+ struct vnode **vpp)
+{
+ int error;
+ struct vrequest treq;
+ register struct vcache *tvp=0;
+ struct proc *p=current_proc();
+ struct ucred cr;
+
+ pcred_readlock(p);
+ cr=*p->p_cred->pc_ucred;
+ pcred_unlock(p);
+ AFS_GLOCK();
+ AFS_STATCNT(afs_root);
+ if (afs_globalVp && (afs_globalVp->states & CStatd)) {
+ tvp = afs_globalVp;
+ error=0;
+ } else {
+
+ if (!(error = afs_InitReq(&treq, &cr)) &&
+ !(error = afs_CheckInit())) {
+ tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0,
+ (struct vcache*)0, WRITE_LOCK);
+ /* we really want this to stay around */
+ if (tvp) {
+ afs_globalVp = tvp;
+ } else
+ error = ENOENT;
+ }
+ }
+ if (tvp) {
+ osi_vnhold(tvp,0);
+ AFS_GUNLOCK();
+ vn_lock((struct vnode *)tvp, LK_EXCLUSIVE | LK_RETRY, p);
+ AFS_GLOCK();
+ afs_globalVFS = mp;
+ *vpp = (struct vnode *) tvp;
+ tvp->v.v_flag |= VROOT;
+ }
+
+ afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
+ ICL_TYPE_INT32, error);
+ AFS_GUNLOCK();
+ return error;
+}
+
+int
+afs_vget(mp, lfl, vp)
+struct mount *mp;
+struct vnode *vp;
+int lfl;
+{
+ int error;
+ printf("vget called. help!\n");
+ if (vp->v_usecount < 0) {
+ vprint("bad usecount", vp);
+ panic("afs_vget");
+ }
+ error = vget(vp, lfl, current_proc());
+ if (!error)
+ insmntque(vp, afs_globalVFS); /* take off free list */
+ return error;
+}
+
+int afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p)
+{
+ AFS_GLOCK();
+ AFS_STATCNT(afs_statfs);
+
+#if 0
+ abp->f_type = MOUNT_AFS;
+#endif
+ abp->f_bsize = mp->vfs_bsize;
+ abp->f_iosize = mp->vfs_bsize;
+
+ /* Fake a high number below to satisfy programs that use the statfs call
+ * to make sure that there's enough space in the device partition before
+ * storing something there.
+ */
+ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
+ abp->f_ffree = 2000000;
+
+ abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
+ abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
+ if (abp != &mp->mnt_stat) {
+ abp->f_type = mp->mnt_vfc->vfc_typenum;
+ bcopy((caddr_t)mp->mnt_stat.f_mntonname,
+ (caddr_t)&abp->f_mntonname[0], MNAMELEN);
+ bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
+ (caddr_t)&abp->f_mntfromname[0], MNAMELEN);
+ }
+
+ AFS_GUNLOCK();
+ return 0;
+}
+
+int afs_sync(mp, waitfor, cred, p)
+struct mount *mp;
+int waitfor;
+struct ucred *cred;
+struct prioc *p;
+{
+return 0;
+}
+
+int afs_sysctl() {
+ return EOPNOTSUPP;
+}
+
+
+typedef (*PFI)();
+extern int vfs_opv_numops; /* The total number of defined vnode operations */
+extern struct vnodeopv_desc afs_vnodeop_opv_desc;
+int afs_init(struct vfsconf *vfc) {
+ int j;
+ int (**opv_desc_vector)();
+ struct vnodeopv_entry_desc *opve_descp;
+
+
+
+ MALLOC(afs_vnodeop_p, PFI *, vfs_opv_numops*sizeof(PFI), M_TEMP, M_WAITOK);
+
+ bzero (afs_vnodeop_p, vfs_opv_numops*sizeof(PFI));
+
+ opv_desc_vector = afs_vnodeop_p;
+ for (j=0; afs_vnodeop_opv_desc.opv_desc_ops[j].opve_op; j++) {
+ opve_descp = &(afs_vnodeop_opv_desc.opv_desc_ops[j]);
+
+ /*
+ * Sanity check: is this operation listed
+ * in the list of operations? We check this
+ * by seeing if its offest is zero. Since
+ * the default routine should always be listed
+ * first, it should be the only one with a zero
+ * offset. Any other operation with a zero
+ * offset is probably not listed in
+ * vfs_op_descs, and so is probably an error.
+ *
+ * A panic here means the layer programmer
+ * has committed the all-too common bug
+ * of adding a new operation to the layer's
+ * list of vnode operations but
+ * not adding the operation to the system-wide
+ * list of supported operations.
+ */
+ if (opve_descp->opve_op->vdesc_offset == 0 &&
+ opve_descp->opve_op->vdesc_offset != VOFFSET(vop_default)) {
+ printf("afs_init: operation %s not listed in %s.\n",
+ opve_descp->opve_op->vdesc_name,
+ "vfs_op_descs");
+ panic ("load_afs: bad operation");
+ }
+ /*
+ * Fill in this entry.
+ */
+ opv_desc_vector[opve_descp->opve_op->vdesc_offset] =
+ opve_descp->opve_impl;
+ }
+
+ /*
+ * Finally, go back and replace unfilled routines
+ * with their default. (Sigh, an O(n^3) algorithm. I
+ * could make it better, but that'd be work, and n is small.)
+ */
+
+ /*
+ * Force every operations vector to have a default routine.
+ */
+ opv_desc_vector = afs_vnodeop_p;
+ if (opv_desc_vector[VOFFSET(vop_default)]==NULL) {
+ panic("afs_init: operation vector without default routine.");
+ }
+ for (j = 0;j<vfs_opv_numops; j++)
+ if (opv_desc_vector[j] == NULL)
+ opv_desc_vector[j] =
+ opv_desc_vector[VOFFSET(vop_default)];
+}
+
+struct vfsops afs_vfsops = {
+ afs_mount,
+ afs_start,
+ afs_unmount,
+ afs_root,
+ afs_quotactl,
+ afs_statfs,
+ afs_sync,
+ afs_vget,
+ afs_fhtovp,
+ afs_vptofh,
+ afs_init,
+ afs_sysctl
+};
--- /dev/null
+/*
+ * 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
+ */
+
+#include "../afs/param.h" /* Should be always first */
+#include "../afs/sysincludes.h" /* Standard vendor system headers */
+#include "../afs/afsincludes.h" /* Afs-based standard headers */
+#include "../afs/afs_stats.h" /* statistics */
+#include <sys/ubc.h>
+
+/* Try to discard pages, in order to recycle a vcache entry.
+ *
+ * We also make some sanity checks: ref count, open count, held locks.
+ *
+ * We also do some non-VM-related chores, such as releasing the cred pointer
+ * (for AIX and Solaris) and releasing the gnode (for AIX).
+ *
+ * Locking: afs_xvcache lock is held. If it is dropped and re-acquired,
+ * *slept should be set to warn the caller.
+ *
+ * Formerly, afs_xvcache was dropped and re-acquired for Solaris, but now it
+ * is not dropped and re-acquired for any platform. It may be that *slept is
+ * therefore obsolescent.
+ *
+ * OSF/1 Locking: VN_LOCK has been called.
+ */
+int
+osi_VM_FlushVCache(avc, slept)
+ struct vcache *avc;
+ int *slept;
+{
+ struct vnode *vp=(struct vnode *)avc;
+ if (avc->vrefCount)
+ return EBUSY;
+
+ if (avc->opens)
+ return EBUSY;
+
+ /* if a lock is held, give up */
+ if (CheckLock(&avc->lock) || afs_CheckBozonLock(&avc->pvnLock))
+ return EBUSY;
+
+ AFS_GUNLOCK();
+ cache_purge(vp);
+ if (UBCINFOEXISTS(vp))
+ {
+ ubc_clean(vp, 1);
+ ubc_uncache(vp);
+ ubc_release(vp);
+ ubc_info_free(vp);
+ }
+
+ AFS_GLOCK();
+
+ return 0;
+}
+
+
+/* Try to store pages to cache, in order to store a file back to the server.
+ *
+ * Locking: the vcache entry's lock is held. It will usually be dropped and
+ * re-obtained.
+ */
+void
+osi_VM_StoreAllSegments(avc)
+ struct vcache *avc;
+{
+ struct vnode *vp=(struct vnode *)avc;
+ ReleaseWriteLock(&avc->lock);
+ AFS_GUNLOCK();
+ if (UBCINFOEXISTS(vp)) {
+ ubc_pushdirty(vp);
+ }
+ AFS_GLOCK();
+ ObtainWriteLock(&avc->lock,94);
+}
+
+/* Try to invalidate pages, for "fs flush" or "fs flushv"; or
+ * try to free pages, when deleting a file.
+ *
+ * Locking: the vcache entry's lock is held. It may be dropped and
+ * re-obtained.
+ *
+ * Since we drop and re-obtain the lock, we can't guarantee that there won't
+ * be some pages around when we return, newly created by concurrent activity.
+ */
+void
+osi_VM_TryToSmush(avc, acred, sync)
+ struct vcache *avc;
+ struct AFS_UCRED *acred;
+ int sync;
+{
+ struct vnode *vp=(struct vnode *)avc;
+ void *object;
+ kern_return_t kret;
+ off_t size, lastpg;
+
+ ReleaseWriteLock(&avc->lock);
+ AFS_GUNLOCK();
+ if (UBCINFOEXISTS(vp)) {
+ size=ubc_getsize(vp);
+ kret=ubc_invalidate(vp,0,size);
+ if (kret != 1) /* should be KERN_SUCCESS */
+ printf("TryToSmush: invalidate failed (error = %d)\n", kret);
+ }
+ AFS_GLOCK();
+ ObtainWriteLock(&avc->lock,59);
+}
+
+/* Purge VM for a file when its callback is revoked.
+ *
+ * Locking: No lock is held, not even the global lock.
+ */
+/* XXX this seems to not be referenced anywhere. *somebody* ought to be calling
+ this, and also making sure that ubc's idea of the filesize is right more
+ often */
+void
+osi_VM_FlushPages(avc, credp)
+ struct vcache *avc;
+ struct AFS_UCRED *credp;
+{
+ struct vnode *vp=(struct vnode *)avc;
+ void *object;
+ kern_return_t kret;
+ off_t size;
+ if (UBCINFOEXISTS(vp)) {
+ size=ubc_getsize(vp);
+ kret=ubc_invalidate(vp,0,size);
+ if (kret != 1) /* Should be KERN_SUCCESS */
+ printf("VMFlushPages: invalidate failed (error = %d)\n", kret);
+ /* XXX what about when not CStatd */
+ if (avc->states & CStatd && size != avc->m.Length)
+ ubc_setsize(vp, avc->m.Length);
+ }
+}
+
+/* Purge pages beyond end-of-file, when truncating a file.
+ *
+ * Locking: no lock is held, not even the global lock.
+ * activeV is raised. This is supposed to block pageins, but at present
+ * it only works on Solaris.
+ */
+void
+osi_VM_Truncate(avc, alen, acred)
+ struct vcache *avc;
+ int alen;
+ struct AFS_UCRED *acred;
+{
+ struct vnode *vp=(struct vnode *)avc;
+ if (UBCINFOEXISTS(vp)) {
+ ubc_setsize(vp, alen);
+ }
+}
+
+extern struct AFS_UCRED afs_osi_cred;
+extern afs_rwlock_t afs_xvcache;
+/* vnreclaim and vinactive are probably not aggressive enough to keep
+ enough afs vcaches free, so we try to do some of it ourselves */
+/* XXX there's probably not nearly enough locking here */
+void osi_VM_TryReclaim(avc, slept)
+ struct vcache *avc;
+ int *slept;
+{
+ struct proc *p=current_proc();
+ struct vnode *vp=(struct vnode *)avc;
+ void *obj;
+
+ if (slept)
+ *slept=0;
+ VN_HOLD(vp); /* remove from inactive list */
+ if (!simple_lock_try(&vp->v_interlock)) {
+ AFS_RELE(vp);
+ return;
+ }
+ if (!UBCINFOEXISTS(vp) || vp->v_count != 2) {
+ simple_unlock(&vp->v_interlock);
+ AFS_RELE(vp);
+ return;
+ }
+ if (vp->v_ubcinfo->ui_holdcnt) {
+ simple_unlock(&vp->v_interlock);
+ AFS_RELE(vp);
+ return;
+ }
+ if (slept && ubc_issetflags(vp, UI_WASMAPPED)) {
+ /* We can't possibly release this in time for this NewVCache to get it */
+ simple_unlock(&vp->v_interlock);
+ AFS_RELE(vp);
+ return;
+ }
+
+ vp->v_usecount--; /* we want the usecount to be 1 */
+
+ if (slept) {
+ ReleaseWriteLock(&afs_xvcache);
+ *slept=1;
+ } else
+ ReleaseReadLock(&afs_xvcache);
+ AFS_GUNLOCK();
+ obj=0;
+ if (ubc_issetflags(vp, UI_WASMAPPED)) {
+ simple_unlock(&vp->v_interlock);
+ ubc_release(vp);
+ if (ubc_issetflags(vp, UI_HASOBJREF))
+ printf("ubc_release didn't release the reference?!\n");
+ } else if (!vn_lock(vp, LK_EXCLUSIVE|LK_INTERLOCK,current_proc())) {
+#ifdef UBC_NOREACTIVATE
+ obj = ubc_getobject(vp,(UBC_NOREACTIVATE|UBC_HOLDOBJECT));
+#else
+ obj = ubc_getobject(vp);
+#endif
+ (void)ubc_clean(vp, 1);
+ vinvalbuf(vp, V_SAVE, &afs_osi_cred, p, 0, 0);
+ if (vp->v_usecount == 1)
+ VOP_INACTIVE(vp, p);
+ else
+ VOP_UNLOCK(vp, 0, p);
+ if (ISSET(vp->v_flag, VTERMINATE))
+ panic("afs_vnreclaim: already teminating");
+ SET(vp->v_flag, VTERMINATE);
+ memory_object_destroy(obj, 0);
+ while (ISSET(vp->v_flag, VTERMINATE)) {
+ SET(vp->v_flag, VTERMWANT);
+ tsleep((caddr_t)&vp->v_ubcinfo, PINOD, "afs_vnreclaim", 0);
+ }
+ } else {
+ if (simple_lock_try(&vp->v_interlock))
+ panic("afs_vnreclaim: slept, but did no work :(");
+ if (UBCINFOEXISTS(vp) && vp->v_count == 1) {
+ vp->v_usecount++;
+ simple_unlock(&vp->v_interlock);
+ AFS_RELE(vp);
+ } else
+ simple_unlock(&vp->v_interlock);
+ }
+ AFS_GLOCK();
+ if (slept)
+ ObtainWriteLock(&afs_xvcache,175);
+ else
+ ObtainReadLock(&afs_xvcache);
+}
+
+void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size) {
+
+ void *object;
+ struct vcache *avc = (struct vcache *)vp;
+
+ object=NULL;
+#ifdef UBC_NOREACTIVATE
+ if (UBCINFOEXISTS(vp))
+ object = ubc_getobject(vp, UBC_NOREACTIVATE);
+#else
+ if (UBCINFOEXISTS(vp))
+ object = ubc_getobject(vp);
+#endif
+ if (!object)
+ return;
+
+ offset=trunc_page(offset);
+ size=round_page(size+1);
+
+#ifdef UBC_NOREACTIVATE
+ while (size) {
+ memory_object_page_op(object, (vm_offset_t)offset,
+ UPL_POP_SET | UPL_POP_BUSY | UPL_POP_DUMP,
+ 0, 0);
+ size-=PAGE_SIZE;
+ offset+=PAGE_SIZE;
+ }
+#else
+ ubc_setsize(vp, offset);
+ size=(offset + size > avc->m.Length) ? offset + size : avc->m.Length;
+ ubc_setsize(vp, size);
+#endif
+
+}
+int osi_VM_Setup(struct vcache *avc) {
+ int error;
+ struct vnode *vp=(struct vnode *)avc;
+
+ if (UBCISVALID(vp) && (avc->states & CStatd)) {
+ if (!UBCINFOEXISTS(vp) && !ISSET(vp->v_flag, VTERMINATE)) {
+ osi_vnhold(avc,0);
+ AFS_GUNLOCK();
+ if ((error=ubc_info_init(&avc->v))) {
+ AFS_GLOCK();
+ AFS_RELE(avc);
+ return error;
+ }
+ simple_lock(&avc->v.v_interlock);
+ if (!ubc_issetflags(&avc->v, UI_HASOBJREF))
+#ifdef UBC_NOREACTIVATE
+ if (ubc_getobject(&avc->v, (UBC_NOREACTIVATE|UBC_HOLDOBJECT)))
+ panic("VM_Setup: null object");
+#else
+ (void)_ubc_getobject(&avc->v, 1); /* return value not used */
+#endif
+ simple_unlock(&avc->v.v_interlock);
+ AFS_GLOCK();
+ AFS_RELE(avc);
+ }
+ if (UBCINFOEXISTS(&avc->v))
+ ubc_setsize(&avc->v, avc->m.Length);
+ }
+ return 0;
+}
--- /dev/null
+#include <afs/param.h> /* Should be always first */
+#include <afs/sysincludes.h> /* Standard vendor system headers */
+#include <afs/afsincludes.h> /* Afs-based standard headers */
+#include <afs/afs_stats.h> /* statistics */
+#include <sys/malloc.h>
+#include <sys/namei.h>
+#include <sys/ubc.h>
+
+int afs_vop_lookup(struct vop_lookup_args *);
+int afs_vop_create(struct vop_create_args *);
+int afs_vop_mknod(struct vop_mknod_args *);
+int afs_vop_open(struct vop_open_args *);
+int afs_vop_close(struct vop_close_args *);
+int afs_vop_access(struct vop_access_args *);
+int afs_vop_getattr(struct vop_getattr_args *);
+int afs_vop_setattr(struct vop_setattr_args *);
+int afs_vop_read(struct vop_read_args *);
+int afs_vop_write(struct vop_write_args *);
+int afs_vop_pagein(struct vop_pagein_args *);
+int afs_vop_pageout(struct vop_pageout_args *);
+int afs_vop_ioctl(struct vop_ioctl_args *);
+int afs_vop_select(struct vop_select_args *);
+int afs_vop_mmap(struct vop_mmap_args *);
+int afs_vop_fsync(struct vop_fsync_args *);
+int afs_vop_seek(struct vop_seek_args *);
+int afs_vop_remove(struct vop_remove_args *);
+int afs_vop_link(struct vop_link_args *);
+int afs_vop_rename(struct vop_rename_args *);
+int afs_vop_mkdir(struct vop_mkdir_args *);
+int afs_vop_rmdir(struct vop_rmdir_args *);
+int afs_vop_symlink(struct vop_symlink_args *);
+int afs_vop_readdir(struct vop_readdir_args *);
+int afs_vop_readlink(struct vop_readlink_args *);
+extern int ufs_abortop(struct vop_abortop_args *);
+int afs_vop_inactive(struct vop_inactive_args *);
+int afs_vop_reclaim(struct vop_reclaim_args *);
+int afs_vop_lock(struct vop_lock_args *);
+int afs_vop_unlock(struct vop_unlock_args *);
+int afs_vop_bmap(struct vop_bmap_args *);
+int afs_vop_strategy(struct vop_strategy_args *);
+int afs_vop_print(struct vop_print_args *);
+int afs_vop_islocked(struct vop_islocked_args *);
+int afs_vop_pathconf(struct vop_pathconf_args *);
+int afs_vop_advlock(struct vop_advlock_args *);
+int afs_vop_truncate(struct vop_truncate_args *);
+int afs_vop_update(struct vop_update_args *);
+int afs_vop_blktooff __P((struct vop_blktooff_args *));
+int afs_vop_offtoblk __P((struct vop_offtoblk_args *));
+int afs_vop_cmap __P((struct vop_cmap_args *));
+
+
+#define afs_vop_opnotsupp \
+ ((int (*) __P((struct vop_reallocblks_args *)))eopnotsupp)
+#define afs_vop_valloc afs_vop_opnotsupp
+#define afs_vop_vfree afs_vop_opnotsupp
+#define afs_vop_blkatoff afs_vop_opnotsupp
+#define afs_vop_reallocblks afs_vop_opnotsupp
+
+/* Global vfs data structures for AFS. */
+int (**afs_vnodeop_p)();
+struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
+ { &vop_default_desc, vn_default_error },
+ { &vop_lookup_desc, afs_vop_lookup }, /* lookup */
+ { &vop_create_desc, afs_vop_create }, /* create */
+ { &vop_mknod_desc, afs_vop_mknod }, /* mknod */
+ { &vop_open_desc, afs_vop_open }, /* open */
+ { &vop_close_desc, afs_vop_close }, /* close */
+ { &vop_access_desc, afs_vop_access }, /* access */
+ { &vop_getattr_desc, afs_vop_getattr }, /* getattr */
+ { &vop_setattr_desc, afs_vop_setattr }, /* setattr */
+ { &vop_read_desc, afs_vop_read }, /* read */
+ { &vop_write_desc, afs_vop_write }, /* write */
+ { &vop_pagein_desc, afs_vop_pagein }, /* read */
+ { &vop_pageout_desc, afs_vop_pageout }, /* write */
+ { &vop_ioctl_desc, afs_vop_ioctl }, /* XXX ioctl */
+ { &vop_select_desc, afs_vop_select }, /* select */
+ { &vop_mmap_desc, afs_vop_mmap }, /* mmap */
+ { &vop_fsync_desc, afs_vop_fsync }, /* fsync */
+ { &vop_seek_desc, afs_vop_seek }, /* seek */
+ { &vop_remove_desc, afs_vop_remove }, /* remove */
+ { &vop_link_desc, afs_vop_link }, /* link */
+ { &vop_rename_desc, afs_vop_rename }, /* rename */
+ { &vop_mkdir_desc, afs_vop_mkdir }, /* mkdir */
+ { &vop_rmdir_desc, afs_vop_rmdir }, /* rmdir */
+ { &vop_symlink_desc, afs_vop_symlink }, /* symlink */
+ { &vop_readdir_desc, afs_vop_readdir }, /* readdir */
+ { &vop_readlink_desc, afs_vop_readlink }, /* readlink */
+ /* Yes, we use the ufs_abortop call. It just releases the namei
+ buffer stuff */
+ { &vop_abortop_desc, ufs_abortop }, /* abortop */
+ { &vop_inactive_desc, afs_vop_inactive }, /* inactive */
+ { &vop_reclaim_desc, afs_vop_reclaim }, /* reclaim */
+ { &vop_lock_desc, afs_vop_lock }, /* lock */
+ { &vop_unlock_desc, afs_vop_unlock }, /* unlock */
+ { &vop_bmap_desc, afs_vop_bmap }, /* bmap */
+ { &vop_strategy_desc, afs_vop_strategy }, /* strategy */
+ { &vop_print_desc, afs_vop_print }, /* print */
+ { &vop_islocked_desc, afs_vop_islocked }, /* islocked */
+ { &vop_pathconf_desc, afs_vop_pathconf }, /* pathconf */
+ { &vop_advlock_desc, afs_vop_advlock }, /* advlock */
+ { &vop_blkatoff_desc, afs_vop_blkatoff }, /* blkatoff */
+ { &vop_valloc_desc, afs_vop_valloc }, /* valloc */
+ { &vop_reallocblks_desc, afs_vop_reallocblks }, /* reallocblks */
+ { &vop_vfree_desc, afs_vop_vfree }, /* vfree */
+ { &vop_truncate_desc, afs_vop_truncate }, /* truncate */
+ { &vop_update_desc, afs_vop_update }, /* update */
+ { &vop_blktooff_desc, afs_vop_blktooff }, /* blktooff */
+ { &vop_offtoblk_desc, afs_vop_offtoblk }, /* offtoblk */
+ { &vop_cmap_desc, afs_vop_cmap }, /* cmap */
+ { &vop_bwrite_desc, vn_bwrite },
+ { (struct vnodeop_desc*)NULL, (int(*)())NULL }
+};
+struct vnodeopv_desc afs_vnodeop_opv_desc =
+ { &afs_vnodeop_p, afs_vnodeop_entries };
+
+#define GETNAME() \
+ struct componentname *cnp = ap->a_cnp; \
+ char *name; \
+ MALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \
+ bcopy(cnp->cn_nameptr, name, cnp->cn_namelen); \
+ name[cnp->cn_namelen] = '\0'
+
+#define DROPNAME() FREE(name, M_TEMP)
+
+
+
+int
+afs_vop_lookup(ap)
+struct vop_lookup_args /* {
+ struct vnodeop_desc * a_desc;
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ } */ *ap;
+{
+ int error;
+ struct vcache *vcp;
+ struct vnode *vp, *dvp;
+ register int flags = ap->a_cnp->cn_flags;
+ int lockparent; /* 1 => lockparent flag is set */
+ int wantparent; /* 1 => wantparent or lockparent flag */
+ struct proc *p;
+ GETNAME();
+ p=cnp->cn_proc;
+ lockparent = flags & LOCKPARENT;
+ wantparent = flags & (LOCKPARENT|WANTPARENT);
+
+ if (ap->a_dvp->v_type != VDIR) {
+ *ap->a_vpp = 0;
+ DROPNAME();
+ return ENOTDIR;
+ }
+ dvp = ap->a_dvp;
+ if (flags & ISDOTDOT)
+ VOP_UNLOCK(dvp, 0, p);
+ AFS_GLOCK();
+ error = afs_lookup((struct vcache *)dvp, name, &vcp, cnp->cn_cred);
+ AFS_GUNLOCK();
+ if (error) {
+ if (flags & ISDOTDOT)
+ VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p);
+ if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) &&
+ (flags & ISLASTCN) && error == ENOENT)
+ error = EJUSTRETURN;
+ if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
+ cnp->cn_flags |= SAVENAME;
+ DROPNAME();
+ *ap->a_vpp = 0;
+ return (error);
+ }
+ vp = (struct vnode *)vcp; /* always get a node if no error */
+
+ /* The parent directory comes in locked. We unlock it on return
+ unless the caller wants it left locked.
+ we also always return the vnode locked. */
+
+ if (flags & ISDOTDOT) {
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
+ /* always return the child locked */
+ if (lockparent && (flags & ISLASTCN) &&
+ (error = vn_lock(dvp, LK_EXCLUSIVE, p))) {
+ vput(vp);
+ DROPNAME();
+ return (error);
+ }
+ } else if (vp == dvp) {
+ /* they're the same; afs_lookup() already ref'ed the leaf.
+ It came in locked, so we don't need to ref OR lock it */
+ } else {
+ if (!lockparent || !(flags & ISLASTCN))
+ VOP_UNLOCK(dvp, 0, p); /* done with parent. */
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
+ /* always return the child locked */
+ }
+ *ap->a_vpp = vp;
+
+ if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN) ||
+ (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))))
+ cnp->cn_flags |= SAVENAME;
+
+ DROPNAME();
+ return error;
+}
+
+int
+afs_vop_create(ap)
+ struct vop_create_args /* {
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ struct vattr *a_vap;
+ } */ *ap;
+{
+ int error = 0;
+ struct vcache *vcp;
+ register struct vnode *dvp = ap->a_dvp;
+ struct proc *p;
+ GETNAME();
+ p=cnp->cn_proc;
+
+ /* vnode layer handles excl/nonexcl */
+ AFS_GLOCK();
+ error = afs_create((struct vcache *)dvp, name, ap->a_vap, NONEXCL,
+ ap->a_vap->va_mode, &vcp,
+ cnp->cn_cred);
+ AFS_GUNLOCK();
+ if (error) {
+ VOP_ABORTOP(dvp, cnp);
+ vput(dvp);
+ DROPNAME();
+ return(error);
+ }
+
+ if (vcp) {
+ *ap->a_vpp = (struct vnode *)vcp;
+ vn_lock((struct vnode *)vcp, LK_EXCLUSIVE| LK_RETRY, p);
+ if (UBCINFOMISSING((struct vnode *)vcp) ||
+ UBCINFORECLAIMED((struct vnode *)vcp))
+ ubc_info_init((struct vnode *)vcp);
+ }
+ else *ap->a_vpp = 0;
+
+ if ((cnp->cn_flags & SAVESTART) == 0)
+ FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ vput(dvp);
+ DROPNAME();
+ return error;
+}
+
+int
+afs_vop_mknod(ap)
+ struct vop_mknod_args /* {
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ struct vattr *a_vap;
+ } */ *ap;
+{
+ FREE_ZONE(ap->a_cnp->cn_pnbuf, ap->a_cnp->cn_pnlen, M_NAMEI);
+ vput(ap->a_dvp);
+ return(ENODEV);
+}
+
+int
+afs_vop_open(ap)
+ struct vop_open_args /* {
+ struct vnode *a_vp;
+ int a_mode;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ int error;
+ struct vcache *vc = (struct vcache *)ap->a_vp;
+ AFS_GLOCK();
+ error = afs_open(&vc, ap->a_mode, ap->a_cred);
+#ifdef DIAGNOSTIC
+ if ((struct vnode *)vc != ap->a_vp)
+ panic("AFS open changed vnode!");
+#endif
+ afs_BozonLock(&vc->pvnLock, vc);
+ osi_FlushPages(vc);
+ afs_BozonUnlock(&vc->pvnLock, vc);
+ AFS_GUNLOCK();
+ return error;
+}
+
+int
+afs_vop_close(ap)
+ struct vop_close_args /* {
+ struct vnode *a_vp;
+ int a_fflag;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ int code;
+ struct vcache *avc=ap->a_vp;
+ AFS_GLOCK();
+ if (ap->a_cred)
+ code=afs_close(avc, ap->a_fflag, ap->a_cred, ap->a_p);
+ else
+ code=afs_close(avc, ap->a_fflag, &afs_osi_cred, ap->a_p);
+ afs_BozonLock(&avc->pvnLock, avc);
+ osi_FlushPages(avc); /* hold bozon lock, but not basic vnode lock */
+ afs_BozonUnlock(&avc->pvnLock, avc);
+ AFS_GUNLOCK();
+ return code;
+}
+
+int
+afs_vop_access(ap)
+ struct vop_access_args /* {
+ struct vnode *a_vp;
+ int a_mode;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ int code;
+ AFS_GLOCK();
+ code=afs_access((struct vcache *)ap->a_vp, ap->a_mode, ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
+}
+int
+afs_vop_getattr(ap)
+ struct vop_getattr_args /* {
+ struct vnode *a_vp;
+ struct vattr *a_vap;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ int code;
+ AFS_GLOCK();
+ code=afs_getattr((struct vcache *)ap->a_vp, ap->a_vap, ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
+}
+int
+afs_vop_setattr(ap)
+ struct vop_setattr_args /* {
+ struct vnode *a_vp;
+ struct vattr *a_vap;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ int code;
+ AFS_GLOCK();
+ code=afs_setattr((struct vcache *)ap->a_vp, ap->a_vap, ap->a_cred);
+ AFS_GUNLOCK();
+ return code;
+}
+int
+afs_vop_read(ap)
+ struct vop_read_args /* {
+ struct vnode *a_vp;
+ struct uio *a_uio;
+ int a_ioflag;
+ struct ucred *a_cred;
+ } */ *ap;
+{
+ int code;
+ struct vcache *avc=(struct vcache *)ap->a_vp;
+ AFS_GLOCK();
+ afs_BozonLock(&avc->pvnLock, avc);
+ osi_FlushPages(avc); /* hold bozon lock, but not basic vnode lock */
+ code=afs_read(avc, ap->a_uio, ap->a_cred, 0, 0, 0);
+ afs_BozonUnlock(&avc->pvnLock, avc);
+ AFS_GUNLOCK();
+ return code;
+}
+int
+afs_vop_pagein(ap)
+ struct vop_pagein_args /* {
+ struct vnode *a_vp;
+ upl_t a_pl;
+ vm_offset_t a_pl_offset;
+ off_t a_f_offset;
+ size_t a_size;
+ struct ucred *a_cred;
+ int a_flags;
+ } */ *ap;
+{
+ register struct vnode *vp = ap->a_vp;
+ upl_t pl = ap->a_pl;
+ size_t size= ap->a_size;
+ off_t f_offset = ap->a_f_offset;
+ vm_offset_t pl_offset = ap->a_pl_offset;
+ int flags = ap->a_flags;
+ struct ucred *cred;
+ vm_offset_t ioaddr;
+ struct uio auio;
+ struct iovec aiov;
+ struct uio * uio = &auio;
+ int nocommit = flags & UPL_NOCOMMIT;
+
+ int code;
+ struct vcache *tvc=(struct vcache *)vp;
+
+ if (UBCINVALID(vp)) {
+#if DIAGNOSTIC
+ panic("afs_vop_pagein: invalid vp");
+#endif /* DIAGNOSTIC */
+ return (EPERM);
+ }
+
+ UBCINFOCHECK("afs_vop_pagein", vp);
+ if(pl == (upl_t)NULL) {
+ panic("afs_vop_pagein: no upl");
+ }
+
+ cred = ubc_getcred(vp);
+ if (cred == NOCRED)
+ cred = ap->a_cred;
+
+ if (size == 0) {
+ if (!nocommit)
+ kernel_upl_abort_range(pl, pl_offset, size,
+ UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
+ return (0);
+ }
+ if (f_offset < 0) {
+ if (!nocommit)
+ kernel_upl_abort_range(pl, pl_offset, size,
+ UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
+ return (EINVAL);
+ }
+ if (f_offset & PAGE_MASK)
+ panic("afs_vop_pagein: offset not page aligned");
+
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_offset = f_offset;
+ auio.uio_segflg = UIO_SYSSPACE;
+ auio.uio_rw = UIO_READ;
+ auio.uio_procp = NULL;
+ kernel_upl_map(kernel_map, pl, &ioaddr);
+ ioaddr += pl_offset;
+ auio.uio_resid = aiov.iov_len = size;
+ aiov.iov_base = (caddr_t)ioaddr;
+ AFS_GLOCK();
+ afs_BozonLock(&tvc->pvnLock, tvc);
+ osi_FlushPages(tvc); /* hold bozon lock, but not basic vnode lock */
+ code=afs_read(tvc, uio, cred, 0, 0, 0);
+ if (code == 0) {
+ ObtainWriteLock(&tvc->lock, 2);
+ tvc->states |= CMAPPED;
+ ReleaseWriteLock(&tvc->lock);
+ }
+ afs_BozonUnlock(&tvc->pvnLock, tvc);
+ AFS_GUNLOCK();
+ kernel_upl_unmap(kernel_map, pl);
+ if (!nocommit) {
+ if (code)
+ kernel_upl_abort_range(pl, pl_offset, size,
+ UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
+ else
+ kernel_upl_commit_range(pl, pl_offset, size,
+ UPL_COMMIT_CLEAR_DIRTY | UPL_COMMIT_FREE_ON_EMPTY,
+ UPL_GET_INTERNAL_PAGE_LIST(pl), MAX_UPL_TRANSFER);
+ }
+ return code;
+}
+
+int
+afs_vop_write(ap)
+ struct vop_write_args /* {
+ struct vnode *a_vp;
+ struct uio *a_uio;
+ int a_ioflag;
+ struct ucred *a_cred;
+ } */ *ap;
+{
+ int code;
+ struct vcache *avc=(struct vcache *)ap->a_vp;
+ void *object;
+ AFS_GLOCK();
+ afs_BozonLock(&avc->pvnLock, avc);
+ osi_FlushPages(avc); /* hold bozon lock, but not basic vnode lock */
+ if (UBCINFOEXISTS(ap->a_vp))
+ ubc_clean(ap->a_vp, 1);
+ if (UBCINFOEXISTS(ap->a_vp))
+ osi_VM_NukePages(ap->a_vp, ap->a_uio->uio_offset, ap->a_uio->uio_resid);
+ code=afs_write((struct vcache *)ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
+ afs_BozonUnlock(&avc->pvnLock, avc);
+ AFS_GUNLOCK();
+ return code;
+}
+
+int
+afs_vop_pageout(ap)
+ struct vop_pageout_args /* {
+ struct vnode *a_vp;
+ upl_t a_pl,
+ vm_offset_t a_pl_offset,
+ off_t a_f_offset,
+ size_t a_size,
+ struct ucred *a_cred,
+ int a_flags
+ } */ *ap;
+{
+ register struct vnode *vp = ap->a_vp;
+ upl_t pl = ap->a_pl;
+ size_t size= ap->a_size;
+ off_t f_offset = ap->a_f_offset;
+ vm_offset_t pl_offset = ap->a_pl_offset;
+ int flags = ap->a_flags;
+ struct ucred *cred;
+ vm_offset_t ioaddr;
+ struct uio auio;
+ struct iovec aiov;
+ struct uio * uio = &auio;
+ int nocommit = flags & UPL_NOCOMMIT;
+
+ int code;
+ struct vcache *tvc=(struct vcache *)vp;
+
+ if (UBCINVALID(vp)) {
+#if DIAGNOSTIC
+ panic("afs_vop_pageout: invalid vp");
+#endif /* DIAGNOSTIC */
+ return (EPERM);
+ }
+
+ UBCINFOCHECK("afs_vop_pageout", vp);
+ if(pl == (upl_t)NULL) {
+ panic("afs_vop_pageout: no upl");
+ }
+#if 1
+ { int lbn, iosize, s;
+ struct buf *bp;
+ int biosize = DEV_BSIZE;
+
+ lbn = f_offset / DEV_BSIZE;
+
+ for (iosize = size; iosize > 0; iosize -= biosize, lbn++) {
+
+ s = splbio();
+ if (bp = incore(vp, lbn)) {
+ if (ISSET(bp->b_flags, B_BUSY))
+ panic("nfs_pageout: found BUSY buffer incore\n")
+;
+
+ bremfree(bp);
+ SET(bp->b_flags, (B_BUSY | B_INVAL));
+ brelse(bp);
+ }
+ splx(s);
+ }
+ }
+#endif
+ cred = ubc_getcred(vp);
+ if (cred == NOCRED)
+ cred = ap->a_cred;
+
+ if (size == 0) {
+ if (!nocommit)
+ kernel_upl_abort_range(pl, pl_offset, size,
+ UPL_ABORT_FREE_ON_EMPTY);
+ return (0);
+ }
+ if (flags & (IO_APPEND | IO_SYNC))
+ panic("nfs_pageout: (IO_APPEND | IO_SYNC)");
+ if (f_offset < 0) {
+ if (!nocommit)
+ kernel_upl_abort_range(pl, pl_offset, size,
+ UPL_ABORT_FREE_ON_EMPTY);
+ return (EINVAL);
+ }
+ if (f_offset >= tvc->m.Length) {
+ if (!nocommit)
+ kernel_upl_abort_range(pl, pl_offset, size,
+ UPL_ABORT_FREE_ON_EMPTY);
+ return (EINVAL);
+ }
+
+ if (f_offset & PAGE_MASK)
+ panic("afs_vop_pageout: offset not page aligned");
+
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_offset = f_offset;
+ auio.uio_segflg = UIO_SYSSPACE;
+ auio.uio_rw = UIO_WRITE;
+ auio.uio_procp = NULL;
+ kernel_upl_map(kernel_map, pl, &ioaddr);
+ ioaddr += pl_offset;
+ auio.uio_resid = aiov.iov_len = size;
+ aiov.iov_base = (caddr_t)ioaddr;
+#if 1 /* USV [ */
+ {
+ /*
+ * check for partial page and clear the
+ * contents past end of the file before
+ * releasing it in the VM page cache
+ */
+ if ((f_offset < tvc->m.Length) && (f_offset + size) > tvc->m.Length) {
+ size_t io = tvc->m.Length - f_offset;
+
+ bzero((caddr_t)(ioaddr + pl_offset + io), size - io);
+ }
+ }
+#endif /* ] USV */
+
+ AFS_GLOCK();
+ afs_BozonLock(&tvc->pvnLock, tvc);
+ osi_FlushPages(tvc); /* hold bozon lock, but not basic vnode lock */
+ ObtainWriteLock(&tvc->lock, 1);
+ afs_FakeOpen(tvc);
+ ReleaseWriteLock(&tvc->lock);
+
+ code=afs_write(tvc, uio, flags, cred, 0);
+
+ ObtainWriteLock(&tvc->lock, 1);
+ afs_FakeClose(tvc, cred);
+ ReleaseWriteLock(&tvc->lock);
+ afs_BozonUnlock(&tvc->pvnLock, tvc);
+ AFS_GUNLOCK();
+ kernel_upl_unmap(kernel_map, pl);
+ if (!nocommit) {
+ if(code)
+ kernel_upl_abort_range(pl, pl_offset, size,
+ UPL_ABORT_FREE_ON_EMPTY);
+ else
+ kernel_upl_commit_range(pl, pl_offset, size,
+ UPL_COMMIT_CLEAR_DIRTY | UPL_COMMIT_FREE_ON_EMPTY,
+ UPL_GET_INTERNAL_PAGE_LIST(pl), MAX_UPL_TRANSFER);
+ }
+
+ return code;
+}
+int
+afs_vop_ioctl(ap)
+ struct vop_ioctl_args /* {
+ struct vnode *a_vp;
+ int a_command;
+ caddr_t a_data;
+ int a_fflag;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ struct vcache *tvc = (struct vcache *)ap->a_vp;
+ struct afs_ioctl data;
+ int error = 0;
+
+ /* in case we ever get in here... */
+
+ AFS_STATCNT(afs_ioctl);
+ if (((ap->a_command >> 8) & 0xff) == 'V') {
+ /* This is a VICEIOCTL call */
+ AFS_GLOCK();
+ error = HandleIoctl(tvc, (struct file *)0/*Not used*/,
+ ap->a_command, ap->a_data);
+ AFS_GUNLOCK();
+ return(error);
+ } else {
+ /* No-op call; just return. */
+ return(ENOTTY);
+ }
+}
+
+/* ARGSUSED */
+int
+afs_vop_select(ap)
+ struct vop_select_args /* {
+ struct vnode *a_vp;
+ int a_which;
+ int a_fflags;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ /*
+ * We should really check to see if I/O is possible.
+ */
+ return (1);
+}
+/*
+ * Mmap a file
+ *
+ * NB Currently unsupported.
+ */
+/* ARGSUSED */
+int
+afs_vop_mmap(ap)
+ struct vop_mmap_args /* {
+ struct vnode *a_vp;
+ int a_fflags;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ return (EINVAL);
+}
+
+int
+afs_vop_fsync(ap)
+ struct vop_fsync_args /* {
+ struct vnode *a_vp;
+ struct ucred *a_cred;
+ int a_waitfor;
+ struct proc *a_p;
+ } */ *ap;
+{
+ int wait = ap->a_waitfor == MNT_WAIT;
+ int error;
+ register struct vnode *vp = ap->a_vp;
+
+ AFS_GLOCK();
+ /*vflushbuf(vp, wait);*/
+ if (ap->a_cred)
+ error=afs_fsync((struct vcache *)vp, ap->a_cred);
+ else
+ error=afs_fsync((struct vcache *)vp, &afs_osi_cred);
+ AFS_GUNLOCK();
+ return error;
+}
+
+int
+afs_vop_seek(ap)
+ struct vop_seek_args /* {
+ struct vnode *a_vp;
+ off_t a_oldoff;
+ off_t a_newoff;
+ struct ucred *a_cred;
+ } */ *ap;
+{
+ if (ap->a_newoff > ULONG_MAX) /* AFS doesn't support 64-bit offsets */
+ return EINVAL;
+ return (0);
+}
+
+int
+afs_vop_remove(ap)
+ struct vop_remove_args /* {
+ struct vnode *a_dvp;
+ struct vnode *a_vp;
+ struct componentname *a_cnp;
+ } */ *ap;
+{
+ int error = 0;
+ register struct vnode *vp = ap->a_vp;
+ register struct vnode *dvp = ap->a_dvp;
+
+ GETNAME();
+ AFS_GLOCK();
+ error = afs_remove((struct vcache *)dvp, name, cnp->cn_cred);
+ AFS_GUNLOCK();
+ cache_purge(vp);
+ if (dvp == vp)
+ vrele(vp);
+ else
+ vput(vp);
+ vput(dvp);
+ if (UBCINFOEXISTS(vp)) {
+ int wasmapped=ubc_issetflags(vp, UI_WASMAPPED);
+ int hasobjref=ubc_issetflags(vp, UI_HASOBJREF);
+ if (wasmapped)
+ (void) ubc_uncache(vp);
+ if (hasobjref)
+ ubc_release(vp);
+ /* WARNING vp may not be valid after this */
+ }
+
+ FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ DROPNAME();
+ return error;
+}
+
+int
+afs_vop_link(ap)
+ struct vop_link_args /* {
+ struct vnode *a_vp;
+ struct vnode *a_tdvp;
+ struct componentname *a_cnp;
+ } */ *ap;
+{
+ int error = 0;
+ register struct vnode *dvp = ap->a_tdvp;
+ register struct vnode *vp = ap->a_vp;
+ struct proc *p;
+
+ GETNAME();
+ p=cnp->cn_proc;
+ if (dvp->v_mount != vp->v_mount) {
+ VOP_ABORTOP(vp, cnp);
+ error = EXDEV;
+ goto out;
+ }
+ if (vp->v_type == VDIR) {
+ VOP_ABORTOP(vp, cnp);
+ error = EISDIR;
+ goto out;
+ }
+ if (error = vn_lock(vp, LK_EXCLUSIVE, p)) {
+ VOP_ABORTOP(dvp, cnp);
+ goto out;
+ }
+ AFS_GLOCK();
+ error = afs_link((struct vcache *)vp, (struct vcache *)dvp, name, cnp->cn_cred);
+ AFS_GUNLOCK();
+ FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ if (dvp != vp)
+ VOP_UNLOCK(vp,0, p);
+out:
+ vput(dvp);
+ DROPNAME();
+ return error;
+}
+
+int
+afs_vop_rename(ap)
+ struct vop_rename_args /* {
+ struct vnode *a_fdvp;
+ struct vnode *a_fvp;
+ struct componentname *a_fcnp;
+ struct vnode *a_tdvp;
+ struct vnode *a_tvp;
+ struct componentname *a_tcnp;
+ } */ *ap;
+{
+ int error = 0;
+ struct componentname *fcnp = ap->a_fcnp;
+ char *fname;
+ struct componentname *tcnp = ap->a_tcnp;
+ char *tname;
+ struct vnode *tvp = ap->a_tvp;
+ register struct vnode *tdvp = ap->a_tdvp;
+ struct vnode *fvp = ap->a_fvp;
+ register struct vnode *fdvp = ap->a_fdvp;
+ struct proc *p=fcnp->cn_proc;
+
+ /*
+ * Check for cross-device rename.
+ */
+ if ((fvp->v_mount != tdvp->v_mount) ||
+ (tvp && (fvp->v_mount != tvp->v_mount))) {
+ error = EXDEV;
+abortit:
+ VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */
+ if (tdvp == tvp)
+ vrele(tdvp);
+ else
+ vput(tdvp);
+ if (tvp)
+ vput(tvp);
+ VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */
+ vrele(fdvp);
+ vrele(fvp);
+ return (error);
+ }
+ /*
+ * if fvp == tvp, we're just removing one name of a pair of
+ * directory entries for the same element. convert call into rename.
+ ( (pinched from NetBSD 1.0's ufs_rename())
+ */
+ if (fvp == tvp) {
+ if (fvp->v_type == VDIR) {
+ error = EINVAL;
+ goto abortit;
+ }
+
+ /* Release destination completely. */
+ VOP_ABORTOP(tdvp, tcnp);
+ vput(tdvp);
+ vput(tvp);
+
+ /* Delete source. */
+ vrele(fdvp);
+ vrele(fvp);
+ fcnp->cn_flags &= ~MODMASK;
+ fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
+ if ((fcnp->cn_flags & SAVESTART) == 0)
+ panic("afs_rename: lost from startdir");
+ fcnp->cn_nameiop = DELETE;
+ (void) relookup(fdvp, &fvp, fcnp);
+ return (VOP_REMOVE(fdvp, fvp, fcnp));
+ }
+ if (error = vn_lock(fvp, LK_EXCLUSIVE, p))
+ goto abortit;
+
+ MALLOC(fname, char *, fcnp->cn_namelen+1, M_TEMP, M_WAITOK);
+ bcopy(fcnp->cn_nameptr, fname, fcnp->cn_namelen);
+ fname[fcnp->cn_namelen] = '\0';
+ MALLOC(tname, char *, tcnp->cn_namelen+1, M_TEMP, M_WAITOK);
+ bcopy(tcnp->cn_nameptr, tname, tcnp->cn_namelen);
+ tname[tcnp->cn_namelen] = '\0';
+
+
+ AFS_GLOCK();
+ /* XXX use "from" or "to" creds? NFS uses "to" creds */
+ error = afs_rename((struct vcache *)fdvp, fname, (struct vcache *)tdvp, tname, tcnp->cn_cred);
+ AFS_GUNLOCK();
+
+ VOP_UNLOCK(fvp, 0, p);
+ FREE(fname, M_TEMP);
+ FREE(tname, M_TEMP);
+ if (error)
+ goto abortit; /* XXX */
+ if (tdvp == tvp)
+ vrele(tdvp);
+ else
+ vput(tdvp);
+ if (tvp)
+ vput(tvp);
+ vrele(fdvp);
+ vrele(fvp);
+ return error;
+}
+
+int
+afs_vop_mkdir(ap)
+ struct vop_mkdir_args /* {
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ struct vattr *a_vap;
+ } */ *ap;
+{
+ register struct vnode *dvp = ap->a_dvp;
+ register struct vattr *vap = ap->a_vap;
+ int error = 0;
+ struct vcache *vcp;
+ struct proc *p;
+
+ GETNAME();
+ p=cnp->cn_proc;
+#ifdef DIAGNOSTIC
+ if ((cnp->cn_flags & HASBUF) == 0)
+ panic("afs_vop_mkdir: no name");
+#endif
+ AFS_GLOCK();
+ error = afs_mkdir((struct vcache *)dvp, name, vap, &vcp, cnp->cn_cred);
+ AFS_GUNLOCK();
+ if (error) {
+ VOP_ABORTOP(dvp, cnp);
+ vput(dvp);
+ DROPNAME();
+ return(error);
+ }
+ if (vcp) {
+ *ap->a_vpp = (struct vnode *)vcp;
+ vn_lock((struct vnode *)vcp, LK_EXCLUSIVE|LK_RETRY, p);
+ } else
+ *ap->a_vpp = 0;
+ DROPNAME();
+ FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ vput(dvp);
+ return error;
+}
+
+int
+afs_vop_rmdir(ap)
+ struct vop_rmdir_args /* {
+ struct vnode *a_dvp;
+ struct vnode *a_vp;
+ struct componentname *a_cnp;
+ } */ *ap;
+{
+ int error = 0;
+ register struct vnode *vp = ap->a_vp;
+ register struct vnode *dvp = ap->a_dvp;
+
+ GETNAME();
+ if (dvp == vp) {
+ vrele(dvp);
+ vput(vp);
+ FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ DROPNAME();
+ return (EINVAL);
+ }
+
+ AFS_GLOCK();
+ error = afs_rmdir((struct vcache *)dvp, name, cnp->cn_cred);
+ AFS_GUNLOCK();
+ DROPNAME();
+ vput(dvp);
+ vput(vp);
+ return error;
+}
+
+int
+afs_vop_symlink(ap)
+ struct vop_symlink_args /* {
+ struct vnode *a_dvp;
+ struct vnode **a_vpp;
+ struct componentname *a_cnp;
+ struct vattr *a_vap;
+ char *a_target;
+ } */ *ap;
+{
+ register struct vnode *dvp = ap->a_dvp;
+ int error = 0;
+ /* NFS ignores a_vpp; so do we. */
+
+ GETNAME();
+ AFS_GLOCK();
+ error = afs_symlink((struct vcache *)dvp, name, ap->a_vap, ap->a_target,
+ cnp->cn_cred);
+ AFS_GUNLOCK();
+ DROPNAME();
+ FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+ vput(dvp);
+ return error;
+}
+
+int
+afs_vop_readdir(ap)
+ struct vop_readdir_args /* {
+ struct vnode *a_vp;
+ struct uio *a_uio;
+ struct ucred *a_cred;
+ int *a_eofflag;
+ u_long *a_cookies;
+ int ncookies;
+ } */ *ap;
+{
+ int error;
+ off_t off;
+/* printf("readdir %x cookies %x ncookies %d\n", ap->a_vp, ap->a_cookies,
+ ap->a_ncookies); */
+ off=ap->a_uio->uio_offset;
+ AFS_GLOCK();
+ error= afs_readdir((struct vcache *)ap->a_vp, ap->a_uio, ap->a_cred,
+ ap->a_eofflag);
+ AFS_GUNLOCK();
+ if (!error && ap->a_ncookies != NULL) {
+ struct uio *uio = ap->a_uio;
+ const struct dirent *dp, *dp_start, *dp_end;
+ int ncookies;
+ u_long *cookies, *cookiep;
+
+ if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
+ panic("afs_readdir: burned cookies");
+ dp = (const struct dirent *)
+ ((const char *)uio->uio_iov->iov_base - (uio->uio_offset - off));
+
+ dp_end = (const struct dirent *) uio->uio_iov->iov_base;
+ for (dp_start = dp, ncookies = 0;
+ dp < dp_end;
+ dp = (const struct dirent *)((const char *) dp + dp->d_reclen))
+ ncookies++;
+
+ MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
+ M_TEMP, M_WAITOK);
+ for (dp = dp_start, cookiep = cookies;
+ dp < dp_end;
+ dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) {
+ off += dp->d_reclen;
+ *cookiep++ = off;
+ }
+ *ap->a_cookies = cookies;
+ *ap->a_ncookies = ncookies;
+ }
+
+ return error;
+}
+
+int
+afs_vop_readlink(ap)
+ struct vop_readlink_args /* {
+ struct vnode *a_vp;
+ struct uio *a_uio;
+ struct ucred *a_cred;
+ } */ *ap;
+{
+ int error;
+/* printf("readlink %x\n", ap->a_vp);*/
+ AFS_GLOCK();
+ error= afs_readlink((struct vcache *)ap->a_vp, ap->a_uio, ap->a_cred);
+ AFS_GUNLOCK();
+ return error;
+}
+
+extern int prtactive;
+
+int
+afs_vop_inactive(ap)
+ struct vop_inactive_args /* {
+ struct vnode *a_vp;
+ struct proc *a_p;
+ } */ *ap;
+{
+ register struct vnode *vp = ap->a_vp;
+
+ if (prtactive && vp->v_usecount != 0)
+ vprint("afs_vop_inactive(): pushing active", vp);
+
+ AFS_GLOCK();
+ afs_InactiveVCache((struct vcache *)vp, 0); /* decrs ref counts */
+ AFS_GUNLOCK();
+ VOP_UNLOCK(vp, 0, ap->a_p);
+ return 0;
+}
+
+int
+afs_vop_reclaim(ap)
+ struct vop_reclaim_args /* {
+ struct vnode *a_vp;
+ } */ *ap;
+{
+ int error;
+ int sl;
+ register struct vnode *vp = ap->a_vp;
+
+ cache_purge(vp); /* just in case... */
+
+#if 0
+ AFS_GLOCK();
+ error = afs_FlushVCache((struct vcache *)vp, &sl); /* tosses our stuff from vnode */
+ AFS_GUNLOCK();
+ ubc_unlink(vp);
+ if (!error && vp->v_data)
+ panic("afs_reclaim: vnode not cleaned");
+ return error;
+#else
+ if (vp->v_usecount == 2) {
+ vprint("reclaim count==2", vp);
+ } else if (vp->v_usecount == 1) {
+ vprint("reclaim count==1", vp);
+ } else
+ vprint("reclaim bad count", vp);
+
+ return 0;
+#endif
+}
+
+int
+afs_vop_lock(ap)
+ struct vop_lock_args /* {
+ struct vnode *a_vp;
+ } */ *ap;
+{
+ register struct vnode *vp = ap->a_vp;
+ register struct vcache *avc = (struct vcache *)vp;
+
+ if (vp->v_tag == VT_NON)
+ return (ENOENT);
+ return (lockmgr(&avc->rwlock, ap->a_flags, &vp->v_interlock,
+ ap->a_p));
+}
+
+int
+afs_vop_unlock(ap)
+ struct vop_unlock_args /* {
+ struct vnode *a_vp;
+ } */ *ap;
+{
+ struct vnode *vp = ap->a_vp;
+ struct vcache *avc = (struct vcache *)vp;
+ return (lockmgr(&avc->rwlock, ap->a_flags | LK_RELEASE,
+ &vp->v_interlock, ap->a_p));
+
+}
+
+int
+afs_vop_bmap(ap)
+ struct vop_bmap_args /* {
+ struct vnode *a_vp;
+ daddr_t a_bn;
+ struct vnode **a_vpp;
+ daddr_t *a_bnp;
+ int *a_runp;
+ int *a_runb;
+ } */ *ap;
+{
+ struct vcache *vcp;
+ int error;
+ if (ap->a_bnp) {
+ *ap->a_bnp = ap->a_bn * (PAGE_SIZE / DEV_BSIZE);
+ }
+ if (ap->a_vpp) {
+ *ap->a_vpp = ap->a_vp;
+ }
+ if (ap->a_runp != NULL)
+ *ap->a_runp = 0;
+#ifdef notyet
+ if (ap->a_runb != NULL)
+ *ap->a_runb = 0;
+#endif
+
+ return 0;
+}
+int
+afs_vop_strategy(ap)
+ struct vop_strategy_args /* {
+ struct buf *a_bp;
+ } */ *ap;
+{
+ int error;
+ AFS_GLOCK();
+ error= afs_ustrategy(ap->a_bp);
+ AFS_GUNLOCK();
+ return error;
+}
+int
+afs_vop_print(ap)
+ struct vop_print_args /* {
+ struct vnode *a_vp;
+ } */ *ap;
+{
+ register struct vnode *vp = ap->a_vp;
+ register struct vcache *vc = (struct vcache *)ap->a_vp;
+ int s = vc->states;
+ char buf[20];
+ printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell,
+ vc->fid.Fid.Volume, vc->fid.Fid.Vnode, vc->fid.Fid.Unique, vc->opens,
+ vc->execsOrWriters);
+ printf("\n states%s%s%s%s%s", (s&CStatd) ? " statd" : "", (s&CRO) ? " readonly" : "",(s&CDirty) ? " dirty" : "",(s&CMAPPED) ? " mapped" : "", (s&CVFlushed) ? " flush in progress" : "");
+ if (UBCISVALID(vp))
+ printf("\n UBC: %s%s",
+ UBCINFOEXISTS(vp) ? "exists, " : "does not exist",
+ UBCINFOEXISTS(vp) ?
+ sprintf(buf, "holdcnt %d", vp->v_ubcinfo->ui_holdcnt),buf : "");
+ printf("\n");
+ return 0;
+}
+
+int
+afs_vop_islocked(ap)
+ struct vop_islocked_args /* {
+ struct vnode *a_vp;
+ } */ *ap;
+{
+ struct vcache *vc = (struct vcache *)ap->a_vp;
+ return lockstatus(&vc->rwlock);
+}
+
+/*
+ * Return POSIX pathconf information applicable to ufs filesystems.
+ */
+afs_vop_pathconf(ap)
+ struct vop_pathconf_args /* {
+ struct vnode *a_vp;
+ int a_name;
+ int *a_retval;
+ } */ *ap;
+{
+ AFS_STATCNT(afs_cntl);
+ switch (ap->a_name) {
+ case _PC_LINK_MAX:
+ *ap->a_retval = LINK_MAX;
+ break;
+ case _PC_NAME_MAX:
+ *ap->a_retval = NAME_MAX;
+ break;
+ case _PC_PATH_MAX:
+ *ap->a_retval = PATH_MAX;
+ break;
+ case _PC_CHOWN_RESTRICTED:
+ *ap->a_retval = 1;
+ break;
+ case _PC_NO_TRUNC:
+ *ap->a_retval = 1;
+ break;
+ case _PC_PIPE_BUF:
+ return EINVAL;
+ break;
+ default:
+ return EINVAL;
+ }
+ return 0;
+}
+
+/*
+ * Advisory record locking support (fcntl() POSIX style)
+ */
+int
+afs_vop_advlock(ap)
+ struct vop_advlock_args /* {
+ struct vnode *a_vp;
+ caddr_t a_id;
+ int a_op;
+ struct flock *a_fl;
+ int a_flags;
+ } */ *ap;
+{
+ int error;
+ struct proc *p=current_proc();
+ struct ucred cr;
+ pcred_readlock(p);
+ cr=*p->p_cred->pc_ucred;
+ pcred_unlock(p);
+ AFS_GLOCK();
+ error= afs_lockctl((struct vcache *)ap->a_vp, ap->a_fl, ap->a_op, &cr,
+ (int) ap->a_id);
+ AFS_GUNLOCK();
+ return error;
+}
+
+int
+afs_vop_truncate(ap)
+ struct vop_truncate_args /* {
+ struct vnode *a_vp;
+ off_t a_length;
+ int a_flags;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ printf("stray afs_vop_truncate\n");
+ return EOPNOTSUPP;
+}
+
+int
+afs_vop_update(ap)
+ struct vop_update_args /* {
+ struct vnode *a_vp;
+ struct timeval *a_access;
+ struct timeval *a_modify;
+ int a_waitfor;
+ } */ *ap;
+{
+ printf("stray afs_vop_update\n");
+ return EOPNOTSUPP;
+}
+
+int afs_vop_blktooff(ap)
+ struct vop_blktooff_args /* {
+ struct vnode *a_vp;
+ daddr_t a_lblkno;
+ off_t *a_offset;
+ } */ *ap;
+{
+ *ap->a_offset = (off_t)(ap->a_lblkno * DEV_BSIZE);
+ return 0;
+}
+
+int afs_vop_offtoblk(ap)
+ struct vop_offtoblk_args /* {
+ struct vnode *a_vp;
+ off_t a_offset;
+ daddr_t *a_lblkno;
+ } */ *ap;
+{
+ *ap->a_lblkno = (daddr_t)(ap->a_offset / DEV_BSIZE);
+
+ return (0);
+}
+
+int afs_vop_cmap(ap)
+ struct vop_cmap_args /* {
+ struct vnode *a_vp;
+ off_t a_foffset;
+ size_t a_size;
+ daddr_t *a_bpn;
+ size_t *a_run;
+ void *a_poff;
+ } */ *ap;
+{
+ *ap->a_bpn = (daddr_t)(ap->a_foffset / DEV_BSIZE);
+ *ap->a_run= MAX(ap->a_size, AFS_CHUNKSIZE(ap->a_foffset));
+ return 0;
+}
+
# directory or online at http://www.openafs.org/dl/license10.html
SHELL=/bin/sh
-INSTALL = ${SRCDIR}bin/install
KERNELDIR = ../libafs/
UKERNELDIR = ../libuafs/
gencat -m afszcm.cat afs_trace.msf ;; \
*_linux* ) \
gencat --new afszcm.cat afs_trace.msf ;; \
+ ppc_darwin*) \
+ echo No gencat for ${SYS_NAME} ;; \
* ) \
gencat afszcm.cat afs_trace.msf ;; \
esac
-
-
+
+
ukinstall webinstall: AFS_component_version_number.c
set ${UKERNELDIR}afs; $(MKDIR_IF_NEEDED)
${INSTALL} longc_procs.h ${DESTDIR}include/afs ;; \
esac
case ${SYS_NAME} in \
- next_mach30 | vax_ul43) \
+ next_mach30 | vax_ul43 | ppc_darwin* ) \
echo skipping afszcm.cat install for ${SYS_NAME} ;; \
* ) \
${INSTALL} afszcm.cat ${DESTDIR}root.client/usr/vice/etc/C ;; \
iob.out = tbuffer;
iob.out_size = sizeof(tbuffer);
-#if defined(AFS_USR_SUN5_ENV) || defined(AFS_USR_OSF_ENV) || defined(AFS_USR_HPUX_ENV) || defined(AFS_USR_LINUX22_ENV)
+#if defined(AFS_USR_SUN5_ENV) || defined(AFS_USR_OSF_ENV) || defined(AFS_USR_HPUX_ENV) || defined(AFS_USR_LINUX22_ENV) || defined(AFS_USR_DARWIN_ENV)
rc = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, 0, _VICEIOCTL(8), &iob, 0);
#elif defined(AFS_USR_SGI_ENV)
rc = syscall(AFS_PIOCTL, 0, _VICEIOCTL(8), &iob, 0);
#define __AFS_SYSINCLUDESH__ 1
#include <stdio.h>
+#ifndef AFS_USR_DARWIN_ENV /* must be included after KERNEL undef'd */
#include <errno.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define FREAD 0x0001
#endif /* AFS_USR_LINUX22_ENV */
+#ifdef AFS_USR_DARWIN_ENV
+#ifdef KERNEL
+#undef KERNEL
+#define AFS_USR_UNDEF_KERNEL_ENV 1
+#endif
+#include <errno.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+#include <sys/uio.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#ifndef O_SYNC
+#define O_SYNC O_FSYNC
+#endif
+#endif /* AFS_USR_DARWIN_ENV */
+
/* glibc 2.2 has pthread_attr_setstacksize */
#if defined(AFS_LINUX22_ENV) || defined(AFS_USR_LINUX22_ENV) && (__GLIBC_MINOR__ < 2)
#define pthread_attr_setstacksize(a,b) 0
#undef socket
#endif /* AFS_USR_SGI_ENV */
+#ifdef AFS_USR_DARWIN_ENV
+#undef if_mtu
+#undef if_metric
+#endif
+
#define mount usr_mount
#define fs usr_fs
#define uio usr_uio
* anyway, so the difference between 512K and 1000000 shouldn't matter
* much, and "&" is a lot faster than "%".
*/
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV)
+#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV)
attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
attrs->va_ctime.tv_nsec =
(hgetlo(avc->m.DataVersion) & 0x7ffff) * 1000;
-#ifdef AFS_AIX41_ENV
+#if defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV)
attrs->va_blocksize = PAGESIZE; /* XXX Was 8192 XXX */
#else
attrs->va_blksize = PAGESIZE; /* XXX Was 8192 XXX */
attrs->va_flags = 0;
#endif /* AFS_OSF_ENV */
-#if !defined(AFS_OSF_ENV)
+#if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV)
#if !defined(AFS_HPUX_ENV)
#ifdef AFS_SUN5_ENV
attrs->va_nblocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) << 1 : 0);
return EACCES;
}
if (avc->mvstat == 2) {
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV)
+#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV)
attrs->va_mtime.tv_nsec += ((++avc->xlatordv) * 1000);
#else
attrs->va_mtime.tv_usec += ++avc->xlatordv;
#endif
mask |= AFS_SETMODTIME;
#ifndef AFS_SGI_ENV
-#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV)
if (av->va_mtime.tv_nsec == -1)
#else
if (av->va_mtime.tv_usec == -1)
(afs_Analyze(tc, code, &adp->fid, &treq,
AFS_STATS_FS_RPCIDX_CREATEFILE, SHARED_LOCK, (struct cell *)0));
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
if (code == EEXIST && aexcl == NONEXCL) {
/* This lookup was handled in the common vn_open code in the
vnode layer */
*/
#include "../afs/param.h" /* Should be always first */
-#if !defined(AFS_DUX40_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_DUX40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
#include "../afs/sysincludes.h" /* Standard vendor system headers */
#include "../afs/afsincludes.h" /* Afs-based standard headers */
#include "../afs/afs_stats.h" /* statistics */
#if defined(AFS_SUN5_ENV)
register proc_t *procp = ttoproc(curthread);
#else
-#if !defined(AFS_AIX41_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_SGI65_ENV)
+#if !defined(AFS_AIX41_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_SGI65_ENV) && !defined(AFS_DARWIN_ENV)
#ifdef AFS_SGI_ENV
struct proc *procp = OSI_GET_CURRENT_PROCP();
#else
#endif
slp->pid = clid;
#else
-#if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV)
+#if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
slp->pid = clid;
#else
#if defined(AFS_LINUX20_ENV) || defined(AFS_HPUX_ENV)
#endif
flock->l_pid = clid;
#else
-#if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV)
+#if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
flock->l_pid = clid;
#else
#if defined(AFS_LINUX20_ENV) || defined(AFS_HPUX_ENV)
#if defined(AFS_SUN5_ENV)
register proc_t *procp = ttoproc(curthread);
#else
-#if !defined(AFS_AIX41_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_SGI65_ENV)
+#if !defined(AFS_AIX41_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_SGI65_ENV) && !defined(AFS_DARWIN_ENV)
#ifdef AFS_SGI64_ENV
struct proc *procp = curprocp;
#else /* AFS_SGI64_ENV */
}
#endif
if ((flock1->l_pid == alp->pid) ||
-#if defined(AFS_AIX41_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_HPUX_ENV)
+#if defined(AFS_AIX41_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_DARWIN_ENV)
(!onlymine && (flock1->l_pid == getppid()))
#else
#if defined(AFS_SGI65_ENV)
pid_t clid;
off_t offset;
#else
-#if defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV))
+#if defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) || defined(AFS_DARWIN_ENV)
afs_lockctl(avc, af, acmd, acred, clid)
pid_t clid;
#else
#endif
-#if !defined(AFS_AIX_ENV) && !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_SGI_ENV) && !defined(UKERNEL) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_AIX_ENV) && !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_SGI_ENV) && !defined(UKERNEL) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
/* Flock not support on System V systems */
#ifdef AFS_OSF_ENV
extern struct fileops afs_fileops;
code = osi_file_uio_rdwr(tfile, auio, UIO_READ);
AFS_GLOCK();
#else
+#if defined(AFS_DARWIN_ENV)
+ AFS_GUNLOCK();
+ VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc());
+ code = VOP_READ(tfile->vnode, auio, 0, &afs_osi_cred);
+ VOP_UNLOCK(tfile->vnode, 0, current_proc());
+ AFS_GLOCK();
+#else
code = VOP_RDWR(tfile->vnode, auio, UIO_READ, 0, &afs_osi_cred);
#endif
#endif
#endif
#endif
#endif
+#endif
auio->afsio_offset += avc->quick.minLoc;
osi_UFSClose(tfile);
/* Fix up LRU info */
code = osi_file_uio_rdwr(tfile, &tuio, UIO_READ);
AFS_GLOCK();
#else
+#if defined(AFS_DARWIN_ENV)
+ AFS_GUNLOCK();
+ VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc());
+ code = VOP_READ(tfile->vnode, &tuio, 0, &afs_osi_cred);
+ VOP_UNLOCK(tfile->vnode, 0, current_proc());
+ AFS_GLOCK();
+#else
code = VOP_RDWR(tfile->vnode, &tuio, UIO_READ, 0, &afs_osi_cred);
#endif
#endif
#endif
#endif
#endif
+#endif
#ifdef IHINT
if (!tdc->ihint && nihints < maxIHint) {
#else
struct min_direct { /* miniature direct structure */
/* If struct direct changes, this must too */
+#ifdef AFS_DARWIN_ENV
+ afs_uint32 d_fileno;
+ u_short d_reclen;
+ u_char d_type;
+ u_char d_namlen;
+#else
#ifdef AFS_SUN5_ENV
afs_uint32 d_fileno;
afs_int32 d_off;
u_short d_reclen;
u_short d_namlen;
#endif
+#endif
};
#endif /* AFS_SGI_ENV */
#if defined(AFS_SUN_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_SGI_ENV)
sdirEntry.d_off = off;
#endif
+#if defined(AFS_DARWIN_ENV)
+ sdirEntry.d_type=DT_UNKNOWN;
+#endif
#if defined(AFS_SGI_ENV)
AFS_UIOMOVE(&sdirEntry, DIRENTBASESIZE, UIO_READ, auio, code);
* It has to do with 'offset' (seek locations).
*/
-#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
afs_readdir(OSI_VC_ARG(avc), auio, acred, eofp)
int *eofp;
#else
#endif /* AFS_SGI61_ENV */
#endif /* defined(AFS_SGI53_ENV) */
-#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
/* Not really used by the callee so we ignore it for now */
if (eofp) *eofp = 0;
#endif
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
afs_ustrategy(abp, credp)
struct AFS_UCRED *credp;
#else
struct uio tuio;
register struct vcache *tvc = (struct vcache *) abp->b_vp;
register afs_int32 len = abp->b_bcount;
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV)
#ifdef AFS_AIX41_ENV
struct ucred *credp;
#else
struct AFS_UCRED *credp = u.u_cred;
#endif
#endif
-#if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
+#if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV)
int async = abp->b_flags & B_ASYNC;
#endif
struct iovec tiovec[1];
code = osi_file_uio_rdwr(tfile, &tuio, UIO_WRITE);
AFS_GLOCK();
#else
+#if defined(AFS_DARWIN_ENV)
+ AFS_GUNLOCK();
+ VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc());
+ code = VOP_WRITE(tfile->vnode, &tuio, 0, &afs_osi_cred);
+ VOP_UNLOCK(tfile->vnode, 0, current_proc());
+ AFS_GLOCK();
+#else
code = VOP_RDWR(tfile->vnode, &tuio, UIO_WRITE, 0, &afs_osi_cred);
+#endif /* AFS_DARWIN_ENV */
#endif /* AFS_LINUX20_ENV */
#endif /* AFS_HPUX100_ENV */
#endif /* AFS_OSF_ENV */
* If write is implemented via VM, afs_fsync() is called from the high-level
* write op.
*/
+#ifdef AFS_DARWIN_ENV
+ if (noLock && (aio & IO_SYNC)) {
+#else
#ifdef AFS_HPUX_ENV
/* On hpux on synchronous writes syncio will be set to IO_SYNC. If
* we're doing them because the file was opened with O_SYNCIO specified,
#else
if (noLock && (aio & FSYNC)) {
#endif
+#endif
if (!AFS_NFSXLATORREQ(acred))
afs_fsync(avc, acred);
}
-#if !defined (AFS_AIX_ENV) && !defined (AFS_HPUX_ENV) && !defined (AFS_SUN5_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined (AFS_AIX_ENV) && !defined (AFS_HPUX_ENV) && !defined (AFS_SUN5_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
#ifdef AFS_DUX50_ENV
#define vno_close(X) vn_close((X), 0, NOCRED)
#elif defined(AFS_DUX40_ENV)
* Do not try to get the vcache lock when the vlock is held */
afs_rwlock_t vlock;
#endif /* defined(AFS_SUN5_ENV) */
-#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV)
+#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_DARWIN_ENV)
#if defined(AFS_SUN5_ENV)
krwlock_t rwlock;
struct cred *credp;
#ifdef AFS_AIX_ENV
int ownslock; /* pid of owner of excl lock, else 0 - defect 3083 */
#endif
+#ifdef AFS_DARWIN_ENV
+ struct lock__bsd__ rwlock;
+#endif
afs_int32 parentVnode; /* Parent dir, if a file. */
afs_int32 parentUnique;
struct VenusFid *mvid; /* Either parent dir (if root) or root (if mt pt) */
(((avc)->states & CStatd) ? (vcache2inode(avc), 0) : \
afs_VerifyVCache2((avc),areq))
#else
+#ifdef AFS_DARWIN_ENV
+#define afs_VerifyVCache(avc, areq) \
+ (((avc)->states & CStatd) ? (osi_VM_Setup(avc), 0) : \
+ afs_VerifyVCache2((avc),areq))
+#else
#define afs_VerifyVCache(avc, areq) \
(((avc)->states & CStatd) ? 0 : afs_VerifyVCache2((avc),areq))
#endif
+#endif
#define DO_STATS 1 /* bits used by FindVCache */
#define DO_VLRU 2
/* get a file's serial number from a vnode */
#ifndef afs_vnodeToInumber
-#if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS)
+#if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
#define afs_vnodeToInumber(V) VnodeToIno(V)
#else
#ifdef AFS_DECOSF_ENV
/* get a file's device number from a vnode */
#ifndef afs_vnodeToDev
-#if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS)
+#if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
#define afs_vnodeToDev(V) VnodeToDev(V)
#else
#ifdef AFS_DECOSF_ENV
struct afs_icl_set *afs_iclSetp = (struct afs_icl_set*)0;
struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set*)0;
-#if defined(AFS_GLOBAL_SUNLOCK) && !defined(AFS_HPUX_ENV) && !defined(AFS_AIX41_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
+#if defined(AFS_GLOBAL_SUNLOCK) && !defined(AFS_HPUX_ENV) && !defined(AFS_AIX41_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV)
+
kmutex_t afs_global_lock;
kmutex_t afs_rxglobal_lock;
#if defined(AFS_OSF_ENV)
simple_lock_data_t afs_global_lock;
+#elif defined(AFS_DARWIN_ENV)
+struct lock__bsd__ afs_global_lock;
+#endif
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
thread_t afs_global_owner;
#endif /* AFS_OSF_ENV */
if (!afs_suser() && (parm != AFSOP_GETMTU)
&& (parm != AFSOP_GETMASK)) {
/* only root can run this code */
-#if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
setuerror(EACCES);
return(EACCES);
#else
while (afs_initState < AFSOP_START_AFS)
afs_osi_Sleep(&afs_initState);
-#if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
temp = AFS_MINBUFFERS; /* Should fix this soon */
#else
temp = ((afs_bufferpages * NBPG)>>11); /* number of 2k buffers we could get from all of the buffer space */
struct afsop_cell tcell;
char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *lcnamep = 0;
char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *cnamep = 0;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV)
size_t bufferSize;
#else /* AFS_SGI61_ENV */
u_int bufferSize;
while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
AFS_COPYIN((char *)parm2, (caddr_t) &cparms, sizeof(cparms), code);
if (code) {
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined (AFS_SGI64_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined (AFS_SGI64_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
goto out;
#else
setuerror(code);
code = afs_InitCacheFile((char *) 0, ainode);
}
else if (parm == AFSOP_ROOTVOLUME) {
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV)
size_t bufferSize;
#else /* AFS_SGI61_ENV */
u_int bufferSize;
else if (parm == AFSOP_CACHEFILE || parm == AFSOP_CACHEINFO ||
parm == AFSOP_VOLUMEINFO || parm == AFSOP_AFSLOG) {
char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV)
size_t bufferSize;
#else /* AFS_SGI61_ENV */
u_int bufferSize;
#endif /* AFS_SGI62_ENV && !AFS_SGI65_ENV */
#endif /* AFS_SGI53_ENV */
else if (parm == AFSOP_SHUTDOWN) {
-#if defined(AFS_OSF_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
extern struct mount *afs_globalVFS;
#else /* AFS_OSF_ENV */
extern struct vfs *afs_globalVFS;
afs_vfs_mount(parm2, parm3, parm4, parm5);
#endif /* AFS_HPUX100_ENV */
#else /* defined(AFS_HPUX_ENV) */
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
code = EINVAL;
#else
setuerror(EINVAL);
{
int *retval = &rvp->r_val1;
#else /* AFS_SUN5_ENV */
-#if defined(AFS_OSF_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
afs3_syscall(p, args, retval)
struct proc *p;
void *args;
mutex_exit(&procp->p_crlock);
#else
AFS_GLOCK();
-#if defined(AFS_OSF_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
code = afs_setpag(p, args, retval);
#else /* AFS_OSF_ENV */
code = afs_setpag();
#ifdef AFS_SUN5_ENV
code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, rvp, CRED());
#else
+#ifdef AFS_DARWIN_ENV
+ code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, p->p_cred->pc_ucred);
+#else
code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4);
#endif
+#endif
AFS_GUNLOCK();
} else if (uap->syscall == AFSCALL_ICREATE) {
struct iparam iparams;
code = copyin_iparam((char *)uap->parm3, &iparams);
if (code) {
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
setuerror(code);
#endif
} else
iparams.param3, iparams.param4, rvp, CRED());
#else
code = afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2,
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
iparams.param3, iparams.param4, retval);
#else
iparams.param3, iparams.param4);
#ifdef AFS_SUN5_ENV
code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp, CRED());
#else
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, retval);
#else
code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3);
}
#else
if (code) {
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV)
setuerror(code);
#endif
}
#endif /* !AFS_LINUX20_ENV */
} else {
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
code = EINVAL;
#else
setuerror(EINVAL);
register afs_int32 code;
struct afs_icl_log *logp;
struct afs_icl_set *setp;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV)
size_t temp;
#else /* AFS_SGI61_ENV */
afs_uint32 temp;
}
#else
if (!afs_suser()) { /* only root can run this code */
-#if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
setuerror(EACCES);
return EACCES;
#else
tlen = (alen > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : alen);
got = afs_osi_Read(afile, -1, tbuffer, tlen);
if ((got < 0)
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
|| (got != tlen && getuerror())
#endif
) {
updateV2DC(setLocks,avc,tdc,567);
return tdc; /* check if we're done */
}
+ osi_Assert(setLocks || WriteLocked(&avc->lock));
if (setLocks) ObtainReadLock(&avc->lock);
if (!hsame(avc->m.DataVersion, tdc->f.versionNo)) {
tdc->f.chunk = -1;
hones(tdc->f.versionNo);
tdc->flags |= DFEntryMod;
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
last_error = getuerror();
#endif
lasterrtime = osi_Time();
/* Exported variables */
struct osi_dev cacheDev; /*Cache device*/
afs_int32 cacheInfoModTime; /*Last time cache info modified*/
-#if defined(AFS_OSF_ENV) || defined(AFS_DEC_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DEC_ENV) || defined(AFS_DARWIN_ENV)
struct mount *afs_cacheVfsp=0;
#elif defined(AFS_LINUX20_ENV)
struct super_block *afs_cacheSBp = 0;
TO_KERNEL_SPACE();
}
#else
+#ifdef AFS_DARWIN_ENV
+ if (!VFS_STATFS(filevp->v_mount, &st, current_proc()))
+#else
if (!VFS_STATFS(filevp->v_vfsp, &st))
+#endif /* AFS_DARWIN_ENV */
#endif /* AFS_LINUX20_ENV */
#endif /* AIX41 */
#endif /* OSF */
#else
cacheInode = afs_vnodeToInumber(filevp);
cacheDev.dev = afs_vnodeToDev(filevp);
-#if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS)
+#if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
afs_InitDualFSCacheOps(filevp);
#endif
afs_cacheVfsp = filevp->v_vfsp;
#elif defined(AFS_OSF_ENV)
usimple_lock_init(&afs_global_lock);
afs_global_owner = (thread_t)0;
+#elif defined(AFS_DARWIN_ENV)
+ lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0);
+ afs_global_owner = (thread_t)0;
#elif defined(AFS_AIX41_ENV)
lock_alloc((void*)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1);
simple_lock_init((void *)&afs_global_lock);
osi_Active(avc)
register struct vcache *avc; {
AFS_STATCNT(osi_Active);
-#if defined(AFS_SUN_ENV) || defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || (AFS_LINUX20_ENV)
+#if defined(AFS_SUN_ENV) || defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || (AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
if ((avc->opens > 0) || (avc->states & CMAPPED)) return 1; /* XXX: Warning, verify this XXX */
#else
#if defined(AFS_MACH_ENV)
#if defined(AFS_HPUX101_ENV)
set_system_proc(u.u_procp);
#else
+#if defined(AFS_DARWIN_ENV)
+ current_proc()->p_flag |= P_SYSTEM;
+#else
#if !defined(AFS_SGI64_ENV) && !defined(AFS_LINUX20_ENV)
u.u_procp->p_flag |= SSYS;
#endif /* AFS_SGI64_ENV */
#endif
#endif
#endif
+#endif
AFS_STATCNT(osi_Invisible);
}
stime(&sta);
AFS_GLOCK();
#else
+#ifdef AFS_DARWIN_ENV
+ AFS_GUNLOCK();
+ setthetime(atv);
+ AFS_GLOCK();
+#else
/* stolen from kern_time.c */
#ifndef AFS_AUX_ENV
boottime.tv_sec += atv->tv_sec - time.tv_sec;
#ifdef AFS_AUX_ENV
logtchg(atv->tv_sec);
#endif
+#endif /* AFS_DARWIN_ENV */
#endif /* AFS_SGI_ENV */
#endif /* AFS_SUN55_ENV */
#endif /* AFS_SUN5_ENV */
}
#endif
+#if defined(AFS_DARWIN_ENV)
+void afs_osi_TraverseProcTable()
+{
+ struct proc *p;
+ LIST_FOREACH(p, &allproc, p_list) {
+ if (p->p_stat == SIDL)
+ continue;
+ if (p->p_stat == SZOMB)
+ continue;
+ if (p->p_flag & P_SYSTEM)
+ continue;
+ afs_GCPAGs_perproc_func(p);
+ }
+}
+#endif
+
/* return a pointer (sometimes a static copy ) to the cred for a
* given AFS_PROC.
* subsequent calls may overwrite the previously returned value.
return rv;
}
+#elif defined(AFS_DARWIN_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_readlock(pr);
+ cr.cr_ref=1;
+ cr.cr_uid=pr->p_cred->pc_ucred->cr_uid;
+ cr.cr_ngroups=pr->p_cred->pc_ucred->cr_ngroups;
+ bcopy(pr->p_cred->pc_ucred->cr_groups, cr.cr_groups,NGROUPS *
+ sizeof(gid_t));
+ pcred_unlock(pr);
+ rv = &cr;
+ }
+
+ return rv;
+}
#else
const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr)
{
/*
* Vnode related macros
*/
+#ifdef AFS_DARWIN_ENV
+extern int (**afs_vnodeop_p)();
+#define IsAfsVnode(vc) ((vc)->v_op == afs_vnodeop_p)
+#define SetAfsVnode(vc) (vc)->v_op = afs_vnodeop_p
+#else
extern struct vnodeops *afs_ops;
-#define vType(vc) (vc)->v.v_type
-#define vSetType(vc,type) (vc)->v.v_type = (type)
#define IsAfsVnode(vc) ((vc)->v_op == afs_ops)
#define SetAfsVnode(vc) (vc)->v_op = afs_ops
+#endif
+#define vType(vc) (vc)->v.v_type
+#define vSetType(vc,type) (vc)->v.v_type = (type)
#define vSetVfsp(vc,vfsp) (vc)->v.v_vfsp = (vfsp)
#ifdef AFS_SGI65_ENV
* (Also, of course, the vnode is assumed to be one of ours. Can't use this
* macro for V-file vnodes.)
*/
+#ifdef AFS_DARWIN_ENV
+/* Bare refcount manipulation would probably work on this platform, but just
+ calling VREF does not */
+#define AFS_FAST_HOLD(vp) osi_vnhold((vp),0)
+#else
#define AFS_FAST_HOLD(vp) VN_HOLD(&(vp)->v)
+#endif
#define AFS_FAST_RELE(vp) AFS_RELE(&(vp)->v)
/*
AFS_GLOCK(); \
} while(0)
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
#define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
do { \
int haveGlock = ISAFS_GLOCK(); \
CODE = copyout((SRC),(DST),(LEN)); \
} while(0)
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
#define AFS_UIOMOVE(SRC,LEN,RW,UIO,CODE) \
do { \
(UIO)->uio_rw = (RW); \
int
#if defined(AFS_SUN5_ENV)
afs_setpag (struct AFS_UCRED **credpp)
-#elif defined(AFS_OSF_ENV)
+#elif defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
afs_setpag (struct proc *p, void *args, int *retval)
#else
afs_setpag (void)
code = AddPag(genpag(), &credp);
crfree(credp);
}
+#elif defined(AFS_DARWIN_ENV)
+ {
+ struct ucred *credp=crdup(p->p_cred->pc_ucred);
+ code=AddPag(p, genpag(), &credp);
+ crfree(credp);
+ }
#else
code = AddPag(genpag(), &u.u_cred);
#endif
afs_Trace1(afs_iclSetp, CM_TRACE_SETPAG, ICL_TYPE_INT32, code);
-#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
#if defined(AFS_SGI53_ENV) && defined(MP)
AFS_GUNLOCK();
#endif /* defined(AFS_SGI53_ENV) && defined(MP) */
#endif
}
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
int AddPag(struct proc *p, afs_int32 aval, struct AFS_UCRED **credpp)
#else /* AFS_OSF_ENV */
int AddPag(afs_int32 aval, struct AFS_UCRED **credpp)
{
afs_int32 newpag, code;
AFS_STATCNT(AddPag);
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
if (code = setpag(p, credpp, aval, &newpag, 0))
#else /* AFS_OSF_ENV */
if (code = setpag(credpp, aval, &newpag, 0))
#endif
-#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
return (code);
#else
return (setuerror(code), code);
* think it's ok to use the real uid to make setuid
* programs (without setpag) to work properly.
*/
+#ifdef AFS_DARWIN_ENV
+ av->uid = acred->cr_uid; /* default when no pag is set */
+ /* bsd creds don't have ruid */
+#else
av->uid = acred->cr_ruid; /* default when no pag is set */
+#endif
}
av->initd = 0;
return 0;
if (cred == NULL) {
return NOPAG;
}
+#ifdef AFS_DARWIN_ENV
+ if (cred == NOCRED || cred == FSCRED) {
+ return NOPAG;
+ }
+ if (cred->cr_ngroups < 3) return NOPAG;
+ /* gid is stored in cr_groups[0] */
+ g0 = cred->cr_groups[1];
+ g1 = cred->cr_groups[2];
+#else
#ifdef AFS_AIX_ENV
if (cred->cr_ngrps < 2) {
return NOPAG;
if (cred->cr_ngroups < 2) return NOPAG;
#endif
#endif
+#endif
g0 = cred->cr_groups[0];
g1 = cred->cr_groups[1];
pag = (afs_int32)afs_get_pag_from_groups(g0, g1);
caddr_t arg;
} *uap = (struct a *)args;
#else /* AFS_OSF_ENV */
+#ifdef AFS_DARWIN_ENV
+struct ioctl_args {
+ int fd;
+ u_long com;
+ caddr_t arg;
+};
+afs_xioctl(p, uap, retval)
+ struct proc *p;
+ register struct ioctl_args *uap;
+ register_t *retval;
+{
+#else
#ifdef AFS_LINUX22_ENV
struct afs_ioctl_sys {
unsigned int com;
caddr_t arg;
} *uap = (struct a *)u.u_ap;
#endif /* AFS_LINUX22_ENV */
+#endif /* AFS_DARWIN_ENV */
#endif /* AFS_OSF_ENV */
#endif /* AFS_SUN5_ENV */
#endif
#ifndef AFS_LINUX22_ENV
-#if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV)
+#if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
struct file *fd;
#else
register struct file *fd;
register int ioctlDone = 0, code = 0;
AFS_STATCNT(afs_xioctl);
+#ifdef AFS_DARWIN_ENV
+ if ((code=fdgetf(p, uap->fd, &fd)))
+ return code;
+#else
#ifdef AFS_LINUX22_ENV
ua.com = com;
ua.arg = arg;
#endif
#endif
#endif
+#endif
/* first determine whether this is any sort of vnode */
#ifdef AFS_LINUX22_ENV
if (code) {
osi_FreeSmallSpace(datap);
AFS_GUNLOCK();
+#ifdef AFS_DARWIN_ENV
+ return code;
+#else
#if defined(AFS_SUN5_ENV)
#ifdef AFS_SUN54_ENV
releasef(uap->fd);
#endif
#endif
#endif
+#endif
}
code = HandleIoctl(tvc, uap->com, datap);
osi_FreeSmallSpace(datap);
#endif
code = ioctl(uap, rvp);
#else
+#if defined(AFS_DARWIN_ENV)
+ return ioctl(p, uap, retval);
+#else
#ifdef AFS_OSF_ENV
code = ioctl(p, args, retval);
#ifdef AFS_OSF30_ENV
#endif
#endif
#endif
+#endif
}
#ifdef AFS_SUN5_ENV
if (ioctlDone)
#ifdef AFS_LINUX22_ENV
return -code;
#else
-#if !defined(AFS_OSF_ENV)
+#if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV)
if (!getuerror())
setuerror(code);
#if defined(AFS_AIX32_ENV) && !defined(AFS_AIX41_ENV)
#endif
#endif /* AFS_LINUX22_ENV */
#endif /* AFS_SUN5_ENV */
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
return (code);
#endif
}
extern struct mount *afs_globalVFS;
#else /* AFS_OSF_ENV */
+#ifdef AFS_DARWIN_ENV
+afs_pioctl(p, args, retval)
+ struct proc *p;
+ void *args;
+ int *retval;
+{
+ struct a {
+ char *path;
+ int cmd;
+ caddr_t cmarg;
+ int follow;
+ } *uap = (struct a *) args;
+
+ AFS_STATCNT(afs_pioctl);
+ return (afs_syscall_pioctl(uap->path, uap->cmd, uap->cmarg, uap->follow, p->p_cred->pc_ucred));
+}
+
+extern struct mount *afs_globalVFS;
+#else /* AFS_OSF_ENV */
extern struct vfs *afs_globalVFS;
#endif
+#endif
/* macro to avoid adding any more #ifdef's to pioctl code. */
#if defined(AFS_LINUX22_ENV) || defined(AFS_AIX41_ENV)
rval_t *rvp;
struct AFS_UCRED *credp;
#else
+#ifdef AFS_DARWIN_ENV
+afs_syscall_pioctl(path, com, cmarg, follow, credp)
+ struct AFS_UCRED *credp;
+#else
afs_syscall_pioctl(path, com, cmarg, follow)
#endif
+#endif
char *path;
unsigned int com;
caddr_t cmarg;
#ifndef AFS_SUN5_ENV
if (! _VALIDVICEIOCTL(com)) {
PIOCTL_FREE_CRED();
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
return EINVAL;
#else /* AFS_OSF_ENV */
#if defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
code = copyin_afs_ioctl(cmarg, &data);
if (code) {
PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
return (code);
#else
setuerror(code);
#endif
}
if ((com & 0xff) == PSetClientContext) {
-#ifdef AFS_LINUX22_ENV
+#if defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
return EINVAL; /* Not handling these yet. */
-#endif
+#else
#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV)
code = HandleClientContext(&data, &com, &foreigncreds, credp);
#else
#endif /* AFS_SGI_ENV */
#endif
#endif
+#endif
if (code) {
if (foreigncreds) {
crfree(foreigncreds);
}
PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
return (code);
#else
return (setuerror(code), code);
#endif
}
}
-#ifndef AFS_LINUX22_ENV
+#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV)
if (foreigncreds) {
/*
* We could have done without temporary setting the u.u_cred below
if ((com & 0xff) == 15) {
/* 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)
+#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
code = Prefetch(path, &data, follow,
foreigncreds ? foreigncreds : credp);
#else
#endif /* AFS_SGI64_ENV */
#endif /* AFS_HPUX101_ENV */
#endif
-#ifndef AFS_LINUX22_ENV
+#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV)
if (foreigncreds) {
#ifdef AFS_AIX41_ENV
crset(tmpcred); /* restore original credentials */
}
#endif /* AFS_LINUX22_ENV */
PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
return (code);
#else
return (setuerror(code), code);
#endif /* AFS_AIX41_ENV */
AFS_GLOCK();
if (code) {
-#ifndef AFS_LINUX22_ENV
+#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV)
if (foreigncreds) {
#ifdef AFS_AIX41_ENV
crset(tmpcred); /* restore original credentials */
}
#endif /* AFS_LINUX22_ENV */
PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
return (code);
#else
return(setuerror(code), code);
code = afs_HandlePioctl(vp, com, &data, follow, &credp);
}
#else
-#ifdef AFS_LINUX22_ENV
+#if defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
code = afs_HandlePioctl(vp, com, &data, follow, &credp);
#else
code = afs_HandlePioctl(vp, com, &data, follow, &u.u_cred);
#endif /* AFS_AIX41_ENV */
#endif /* AFS_SUN5_ENV */
} else {
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
code = EINVAL; /* not in /afs */
#else
setuerror(EINVAL);
#endif
}
-#ifndef AFS_LINUX22_ENV
+#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV)
if (foreigncreds) {
#ifdef AFS_AIX41_ENV
crset(tmpcred);
#endif
}
PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
return (code);
#else
if (!getuerror())
afs_PutCell(tcell, READ_LOCK);
if (set_parent_pag) {
int pag;
+#ifdef AFS_DARWIN_ENV
+ struct proc *p=current_proc(); /* XXX */
+ uprintf("Process %d (%s) tried to change pags in PSetTokens\n",
+ p->p_pid, p->p_comm);
+ if (!setpag(p, acred, -1, &pag, 1)) {
+#else
#ifdef AFS_OSF_ENV
if (!setpag(u.u_procp, acred, -1, &pag, 1)) { /* XXX u.u_procp is a no-op XXX */
#else
if (!setpag(acred, -1, &pag, 1)) {
#endif
+#endif
afs_InitReq(&treq, *acred);
areq = &treq;
}
{
register char *tp;
register afs_int32 code;
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV)
+ size_t bufferSize;
+#else
u_int bufferSize;
+#endif
AFS_STATCNT(Prefetch);
if (!apath) return EINVAL;
#if defined(AFS_SGI_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
VN_HOLD((struct vnode *)tvc);
#else
+#if defined(AFS_DARWIN_ENV)
+ osi_vnhold(tvc, 0);
+#else
tvc->vrefCount++;
#endif
+#endif
ReleaseReadLock(&afs_xvcache);
#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
afs_BozonLock(&tvc->pvnLock, tvc); /* Since afs_TryToSmush will do a pvn_vptrunc */
AFS_STATCNT(PSetSysName);
if (!afs_globalVFS) {
/* Afsd is NOT running; disable it */
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV)
return (EINVAL);
#else
return (setuerror(EINVAL), EINVAL);
/* afs_osi_pag.c */
extern afs_uint32 genpag(void);
extern afs_uint32 getpag(void);
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
extern int AddPag(struct proc *p, afs_int32 aval, struct AFS_UCRED **credpp);
#else /* AFS_OSF_ENV */
extern int AddPag(afs_int32 aval, struct AFS_UCRED **credpp);
int acell, struct cell *tcell, struct vrequest *areq);
extern void afs_ResetVolumeInfo(struct volume *tv);
-#if defined(AFS_SUN5_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_AIX_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_AIX_ENV) || defined(AFS_DARWIN_ENV)
#include "../afs/osi_prototypes.h"
#endif
#ifdef AFS_SGI62_ENV
(void) hash_enum(&hashinfo_inaddr, afsi_enum_set_rank, HTF_INET, NULL,
(caddr_t)sa, NULL);
+#elif defined(AFS_DARWIN_ENV)
+ {
+ struct in_ifaddr *ifa;
+ TAILQ_FOREACH(ifa , &in_ifaddrhead, ia_link) {
+ afsi_SetServerIPRank(sa, ifa);
+ }
+ }
#else
{
extern struct in_ifaddr *in_ifaddr;
afs_GCPAGs_cred_count++;
pag = PagInCred(pcred);
+#ifdef AFS_DARWIN_ENV
+ uid = (pag != NOPAG ? pag : pcred->cr_uid);
+#else
uid = (pag != NOPAG ? pag : pcred->cr_ruid);
+#endif
hash = UHash(uid);
/* if this token is PAG based, or it's UID based and
#ifdef AFS_OSF_ENV
extern struct mount *afs_globalVFS;
extern struct vnodeops Afs_vnodeops;
+#elif defined(AFS_DARWIN_ENV)
+extern struct mount *afs_globalVFS;
#else
extern struct vfs *afs_globalVFS;
#endif /* AFS_OSF_ENV */
else if (QNext(uq) != tq)
refpanic("VLRU inconsistent");
+#ifdef AFS_DARWIN_ENV
+ if (tvc->opens == 0 && ((tvc->states & CUnlinkedDel) == 0) &&
+ tvc->vrefCount == 1 && UBCINFOEXISTS(&tvc->v)) {
+ osi_VM_TryReclaim(tvc, &fv_slept);
+ if (fv_slept) {
+ uq = VLRU.prev;
+ i = 0;
+ continue; /* start over - may have raced. */
+ }
+ }
+#endif
if (tvc->vrefCount == 0 && tvc->opens == 0
&& (tvc->states & CUnlinkedDel) == 0) {
code = afs_FlushVCache(tvc, &fv_slept);
#else
SetAfsVnode((struct vnode *)tvc);
#endif /* AFS_SGI64_ENV */
+#ifdef AFS_DARWIN_ENV
+ tvc->v.v_ubcinfo = UBC_INFO_NULL;
+ lockinit(&tvc->rwlock, PINOD, "vcache rwlock", 0, 0);
+ cache_purge((struct vnode *)tvc);
+ tvc->v.v_data=tvc;
+ tvc->v.v_tag=VT_AFS;
+ /* VLISTNONE(&tvc->v); */
+ tvc->v.v_freelist.tqe_next=0;
+ tvc->v.v_freelist.tqe_prev=(struct vnode **)0xdeadb;
+ /*tvc->vrefCount++;*/
+#endif
/*
* The proper value for mvstat (for root fids) is setup by the caller.
*/
crfree(cred);
}
}
+#ifdef AFS_DARWIN_ENV
+ if (tvc->vrefCount == 1 && UBCINFOEXISTS(&tvc->v)) {
+ if (tvc->opens) panic("flushactive open, hasubc, but refcnt 1");
+ osi_VM_TryReclaim(tvc,0);
+ }
+#endif
}
}
ReleaseReadLock(&afs_xvcache);
vcache2inode(tvc);
#endif
ReleaseWriteLock(&tvc->lock);
+#ifdef AFS_DARWIN_ENV
+ osi_VM_Setup(tvc);
+#endif
return tvc;
}
}
ReleaseWriteLock(&tvc->lock);
+#ifdef AFS_DARWIN_ENV
+ osi_VM_Setup(avc);
+#endif
return tvc;
} /*afs_GetVCache*/
afs_ProcessFS(tvc, &OutStatus, areq);
ReleaseWriteLock(&tvc->lock);
+#ifdef AFS_DARWIN_ENV
+ osi_VM_Setup(tvc);
+#endif
return tvc;
}
return code;
}
+#if 0
/*
* afs_StuffVcache
*
*/
afs_PutVCache(tvc, WRITE_LOCK);
} /*afs_StuffVcache*/
+#endif
/*
* afs_PutVCache
if (tvc && (tvc->states & CStatd))
vcache2inode(tvc); /* mainly to reset i_nlink */
#endif
+#ifdef AFS_DARWIN_ENV
+ if (tvc)
+ osi_VM_Setup(tvc);
+#endif
return tvc;
} /*afs_FindVCache*/
#include "../afs/afs_axscache.h"
#include "../afs/icl.h"
#include "../afs/afs_prototypes.h"
-#ifdef AFS_LINUX20_ENV
+#if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
#include "../afs/osi_machdep.h"
#endif
#define AFS_XLATOR_MAGIC 0x87654321
#endif
+#ifdef AFS_DARWIN_ENV
+#define AFS_NFSXLATORREQ(cred) 0
+#else
#ifdef AFS_OSF_ENV
#define AFS_NFSXLATORREQ(cred) ((cred)->cr_ruid == NFSXLATOR_CRED)
#else
#define AFS_NFSXLATORREQ(cred) ((cred)->cr_rgid == NFSXLATOR_CRED)
#endif
+#endif
struct exporterops {
int (*export_reqhandler)();
#ifdef AFS_LINUX20_ENV
#define MyPidxx current->pid
#else
+#ifdef AFS_DARWIN_ENV
+#define MyPidxx (current_proc()->p_pid )
+#else
#define MyPidxx (u.u_procp->p_pid )
+#endif /* AFS_DARWIN_ENV */
#endif /* AFS_LINUX20_ENV */
#endif /* AFS_SGI64_ENV */
#endif /* AFS_HPUX101_ENV */
#include <linux/errno.h>
#else /* AFS_LINUX22_ENV */
+#ifdef AFS_DARWIN_ENV
+#define _MACH_ETAP_H_
+typedef unsigned short etap_event_t;
+#endif
#if !defined(AFS_OSF_ENV)
#include "../h/errno.h"
#include "../h/types.h"
# include "../h/swap.h" /* for struct swpdbd, for vnode.h compiler warnings */
# include "../h/dbd.h" /* for union idbd, for vnode.h compiler warnings */
# endif /* AFS_HPUX_ENV */
+#ifdef AFS_DARWIN_ENV
+# include <sys/uio.h>
+# include <sys/mount.h>
+# include <sys/namei.h>
+# include <sys/vnode.h>
+# include <sys/queue.h>
+# include <sys/ubc.h>
+#define timeout_fcn_t mach_timeout_fcn_t
+# include <kern/sched_prim.h>
+#undef timeout_fcn_t
+#define _DIR_H_
+#define doff_t int32_t
+# include <ufs/ufs/quota.h>
+# include <ufs/ufs/inode.h>
+# include <ufs/ffs/fs.h>
+#else
# include "../h/vfs.h"
# include "../h/vnode.h"
# ifdef AFS_SUN5_ENV
# endif /* !AFS_HPUX_ENV */
# endif /* !AFS_AIX32_ENV */
# endif /* AFS_SUN5_ENV */
+#endif /* AFS_DARWIN_ENV */
#endif /* AFS_DEC_ENV */
/* These mainly deal with networking and rpc headers */
#include "../h/tty.h"
#endif
-#if !defined(AFS_SGI_ENV) && !defined(AFS_SUN_ENV) && !defined(AFS_MACH_ENV) && !defined(AFS_AIX32_ENV) && !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV)
+#if !defined(AFS_SGI_ENV) && !defined(AFS_SUN_ENV) && !defined(AFS_MACH_ENV) && !defined(AFS_AIX32_ENV) && !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_DARWIN_ENV)
+
# include "../h/text.h"
#endif
SRCDIR = DEST/
SOURCES = afsd.c sys.c
-INSTALL = ${SRCDIR}bin/install
-INSTALLro = ${SRCDIR}bin/install -m 644
-INSTALLex = ${SRCDIR}bin/install -m 755
COMPONENT=afsd
include ../config/Makefile.${SYS_NAME}
include ../config/Makefile.version
+INSTALLro = ${INSTALL} -m 644
+INSTALLex = ${INSTALL} -m 755
CFLAGS = -g -I${SRCDIR}include ${XCFLAGS}
LDFLAGS = -g ${XLDFLAGS}
*linux* ) \
${INSTALLex} -f afs.rc.linux ${DESTDIR}root.client/usr/vice/etc/afs.rc; \
${INSTALL} -f afs.conf.linux ${DESTDIR}root.client/usr/vice/etc/afs.conf ;; \
+ ppc_darwin*) \
+ mkdir -p ${DESTDIR}root.client/usr/vice/etc/afs.kext/Contents/MacOS ;\
+ ${INSTALL} -f afs.ppc_darwin.plist ${DESTDIR}root.client/usr/vice/etc/afs.kext/Contents/Info.plist ; \
+ ${INSTALLex} -f afs.rc.darwin ${DESTDIR}root.client/usr/vice/etc/afs.rc ; \
+ ${INSTALL} -f afs.rc.darwin.plist ${DESTDIR}root.client/usr/vice/etc/StartupParameters.plist ;; \
* ) \
echo No rc scripts installed for ${SYS_NAME} ;; \
esac
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>afs</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.openafs.filesystems.afs</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>afs</string>
+ <key>CFBundlePackageType</key>
+ <string>KEXT</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0.3</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0.3</string>
+ <key>OSBundleLibraries</key>
+ <dict>
+ <key>com.apple.kernel.bsd</key>
+ <string>1.0.0b1</string>
+ <key>com.apple.kernel.mach</key>
+ <string>1.0.0b1</string>
+ </dict>
+</dict>
+</plist>
--- /dev/null
+#!/bin/sh
+# 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
+
+. /etc/rc.common
+
+CheckForNetwork
+
+if [ "${NETWORKUP}" = "-NO-" ]; then exit; fi
+
+if [ -r /var/db/openafs ]; then
+ VICEETC=/var/db/openafs/etc
+ AFSD=/usr/sbin/afsd
+else
+ VICEETC=/usr/vice/etc
+ AFSD=$VICEETC/afsd
+fi
+CONFIG=$VICEETC/config
+AFSDOPT=$CONFIG/afsd.options
+PACKAGE=$CONFIG/package.options
+
+LARGE="-stat 2800 -dcache 2400 -daemons 5 -volumes 128"
+MEDIUM="-stat 2000 -dcache 800 -daemons 3 -volumes 70"
+SMALL="-stat 300 -dcache 100 -daemons 2 -volumes 50"
+
+if [ -f $AFSDOPT ]; then
+ OPTIONS=`cat $AFSDOPT`
+else
+ OPTIONS=$MEDIUM
+fi
+
+# Need the commands ps, awk, kill, sleep
+PATH=${PATH}${PATH:+:}/sbin:/bin:/usr/bin
+if kmodstat | grep -q openafs ; then
+:
+else
+if [ -d $VICEETC/afs.kext ]; then
+ echo "Loading AFS kernel extensions"
+ kextload $VICEETC/afs.kext
+else
+ echo "$VICEETC/afs.kext does not exist. Skipping AFS startup."
+ exit 1
+fi
+fi
+if kmodstat | grep -q openafs ; then
+:
+else
+ echo "AFS kernel extensions failed to initialize. Skipping AFS startup."
+fi
+
+#
+# Start the AFS server processes if a bosserver exists
+#
+
+if [ -x /usr/afs/bin/bosserver ]; then
+ echo "Starting AFS Server processes"
+ /usr/afs/bin/bosserver
+ OPTIONS="$OPTIONS -nosettime"
+ sleep 30
+fi
+
+#
+# Check that all of the client configuration files exist
+#
+
+for file in $AFSD $VICEETC/cacheinfo \
+ $VICEETC/ThisCell $VICEETC/CellServDB
+do
+ if [ ! -f ${file} ]; then
+ echo "${file} does not exist. Not starting AFS client."
+ exit 1
+ fi
+done
+
+#
+# Check that the root directory for AFS (/afs)
+# and the cache directory (/usr/vice/cache) both exist
+#
+
+for dir in `awk -F: '{print $1, $2}' $VICEETC/cacheinfo`
+do
+ if [ ! -d ${dir} ]; then
+ echo "${dir} does not exist. Not starting AFS client."
+ exit 2
+ fi
+done
+
+echo "Starting afsd"
+$AFSD $OPTIONS
+
+#
+# Run package to update the disk
+#
+if [ -f /usr/afsws/etc/package -a -f $PACKAGE ]; then
+ /usr/afsws/etc/package -v -o `cat $PACKAGE` > /dev/console 2>&1
+case $? in
+0)
+ (echo "Package completed successfully") > /dev/console 2>&1
+ date > /dev/console 2>&1
+ ;;
+4)
+ (echo "Rebooting to restart system") > /dev/console 2>&1
+ sync
+ /sbin/reboot
+ ;;
+*)
+ (echo "Package update failed; continuing") > /dev/console 2>&1
+ ;;
+esac
+
+fi
+
+#
+# Start AFS inetd services
+# (See the AFS Command Ref. for notes on the proper configuration of inetd.afs)
+#
+if [ -f /usr/sbin/inetd.afs -a -f /etc/inetd.conf.afs ]; then
+ /usr/sbin/inetd.afs /etc/inetd.conf.afs
+fi
--- /dev/null
+{
+ Description = "OpenAFS network file system";
+ Provides = ("AFS");
+ Requires = ("Resolver");
+ OrderPreference = "None";
+ Messages =
+ {
+ start = "Starting OpenAFS file system";
+ stop = "Stopping OpenAFS file system";
+ };
+}
#endif
#endif
-#if defined(AFS_OSF_ENV) || defined(AFS_DEC_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_DEC_ENV) || defined(AFS_DARWIN_ENV)
#include <sys/mount.h>
#else
#include <sys/vfs.h>
#if AFS_HAVE_STATVFS
#include <sys/statvfs.h>
#else
-#if !defined(AFS_OSF_ENV)
+#if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV)
#include <sys/statfs.h>
#endif
#endif
COMPONENT=afsmonitor
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
-
CFLAGS=-g -I. \
-I${SRCDIR}include \
-I${SRCDIR}include/afs \
}
/* copy connection information */
-#ifdef AFS_LINUX20_ENV
+#if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
bcopy(&(xstat_fs_Results.connP->skt), &(tmp_fsPR->connP->skt),
sizeof(struct sockaddr_in));
#else
/* copy connection information */
-#ifdef AFS_LINUX20_ENV
+#if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
bcopy(&(xstat_cm_Results.connP->skt), &(tmp_cmPR->connP->skt),
sizeof(struct sockaddr_in));
#else
include ../config/Makefile.${SYS_NAME}
UKERNELDIR=../libuafs/
-INSTALL=${SRCDIR}bin/install
COMPILE_ET=${SRCDIR}bin/compile_et
MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
${SRCDIR}include/rx/xdr.h \
${SRCDIR}include/rx/rxkad.h \
${SRCDIR}include/afs/com_err.h \
- weblog_errors.h $(DCE_DLOG_INCLUDES)
+ weblog_errors.h $(DCE_DLOG_INCLUDES)
deslib=${SRCDIR}lib/libdes.a
rxkadlib=${SRCDIR}lib/librxkad.a
authlib=${SRCDIR}lib/afs/libauth.a
UKERNELDIR = ../libuafs/
LOCALDIR = ${DESTDIR}root.server/usr/afs/local/
-INSTALL = ${SRCDIR}bin/install
audobjs = audit.o
KERNELDIR = ../libafs/
UKERNELDIR = ../libuafs/
-INSTALL = ${SRCDIR}bin/install
COMPILE_ET = ${SRCDIR}bin/compile_et
OBJS= cellconfig.o ktc.o userok.o writeconfig.o authcon.o \
acfg_errors.o ktc_errors.o # comktc.o comvice.o comauth.o
#comauth.o: comauth.c ${INCLS} ${SRCDIR}include/afs/vice.h
ktc.krb.o: ktc.c ${INCLS} ${SRCDIR}include/afs/vice.h
- ${CC} ${CFLAGS} -DMAYBE_NO_KTC -DAFS_KERBEROS_ENV -c ktc.c
- mv ktc.o ktc.krb.o
+ ${CC} ${CFLAGS} -DMAYBE_NO_KTC -DAFS_KERBEROS_ENV -c ktc.c -o ktc.krb.o
ktc.o: ktc.c ${INCLS} ${SRCDIR}include/afs/vice.h
${CC} ${CFLAGS} -DMAYBE_NO_KTC -c ktc.c
COMPONENT=bozo
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
COMPILE_ET=$(SRCDIR)bin/compile_et
CFLAGS=-g -I${SRCDIR}include ${XCFLAGS}
RPCINCLS=${SRCDIR}include/lwp.h ${SRCDIR}include/rx/rx.h bosint.h
COMPONENT=bu_utils
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
COMPILE_ET = ${DESTDIR}/bin/compile_et
CFLAGS= -g -w -I${SRCDIR}include -I${SRCDIR}include/afs ${XCFLAGS}
LDFLAGS = ${XLDFLAGS}
COMPONENT=bubasics
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
RXGEN=${SRCDIR}bin/rxgen
COMPILE_ET = ${SRCDIR}bin/compile_et
COMPONENT=bucoord
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
COMPILE_ET = ${SRCDIR}bin/compile_et
CFLAGS= ${DBUG} -w -I${SRCDIR}include -I${SRCDIR}include/afs ${XCFLAGS}
COMPONENT=budb
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
COMPILE_ET = ${SRCDIR}bin/compile_et
RXGEN=${SRCDIR}bin/rxgen
COMPONENT=butc
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
-
CFLAGS=-g -w ${INCDIRS} ${XCFLAGS}
INCDIRS= -I${SRCDIR}include/afs -I${SRCDIR}include/rx -I${SRCDIR}include
else \
sprintf(dumpname, "%s (DumpId %u)", name, dbDumpId);
-#ifdef AFS_NT40_ENV
+#if defined(AFS_NT40_ENV) || defined(AFS_DARWIN_ENV)
localtime_r(t, tm)
time_t *t;
struct tm *tm;
SHELL = /bin/sh
SRCDIR=DEST/
DESTDIR=DEST/
-INSTALL=${SRCDIR}bin/install
CFLAGS = -g -w -I${SRCDIR}include ${XCFLAGS}
LDFLAGS = -g ${XLDFLAGS}
COMPONENT=cmd
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
COMPILE_ET = ${SRCDIR}bin/compile_et
INCLS=cmd.h ${XINCLS}
LIBOBJS= error_msg.o et_name.o com_err.o
UKERNELDIR=../libuafs/
-INSTALL=${SRCDIR}bin/install
CFLAGS= ${OPTMZ} -I${DESTDIR}include ${XCFLAGS}
FILES= Makefile et_name.c error_msg.c compile_et.c \
DBG=-g3
CSTATIC=-non_shared
RANLIB=/bin/true
-WASHTOOL=${SRCDIR}bin/washtool
-INSTALL=${SRCDIR}bin/install
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#this is for the vol package
FS_CONV_OSF40D= $(DESTDIR)root.server/usr/afs/bin/fs_conv_dux40D
CP=cp
CSTATIC=-non_shared
RANLIB=/bin/true
-WASHTOOL=${SRCDIR}bin/washtool
-INSTALL=${SRCDIR}bin/install
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#this is for the vol package
FS_CONV_OSF40D= $(DESTDIR)root.server/usr/afs/bin/fs_conv_dux40D
OPTMZ=-O
DBG=-g
RANLIB=ranlib
-INSTALL=${SRCDIR}bin/install
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
RM=/bin/rm
CP=/bin/cp
AR=/bin/ar
AR=ar
AS=as
CP=cp
-INSTALL=${SRCDIR}bin/install
LD=ld
MT_CC=cc
MV=mv
RANLIB=ranlib
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# Other OS specific requirements
#
AR=ar
AS=as
CP=cp
-INSTALL=${SRCDIR}bin/install
LD=ld
MT_CC=cc
MV=mv
RANLIB=ranlib
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# Other OS specific requirements
#
--- /dev/null
+# Keep macros within each section in sorted order for clean diff displays.
+#
+# AFS_OSTYPE used to indicate suffixes and os specific subdirectories.
+AFS_OSTYPE = DARWIN
+#
+# Pointers to destination and source directories
+DESTDIR=DEST/
+DESTDIR=DEST/
+#
+# compilation and link editor flags
+XCFLAGS=-traditional-cpp
+#MT_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV ${XCFLAGS}
+#MT_CC=cc
+KROOT=
+KINCLUDES=-I$(KROOT)/System/Library/Frameworks/Kernel.framework/Headers
+#SHARE_LDFLAGS =
+LWP_OPTMZ=-g
+OPTMZ=-g
+DBG=-g
+REGEX_OBJ=regex.o
+
+
+#
+# libraries
+#XLIBS=
+TXLIBS=
+#MTLIBS=
+#XLIBELFA=
+#XLIBKVM=
+#
+SHLIB_SUFFIX=
+SHLIB_CFLAGS=
+#
+# programs
+AR=ar
+AS=as
+CC=cc
+CP=cp
+INSTALL=${DESTDIR}bin/pinstall
+LEX=lex -l
+LD= ld
+LORDER = lorder
+MV=mv
+RANLIB=ranlib
+RM=rm
+STRIP= strip
--- /dev/null
+# Keep macros within each section in sorted order for clean diff displays.
+#
+# AFS_OSTYPE used to indicate suffixes and os specific subdirectories.
+AFS_OSTYPE = DARWIN
+#
+# Pointers to destination and source directories
+DESTDIR=DEST/
+DESTDIR=DEST/
+#
+# compilation and link editor flags
+XCFLAGS=-traditional-cpp
+#MT_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV ${XCFLAGS}
+#MT_CC=cc
+KROOT=
+KINCLUDES=-I$(KROOT)/System/Library/Frameworks/Kernel.framework/Headers
+#SHARE_LDFLAGS =
+LWP_OPTMZ=-g
+OPTMZ=-g
+DBG=-g
+REGEX_OBJ=regex.o
+
+
+#
+# libraries
+#XLIBS=
+TXLIBS=
+#MTLIBS=
+#XLIBELFA=
+#XLIBKVM=
+#
+SHLIB_SUFFIX=
+SHLIB_CFLAGS=
+#
+# programs
+AR=ar
+AS=as
+CC=cc
+CP=cp
+INSTALL=${DESTDIR}bin/pinstall
+LEX=lex -l
+LD= ld
+LORDER = lorder
+MV=mv
+RANLIB=ranlib
+RM=rm
+STRIP= strip
AR=ar
AS=as
CP=cp
-INSTALL=${SRCDIR}bin/install
LD=ld
MT_CC=cc
MV=mv
RANLIB=ranlib
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# Other OS specific requirements
#
AR=ar
AS=as
CP=cp
-INSTALL=${SRCDIR}bin/install
LD=ld
LEX=lex
MV=mv
RANLIB=ranlib
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# This is the XBSA make flag and pathname to XBSA header files (xbsa.h)
XBSA_FLAGS=-Dxbsa
AR=ar
AS=as
CP=cp
-INSTALL=${SRCDIR}bin/install
LD=gcc
MT_CC=gcc
MV=mv
RANLIB=ranlib
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# Other OS specific requirements
#
AS=as
CP=cp
MT_CC=cc
-INSTALL=${SRCDIR}bin/install
LD=ld
LEX=lex
MV=mv
RANLIB=/bin/true
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# This is for the vol package
XFS_SIZE_CHECK = $(DESTDIR)root.server/usr/afs/bin/xfs_size_check
AS=as
CP=cp
MT_CC=cc
-INSTALL=${SRCDIR}bin/install
LD=ld
LEX=lex
MV=mv
RANLIB=/bin/true
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
AS=as
CP=cp
MT_CC=cc
-INSTALL=${SRCDIR}bin/install
LD=ld
LEX=lex
MV=mv
RANLIB=/bin/true
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# This is for the vol package
XFS_SIZE_CHECK = $(DESTDIR)root.server/usr/afs/bin/xfs_size_check
AS=as
CP=cp
MT_CC=/usr/bin/cc
-INSTALL=${SRCDIR}bin/install
LD=/usr/bin/ld
LEX=lex
MV=mv
RANLIB=/bin/true
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# This is for the vol package
XFS_SIZE_CHECK = $(DESTDIR)root.server/usr/afs/bin/xfs_size_check
AR=ar
AS=as
CP=cp
-INSTALL=${SRCDIR}bin/install
LD=ld
MT_CC=cc
MV=mv
RANLIB=ranlib
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# Other OS specific requirements
#
AR=ar
AS=as
CP=cp
-INSTALL=${SRCDIR}bin/install
LD=ld
MT_CC=cc
MV=mv
RANLIB=ranlib
RM=rm
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# Other OS specific requirements
#
CC=/opt/SUNWspro/bin/cc
MT_CC=/opt/SUNWspro/bin/cc
CP=/bin/cp
-INSTALL=${SRCDIR}bin/install
LEX=lex
LD= /usr/ccs/bin/ld
LORDER = /usr/ccs/bin/lorder
RANLIB=/bin/true
RM=rm
STRIP= /usr/ccs/bin/strip
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# this is for the vol package
FS_CONV_SOL26= $(DESTDIR)root.server/usr/afs/bin/fs_conv_sol26
CC=/opt/SUNWspro/bin/cc
MT_CC=/opt/SUNWspro/bin/cc
CP=/bin/cp
-INSTALL=${SRCDIR}bin/install
LEX=lex
LD= /usr/ccs/bin/ld
LORDER = /usr/ccs/bin/lorder
RANLIB=/bin/true
RM=rm
STRIP= /usr/ccs/bin/strip
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# this is for the vol package
FS_CONV_SOL26= $(DESTDIR)root.server/usr/afs/bin/fs_conv_sol26
CC=/opt/SUNWspro/bin/cc
MT_CC=/opt/SUNWspro/bin/cc
CP=/bin/cp
-INSTALL=${SRCDIR}bin/install
LEX=lex
LD= /usr/ccs/bin/ld
LORDER = /usr/ccs/bin/lorder
RANLIB=/bin/true
RM=rm
STRIP= /usr/ccs/bin/strip
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# this is for the vol package
FS_CONV_SOL26= $(DESTDIR)root.server/usr/afs/bin/fs_conv_sol26
CC=/opt/SUNWspro/bin/cc
MT_CC=/opt/SUNWspro/bin/cc
CP=/bin/cp
-INSTALL=${SRCDIR}bin/install
LEX=lex
LD= /usr/ccs/bin/ld
LORDER = /usr/ccs/bin/lorder
RANLIB=/bin/true
RM=rm
STRIP= /usr/ccs/bin/strip
-WASHTOOL=${SRCDIR}bin/washtool
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#
# this is for the vol package
FS_CONV_SOL26= $(DESTDIR)root.server/usr/afs/bin/fs_conv_sol26
LD = /usr/ccs/bin/ld
LORDER = /usr/ccs/bin/lorder
STRIP= /usr/ccs/bin/strip
+WASHTOOL=${DESTDIR}bin/washtool
+INSTALL=${DESTDIR}bin/install
#define SYS_NAME_ID_mac2_51 500
#define SYS_NAME_ID_mac_aux10 501
#define SYS_NAME_ID_mac_mach51 502
+#define SYS_NAME_ID_ppc_darwin_12 503
+#define SYS_NAME_ID_ppc_darwin_13 504
#define SYS_NAME_ID_next_mach20 601
#define SYS_NAME_ID_next_mach30 602
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
+#ifndef __APPLE_CC__
#include <malloc.h>
+#endif
#include <assert.h>
#include <string.h>
--- /dev/null
+#ifndef _PARAM_PPC_DARWIN_H_
+#define _PARAM_PPC_DARWIN_H_
+
+#define AFS_ENV 1
+#define AFS_64BIT_ENV 1 /* Defines afs_int32 as int, not long. */
+#define AFS_PPC_ENV 1
+#define AFS_VFSINCL_ENV 1
+
+#include <afs/afs_sysnames.h>
+
+#define AFS_DARWIN_ENV
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL 230
+
+/* File system entry (used if mount.h doesn't define MOUNT_AFS */
+#define AFS_MOUNT_AFS "afs"
+
+/* Machine / Operating system information */
+#define sys_ppc_darwin_12 1
+#define SYS_NAME "ppc_darwin_12"
+#define SYS_NAME_ID SYS_NAME_ID_ppc_darwin_12
+#define AFSBIG_ENDIAN 1
+#define AFS_HAVE_FFS 1 /* Use system's ffs. */
+
+#define AFS_GCPAGS 1 /* if nonzero, garbage collect PAGs */
+#define RXK_LISTENER_ENV 1
+
+#ifdef KERNEL
+#undef MACRO_BEGIN
+#undef MACRO_END
+#include <kern/macro_help.h>
+#define AFS_GLOBAL_SUNLOCK 1
+#define AFS_VFS34 1 /* What is VFS34??? */
+#define afsio_iov uio_iov
+#define afsio_iovcnt uio_iovcnt
+#define afsio_offset uio_offset
+#define afsio_seg uio_segflg
+#define afsio_resid uio_resid
+#define AFS_UIOSYS UIO_SYSSPACE
+#define AFS_UIOUSER UIO_USERSPACE
+#define AFS_CLBYTES CLBYTES
+#define osi_GetTime(x) microtime(x)
+#define AFS_KALLOC(x) kalloc(x)
+#define AFS_KFREE(x,y) kfree(x,y)
+#define v_count v_usecount
+#define v_vfsp v_mount
+#define vfs_bsize mnt_stat.f_bsize
+#define vfs_fsid mnt_stat.f_fsid
+#define va_nodeid va_fileid
+#define vfs_vnodecovered mnt_vnodecovered
+#define direct dirent
+#define vnode_t struct vnode
+
+#define VN_RELE(vp) vrele(((struct vnode *)(vp)))
+#define VN_HOLD(vp) VREF(((struct vnode *)(vp)))
+
+#endif
+#endif _PARAM_PPC_DARWIN_H_
--- /dev/null
+#ifndef _PARAM_PPC_DARWIN_H_
+#define _PARAM_PPC_DARWIN_H_
+
+#define AFS_VFSINCL_ENV 1 /* NOBODY uses this.... */
+#define AFS_ENV 1
+#define AFS_64BIT_ENV 1 /* Defines afs_int32 as int, not long. */
+#define AFS_PPC_ENV 1
+
+#include <afs/afs_sysnames.h>
+#define AFS_USERSPACE_ENV
+#define AFS_USR_DARWIN_ENV
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL 230
+
+/* File system entry (used if mount.h doesn't define MOUNT_AFS */
+#define AFS_MOUNT_AFS "afs"
+
+/* Machine / Operating system information */
+#define sys_ppc_darwin_12 1
+#define SYS_NAME "ppc_darwin_12"
+#define SYS_NAME_ID SYS_NAME_ID_ppc_darwin_12
+#define AFSBIG_ENDIAN 1
+#define AFS_HAVE_FFS 1 /* Use system's ffs. */
+
+#define AFS_UIOSYS UIO_SYSSPACE
+#define AFS_UIOUSER UIO_USERSPACE
+
+#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */
+#define RXK_LISTENER_ENV 1
+
+#define AFS_VFS34 1 /* What is VFS34??? */
+#define afsio_iov uio_iov
+#define afsio_iovcnt uio_iovcnt
+#define afsio_offset uio_offset
+#define afsio_seg uio_segflg
+#define afsio_resid uio_resid
+#define AFS_UIOSYS UIO_SYSSPACE
+#define AFS_UIOUSER UIO_USERSPACE
+#define VATTR_NULL usr_vattr_null
+
+#define AFS_DIRENT
+#ifndef CMSERVERPREF
+#define CMSERVERPREF
+#endif
+
+#endif _PARAM_PPC_DARWIN_H_
--- /dev/null
+#ifndef _PARAM_PPC_DARWIN_H_
+#define _PARAM_PPC_DARWIN_H_
+
+#define AFS_ENV 1
+#define AFS_64BIT_ENV 1 /* Defines afs_int32 as int, not long. */
+#define AFS_PPC_ENV 1
+#define AFS_VFSINCL_ENV 1
+
+#include <afs/afs_sysnames.h>
+
+#define AFS_DARWIN_ENV
+#define AFS_DARWIN13_ENV
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL 230
+
+/* File system entry (used if mount.h doesn't define MOUNT_AFS */
+#define AFS_MOUNT_AFS "afs"
+
+/* Machine / Operating system information */
+#define sys_ppc_darwin_12 1
+#define sys_ppc_darwin_13 1
+#define SYS_NAME "ppc_darwin_13"
+#define SYS_NAME_ID SYS_NAME_ID_ppc_darwin_13
+#define AFSBIG_ENDIAN 1
+#define AFS_HAVE_FFS 1 /* Use system's ffs. */
+
+#define AFS_GCPAGS 1 /* if nonzero, garbage collect PAGs */
+#define RXK_LISTENER_ENV 1
+
+#ifdef KERNEL
+#undef MACRO_BEGIN
+#undef MACRO_END
+#include <kern/macro_help.h>
+#define AFS_GLOBAL_SUNLOCK 1
+#define AFS_VFS34 1 /* What is VFS34??? */
+#define afsio_iov uio_iov
+#define afsio_iovcnt uio_iovcnt
+#define afsio_offset uio_offset
+#define afsio_seg uio_segflg
+#define afsio_resid uio_resid
+#define AFS_UIOSYS UIO_SYSSPACE
+#define AFS_UIOUSER UIO_USERSPACE
+#define AFS_CLBYTES CLBYTES
+#define osi_GetTime(x) microtime(x)
+#define AFS_KALLOC(x) kalloc(x)
+#define AFS_KFREE(x,y) kfree(x,y)
+#define v_count v_usecount
+#define v_vfsp v_mount
+#define vfs_bsize mnt_stat.f_bsize
+#define vfs_fsid mnt_stat.f_fsid
+#define va_nodeid va_fileid
+#define vfs_vnodecovered mnt_vnodecovered
+#define direct dirent
+#define vnode_t struct vnode
+
+#define VN_RELE(vp) vrele(((struct vnode *)(vp)))
+#define VN_HOLD(vp) VREF(((struct vnode *)(vp)))
+
+#endif
+#endif _PARAM_PPC_DARWIN_H_
--- /dev/null
+#ifndef _PARAM_PPC_DARWIN_H_
+#define _PARAM_PPC_DARWIN_H_
+
+#define AFS_VFSINCL_ENV 1 /* NOBODY uses this.... */
+#define AFS_ENV 1
+#define AFS_64BIT_ENV 1 /* Defines afs_int32 as int, not long. */
+#define AFS_PPC_ENV 1
+
+#include <afs/afs_sysnames.h>
+#define AFS_USERSPACE_ENV
+#define AFS_USR_DARWIN_ENV
+#define AFS_USR_DARWIN13_ENV
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL 230
+
+/* File system entry (used if mount.h doesn't define MOUNT_AFS */
+#define AFS_MOUNT_AFS "afs"
+
+/* Machine / Operating system information */
+#define sys_ppc_darwin_12 1
+#define sys_ppc_darwin_13 1
+#define SYS_NAME "ppc_darwin_13"
+#define SYS_NAME_ID SYS_NAME_ID_ppc_darwin_13
+#define AFSBIG_ENDIAN 1
+#define AFS_HAVE_FFS 1 /* Use system's ffs. */
+
+#define AFS_UIOSYS UIO_SYSSPACE
+#define AFS_UIOUSER UIO_USERSPACE
+
+#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */
+#define RXK_LISTENER_ENV 1
+
+#define AFS_VFS34 1 /* What is VFS34??? */
+#define afsio_iov uio_iov
+#define afsio_iovcnt uio_iovcnt
+#define afsio_offset uio_offset
+#define afsio_seg uio_segflg
+#define afsio_resid uio_resid
+#define AFS_UIOSYS UIO_SYSSPACE
+#define AFS_UIOUSER UIO_USERSPACE
+#define VATTR_NULL usr_vattr_null
+
+#define AFS_DIRENT
+#ifndef CMSERVERPREF
+#define CMSERVERPREF
+#endif
+
+#endif _PARAM_PPC_DARWIN_H_
COMPONENT= dauth
include ../config/Makefile.${SYS_NAME}
-INSTALL= ${SRCDIR}bin/install
COMPILE_ET = ${SRCDIR}bin/compile_et
OPTMZ= -g
LDFLAGS = ${OPTMZ} ${XLDFLAGS}
INCLS= ${SRCDIR}include/ubik.h \
- ${SRCDIR}include/lwp.h \
- ${SRCDIR}include/lock.h \
- ${SRCDIR}include/rx/rx.h \
- ${SRCDIR}include/rx/xdr.h \
- ${SRCDIR}include/afs/com_err.h
+ ${SRCDIR}include/lwp.h \
+ ${SRCDIR}include/lock.h \
+ ${SRCDIR}include/rx/rx.h \
+ ${SRCDIR}include/rx/xdr.h \
+ ${SRCDIR}include/afs/com_err.h
VERSION = AFS_component_version_number.o
OBJS = adkint.cs.o adkint.xdr.o
dlog_test: dlog.c $(OBJS) $(LIBS)
$(CC) $(LDFLAGS) -DDLOG_TEST -o dlog_test dlog.c $(OBJS) \
$(LIBS) ${XLIBS}
-
+
system: install
${DESTDIR}bin/dlog: dlog
include ../config/Makefile.${SYS_NAME}
UKERNELDIR=../libuafs/
-INSTALL=${SRCDIR}bin/install
SRC =.
MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
#endif /* AFS_SPARC_LINUX20_ENV */
#endif
#else
+#if defined(AFS_DARWIN_ENV) && defined(AFS_PPC_ENV)
+#include "conf-ppc-darwin.h"
+#else
Sorry, you lose.
Figure out what the machine looks like and fix this file to include it.
+#endif
#endif /* AFS_LINUX20_ENV */
#endif /* AFS_NT40_ENV */
#endif /* NCR || X86 */
--- /dev/null
+#define BITS32
+#define BIG
+#undef BSDUNIX
+#define MSBFIRST
+#define MUSTALIGN
+
*
* Note: this routine calls des_set_random_generator_seed.
*/
-#if !defined(BSDUNIX) && !defined(AFS_SGI_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(BSDUNIX) && !defined(AFS_SGI_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
you lose... (aka, you get to implement an analog of this for your
system...)
#else
#include <setjmp.h>
#endif
-#if defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
#include <signal.h>
#endif
#include <termios.h>
#endif
+#ifdef AFS_DARWIN_ENV
+#include <termios.h>
+#endif
#ifdef AFS_NT40_ENV
#include <windows.h>
#endif
return ok;
}
-#if defined (AFS_AIX_ENV) || defined (AFS_HPUX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_LINUX20_ENV)
+#if defined (AFS_AIX_ENV) || defined (AFS_HPUX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
static void catch(int);
#endif
{
int ok = 0, cnt1=0;
char *ptr;
-#ifdef AFS_HPUX_ENV
+#if defined(AFS_HPUX_ENV) || defined(AFS_DARWIN_ENV)
register int fno;
struct sigaction newsig, oldsig;
struct termios save_ttyb, ttyb;
#endif
+#if defined(AFS_DARWIN_ENV)
+ FILE *fi;
+#endif
#if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
struct termios ttyb;
struct sigaction osa, sa;
return -1;
}
-#ifdef AFS_HPUX_ENV
+#if defined(AFS_HPUX_ENV) || defined(AFS_DARWIN_ENV)
if ((fi = fopen("/dev/tty", "r")) == NULL)
return -1;
setbuf(fi, (char *)NULL); /* We don't want any buffering for our i/o. */
#endif
-#if defined (AFS_AIX_ENV) || defined (AFS_HPUX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_LINUX20_ENV)
+#if defined (AFS_AIX_ENV) || defined (AFS_HPUX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
static void
catch(int junk)
{
RM = /bin/rm
UKERNELDIR=../libuafs/
-INSTALL=${SRCDIR}bin/install
SRC =.
DESPAR =../../../DESLIB/dest/
DESINC =${DESPAR}include/
KERNELDIR = ../libafs/
UKERNELDIR = ../libuafs/
-INSTALL = ${SRCDIR}bin/install
MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
INCDIRS= -I${DESTDIR}include ${XINCLS}
COMPONENT=export
include ../config/Makefile.${SYS_NAME}
- INSTALL = ${SRCDIR}bin/install
KERNELDIR = ../libafs/
UKERNELDIR = ../libuafs/
DEFS =
SHELL = /bin/sh
KERNELDIR = ../libafs/
UKERNELDIR = ../libuafs/
-INSTALL = ${SRCDIR}bin/install
MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
OBJS=afsaux.o afscbint.cs.o afscbint.ss.o afscbint.xdr.o afsint.cs.o afsint.ss.o afsint.xdr.o
#include "../afs/afsincludes.h"
#include "../rx/xdr.h"
#else /* defined(UKERNEL) */
-#if defined(AFS_ALPHA_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_ALPHA_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
#include "../afs/sysincludes.h"
#include "../afs/afsincludes.h"
#else
/* these things are defined in R (but not RX's) library. For now, we add them
only for the kernel system. Later, when R is expunged, we'll remove the ifdef */
#ifdef KERNEL
+#ifndef AFS_USR_DARWIN_ENV
#ifdef AFS_AIXNFS11
#define AUTH_DES 1
#endif
#if (defined(AFS_AIX_ENV) && !defined(AUTH_DES)) || (!defined(AFS_SUN_ENV)) && !defined(AFS_SGI_ENV) && !defined(AFS_ALPHA_ENV) && !defined(AFS_SUN5_ENV)
#ifndef AFS_AIX32_ENV
-#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
/*
* XDR chars; from user mode xdr package.
*/
}
return(TRUE);
}
+#endif
#endif /* KERNEL */
#ifndef KERNEL
COMPONENT=fsprobe
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
-
CFLAGS=-g -I. \
-I${SRCDIR}include \
-I${SRCDIR}include/afs \
COMPONENT=gtx
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
COMPILE_ET=$(SRCDIR)bin/compile_et
CFLAGS= ${DBUG} -I. -I${SRCDIR}include -I${SRCDIR}include/afs ${XCFLAGS}
LDFLAGS = ${XLDFLAGS}
struct gator_cursesgwin *cwp; /*Curses-specific data*/
cwp = (struct gator_cursesgwin *)(gwp->w_data);
+#ifdef AFS_DARWIN_ENV
+ aparms->maxx = cwp->wp->maxx;
+ aparms->maxy = cwp->wp->maxy;
+#else
aparms->maxx = cwp->wp->_maxx;
aparms->maxy = cwp->wp->_maxy;
+#endif
return(0);
INCLUDES = -I${DESTDIR}include
DEFINES = ${INCLUDES}
-INSTALL = ${DESTDIR}bin/install
LIBDIR = ${DESTDIR}lib/
AFSLIBS = ${LIBDIR}afs/libkauth.a ${LIBDIR}libubik.a\
${LIBDIR}afs/libauth.a ${LIBDIR}afs/libsys.a \
include ../config/Makefile.${SYS_NAME}
UKERNELDIR = ../libuafs/
-INSTALL=${SRCDIR}bin/install
COMPILE_ET = ${SRCDIR}bin/compile_et
MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
${CC} ${LDFLAGS} -o kpwvalid kpwvalid.o ${LIBS} ${XLIBS}
user.krb.o: user.c ${INCLS} ${SRCDIR}include/afs/vice.h
- ${CC} ${CFLAGS} -DAFS_KERBEROS_ENV -c user.c
- mv user.o user.krb.o
+ ${CC} ${CFLAGS} -DAFS_KERBEROS_ENV -c user.c -o user.krb.o
user.o: user.c ${INCLS} ${SRCDIR}include/afs/vice.h
${CC} ${CFLAGS} -c user.c
int npwSums = KA_NPWSUMS; /* needs to be variable sometime */
#include <stdarg.h>
-#if !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
#undef vfprintf
#define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream)
#endif
* login -h hostname (for telnetd, etc.)
*/
#include <afs/param.h>
-#if !defined(AFS_SUN_ENV) && !defined(AFS_AIX_ENV) && !defined(AFS_HPUX_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_SUN_ENV) && !defined(AFS_AIX_ENV) && !defined(AFS_HPUX_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
#include <sys/param.h>
#define quota(a,b,c,d) 0
COMPONENT=libacl
include ../config/Makefile.${SYS_NAME}
-INSTALL = ${SRCDIR}bin/install
INCDIRS= -I${DESTDIR}include -I.. -I${BACKDIR}include -I${DESTDIR}include/afs
KERNELDIR = ../libafs/
UKERNELDIR = ../libuafs/
rm -f libacl.a
ar rv libacl.a $(LIBOBJS) AFS_component_version_number.o
$(RANLIB) libacl.a
-
+
aclprocs.o: aclprocs.c acl.h
netprocs.o: netprocs.c acl.h
SHELL=/bin/sh
DESTDIR = DEST/
SRCDIR = DEST/
-INSTALL = $(DESTDIR)bin/install
INCLUDE= -I. -I/usr/include
Aobj=COMMON
Dobj=DYNEL
--- /dev/null
+#/* Copyright (C) 1995, 1989 Transarc Corporation - All rights reserved */
+# $Header$
+#
+# MakefileProto for Digital Unix systems
+#
+
+DESTDIR=DEST/
+include $(DESTDIR)../obj/config/Makefile.${SYS_NAME}
+
+
+# OS specific object files:
+AFS_OS_OBJS = \
+ osi_misc.o \
+ osi_file.o \
+ osi_inode.o \
+ osi_groups.o \
+ osi_sleep.o \
+ osi_vm.o \
+ osi_vnodeops.o \
+ osi_module.o \
+ xdr.o \
+ xdr_array.o
+
+
+#AFS_OS_NFSOBJS = osi_vfsops_nfs.o
+
+AFS_OS_NONFSOBJS = osi_vfsops.o
+
+
+# System specific build commands and flags
+KDEFS=
+DBUG = -g
+DEFINES= -D_KERNEL -DKERNEL -DKERNEL_PRIVATE -DDIAGNOSTIC -DUSE_SELECT -DMACH_USER_API -DMACH_KERNEL
+OPTF=${OPT}
+OPTF2=${OPT2}
+KOPTS=-traditional-cpp -static -fno-common -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch
+#CFLAGS=-Werror-implicit-function-declaration -I. -I.. ${KINCLUDES} $(DEFINES) $(KDEFS) $(KOPTS) ${DBUG}
+#CFLAGS=-framework Kernel -I. -I.. ${KINCLUDES} $(DEFINES) $(KDEFS) $(KOPTS) ${DBUG}
+CFLAGS=-I. -I.. ${KINCLUDES} $(DEFINES) $(KDEFS) $(KOPTS) ${DBUG}
+
+
+# Name of directory to hold object files and libraries.
+KOBJ = MODLOAD
+
+# This tells Makefile.common to use it's single directory build target.
+COMPDIRS = single_compdir
+
+include Makefile.common
+
+setup:
+ -mkdir $(KOBJ)
+ -rm $(KOBJ)/Makefile $(KOBJ)/Makefile.common
+ ln -s ../Makefile $(KOBJ)/Makefile
+ ln -s ../Makefile.common $(KOBJ)/Makefile.common
+ -rm -f h net netinet rpc ufs nfs machine sys vm mach kern
+ -ln -s $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/net net
+ -ln -s $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/machine machine
+ -ln -s $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/netinet netinet
+ -ln -s $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/nfs nfs
+ -ln -s /usr/include/rpc rpc
+ -ln -s $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/sys sys
+ -ln -s $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/ufs ufs
+ -ln -s $(KROOT)/System/Library/Frameworks/Kernel.framework/Headers/sys h
+
+
+# Below this line are targets when in the COMMON directory:
+LIBAFS = libafs.o
+LIBAFSNONFS = libafs.nonfs.o
+
+DEST_LIBAFS = ${DESTDIR}/root.client/usr/vice/etc/afs.kext/Contents/MacOS/afs-nfs
+DEST_LIBAFSNONFS = ${DESTDIR}/root.client/usr/vice/etc/afs.kext/Contents/MacOS/afs
+
+
+libafs: $(DEST_LIBAFSNONFS) ;
+
+
+$(DEST_LIBAFS): $(LIBAFS)
+ $(INSTALL) -f $? $@
+
+$(DEST_LIBAFSNONFS): $(LIBAFSNONFS)
+ $(INSTALL) -f $? $@
+
+${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS)
+ $(LD) -r -o ${LIBAFS} ${AFSAOBJS} ${AFSNFSOBJS}
+
+${LIBAFSNONFS}: $(AFSAOBJS) $(AFSNONFSOBJS)
+ $(LD) -r -o ${LIBAFSNONFS} ${AFSAOBJS} ${AFSNONFSOBJS}
+
+
+# Object build rules:
+osi_groups.o: $(AFS)/osi_groups.c
+ $(CRULE1)
+osi_file.o: $(AFS)/osi_file.c
+ $(CRULE1)
+osi_inode.o: $(AFS)/osi_inode.c
+ $(CRULE1)
+osi_misc.o: $(AFS)/osi_misc.c
+ $(CRULE1)
+osi_sleep.o: $(AFS)/osi_sleep.c
+ $(CRULE1)
+osi_vfsops_nfs.o: $(AFS)/osi_vfsops.c
+ $(CRULE1) -o osi_vfsops_nfs.o
+osi_vfsops.o: $(AFS)/osi_vfsops.c
+ $(CRULE1) -DAFS_NONFSTRANS
+osi_vm.o: $(AFS)/osi_vm.c
+ $(CRULE1)
+osi_vnodeops.o: $(AFS)/osi_vnodeops.c
+ $(CRULE1)
+osi_module.o: $(AFS)/osi_module.c
+ $(CRULE1)
+xdr.o: $(RX)/xdr.c
+ $(CRULE1);
+xdr_array.o: $(RX)/xdr_array.c
+ $(CRULE1);
+
include ../config/Makefile.${SYS_NAME}
CC=${MT_CC}
-INSTALL = ${SRCDIR}bin/install
CFLAGS = ${OPTMZ} ${DBG} -I${SRCDIR}include ${MT_CFLAGS}
CCRULE = ${CC} ${CFLAGS} -c $?
COMPONENT=libafsrpc
include ../config/Makefile.${SYS_NAME}
-INSTALL = ${SRCDIR}bin/install
CC=${MT_CC}
INCLUDES = -I${SRCDIR}include -I.. -I../rx
CFLAGS = ${OPTMZ} ${DBG} ${INCLUDES} -DRXDEBUG ${MT_CFLAGS}
/usr/ccs/lib/cpp ${SFLAGS} ${SYS}/syscall.s syscall.ss; \
as -o syscall.o syscall.ss; \
rm syscall.ss;; \
- sgi_* ) \
+ sgi_* | ppc_darwin* ) \
${CC} ${CFLAGS} -c ${SYS}/syscall.s;; \
alpha_dux?? ) \
${AS} -P ${CFLAGS} -D_NO_PROTO -DMACH -DOSF -nostdinc -traditional -DASSEMBLER ${SYS}/syscall.s; \
#
SHELL=/bin/sh
-INSTALL = ${SRCDIR}bin/install
INCLUDE= -I. -I/usr/include
UOBJ =../UAFS
WEBOBJ =../AFSWEB
${INSTALL} AFSWEB/$(LIBAFSWEB) ${DESTDIR}root.afsweb/usr/lib
${INSTALL} AFSWEB/$(LIBAFSWEBKRB) ${DESTDIR}root.afsweb/usr/lib
-ukinstall: UAFS/$(LIBUAFS)
+ukinsthdrs:
${INSTALL} afs/param.h ${DESTDIR}root.perf/include/afs
${INSTALL} afs/stds.h ${DESTDIR}root.perf/include/afs
${INSTALL} afs/afs_sysnames.h ${DESTDIR}root.perf/include/afs
${INSTALL} afs/afs_stats.h ${DESTDIR}root.perf/include/afs
${INSTALL} afs/sysincludes.h ${DESTDIR}root.perf/include/afs
${INSTALL} afs/afs_usrops.h ${DESTDIR}root.perf/include/afs
+
+ukinstall: ukinsthdrs UAFS/$(LIBUAFS) linktest
${INSTALL} des/libdes.a ${DESTDIR}root.perf/lib
${INSTALL} UAFS/$(LIBUAFS) ${DESTDIR}root.perf/lib
+
+linktest: UAFS/$(LIBUAFS) des/libdes.a
$(CC) $(TEST_CFLAGS) $(TEST_LDFLAGS) -o linktest linktest.c -I${DESTDIR}include -I${DESTDIR}include/rx -I${DESTDIR}root.perf/include ${DESTDIR}root.perf/lib/$(LIBUAFS) ${DESTDIR}root.perf/lib/libdes.a $(TEST_LIBS)
CRULE1= $(CC) $(OPTF) -DKERNEL $(CFLAGS) -c $?
--- /dev/null
+# 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
+
+# MakefileProto for Solaris systems
+#
+
+include ../config/Makefile.${SYS_NAME}
+
+MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
+
+# System specific build commands and flags
+CC = cc
+DEFINES= -D_REENTRANT -DAFSDEBUG -DKERNEL -DUKERNEL -DAFS -DVICE
+KOPTS=
+CFLAGS=-I. -I.. ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBUG} $(XCFLAGS)
+OPTF=-O
+# WEBOPTS = -I../nsapi -DNETSCAPE_NSAPI -DNET_SSL -DXP_UNIX -DMCC_HTTPD
+
+TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV
+TEST_LDFLAGS=
+TEST_LIBS=
+
+LIBUAFS = libuafs.a
+LIBAFSWEB = nsafs.so
+LIBAFSWEBKRB = nsafs.krb.so
+
+include Makefile.common
+
+setup_common:
+ -rm -f h net netinet rpc ufs nfs machine sys inet nsapi
+ -ln -s /usr/include/sys h
+ -ln -s /usr/include/net net
+ -ln -s /usr/include/netinet netinet
+ -ln -s /usr/include/rpc rpc
+ -ln -s /usr/include/sys sys
+ -ln -s /usr/include/nfs nfs
+ -ln -s /usr/include/inet inet
+ -ln -s /usr/include/ufs ufs
+ -ln -s $(NS_INCL) nsapi
+
+setup_uafs: setup_common
+ set UAFS; $(MKDIR_IF_NEEDED)
+ -rm -f UAFS/Makefile UAFS/Makefile.common
+ ln -s ../Makefile UAFS/Makefile
+ ln -s ../Makefile.common UAFS/Makefile.common
+
+setup_nsafs: setup_common
+ set AFSWEB; $(MKDIR_IF_NEEDED)
+ -rm -f AFSWEB/Makefile AFSWEB/Makefile.common
+ ln -s ../Makefile AFSWEB/Makefile
+ ln -s ../Makefile.common AFSWEB/Makefile.common
+
+UAFS/$(LIBUAFS): setup_uafs
+ cd UAFS; \
+ $(MAKE) $(LIBUAFS) DESTDIR=${DESTDIR}; \
+ ranlib $(LIBUAFS)
+
+AFSWEB/$(LIBAFSWEB): setup_nsafs
+ cd AFSWEB; \
+ $(MAKE) $(LIBAFSWEB) DESTDIR=${DESTDIR}
+
+AFSWEB/$(LIBAFSWEBKRB): setup_nsafs
+ cd AFSWEB; \
+ $(MAKE) $(LIBAFSWEBKRB) DESTDIR=${DESTDIR}
+
+# Below this line are targets when in the COMMON directory:
+
+$(LIBUAFS): $(UAFSOBJ)
+ -rm -f $(LIBUAFS)
+ $(AR) $(ARFLAGS) $(LIBUAFS) $(UAFSOBJ)
+
+$(LIBAFSWEB): $(AFSWEBOBJ) ${DES}/libdes.a
+ -rm -f $(LIBAFSWEB)
+ ld -b $(LIBAFSWEB) $(AFSWEBOBJ) ${DES}/libdes.a $(WEBLIBS)
+
+$(LIBAFSWEBKRB): $(AFSWEBOBJKRB) ${DES}/libdes.a
+ -rm -f $(LIBAFSWEBKRB)
+ ld -b $(LIBAFSWEBKRB) $(AFSWEBOBJKRB) ${DES}/libdes.a $(WEBLIBS)
PROGRAMS= unlog tokens tokens.krb kseal
-INSTALL = ${SRCDIR}bin/install
-INSTALLro = ${SRCDIR}bin/install -m 644
-
INCLS=${SRCDIR}include/afs/auth.h ${SRCDIR}include/rx/rx.h \
${SRCDIR}include/rx/xdr.h ${SRCDIR}include/des.h ${SRCDIR}include/rx/rxkad.h \
${SRCDIR}include/afs/cellconfig.h
include ../config/Makefile.${SYS_NAME}
LIBDIR = ${DESTDIR}lib/
-INSTALL=${SRCDIR}bin/install
AFSLIBS = ${LIBDIR}afs/libkauth.a ${LIBDIR}afs/libprot.a ${LIBDIR}libubik.a \
${LIBDIR}afs/libauth.a ${DESTDIR}lib/librxkad.a ${LIBDIR}afs/libsys.a \
${DESTDIR}lib/libdes.a ${LIBDIR}librx.a ${LIBDIR}liblwp.a \
COMPONENT=lwp
include ../config/Makefile.${SYS_NAME}
-INSTALL = ${SRCDIR}bin/install
-
-include ../config/Makefile.${SYS_NAME}
# this is important code, so let's optimize it. The optimizer aggravates any
# subtle bugs that may have been introduced in process.s, be warned!
OPTIMIZE=${LWP_OPTMZ}
/lib/cpp -P -I${SRCDIR}include process.s >process.ss; \
${AS} -ahlns process.ss -o process.o >process.lst; \
rm process.ss ;; \
+ ppc_darwin* ) \
+ $(CC) -c ${XCFLAGS} -I${SRCDIR}include process.s;; \
hp* | *_linux* | sgi_64 | sgi_65) \
${CC} ${CFLAGS} -c process.c;; \
ncrx86_*) \
#ifdef __hp9000s800
savecontext(Create_Process_Part2, &temp2->context, stackptr+MINFRAME);
#else
-#ifdef AFS_SGI62_ENV
+#if defined(AFS_SGI62_ENV) || defined(AFS_DARWIN_ENV)
/* Need to have the sp on an 8-byte boundary for storing doubles. */
savecontext(Create_Process_Part2, &temp2->context,
stackptr+stacksize-16); /* 16 = 2 * jmp_buf_type*/
savecontext(Dispatcher, &(temp -> context),
&(LWPANCHOR.dsptchstack[MINFRAME]));
#else
-#ifdef AFS_SGI62_ENV
+#if defined(AFS_SGI62_ENV) || defined(AFS_DARWIN_ENV)
savecontext(Dispatcher, &(temp -> context),
&(LWPANCHOR.dsptchstack[(sizeof LWPANCHOR.dsptchstack)-8]));
#else
\*******************************************************************/
#include <afs/param.h>
-#ifdef AFS_LINUX20_ENV
+#if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
int PRE_Block = 0;
#else
#include <sys/time.h>
#else
#error Unsupported linux LWP system type.
#endif
+#elif defined(AFS_DARWIN_ENV)
+#define LWP_SP 16
#else
Need offset to SP in jmp_buf for this platform.
#endif
#endif /* AFS_NCR_ENV */
+#ifdef AFS_PPC_ENV
+/* Comments:
+ * 1. Registers R10..R31 and CR0..CR7 are saved
+ * 2. "struct savearea" must hold at least 3 pointers (long)
+ * 3. This code will only work on 32 bit machines (601..604), not 620
+ * 4. No floating point registers are saved
+ * 5. The save stack "frame" is bigger than absolutely necessary. The
+ * PowerPC [AIX] ABI needs this extra space.
+ */
+
+
+/* Mach-O assemblers */
+#if !defined(NeXT) && !defined(__APPLE__)
+#define r0 0
+#define r1 1
+#define r2 2
+#define r3 3
+#define r4 4
+#define r5 5
+#define r6 6
+#define r7 7
+#define r8 8
+#define r9 9
+#define r10 10
+#define r11 11
+#define r12 12
+#define r13 13
+#define r14 14
+#define r15 15
+#define r16 16
+#define r17 17
+#define r18 18
+#define r19 19
+#define r20 20
+#define r21 21
+#define r22 22
+#define r23 23
+#define r24 24
+#define r25 25
+#define r26 26
+#define r27 27
+#define r28 28
+#define r29 29
+#define r30 30
+#define r31 31
+#endif /* !NeXT && !__APPLE__ */
+
+
+/*
+ * savecontext(int (*f)(), struct savearea *save, char *newsp)
+ */
+
+#define FRAME_SIZE (32*4)+(8*4)
+#define FRAME_OFFSET (8*4)
+#define TOP_OF_STACK (0*4)
+#define RETURN (1*4)
+#define CCR (2*4)
+
+#if defined(NeXT) || defined(__APPLE__)
+ .globl _savecontext
+_savecontext:
+ lis r9,ha16(_PRE_Block) /* Disable interrupt fiddling */
+ li r8,1
+ stb r8,lo16(_PRE_Block)(r9)
+#else
+ .globl savecontext
+savecontext:
+ lis r9,PRE_Block@ha /* Disable interrupt fiddling */
+ li r8,1
+ stb r8,PRE_Block@l(r9)
+#endif /* NeXT || __APPLE__ */
+ subi r1,r1,FRAME_SIZE
+ mfcr r9
+ stw r9,CCR(r4)
+ stw r10,10*4+FRAME_OFFSET(r1) /* Save registers */
+ stw r11,11*4+FRAME_OFFSET(r1)
+ stw r12,12*4+FRAME_OFFSET(r1)
+ stw r13,13*4+FRAME_OFFSET(r1)
+ stw r14,14*4+FRAME_OFFSET(r1)
+ stw r15,15*4+FRAME_OFFSET(r1)
+ stw r16,16*4+FRAME_OFFSET(r1)
+ stw r17,17*4+FRAME_OFFSET(r1)
+ stw r18,18*4+FRAME_OFFSET(r1)
+ stw r19,19*4+FRAME_OFFSET(r1)
+ stw r20,20*4+FRAME_OFFSET(r1)
+ stw r21,21*4+FRAME_OFFSET(r1)
+ stw r22,22*4+FRAME_OFFSET(r1)
+ stw r23,23*4+FRAME_OFFSET(r1)
+ stw r24,24*4+FRAME_OFFSET(r1)
+ stw r25,25*4+FRAME_OFFSET(r1)
+ stw r26,26*4+FRAME_OFFSET(r1)
+ stw r27,27*4+FRAME_OFFSET(r1)
+ stw r28,28*4+FRAME_OFFSET(r1)
+ stw r29,29*4+FRAME_OFFSET(r1)
+ stw r30,30*4+FRAME_OFFSET(r1)
+ stw r31,31*4+FRAME_OFFSET(r1)
+ stw r1,TOP_OF_STACK(r4)
+ cmpi 0,r5,0 /* New stack specified? */
+ mflr r0
+ stw r0,RETURN(r4)
+ mtlr r3
+ beq L1 /* No - don't muck with pointer */
+
+ mr r1,r5
+L1: blr /* Return */
+/*
+ * returnto(struct savearea *area)
+ */
+#if defined(NeXT) || defined(__APPLE__)
+ .globl _returnto
+_returnto:
+#else
+ .globl returnto
+returnto:
+#endif /* NeXT || __APPLE__ */
+ lwz r1,TOP_OF_STACK(r3) /* Update stack pointer */
+ lwz r0,RETURN(r3) /* Get return address */
+ mtlr r0
+ lwz r4,CCR(r3)
+ mtcrf 0xFF,r4
+ lwz r10,10*4+FRAME_OFFSET(r1) /* Restore registers */
+ lwz r11,11*4+FRAME_OFFSET(r1)
+ lwz r12,12*4+FRAME_OFFSET(r1)
+ lwz r13,13*4+FRAME_OFFSET(r1)
+ lwz r14,14*4+FRAME_OFFSET(r1)
+ lwz r15,15*4+FRAME_OFFSET(r1)
+ lwz r16,16*4+FRAME_OFFSET(r1)
+ lwz r17,17*4+FRAME_OFFSET(r1)
+ lwz r18,18*4+FRAME_OFFSET(r1)
+ lwz r19,19*4+FRAME_OFFSET(r1)
+ lwz r20,20*4+FRAME_OFFSET(r1)
+ lwz r21,21*4+FRAME_OFFSET(r1)
+ lwz r22,22*4+FRAME_OFFSET(r1)
+ lwz r23,23*4+FRAME_OFFSET(r1)
+ lwz r24,24*4+FRAME_OFFSET(r1)
+ lwz r25,25*4+FRAME_OFFSET(r1)
+ lwz r26,26*4+FRAME_OFFSET(r1)
+ lwz r27,27*4+FRAME_OFFSET(r1)
+ lwz r28,28*4+FRAME_OFFSET(r1)
+ lwz r29,29*4+FRAME_OFFSET(r1)
+ lwz r30,30*4+FRAME_OFFSET(r1)
+ lwz r31,31*4+FRAME_OFFSET(r1)
+#if defined(NeXT) || defined(__APPLE__)
+ lis r9,ha16(_PRE_Block) /* Re-enable interrupt fiddling */
+ li r8,0
+ stb r8,lo16(_PRE_Block)(r9)
+#else
+ lis r9,PRE_Block@ha /* Re-enable interrupt fiddling */
+ li r8,0
+ stb r8,PRE_Block@l(r9)
+#endif /* NeXT || __APPLE__ */
+ addi r1,r1,FRAME_SIZE
+ blr
+#endif
+
if (stdin->_IO_read_ptr < stdin->_IO_read_end)
return 1;
#else
+#ifdef AFS_DARWIN_ENV
+ if (stdin->_bf._size > 0)
+ return 1;
+#else
if (stdin->_cnt > 0)
return 1;
#endif
+#endif
FD_ZERO(&rdfds);
DESTDIR=DEST/
SRCDIR=DEST/
CFLAGS= ${OPTMZ} ${XCFLAGS}
-INSTALL=${SRCDIR}bin/install
LIBS = ${XLIBS}
PROGRAM=mpp
COMPONENT=ntp
include ../config/Makefile.${SYS_NAME}
-INSTALL=${SRCDIR}bin/install
INCPATH= -I${DESTDIR}include
BINDIR=/usr/local/etc
LINKDIR=/etc
# Makefile for the null library.
DESTDIR=DEST/
SRCDIR=DEST/
-INSTALL=${SRCDIR}bin/install
SHELL=/bin/sh
COMPONENT=null
YFLAGS = -vd
#LFLAGS = -ll
LINT = lint -hp
-INSTALL = ${SRCDIR}bin/install
HFILES = package.h \
validupdates.h \
# directory or online at http://www.openafs.org/dl/license10.html
SHELL=/bin/sh
-INSTALL = ${SRCDIR}bin/install
KERNELDIR = ../libafs/
COMPONENT=afs
include ../config/Makefile.${SYS_NAME}
LIBDIR = ${DESTDIR}lib/
-INSTALL=${SRCDIR}bin/install
LIBSA = ${LIBDIR}afs/libprot.a ${LIBDIR}libubik.a
AFSLIBS = ${DESTDIR}lib/librxkad.a \
${LIBDIR}afs/libsys.a ${DESTDIR}lib/libdes.a \
- [ -d test ] && ./test/test_install
${DESTDIR}bin/install: pinstall
- ./pinstall -f pinstall ${DESTDIR}bin/install
+ case ${SYS_NAME} in \
+ ppc_darwin*) \
+ ./pinstall -f pinstall ${DESTDIR}bin/pinstall ;;\
+ *) \
+ ./pinstall -f pinstall ${DESTDIR}bin/install ;;\
+ esac
# Note: Some rule needs to appear here so that OSF's make does not try to
# compile install from install.c. A ";" will not work since other platforms
#include <string.h>
#include <elf.h>
#else
+#ifdef AFS_DARWIN_ENV
+#include <fcntl.h>
+#include <string.h>
+#else
#include <strings.h>
#include <a.out.h>
#endif
+#endif
#ifdef AFS_HPUX_ENV
#include <utime.h>
#endif
extern int errno;
extern int sys_nerr;
-#ifndef AFS_LINUX20_ENV
+#if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
extern char *sys_errlist[];
#endif
-#if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
extern struct passwd *getpwnam();
int stripcalled = 0;
#endif
return value;
}
-#if defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
/*
* Implementation lifted from that for AIX 3.1, since there didn't seem to be any
* reason why it wouldn't work.
strip[1] = oname;
#ifdef AFS_SUN5_ENV
#define STRIP_BIN "/usr/ccs/bin/strip"
-#elif defined(AFS_LINUX20_ENV)
+#elif defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
#define STRIP_BIN "/usr/bin/strip"
#else
#define STRIP_BIN "/bin/strip"
continue;
}
}
-#if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
stripcalled = 0;
if (strip == 1 ||
(strip == -1 && ((istat.st_mode & 0111) == 0111) && stripName(newNames[i])) && AIXobject(fnames[i]))
include ../config/Makefile.${SYS_NAME}
include ../config/Makefile.version
-INSTALL=${SRCDIR}bin/install
CFLAGS = $(DBUG) -I${SRCDIR}include ${XCFLAGS}
########################################################################
include ../config/Makefile.${SYS_NAME}
UKERNELDIR=../libuafs/
-INSTALL=${SRCDIR}bin/install
RXGEN=${SRCDIR}bin/rxgen
COMPILE_ET = ${SRCDIR}bin/compile_et
MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
readpwd.o: readpwd.c ${LINCLS} AFS_component_version_number.c
testpt: testpt.o libprot.a ${SRCDIR}lib/afs/libcmd.a $(LIBS)
- $(CC) ${CFLAGS} -o testpt testpt.o -lm ${SRCDIR}lib/afs/libcmd.a libprot.a $(LIBS) ${XLIBS}
+ case "$(SYS_NAME)" in \
+ ppc_darwin_12 ) \
+ $(CC) ${CFLAGS} -o testpt testpt.o ${SRCDIR}lib/afs/libcmd.a libprot.a $(LIBS) ;; \
+ * ) \
+ $(CC) ${CFLAGS} -o testpt testpt.o -lm ${SRCDIR}lib/afs/libcmd.a libprot.a $(LIBS) ${XLIBS} ;; \
+ esac
testpt.o: testpt.c ${INCLS} ${SRCDIR}include/afs/cmd.h AFS_component_version_number.c
OBJS= rcp.o ../rsh/rcmd.o ../rsh/herror.o ../inetd/ta-rauth.o
COMPONENT=rcp
-INSTALL = ${DESTDIR}bin/install
CFLAGS = ${OPTMZ} -I${DESTDIR}include ${XCFLAGS}
LIBDIR = ${DESTDIR}lib/
AFSLIBS = ${LIBDIR}afs/libkauth.a ${LIBDIR}libubik.a\
int rem;
char *colon(), *index(), *rindex(), *malloc(), *strcpy();
int errs;
-#ifndef AFS_LINUX20_ENV
+#if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
extern char *sys_errlist[];
#endif
void lostconn();
SRCS= rlogind.c ../rsh/rcmd.c ../rsh/herror.c ../inetd/ta-rauth.c
OBJS= rlogind.o ../rsh/rcmd.o ../rsh/herror.o ../inetd/ta-rauth.o
MAN=
-INSTALL = ${DESTDIR}bin/install
LIBDIR = ${DESTDIR}lib/
AFSLIBS = ${LIBDIR}afs/libkauth.a ${LIBDIR}afs/libprot.a ${LIBDIR}libubik.a\
${LIBDIR}afs/libauth.a ${DESTDIR}lib/librxkad.a ${LIBDIR}afs/libsys.a \
COMPONENT=rsh
include ../config/Makefile.${SYS_NAME}
-INSTALL = ${SRCDIR}bin/install
LIBDIR = ${DESTDIR}lib/
INCLUDES= -I${SRCDIR}include
CFLAGS= ${DBUG} ${INCLUDES} ${XCFLAGS}
#endif /* LIBC_SCCS and not lint */
#include <afs/param.h>
+#ifndef AFS_DARWIN_ENV
#include <sys/types.h>
#include <sys/uio.h>
v->iov_len = 1;
writev(2, iov, (v - iov) + 1);
}
+#endif
#endif
char **ahost;
u_short rport;
-#ifdef AFS_LINUX20_ENV
+#if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
const char *locuser, *remuser, *cmd;
#else
char *locuser, *remuser, *cmd;
int _check_rhosts_file = 1;
-#if defined(AFS_HPUX102_ENV) || defined(AFS_LINUX20_ENV)
+#if defined(AFS_HPUX102_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV)
ruserok(rhost, superuser, ruser, luser)
const char *rhost;
int superuser;
--- /dev/null
+/*
+ * 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
+ */
+
+/*
+ * rx_kmutex.h - mutex and condition variable macros for kernel environment.
+ *
+ * MACOS implementation.
+ */
+
+#ifndef _RX_KMUTEX_H_
+#define _RX_KMUTEX_H_
+
+#include <sys/lock.h>
+#include <kern/thread.h>
+#include <sys/vm.h>
+
+#define RX_ENABLE_LOCKS 1
+#define AFS_GLOBAL_RXLOCK_KERNEL
+
+/*
+ * Condition variables
+ *
+ * In Digital Unix (OSF/1), we use something akin to the ancient sleep/wakeup
+ * mechanism. The condition variable itself plays no role; we just use its
+ * address as a convenient unique number.
+ *
+ * XXX in darwin, both mach and bsd facilities are available. Should really
+ * stick to one or the other (but mach locks don't have a _try.....)
+ */
+#define CV_INIT(cv,a,b,c)
+#define CV_DESTROY(cv)
+#define CV_WAIT(cv, lck) { \
+ int isGlockOwner = ISAFS_GLOCK(); \
+ if (isGlockOwner) AFS_GUNLOCK(); \
+ assert_wait((event_t)(cv), 0); \
+ MUTEX_EXIT(lck); \
+ thread_block(0); \
+ if (isGlockOwner) AFS_GLOCK(); \
+ MUTEX_ENTER(lck); \
+ }
+
+#define CV_TIMEDWAIT(cv,lck,t) { \
+ int isGlockOwner = ISAFS_GLOCK(); \
+ if (isGlockOwner) AFS_GUNLOCK(); \
+ assert_wait((event_t)(cv), 0); \
+ thread_set_timer(t, NSEC_PER_SEC/hz); \
+ MUTEX_EXIT(lck); \
+ thread_block(0); \
+ if (isGlockOwner) AFS_GLOCK(); \
+ MUTEX_ENTER(lck); \
+
+#define CV_SIGNAL(cv) thread_wakeup_one((event_t)(cv))
+#define CV_BROADCAST(cv) thread_wakeup((event_t)(cv))
+
+typedef struct {
+ struct lock__bsd__ lock;
+ thread_t owner;
+} afs_kmutex_t;
+typedef int afs_kcondvar_t;
+
+#define osi_rxWakeup(cv) thread_wakeup((event_t)(cv))
+
+#define LOCK_INIT(a,b) \
+ do { \
+ lockinit(&(a)->lock,PSOCK, "afs rx lock", 0, 0); \
+ (a)->owner = (thread_t)0; \
+ } while(0);
+#define MUTEX_INIT(a,b,c,d) \
+ do { \
+ lockinit(&(a)->lock,PSOCK, "afs rx mutex", 0, 0); \
+ (a)->owner = (thread_t)0; \
+ } while(0);
+#define MUTEX_DESTROY(a) \
+ do { \
+ (a)->owner = (thread_t)-1; \
+ } while(0);
+#define MUTEX_ENTER(a) \
+ do { \
+ lockmgr(&(a)->lock, LK_EXCLUSIVE, 0, current_proc()); \
+ osi_Assert((a)->owner == (thread_t)0); \
+ (a)->owner = current_thread(); \
+ } while(0);
+#define MUTEX_TRYENTER(a) \
+ ( lockmgr(&(a)->lock, LK_EXCLUSIVE|LK_NOWAIT, 0, current_proc()) ? 0 : ((a)->owner = current_thread(), 1) )
+#define xMUTEX_TRYENTER(a) \
+ ( osi_Assert((a)->owner == (thread_t)0), (a)->owner = current_thread(), 1)
+#define MUTEX_EXIT(a) \
+ do { \
+ osi_Assert((a)->owner == current_thread()); \
+ (a)->owner = (thread_t)0; \
+ lockmgr(&(a)->lock, LK_RELEASE, 0, current_proc()); \
+ } while(0);
+
+#undef MUTEX_ISMINE
+#define MUTEX_ISMINE(a) (((afs_kmutex_t *)(a))->owner == current_thread())
+
+#undef osirx_AssertMine
+extern void osirx_AssertMine(afs_kmutex_t *lockaddr, char *msg);
+
+#endif /* _RX_KMUTEX_H_ */
+
--- /dev/null
+/*
+ * 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
+ */
+
+#include "../afs/param.h"
+#include "../rx/rx_kcommon.h"
+
+int osi_NetReceive(asocket, addr, dvec, nvecs, alength)
+ struct socket *asocket;
+ struct sockaddr_in *addr;
+ struct iovec *dvec;
+ int nvecs;
+ int *alength;
+{
+ struct uio u;
+ int i;
+ struct iovec iov[RX_MAXIOVECS];
+ struct sockaddr *sa;
+ int code;
+
+ int haveGlock = ISAFS_GLOCK();
+ /*AFS_STATCNT(osi_NetReceive);*/
+
+ if (nvecs > RX_MAXIOVECS) {
+ osi_Panic("osi_NetReceive: %d: Too many iovecs.\n", nvecs);
+ }
+
+ for (i = 0 ; i < nvecs ; i++) {
+ iov[i].iov_base = dvec[i].iov_base;
+ iov[i].iov_len = dvec[i].iov_len;
+ }
+
+ u.uio_iov=&iov[0];
+ u.uio_iovcnt=nvecs;
+ u.uio_offset=0;
+ u.uio_resid=*alength;
+ u.uio_segflg=UIO_SYSSPACE;
+ u.uio_rw=UIO_READ;
+ u.uio_procp=NULL;
+
+ if (haveGlock) {
+ AFS_GUNLOCK();
+ }
+#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
+ thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
+#endif
+ code = soreceive(asocket, &sa, &u, NULL, NULL, NULL);
+#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
+ thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
+#endif
+ if (haveGlock) {
+ AFS_GLOCK();
+ }
+ *alength=*alength-u.uio_resid;
+ if (sa) {
+ if (sa->sa_family == AF_INET) {
+ if (addr) *addr=*(struct sockaddr_in *)sa;
+ } else {
+ printf("Unknown socket family %d in NetReceive\n");
+ }
+ }
+ return code;
+}
+
+extern int rxk_ListenerPid;
+void osi_StopListener(void)
+{
+ struct proc *p;
+
+#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
+ thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
+#endif
+ soclose(rx_socket);
+#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
+ thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
+#endif
+ p=pfind(rxk_ListenerPid);
+ if (p)
+ psignal(p, SIGUSR1);
+}
+
+/* rx_NetSend - send asize bytes at adata from asocket to host at addr.
+ *
+ * Now, why do we allocate a new buffer when we could theoretically use the one
+ * pointed to by adata? Because PRU_SEND returns after queueing the message,
+ * not after sending it. If the sender changes the data after queueing it,
+ * we'd see the already-queued data change. One attempt to fix this without
+ * adding a copy would be to have this function wait until the datagram is
+ * sent; however this doesn't work well. In particular, if a host is down, and
+ * an ARP fails to that host, this packet will be queued until the ARP request
+ * comes back, which could be hours later. We can't block in this routine that
+ * long, since it prevents RPC timeouts from happening.
+ */
+/* XXX In the brave new world, steal the data bufs out of the rx_packet iovec,
+ * and just queue those. XXX
+ */
+
+
+int
+osi_NetSend(asocket, addr, dvec, nvecs, alength, istack)
+ register struct socket *asocket;
+ struct iovec *dvec;
+ int nvecs;
+ register afs_int32 alength;
+ struct sockaddr_in *addr;
+ int istack;
+{
+ register afs_int32 code;
+ int s;
+ int len;
+ int i;
+ struct iovec iov[RX_MAXIOVECS];
+ char *tdata;
+ struct uio u;
+ struct mbuf *nam;
+ int haveGlock = ISAFS_GLOCK();
+
+ AFS_STATCNT(osi_NetSend);
+ if (nvecs > RX_MAXIOVECS) {
+ osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
+ }
+
+ for (i = 0 ; i < nvecs ; i++) {
+ iov[i].iov_base = dvec[i].iov_base;
+ iov[i].iov_len = dvec[i].iov_len;
+ }
+
+ u.uio_iov=&iov[0];
+ u.uio_iovcnt=nvecs;
+ u.uio_offset=0;
+ u.uio_resid=alength;
+ u.uio_segflg=UIO_SYSSPACE;
+ u.uio_rw=UIO_WRITE;
+ u.uio_procp=NULL;
+ if (haveGlock) {
+ AFS_GUNLOCK();
+ }
+#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
+ thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
+#endif
+ nam=m_get(M_DONTWAIT, MT_SONAME);
+ if (nam == NULL) {
+ code=ENOBUFS;
+ goto bad;
+ }
+ nam->m_len=addr->sin_len=sizeof(struct sockaddr_in);
+ bcopy((caddr_t)addr, mtod(nam, caddr_t), addr->sin_len);
+ code = sosend(asocket, mtod(nam, struct sockaddr *), &u, NULL, NULL, 0);
+ m_freem(nam);
+bad:
+#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL)
+ thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
+#endif
+ if (haveGlock) {
+ AFS_GLOCK();
+ }
+ return code;
+}
KERNELDIR = ../libafs/
UKERNELDIR = ../libuafs/
-INSTALL=${SRCDIR}bin/install
MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1
#CC=pcc
rxdumptrace: rx_trace.c
rm -f rxdumptrace
- $(CC) $(CFLAGS) -DDUMPTRACE -o rxdumptrace rx_trace.c ${LIBS} ${XLIBS}
- rm -f rx_trace.o
+ $(CC) $(CFLAGS) -DDUMPTRACE -c -o rxdumptrace.o rx_trace.c
+ $(CC) $(CFLAGS) -o rxdumptrace rxdumptrace.o ${LIBS} ${XLIBS}
rx_getaddr.o: rx.h rx_getaddr.c
$(INSTALL) AIX/*.[ch] $(KERNELDIR)rx;; \
sgi_* ) \
$(INSTALL) IRIX/*.[ch] $(KERNELDIR)rx;; \
+ ppc_darwin* ) \
+ $(INSTALL) DARWIN/*.[ch] $(KERNELDIR)rx;; \
sun4x_5* ) \
$(INSTALL) SOLARIS/*.[ch] $(KERNELDIR)rx;; \
* ) \
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
+#ifdef AFS_DARWIN_ENV
+#include <sys/sysctl.h>
+#include <net/route.h>
+#include <net/if_dl.h>
+#endif
/*
* By including this, we get any system dependencies. In particular,
* the pthreads for solaris requires the socket call to be mapped.
#undef socket
#endif /* UKERNEL */
+#ifdef AFS_DARWIN_ENV
+#define ROUNDUP(a) \
+ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
+#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
+
+static void
+rt_xaddrs(cp, cplim, rtinfo)
+ caddr_t cp, cplim;
+ struct rt_addrinfo *rtinfo;
+{
+ struct sockaddr *sa;
+ int i;
+
+ memset(rtinfo->rti_info, 0, sizeof(rtinfo->rti_info));
+ for (i = 0; (i < RTAX_MAX) && (cp < cplim); i++) {
+ if ((rtinfo->rti_addrs & (1 << i)) == 0)
+ continue;
+ rtinfo->rti_info[i] = sa = (struct sockaddr *)cp;
+ ADVANCE(cp, sa);
+ }
+}
+#endif
+
+
/* this function returns the total number of interface addresses
** the buffer has to be passed in by the caller
*/
+#ifdef AFS_DARWIN_ENV
int rx_getAllAddr (buffer,maxSize)
afs_int32 buffer[];
int maxSize; /* sizeof of buffer in afs_int32 units */
{
+ size_t needed;
+ int mib[6];
+ struct if_msghdr *ifm, *nextifm;
+ struct ifa_msghdr *ifam;
+ struct sockaddr_dl *sdl;
+ struct rt_addrinfo info;
+ char *buf, *lim, *next;
+ int count=0,addrcount=0;
+
+ mib[0] = CTL_NET;
+ mib[1] = PF_ROUTE;
+ mib[2] = 0;
+ mib[3] = AF_INET; /* address family */
+ mib[4] = NET_RT_IFLIST;
+ mib[5] = 0;
+ if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
+ return 0;
+ if ((buf = malloc(needed)) == NULL)
+ return 0;
+ if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
+ free(buf);
+ return 0;
+ }
+ lim = buf + needed;
+ next = buf;
+ while (next < lim) {
+ ifm = (struct if_msghdr *)next;
+ if (ifm->ifm_type != RTM_IFINFO) {
+ printf("out of sync parsing NET_RT_IFLIST\n");
+ free(buf);
+ return 0;
+ }
+ sdl = (struct sockaddr_dl *)(ifm + 1);
+ next += ifm->ifm_msglen;
+ ifam = NULL;
+ addrcount = 0;
+ while (next < lim) {
+ nextifm = (struct if_msghdr *)next;
+ if (nextifm->ifm_type != RTM_NEWADDR)
+ break;
+ if (ifam == NULL)
+ ifam = (struct ifa_msghdr *)nextifm;
+ addrcount++;
+ next += nextifm->ifm_msglen;
+ }
+ if ((ifm->ifm_flags & IFF_UP) == 0)
+ continue; /* not up */
+ if (ifm->ifm_flags & IFF_LOOPBACK) {
+ continue; /* skip aliased loopbacks as well. */
+ }
+ while (addrcount > 0) {
+ struct sockaddr_in *a;
+
+ info.rti_addrs = ifam->ifam_addrs;
+
+ /* Expand the compacted addresses */
+ rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam,
+ &info);
+ if (info.rti_info[RTAX_IFA]->sa_family != AF_INET)
+ continue;
+ a=info.rti_info[RTAX_IFA];
+
+ if ( count >= maxSize ) /* no more space */
+ printf("Too many interfaces..ignoring 0x%x\n",
+ a->sin_addr.s_addr);
+ else
+ buffer[count++] = a->sin_addr.s_addr;
+ addrcount--;
+ ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen);
+ }
+ }
+ free(buf);
+ return count;
+}
+int rxi_getAllAddrMaskMtu (addrBuffer, maskBuffer, mtuBuffer, maxSize)
+ afs_int32 addrBuffer[]; /* the network addrs in net byte order */
+ afs_int32 maskBuffer[]; /* the subnet masks */
+ afs_int32 mtuBuffer[]; /* the MTU sizes */
+ int maxSize; /* sizeof of buffer in afs_int32 units */
+{
+ int s;
+
+ size_t needed;
+ int mib[6];
+ struct if_msghdr *ifm, *nextifm;
+ struct ifa_msghdr *ifam;
+ struct sockaddr_dl *sdl;
+ struct rt_addrinfo info;
+ char *buf, *lim, *next;
+ int count=0,addrcount=0;
+
+ mib[0] = CTL_NET;
+ mib[1] = PF_ROUTE;
+ mib[2] = 0;
+ mib[3] = AF_INET; /* address family */
+ mib[4] = NET_RT_IFLIST;
+ mib[5] = 0;
+ if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
+ return 0;
+ if ((buf = malloc(needed)) == NULL)
+ return 0;
+ if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
+ free(buf);
+ return 0;
+ }
+ s=socket(PF_INET, SOCK_DGRAM, 0);
+ if (s < 0)
+ return 0;
+ lim = buf + needed;
+ next = buf;
+ while (next < lim) {
+ ifm = (struct if_msghdr *)next;
+ if (ifm->ifm_type != RTM_IFINFO) {
+ printf("out of sync parsing NET_RT_IFLIST\n");
+ free(buf);
+ return 0;
+ }
+ sdl = (struct sockaddr_dl *)(ifm + 1);
+ next += ifm->ifm_msglen;
+ ifam = NULL;
+ addrcount = 0;
+ while (next < lim) {
+ nextifm = (struct if_msghdr *)next;
+ if (nextifm->ifm_type != RTM_NEWADDR)
+ break;
+ if (ifam == NULL)
+ ifam = (struct ifa_msghdr *)nextifm;
+ addrcount++;
+ next += nextifm->ifm_msglen;
+ }
+ if ((ifm->ifm_flags & IFF_UP) == 0)
+ continue; /* not up */
+ if (ifm->ifm_flags & IFF_LOOPBACK) {
+ continue; /* skip aliased loopbacks as well. */
+ }
+ while (addrcount > 0) {
+ struct sockaddr_in *a;
+
+ info.rti_addrs = ifam->ifam_addrs;
+
+ /* Expand the compacted addresses */
+ rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam,
+ &info);
+ if (info.rti_info[RTAX_IFA]->sa_family != AF_INET)
+ continue;
+ a=info.rti_info[RTAX_IFA];
+
+ if ( count >= maxSize ) { /* no more space */
+ printf("Too many interfaces..ignoring 0x%x\n",
+ a->sin_addr.s_addr);
+ } else {
+ struct ifreq ifr;
+
+ addrBuffer[count] = a->sin_addr.s_addr;
+ a=info.rti_info[RTAX_NETMASK];
+ if (a)
+ maskBuffer[count]=a->sin_addr.s_addr;
+ else
+ maskBuffer[count] = htonl(0xffffffff);
+ memset(&ifr, sizeof(ifr), 0);
+ ifr.ifr_addr.sa_family=AF_INET;
+ strncpy(ifr.ifr_name, sdl->sdl_data, sdl->sdl_nlen);
+ if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) < 0)
+ mtuBuffer[count]=1500;
+ else
+ mtuBuffer[count]=ifr.ifr_mtu;
+ count++;
+ }
+ addrcount--;
+ ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen);
+ }
+ }
+ free(buf);
+ return count;
+}
+
+
+#else
+int rx_getAllAddr (buffer,maxSize)
+afs_int32 buffer[];
+int maxSize; /* sizeof of buffer in afs_int32 units */
+{
int s;
int i, len, count=0;
struct ifconf ifc;
len = ifc.ifc_len / sizeof(struct ifreq);
if (len > NIFS)
len = NIFS;
-#if defined(AFS_AIX41_ENV)
+#if defined(AFS_AIX41_ENV) || defined (AFS_DARWIN_ENV)
if ( ifc.ifc_len > sizeof(ifs) ) /* safety check */
ifc.ifc_len = sizeof(ifs);
for ( cp = (char *)ifc.ifc_buf,
cplim= ifc.ifc_buf+ifc.ifc_len;
cp < cplim;
- cp += sizeof(ifr->ifr_name) + MAX(a->sin_len, sizeof(*a))){
+#ifdef AFS_DARWIN_ENV
+ cp += _SIZEOF_ADDR_IFREQ(*ifr))
+#else
+ cp += sizeof(ifr->ifr_name) + MAX(a->sin_len, sizeof(*a)))
+#endif
+ {
ifr = (struct ifreq *)cp;
#else
for (i = 0; i < len; ++i) {
return count;
#endif /* AFS_USERSPACE_IP_ADDR */
}
+#endif
#endif /* ! AFS_NT40_ENV */
#endif /* !KERNEL || UKERNEL */
*/
-#if ! defined(AFS_AIX_ENV) && ! defined(AFS_SUN5_ENV) && ! defined(UKERNEL) && ! defined(AFS_LINUX20_ENV)
+#if ! defined(AFS_AIX_ENV) && ! defined(AFS_SUN5_ENV) && ! defined(UKERNEL) && ! defined(AFS_LINUX20_ENV) && !defined (AFS_DARWIN_ENV)
/* Routine called during the afsd "-shutdown" process to put things back to
* the initial state.
*/
#else /* AFS_USERSPACE_IP_ADDR */
-#if !defined(AFS_AIX41_ENV) && !defined(AFS_DUX40_ENV)
+#if !defined(AFS_AIX41_ENV) && !defined(AFS_DUX40_ENV) && !defined(AFS_DARWIN_ENV)
#define IFADDR2SA(f) (&((f)->ifa_addr))
#else /* AFS_AIX41_ENV */
#define IFADDR2SA(f) ((f)->ifa_addr)
bzero(addrs, sizeof(addrs));
bzero(mtus, sizeof(mtus));
+#ifdef AFS_DARWIN_ENV
+ TAILQ_FOREACH(ifn, &ifnet, if_link) {
+ if (i >= ADDRSPERSITE) break;
+#else
for (ifn = ifnet; ifn != NULL && i < ADDRSPERSITE; ifn = ifn->if_next) {
+#endif
rxmtu = (ifn->if_mtu - RX_IPUDP_SIZE);
+#ifdef AFS_DARWIN_ENV
+ TAILQ_FOREACH(ifad, &ifn->if_addrhead, ifa_link) {
+ if (i >= ADDRSPERSITE) break;
+#else
for (ifad = ifn->if_addrlist; ifad != NULL && i < ADDRSPERSITE;
ifad = ifad->ifa_next){
+#endif
if (IFADDR2SA(ifad)->sa_family == AF_INET) {
ifinaddr = ntohl(((struct sockaddr_in *) IFADDR2SA(ifad))->sin_addr.s_addr);
if (myNetAddrs[i] != ifinaddr) {
/* if we're given an address, skip everything until we find it */
if (!*pifad)
+#ifdef AFS_DARWIN_ENV
+ *pifad = TAILQ_FIRST(&in_ifaddrhead);
+#else
*pifad = in_ifaddr;
+#endif
else {
if (((ppaddr & (*pifad)->ia_subnetmask) == (*pifad)->ia_subnet))
match_value = 2; /* don't find matching nets, just subnets */
+#ifdef AFS_DARWIN_ENV
+ *pifad = TAILQ_NEXT(*pifad, ia_link);
+#else
*pifad = (*pifad)->ia_next;
+#endif
}
+#ifdef AFS_DARWIN_ENV
+ for (ifa = *pifad; ifa; ifa = TAILQ_NEXT(ifa, ia_link) ) {
+#else
for (ifa = *pifad; ifa; ifa = ifa->ia_next ) {
+#endif
if ((ppaddr & ifa->ia_netmask) == ifa->ia_net) {
if ((ppaddr & ifa->ia_subnetmask) == ifa->ia_subnet) {
sin=IA_SIN(ifa);