From a41175cfbbf4d06ccfe14ae54bef8b7464ecd80b Mon Sep 17 00:00:00 2001 From: Chaskiel M Grundman Date: Tue, 27 Mar 2001 08:43:13 +0000 Subject: [PATCH] initial-darwin-support-20010327 setup for darwin port ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== changes for darwin port ==================== added files for the darwin port ==================== changes for darwin port --- src/Makefile | 42 +- src/README | 1 + src/afs/DARWIN/osi_file.c | 289 ++++++ src/afs/DARWIN/osi_groups.c | 169 ++++ src/afs/DARWIN/osi_inode.c | 317 ++++++ src/afs/DARWIN/osi_inode.h | 42 + src/afs/DARWIN/osi_machdep.h | 109 +++ src/afs/DARWIN/osi_misc.c | 54 + src/afs/DARWIN/osi_module.c | 58 ++ src/afs/DARWIN/osi_prototypes.h | 23 + src/afs/DARWIN/osi_sleep.c | 186 ++++ src/afs/DARWIN/osi_vfsops.c | 295 ++++++ src/afs/DARWIN/osi_vm.c | 311 ++++++ src/afs/DARWIN/osi_vnodeops.c | 1359 ++++++++++++++++++++++++++ src/afs/Makefile | 9 +- src/afs/UKERNEL/afs_usrops.c | 2 +- src/afs/UKERNEL/sysincludes.h | 30 + src/afs/VNOPS/afs_vnop_attrs.c | 10 +- src/afs/VNOPS/afs_vnop_create.c | 2 +- src/afs/VNOPS/afs_vnop_fid.c | 2 +- src/afs/VNOPS/afs_vnop_flock.c | 14 +- src/afs/VNOPS/afs_vnop_read.c | 16 + src/afs/VNOPS/afs_vnop_readdir.c | 14 +- src/afs/VNOPS/afs_vnop_strategy.c | 6 +- src/afs/VNOPS/afs_vnop_write.c | 14 +- src/afs/afs.h | 15 +- src/afs/afs_call.c | 45 +- src/afs/afs_dcache.c | 5 +- src/afs/afs_init.c | 8 +- src/afs/afs_osi.c | 56 +- src/afs/afs_osi.h | 20 +- src/afs/afs_osi_pag.c | 31 +- src/afs/afs_pioctl.c | 105 +- src/afs/afs_prototypes.h | 4 +- src/afs/afs_server.c | 7 + src/afs/afs_user.c | 4 + src/afs/afs_vcache.c | 45 + src/afs/afsincludes.h | 2 +- src/afs/exporter.h | 4 + src/afs/lock.h | 4 + src/afs/sysincludes.h | 24 +- src/afsd/Makefile | 10 +- src/afsd/afs.ppc_darwin.plist | 31 + src/afsd/afs.rc.darwin | 123 +++ src/afsd/afs.rc.darwin.plist | 11 + src/afsd/afsd.c | 4 +- src/afsmonitor/Makefile | 2 - src/afsmonitor/afsmonitor.c | 4 +- src/afsweb/Makefile | 3 +- src/audit/Makefile | 1 - src/auth/Makefile | 4 +- src/bozo/Makefile | 1 - src/bu_utils/Makefile | 1 - src/bubasics/Makefile | 1 - src/bucoord/Makefile | 1 - src/budb/Makefile | 1 - src/butc/Makefile | 2 - src/butc/dump.c | 2 +- src/butm/Makefile | 1 - src/cmd/Makefile | 1 - src/comerr/Makefile | 1 - src/config/Makefile.alpha_dux40 | 4 +- src/config/Makefile.alpha_dux50 | 4 +- src/config/Makefile.hp_ux110 | 4 +- src/config/Makefile.i386_linux22 | 4 +- src/config/Makefile.i386_linux24 | 4 +- src/config/Makefile.ppc_darwin_12 | 46 + src/config/Makefile.ppc_darwin_13 | 46 + src/config/Makefile.ppc_linux24 | 4 +- src/config/Makefile.rs_aix42 | 4 +- src/config/Makefile.s390_linux22 | 4 +- src/config/Makefile.sgi_62 | 4 +- src/config/Makefile.sgi_63 | 4 +- src/config/Makefile.sgi_64 | 4 +- src/config/Makefile.sgi_65 | 4 +- src/config/Makefile.sparc64_linux22 | 4 +- src/config/Makefile.sparc_linux22 | 4 +- src/config/Makefile.sun4x_55 | 4 +- src/config/Makefile.sun4x_56 | 4 +- src/config/Makefile.sun4x_57 | 4 +- src/config/Makefile.sun4x_58 | 4 +- src/config/Makefile.sunx86_54 | 2 + src/config/afs_sysnames.h | 2 + src/config/mkvers.c | 2 + src/config/param.ppc_darwin_12.h | 58 ++ src/config/param.ppc_darwin_12_usr.h | 46 + src/config/param.ppc_darwin_13.h | 60 ++ src/config/param.ppc_darwin_13_usr.h | 48 + src/dauth/Makefile | 13 +- src/des/Makefile | 1 - src/des/andrew-conf.h | 4 + src/des/conf-ppc-darwin.h | 6 + src/des/new_rnd_key.c | 2 +- src/des/read_pssword.c | 16 +- src/des_stub/Makefile | 1 - src/dir/Makefile | 1 - src/export/Makefile | 1 - src/fsint/Makefile | 1 - src/fsint/afsaux.c | 6 +- src/fsprobe/Makefile | 2 - src/gtx/Makefile | 1 - src/gtx/curseswindows.c | 5 + src/inetd/Makefile | 1 - src/kauth/Makefile | 4 +- src/kauth/kaserver.c | 2 +- src/kauth/klogin.c | 2 +- src/libacl/Makefile | 3 +- src/libafs/Makefile.common | 1 - src/libafs/MakefileProto.DARWIN | 115 +++ src/libafsauthent/Makefile | 1 - src/libafsrpc/Makefile | 3 +- src/libuafs/Makefile.common | 7 +- src/libuafs/MakefileProto.DARWIN | 82 ++ src/log/Makefile | 3 - src/login/Makefile | 1 - src/lwp/Makefile | 5 +- src/lwp/lwp.c | 4 +- src/lwp/preempt.c | 2 +- src/lwp/process.c | 2 + src/lwp/process.s | 155 +++ src/lwp/waitkey.c | 5 + src/mpp/Makefile | 1 - src/ntp/Makefile | 1 - src/null/Makefile | 1 - src/package/Makefile | 1 - src/pam/Makefile | 2 - src/pinstall/Makefile | 7 +- src/pinstall/install.c | 15 +- src/procmgmt/Makefile | 1 - src/ptserver/Makefile | 8 +- src/rcp/Makefile | 1 - src/rcp/rcp.c | 2 +- src/rlogind/Makefile | 1 - src/rsh/Makefile | 1 - src/rsh/herror.c | 2 + src/rsh/rcmd.c | 4 +- src/rx/DARWIN/rx_kmutex.h | 107 ++ src/rx/DARWIN/rx_knet.c | 163 +++ src/rx/Makefile | 7 +- src/rx/rx_getaddr.c | 222 ++++- src/rx/rx_kcommon.c | 69 +- src/rx/rx_kcommon.h | 6 + src/rx/rx_packet.h | 2 + src/rx/rx_rdwr.c | 7 +- src/rxgen/Makefile | 1 - src/rxgen/rpc_main.c | 2 + src/rxkad/Makefile | 1 - src/rxkad/rxkad_common.c | 1 - src/rxstat/Makefile | 1 - src/scout/Makefile | 2 - src/sgistuff/Makefile | 1 - src/sia/Makefile | 2 - src/sys/Makefile | 3 +- src/tbutc/Makefile | 1 - src/tsm41/Makefile | 1 - src/tviced/Makefile | 1 - src/ubik/Makefile | 1 - src/update/Makefile | 1 - src/usd/Makefile | 1 - src/usd/usd_file.c | 5 + src/uss/Makefile | 2 - src/uss/uss_common.h | 2 +- src/util/Makefile | 7 +- src/util/dirpath.c | 8 + src/util/dirpath.h | 3 + src/util/netutils.c | 4 +- src/venus/Makefile | 3 +- src/venus/fstrace.c | 2 +- src/venus/kdump.c | 16 + src/venus/up.c | 2 +- src/vfsck/Makefile | 3 +- src/viced/Makefile | 25 +- src/viced/afsfileprocs.c | 4 +- src/vlserver/Makefile | 1 - src/vol/Makefile | 1 - src/vol/devname.c | 5 + src/vol/listinodes.c | 23 +- src/vol/partition.c | 12 +- src/vol/vol-salvage.c | 9 + src/vol/volume.c | 5 + src/volser/Makefile | 2 - src/xstat/Makefile | 1 - 182 files changed, 5302 insertions(+), 292 deletions(-) create mode 100644 src/afs/DARWIN/osi_file.c create mode 100644 src/afs/DARWIN/osi_groups.c create mode 100644 src/afs/DARWIN/osi_inode.c create mode 100644 src/afs/DARWIN/osi_inode.h create mode 100644 src/afs/DARWIN/osi_machdep.h create mode 100644 src/afs/DARWIN/osi_misc.c create mode 100644 src/afs/DARWIN/osi_module.c create mode 100644 src/afs/DARWIN/osi_prototypes.h create mode 100644 src/afs/DARWIN/osi_sleep.c create mode 100644 src/afs/DARWIN/osi_vfsops.c create mode 100644 src/afs/DARWIN/osi_vm.c create mode 100644 src/afs/DARWIN/osi_vnodeops.c create mode 100644 src/afsd/afs.ppc_darwin.plist create mode 100644 src/afsd/afs.rc.darwin create mode 100644 src/afsd/afs.rc.darwin.plist create mode 100644 src/config/Makefile.ppc_darwin_12 create mode 100644 src/config/Makefile.ppc_darwin_13 create mode 100644 src/config/param.ppc_darwin_12.h create mode 100644 src/config/param.ppc_darwin_12_usr.h create mode 100644 src/config/param.ppc_darwin_13.h create mode 100644 src/config/param.ppc_darwin_13_usr.h create mode 100644 src/des/conf-ppc-darwin.h create mode 100644 src/libafs/MakefileProto.DARWIN create mode 100644 src/libuafs/MakefileProto.DARWIN create mode 100644 src/rx/DARWIN/rx_kmutex.h create mode 100644 src/rx/DARWIN/rx_knet.c diff --git a/src/Makefile b/src/Makefile index 8a3937a1d0..b132891a58 100644 --- a/src/Makefile +++ b/src/Makefile @@ -202,7 +202,7 @@ null: project 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};; \ @@ -234,6 +234,7 @@ ntp: project volser 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 @@ -252,9 +253,7 @@ bozo: project ntp audit 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} ;; \ @@ -274,6 +273,8 @@ login: project kauth rxkad ${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 @@ -411,12 +412,22 @@ tests: rxtests ubiktests # 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} @@ -428,6 +439,19 @@ libadmin: libafsauthent bozo ${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 \ @@ -455,6 +479,8 @@ libafs_setup: config minproject export MKAFS_OSTYPE=IRIX;; \ sun4x_5* ) \ MKAFS_OSTYPE=SOLARIS;; \ + ppc_darwin* ) \ + MKAFS_OSTYPE=DARWIN;; \ * ) \ echo WARNING: No MakefileProto for sys ${SYS_NAME} ; \ esac; \ @@ -478,6 +504,8 @@ libuafs_setup: config minproject export MKAFS_OSTYPE=DUX;; \ sgi_6* ) \ MKAFS_OSTYPE=IRIX;; \ + ppc_darwin* ) \ + MKAFS_OSTYPE=DARWIN;; \ * ) \ echo WARNING: No MakefileProto for sys ${SYS_NAME} ; \ esac; \ diff --git a/src/README b/src/README index 8ff463d530..e6f6d920f3 100644 --- a/src/README +++ b/src/README @@ -27,6 +27,7 @@ A. Creating the proper directory structure. sun4x_56/ sun4x_57/ sun4x_58/ + ppc_darwin_13/ alpha_linux_2216_22/ (DES does not work, will require one more change to compile) diff --git a/src/afs/DARWIN/osi_file.c b/src/afs/DARWIN/osi_file.c new file mode 100644 index 0000000000..3931500652 --- /dev/null +++ b/src/afs/DARWIN/osi_file.c @@ -0,0 +1,289 @@ +/* + * 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; + } +} + diff --git a/src/afs/DARWIN/osi_groups.c b/src/afs/DARWIN/osi_groups.c new file mode 100644 index 0000000000..9fcb36ac98 --- /dev/null +++ b/src/afs/DARWIN/osi_groups.c @@ -0,0 +1,169 @@ +/* + * 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); +} diff --git a/src/afs/DARWIN/osi_inode.c b/src/afs/DARWIN/osi_inode.c new file mode 100644 index 0000000000..30b5154d53 --- /dev/null +++ b/src/afs/DARWIN/osi_inode.c @@ -0,0 +1,317 @@ +/* + * 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 +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 diff --git a/src/afs/DARWIN/osi_inode.h b/src/afs/DARWIN/osi_inode.h new file mode 100644 index 0000000000..f392a26666 --- /dev/null +++ b/src/afs/DARWIN/osi_inode.h @@ -0,0 +1,42 @@ +/* + * 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_ */ diff --git a/src/afs/DARWIN/osi_machdep.h b/src/afs/DARWIN/osi_machdep.h new file mode 100644 index 0000000000..0aa14a706a --- /dev/null +++ b/src/afs/DARWIN/osi_machdep.h @@ -0,0 +1,109 @@ +/* + * 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 +#include +#include + +#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_ */ diff --git a/src/afs/DARWIN/osi_misc.c b/src/afs/DARWIN/osi_misc.c new file mode 100644 index 0000000000..65daf7a732 --- /dev/null +++ b/src/afs/DARWIN/osi_misc.c @@ -0,0 +1,54 @@ +/* + * 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 + +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); +} diff --git a/src/afs/DARWIN/osi_module.c b/src/afs/DARWIN/osi_module.c new file mode 100644 index 0000000000..0fd1443322 --- /dev/null +++ b/src/afs/DARWIN/osi_module.c @@ -0,0 +1,58 @@ +#include "../afs/param.h" +#include "../afs/sysincludes.h" +#include "../afs/afsincludes.h" +#include "../sys/syscall.h" +#include +#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) diff --git a/src/afs/DARWIN/osi_prototypes.h b/src/afs/DARWIN/osi_prototypes.h new file mode 100644 index 0000000000..852e1c388f --- /dev/null +++ b/src/afs/DARWIN/osi_prototypes.h @@ -0,0 +1,23 @@ +/* + * 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_ */ diff --git a/src/afs/DARWIN/osi_sleep.c b/src/afs/DARWIN/osi_sleep.c new file mode 100644 index 0000000000..18ea554421 --- /dev/null +++ b/src/afs/DARWIN/osi_sleep.c @@ -0,0 +1,186 @@ +/* + * 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); +} diff --git a/src/afs/DARWIN/osi_vfsops.c b/src/afs/DARWIN/osi_vfsops.c new file mode 100644 index 0000000000..670f0ade37 --- /dev/null +++ b/src/afs/DARWIN/osi_vfsops.c @@ -0,0 +1,295 @@ +#include /* Should be always first */ +#include /* Standard vendor system headers */ +#include /* Afs-based standard headers */ +#include /* statistics */ +#include +#include +#include +#include + +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 + +/* 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; +} diff --git a/src/afs/DARWIN/osi_vnodeops.c b/src/afs/DARWIN/osi_vnodeops.c new file mode 100644 index 0000000000..37e6029d5d --- /dev/null +++ b/src/afs/DARWIN/osi_vnodeops.c @@ -0,0 +1,1359 @@ +#include /* Should be always first */ +#include /* Standard vendor system headers */ +#include /* Afs-based standard headers */ +#include /* statistics */ +#include +#include +#include + +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; +} + diff --git a/src/afs/Makefile b/src/afs/Makefile index a73f40f7b2..6a8eb91e7a 100644 --- a/src/afs/Makefile +++ b/src/afs/Makefile @@ -6,7 +6,6 @@ # directory or online at http://www.openafs.org/dl/license10.html SHELL=/bin/sh -INSTALL = ${SRCDIR}bin/install KERNELDIR = ../libafs/ UKERNELDIR = ../libuafs/ @@ -34,11 +33,13 @@ kinstall: AFS_component_version_number.c 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) @@ -58,7 +59,7 @@ install install.noversion: kinstall ukinstall ${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 ;; \ diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c index 5bff120ba3..da388ca777 100644 --- a/src/afs/UKERNEL/afs_usrops.c +++ b/src/afs/UKERNEL/afs_usrops.c @@ -1845,7 +1845,7 @@ void uafs_Init( 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); diff --git a/src/afs/UKERNEL/sysincludes.h b/src/afs/UKERNEL/sysincludes.h index 6b4d953fd8..9c768a042f 100644 --- a/src/afs/UKERNEL/sysincludes.h +++ b/src/afs/UKERNEL/sysincludes.h @@ -11,7 +11,9 @@ #define __AFS_SYSINCLUDESH__ 1 #include +#ifndef AFS_USR_DARWIN_ENV /* must be included after KERNEL undef'd */ #include +#endif #include #include #include @@ -112,6 +114,29 @@ #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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 @@ -158,6 +183,11 @@ #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 diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c index 34675191dc..87e0913a55 100644 --- a/src/afs/VNOPS/afs_vnop_attrs.c +++ b/src/afs/VNOPS/afs_vnop_attrs.c @@ -97,11 +97,11 @@ afs_CopyOutAttrs(avc, attrs) * 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 */ @@ -137,7 +137,7 @@ afs_CopyOutAttrs(avc, attrs) 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); @@ -232,7 +232,7 @@ afs_getattr(OSI_VC_ARG(avc), attrs, acred) 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; @@ -359,7 +359,7 @@ register struct AFSStoreStatus *as; { #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) diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c index 9a1ba19ffe..b8deaf2010 100644 --- a/src/afs/VNOPS/afs_vnop_create.c +++ b/src/afs/VNOPS/afs_vnop_create.c @@ -287,7 +287,7 @@ tagain: (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 */ diff --git a/src/afs/VNOPS/afs_vnop_fid.c b/src/afs/VNOPS/afs_vnop_fid.c index 2516273f3a..57819b5d1b 100644 --- a/src/afs/VNOPS/afs_vnop_fid.c +++ b/src/afs/VNOPS/afs_vnop_fid.c @@ -15,7 +15,7 @@ */ #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 */ diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c index 116cd08b47..9bebe9534c 100644 --- a/src/afs/VNOPS/afs_vnop_flock.c +++ b/src/afs/VNOPS/afs_vnop_flock.c @@ -40,7 +40,7 @@ void lockIdSet(flock, slp, clid) #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 @@ -80,7 +80,7 @@ void lockIdSet(flock, slp, clid) #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) @@ -119,7 +119,7 @@ void lockIdSet(flock, slp, clid) #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) @@ -154,7 +154,7 @@ static int lockIdcmp2(flock1, vp, alp, onlymine, clid) #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 */ @@ -171,7 +171,7 @@ static int lockIdcmp2(flock1, vp, alp, onlymine, clid) } #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) @@ -481,7 +481,7 @@ int flag; 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 @@ -828,7 +828,7 @@ static int GetFlockCount(struct vcache *avc, struct vrequest *areq) #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; diff --git a/src/afs/VNOPS/afs_vnop_read.c b/src/afs/VNOPS/afs_vnop_read.c index 70c7521767..2d06f63794 100644 --- a/src/afs/VNOPS/afs_vnop_read.c +++ b/src/afs/VNOPS/afs_vnop_read.c @@ -419,6 +419,13 @@ afs_UFSReadFast(avc, auio, acred, albn, abpp, noLock) AFS_GUNLOCK(); 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 @@ -426,6 +433,7 @@ afs_UFSReadFast(avc, auio, acred, albn, abpp, noLock) #endif #endif #endif +#endif #endif auio->afsio_offset += avc->quick.minLoc; osi_UFSClose(tfile); @@ -749,6 +757,13 @@ tagain: AFS_GUNLOCK(); 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 @@ -758,6 +773,7 @@ tagain: #endif #endif #endif +#endif #ifdef IHINT if (!tdc->ihint && nihints < maxIHint) { diff --git a/src/afs/VNOPS/afs_vnop_readdir.c b/src/afs/VNOPS/afs_vnop_readdir.c index b7f72f83af..ddceaf4759 100644 --- a/src/afs/VNOPS/afs_vnop_readdir.c +++ b/src/afs/VNOPS/afs_vnop_readdir.c @@ -136,6 +136,12 @@ struct irix5_min_dirent { /* miniature dirent structure */ #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; @@ -151,6 +157,7 @@ struct min_direct { /* miniature direct structure */ u_short d_reclen; u_short d_namlen; #endif +#endif }; #endif /* AFS_SGI_ENV */ @@ -337,6 +344,9 @@ int off; #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); @@ -409,7 +419,7 @@ void afs_bulkstat_send( avc, req ) * 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 @@ -466,7 +476,7 @@ afs_readdir(OSI_VC_ARG(avc), auio, acred) #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 diff --git a/src/afs/VNOPS/afs_vnop_strategy.c b/src/afs/VNOPS/afs_vnop_strategy.c index 0868f00a7e..48a07ea5a9 100644 --- a/src/afs/VNOPS/afs_vnop_strategy.c +++ b/src/afs/VNOPS/afs_vnop_strategy.c @@ -25,7 +25,7 @@ -#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 @@ -36,14 +36,14 @@ afs_ustrategy(abp) 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]; diff --git a/src/afs/VNOPS/afs_vnop_write.c b/src/afs/VNOPS/afs_vnop_write.c index e73c1f47b9..49a3d91af6 100644 --- a/src/afs/VNOPS/afs_vnop_write.c +++ b/src/afs/VNOPS/afs_vnop_write.c @@ -528,8 +528,16 @@ afs_UFSWrite(avc, auio, aio, acred, noLock) AFS_GUNLOCK(); 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 */ @@ -601,6 +609,9 @@ afs_UFSWrite(avc, auio, aio, acred, noLock) * 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, @@ -609,6 +620,7 @@ afs_UFSWrite(avc, auio, aio, acred, noLock) if (noLock && ((aio & IO_SYNC) | (auio->uio_fpflags & FSYNCIO))) { #else if (noLock && (aio & FSYNC)) { +#endif #endif if (!AFS_NFSXLATORREQ(acred)) afs_fsync(avc, acred); @@ -638,7 +650,7 @@ struct vrequest *areq; { -#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) diff --git a/src/afs/afs.h b/src/afs/afs.h index 82e69fd083..352c1cf1bf 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -557,7 +557,7 @@ struct vcache { * 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; @@ -572,6 +572,9 @@ struct vcache { #endif #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; @@ -974,9 +977,15 @@ extern void shutdown_osifile(); (((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 @@ -1064,7 +1073,7 @@ extern int afs_norefpanic; /* 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 @@ -1077,7 +1086,7 @@ extern int afs_norefpanic; /* 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 diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index 1bf785834a..ec908418a3 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -42,7 +42,8 @@ char afs_rootVolumeName[64]=""; 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; @@ -53,6 +54,10 @@ long afs_global_owner; #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 */ @@ -127,7 +132,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; 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 @@ -197,7 +202,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; 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 */ @@ -286,7 +291,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; 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; @@ -324,7 +329,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; 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); @@ -370,7 +375,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; 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; @@ -388,7 +393,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; 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; @@ -496,7 +501,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; #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; @@ -519,7 +524,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; 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); @@ -873,7 +878,7 @@ Afs_syscall (uap, rvp) { 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; @@ -1011,7 +1016,7 @@ Afs_syscall () 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(); @@ -1022,8 +1027,12 @@ Afs_syscall () AFS_GLOCK(); #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) { @@ -1031,7 +1040,7 @@ Afs_syscall () 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 @@ -1040,7 +1049,7 @@ Afs_syscall () 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); @@ -1050,7 +1059,7 @@ Afs_syscall () #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); @@ -1079,13 +1088,13 @@ Afs_syscall () } #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); @@ -1277,7 +1286,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval) 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; @@ -1293,7 +1302,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval) } #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 diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 9f264d6494..478d3d8d36 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -1237,7 +1237,7 @@ static int afs_UFSCacheStoreProc(acall, afile, alen, avc, shouldWake, 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 ) { @@ -1718,6 +1718,7 @@ struct dcache *afs_GetDCache(avc, abyte, areq, aoffset, alen, aflags) 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)) { @@ -2299,7 +2300,7 @@ struct dcache *afs_UFSGetDSlot(aslot, tmpdc) 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(); diff --git a/src/afs/afs_init.c b/src/afs/afs_init.c index 84fbc7bd69..74968610a6 100644 --- a/src/afs/afs_init.c +++ b/src/afs/afs_init.c @@ -97,7 +97,7 @@ extern afs_lock_t afs_ftf; /* 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; @@ -432,7 +432,11 @@ afs_InitCacheInfo(afile) 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 */ @@ -450,7 +454,7 @@ afs_InitCacheInfo(afile) #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; diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index 2b2fd206d4..e987925459 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -50,6 +50,9 @@ void osi_Init() #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); @@ -77,7 +80,7 @@ void osi_Init() 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) @@ -292,12 +295,16 @@ void afs_osi_Invisible() { #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 #endif AFS_STATCNT(osi_Invisible); } @@ -343,6 +350,11 @@ afs_osi_SetTime(atv) sta.time = atv->tv_sec; 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 @@ -367,6 +379,7 @@ afs_osi_SetTime(atv) #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 */ @@ -729,6 +742,22 @@ extern int npid; } #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. @@ -885,6 +914,31 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr) 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) { diff --git a/src/afs/afs_osi.h b/src/afs/afs_osi.h index 9676fb344b..bae946ebca 100644 --- a/src/afs/afs_osi.h +++ b/src/afs/afs_osi.h @@ -109,11 +109,17 @@ extern void osi_FreeLargeSpace(void *x); /* * 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 @@ -230,7 +236,13 @@ typedef struct timeval osi_timeval_t; * (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) /* @@ -270,7 +282,7 @@ typedef struct timeval osi_timeval_t; 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(); \ @@ -310,7 +322,7 @@ typedef struct timeval osi_timeval_t; 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); \ diff --git a/src/afs/afs_osi_pag.c b/src/afs/afs_osi_pag.c index c193f3a44d..ca0c5cbd85 100644 --- a/src/afs/afs_osi_pag.c +++ b/src/afs/afs_osi_pag.c @@ -100,7 +100,7 @@ afs_uint32 getpag(void) { 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) @@ -159,12 +159,18 @@ 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) */ @@ -176,7 +182,7 @@ afs_setpag (void) #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) @@ -184,12 +190,12 @@ 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); @@ -211,7 +217,12 @@ afs_InitReq(av, acred) * 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; @@ -268,6 +279,15 @@ afs_int32 PagInCred(const struct AFS_UCRED *cred) 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; @@ -276,6 +296,7 @@ afs_int32 PagInCred(const struct AFS_UCRED *cred) #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DUX40_ENV) || defined(AFS_LINUX_ENV) if (cred->cr_ngroups < 2) return NOPAG; #endif +#endif #endif g0 = cred->cr_groups[0]; g1 = cred->cr_groups[1]; diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index c25964de0e..80a8154614 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -381,6 +381,18 @@ afs_xioctl (p, args, retval) 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; @@ -399,11 +411,12 @@ afs_xioctl () 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; @@ -413,6 +426,10 @@ afs_xioctl () 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; @@ -448,6 +465,7 @@ afs_xioctl () #endif #endif #endif +#endif #endif /* first determine whether this is any sort of vnode */ @@ -484,6 +502,9 @@ afs_xioctl () 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); @@ -510,6 +531,7 @@ afs_xioctl () return; #endif #endif +#endif #endif } code = HandleIoctl(tvc, uap->com, datap); @@ -553,6 +575,9 @@ afs_xioctl () #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 @@ -568,6 +593,7 @@ afs_xioctl () #endif #endif #endif +#endif #endif } #ifdef AFS_SUN5_ENV @@ -582,7 +608,7 @@ afs_xioctl () #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) @@ -593,7 +619,7 @@ afs_xioctl () #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 } @@ -645,8 +671,28 @@ afs_pioctl(p, args, retval) 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) @@ -660,7 +706,12 @@ afs_syscall_pioctl(path, com, cmarg, follow, rvp, credp) 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; @@ -686,7 +737,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) #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) @@ -701,7 +752,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) 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); @@ -709,9 +760,9 @@ afs_syscall_pioctl(path, com, cmarg, follow) #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 @@ -724,20 +775,21 @@ afs_syscall_pioctl(path, com, cmarg, follow) code = HandleClientContext(&data, &com, &foreigncreds, u.u_cred); #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 @@ -774,7 +826,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) 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 @@ -788,7 +840,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) #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 */ @@ -809,7 +861,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) } #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); @@ -831,7 +883,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) #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 */ @@ -852,7 +904,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) } #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); @@ -907,7 +959,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) 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); @@ -917,7 +969,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) #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); @@ -930,7 +982,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) #endif } -#ifndef AFS_LINUX22_ENV +#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) if (foreigncreds) { #ifdef AFS_AIX41_ENV crset(tmpcred); @@ -958,7 +1010,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) #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()) @@ -1369,10 +1421,17 @@ static PGCPAGs(avc, afun, areq, ain, aout, ainSize, aoutSize, acred) 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; @@ -1976,7 +2035,11 @@ struct AFS_UCRED *acred; { 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; @@ -2477,8 +2540,12 @@ struct AFS_UCRED *acred; if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) { #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) @@ -2625,7 +2692,7 @@ register struct AFS_UCRED *acred; 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); diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 91ff82c5ec..109487fbac 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -38,7 +38,7 @@ extern void afs_osi_TraverseProcTable(void); /* 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); @@ -119,7 +119,7 @@ extern void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, 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 diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 84a3b35ba9..62bbfc7bb0 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -1202,6 +1202,13 @@ static afs_SetServerPrefs(sa) #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; diff --git a/src/afs/afs_user.c b/src/afs/afs_user.c index 18c317d572..b1f61fdcc4 100644 --- a/src/afs/afs_user.c +++ b/src/afs/afs_user.c @@ -606,7 +606,11 @@ void afs_GCPAGs_perproc_func(AFS_PROC *pproc) 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 diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 699f5919b6..a238e5c1f9 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -66,6 +66,8 @@ extern struct vcache *afs_globalVp; #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 */ @@ -703,6 +705,17 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp, 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); @@ -867,6 +880,17 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp, #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. */ @@ -1113,6 +1137,12 @@ afs_FlushActiveVcaches(doflocks) 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); @@ -1601,6 +1631,9 @@ loop: vcache2inode(tvc); #endif ReleaseWriteLock(&tvc->lock); +#ifdef AFS_DARWIN_ENV + osi_VM_Setup(tvc); +#endif return tvc; } @@ -1657,6 +1690,9 @@ loop: } ReleaseWriteLock(&tvc->lock); +#ifdef AFS_DARWIN_ENV + osi_VM_Setup(avc); +#endif return tvc; } /*afs_GetVCache*/ @@ -1812,6 +1848,9 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, afs_ProcessFS(tvc, &OutStatus, areq); ReleaseWriteLock(&tvc->lock); +#ifdef AFS_DARWIN_ENV + osi_VM_Setup(tvc); +#endif return tvc; } @@ -2116,6 +2155,7 @@ else { /* used to undo the local callback, but that's too extreme. return code; } +#if 0 /* * afs_StuffVcache * @@ -2254,6 +2294,7 @@ afs_StuffVcache(afid, OutStatus, CallBack, tc, areq) */ afs_PutVCache(tvc, WRITE_LOCK); } /*afs_StuffVcache*/ +#endif /* * afs_PutVCache @@ -2376,6 +2417,10 @@ struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 lockit, #ifdef AFS_LINUX22_ENV 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*/ diff --git a/src/afs/afsincludes.h b/src/afs/afsincludes.h index 97e51b42c7..0fb0d85e07 100644 --- a/src/afs/afsincludes.h +++ b/src/afs/afsincludes.h @@ -51,6 +51,6 @@ #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 diff --git a/src/afs/exporter.h b/src/afs/exporter.h index 974cf8e3f9..30487e9d6b 100644 --- a/src/afs/exporter.h +++ b/src/afs/exporter.h @@ -39,11 +39,15 @@ #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)(); diff --git a/src/afs/lock.h b/src/afs/lock.h index 86893a252a..866b80637f 100644 --- a/src/afs/lock.h +++ b/src/afs/lock.h @@ -109,7 +109,11 @@ extern tid_t thread_self(); #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 */ diff --git a/src/afs/sysincludes.h b/src/afs/sysincludes.h index 6139b6a9a6..28998510c7 100644 --- a/src/afs/sysincludes.h +++ b/src/afs/sysincludes.h @@ -41,6 +41,10 @@ struct xfs_inode_info {}; #include #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" @@ -180,6 +184,22 @@ struct vfspage; /* for vnode.h compiler warnings */ # 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 +# include +# include +# include +# include +# include +#define timeout_fcn_t mach_timeout_fcn_t +# include +#undef timeout_fcn_t +#define _DIR_H_ +#define doff_t int32_t +# include +# include +# include +#else # include "../h/vfs.h" # include "../h/vnode.h" # ifdef AFS_SUN5_ENV @@ -193,6 +213,7 @@ struct vfspage; /* for vnode.h compiler warnings */ # 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 */ @@ -225,7 +246,8 @@ struct vfspage; /* for vnode.h compiler warnings */ #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 diff --git a/src/afsd/Makefile b/src/afsd/Makefile index debf725943..a0066c46fc 100644 --- a/src/afsd/Makefile +++ b/src/afsd/Makefile @@ -12,14 +12,13 @@ DESTDIR = DEST/ 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} @@ -104,6 +103,11 @@ install: all *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 diff --git a/src/afsd/afs.ppc_darwin.plist b/src/afsd/afs.ppc_darwin.plist new file mode 100644 index 0000000000..c29e664219 --- /dev/null +++ b/src/afsd/afs.ppc_darwin.plist @@ -0,0 +1,31 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + afs + CFBundleIdentifier + org.openafs.filesystems.afs + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + afs + CFBundlePackageType + KEXT + CFBundleShortVersionString + 1.0.3 + CFBundleSignature + ???? + CFBundleVersion + 1.0.3 + OSBundleLibraries + + com.apple.kernel.bsd + 1.0.0b1 + com.apple.kernel.mach + 1.0.0b1 + + + diff --git a/src/afsd/afs.rc.darwin b/src/afsd/afs.rc.darwin new file mode 100644 index 0000000000..d82d4efe79 --- /dev/null +++ b/src/afsd/afs.rc.darwin @@ -0,0 +1,123 @@ +#!/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 diff --git a/src/afsd/afs.rc.darwin.plist b/src/afsd/afs.rc.darwin.plist new file mode 100644 index 0000000000..4c05dd1f09 --- /dev/null +++ b/src/afsd/afs.rc.darwin.plist @@ -0,0 +1,11 @@ +{ + Description = "OpenAFS network file system"; + Provides = ("AFS"); + Requires = ("Resolver"); + OrderPreference = "None"; + Messages = + { + start = "Starting OpenAFS file system"; + stop = "Stopping OpenAFS file system"; + }; +} diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 8c82c21b19..a3459f92c1 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -93,7 +93,7 @@ #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 #else #include @@ -132,7 +132,7 @@ void set_staticaddrs(void); #if AFS_HAVE_STATVFS #include #else -#if !defined(AFS_OSF_ENV) +#if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV) #include #endif #endif diff --git a/src/afsmonitor/Makefile b/src/afsmonitor/Makefile index c3b231e84f..c535dc120b 100644 --- a/src/afsmonitor/Makefile +++ b/src/afsmonitor/Makefile @@ -13,8 +13,6 @@ SRCDIR=DEST/ COMPONENT=afsmonitor include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install - CFLAGS=-g -I. \ -I${SRCDIR}include \ -I${SRCDIR}include/afs \ diff --git a/src/afsmonitor/afsmonitor.c b/src/afsmonitor/afsmonitor.c index 0951a928de..7d62124cc0 100644 --- a/src/afsmonitor/afsmonitor.c +++ b/src/afsmonitor/afsmonitor.c @@ -1722,7 +1722,7 @@ int a_newProbeCycle; /* start of a new probe cycle ? */ } /* 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 @@ -2454,7 +2454,7 @@ int a_newProbeCycle; /* start of new probe cycle ? */ /* 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 diff --git a/src/afsweb/Makefile b/src/afsweb/Makefile index e5e3593c06..6c61a62058 100644 --- a/src/afsweb/Makefile +++ b/src/afsweb/Makefile @@ -11,7 +11,6 @@ COMPONENT=nsafs 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 @@ -160,7 +159,7 @@ INCLS=${SRCDIR}include/ubik.h \ ${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 diff --git a/src/audit/Makefile b/src/audit/Makefile index b784985762..618af14cf7 100644 --- a/src/audit/Makefile +++ b/src/audit/Makefile @@ -20,7 +20,6 @@ MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 UKERNELDIR = ../libuafs/ LOCALDIR = ${DESTDIR}root.server/usr/afs/local/ -INSTALL = ${SRCDIR}bin/install audobjs = audit.o diff --git a/src/auth/Makefile b/src/auth/Makefile index a6afaf105f..17ef837746 100644 --- a/src/auth/Makefile +++ b/src/auth/Makefile @@ -12,7 +12,6 @@ include ../config/Makefile.${SYS_NAME} 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 @@ -48,8 +47,7 @@ setkey.o: setkey.c ${INCLS} AFS_component_version_number.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 diff --git a/src/bozo/Makefile b/src/bozo/Makefile index 0a7887f87f..adc1080544 100644 --- a/src/bozo/Makefile +++ b/src/bozo/Makefile @@ -9,7 +9,6 @@ SHELL=/bin/sh 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 diff --git a/src/bu_utils/Makefile b/src/bu_utils/Makefile index 62adef9321..7ccf9153f0 100644 --- a/src/bu_utils/Makefile +++ b/src/bu_utils/Makefile @@ -9,7 +9,6 @@ SHELL = /bin/sh 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} diff --git a/src/bubasics/Makefile b/src/bubasics/Makefile index 0df9aa5c64..91420e14c2 100644 --- a/src/bubasics/Makefile +++ b/src/bubasics/Makefile @@ -9,7 +9,6 @@ SHELL = /bin/sh COMPONENT=bubasics include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install RXGEN=${SRCDIR}bin/rxgen COMPILE_ET = ${SRCDIR}bin/compile_et diff --git a/src/bucoord/Makefile b/src/bucoord/Makefile index d97cbc7a93..517708a9fe 100644 --- a/src/bucoord/Makefile +++ b/src/bucoord/Makefile @@ -9,7 +9,6 @@ SHELL = /bin/sh 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} diff --git a/src/budb/Makefile b/src/budb/Makefile index c375f3e1a5..ac0b03378d 100644 --- a/src/budb/Makefile +++ b/src/budb/Makefile @@ -12,7 +12,6 @@ SHELL = /bin/sh COMPONENT=budb include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install COMPILE_ET = ${SRCDIR}bin/compile_et RXGEN=${SRCDIR}bin/rxgen diff --git a/src/butc/Makefile b/src/butc/Makefile index 105d3f5ab8..edfddbba5e 100644 --- a/src/butc/Makefile +++ b/src/butc/Makefile @@ -9,8 +9,6 @@ SHELL = /bin/sh 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 diff --git a/src/butc/dump.c b/src/butc/dump.c index db7df4f4ce..cc5eae34d8 100644 --- a/src/butc/dump.c +++ b/src/butc/dump.c @@ -97,7 +97,7 @@ afs_int32 tapeblocks; /* Number of 16K tape datablocks in buffer (!CONF_XBS 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; diff --git a/src/butm/Makefile b/src/butm/Makefile index c56fbb25f1..9e12ce2e86 100644 --- a/src/butm/Makefile +++ b/src/butm/Makefile @@ -10,7 +10,6 @@ SHELL = /bin/sh SRCDIR=DEST/ DESTDIR=DEST/ -INSTALL=${SRCDIR}bin/install CFLAGS = -g -w -I${SRCDIR}include ${XCFLAGS} LDFLAGS = -g ${XLDFLAGS} diff --git a/src/cmd/Makefile b/src/cmd/Makefile index cd5ac4a454..61dcd34589 100644 --- a/src/cmd/Makefile +++ b/src/cmd/Makefile @@ -11,7 +11,6 @@ SHELL = /bin/sh COMPONENT=cmd include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install COMPILE_ET = ${SRCDIR}bin/compile_et INCLS=cmd.h ${XINCLS} diff --git a/src/comerr/Makefile b/src/comerr/Makefile index ff7839faf8..c177fd6cea 100644 --- a/src/comerr/Makefile +++ b/src/comerr/Makefile @@ -17,7 +17,6 @@ LINTFILES= error_msg.c et_name.c com_err.c 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 \ diff --git a/src/config/Makefile.alpha_dux40 b/src/config/Makefile.alpha_dux40 index d9567006b5..3e364770e9 100644 --- a/src/config/Makefile.alpha_dux40 +++ b/src/config/Makefile.alpha_dux40 @@ -21,8 +21,8 @@ OPTMZ=-O2 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 diff --git a/src/config/Makefile.alpha_dux50 b/src/config/Makefile.alpha_dux50 index 7bc6378de2..39abb115e4 100644 --- a/src/config/Makefile.alpha_dux50 +++ b/src/config/Makefile.alpha_dux50 @@ -22,8 +22,8 @@ DBG=-g3 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 diff --git a/src/config/Makefile.hp_ux110 b/src/config/Makefile.hp_ux110 index 3064e51d6f..caab152faf 100644 --- a/src/config/Makefile.hp_ux110 +++ b/src/config/Makefile.hp_ux110 @@ -21,8 +21,8 @@ LWP_OPTMZ=-O 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 diff --git a/src/config/Makefile.i386_linux22 b/src/config/Makefile.i386_linux22 index 3095942c3c..03881560c3 100644 --- a/src/config/Makefile.i386_linux22 +++ b/src/config/Makefile.i386_linux22 @@ -39,13 +39,13 @@ XLIBS= 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 # diff --git a/src/config/Makefile.i386_linux24 b/src/config/Makefile.i386_linux24 index f85a3823bf..8fa367fd19 100644 --- a/src/config/Makefile.i386_linux24 +++ b/src/config/Makefile.i386_linux24 @@ -30,13 +30,13 @@ XLIBS= 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 # diff --git a/src/config/Makefile.ppc_darwin_12 b/src/config/Makefile.ppc_darwin_12 new file mode 100644 index 0000000000..bdf3d34c0a --- /dev/null +++ b/src/config/Makefile.ppc_darwin_12 @@ -0,0 +1,46 @@ +# 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 diff --git a/src/config/Makefile.ppc_darwin_13 b/src/config/Makefile.ppc_darwin_13 new file mode 100644 index 0000000000..bdf3d34c0a --- /dev/null +++ b/src/config/Makefile.ppc_darwin_13 @@ -0,0 +1,46 @@ +# 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 diff --git a/src/config/Makefile.ppc_linux24 b/src/config/Makefile.ppc_linux24 index 3230ad69ca..8557f28cc1 100644 --- a/src/config/Makefile.ppc_linux24 +++ b/src/config/Makefile.ppc_linux24 @@ -30,13 +30,13 @@ XLIBS= 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 # diff --git a/src/config/Makefile.rs_aix42 b/src/config/Makefile.rs_aix42 index c2074b6c7f..cb0c2e33ca 100644 --- a/src/config/Makefile.rs_aix42 +++ b/src/config/Makefile.rs_aix42 @@ -29,13 +29,13 @@ MT_CC=xlc_r 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 diff --git a/src/config/Makefile.s390_linux22 b/src/config/Makefile.s390_linux22 index 2c213bc7d8..9104a6efc3 100644 --- a/src/config/Makefile.s390_linux22 +++ b/src/config/Makefile.s390_linux22 @@ -35,13 +35,13 @@ XLIBS= 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 # diff --git a/src/config/Makefile.sgi_62 b/src/config/Makefile.sgi_62 index 964b0ccb52..15185cac7b 100644 --- a/src/config/Makefile.sgi_62 +++ b/src/config/Makefile.sgi_62 @@ -33,13 +33,13 @@ AR=ar 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 diff --git a/src/config/Makefile.sgi_63 b/src/config/Makefile.sgi_63 index 4caf1b5edc..11f274664e 100644 --- a/src/config/Makefile.sgi_63 +++ b/src/config/Makefile.sgi_63 @@ -33,10 +33,10 @@ AR=ar 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 diff --git a/src/config/Makefile.sgi_64 b/src/config/Makefile.sgi_64 index 3d63a167bf..421d801715 100644 --- a/src/config/Makefile.sgi_64 +++ b/src/config/Makefile.sgi_64 @@ -34,13 +34,13 @@ AR=ar 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 diff --git a/src/config/Makefile.sgi_65 b/src/config/Makefile.sgi_65 index 07d163f140..604028ec97 100644 --- a/src/config/Makefile.sgi_65 +++ b/src/config/Makefile.sgi_65 @@ -34,13 +34,13 @@ AR=ar 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 diff --git a/src/config/Makefile.sparc64_linux22 b/src/config/Makefile.sparc64_linux22 index 65e4f2b30c..fe13b0596c 100644 --- a/src/config/Makefile.sparc64_linux22 +++ b/src/config/Makefile.sparc64_linux22 @@ -34,13 +34,13 @@ XLIBS= 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 # diff --git a/src/config/Makefile.sparc_linux22 b/src/config/Makefile.sparc_linux22 index 65e4f2b30c..fe13b0596c 100644 --- a/src/config/Makefile.sparc_linux22 +++ b/src/config/Makefile.sparc_linux22 @@ -34,13 +34,13 @@ XLIBS= 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 # diff --git a/src/config/Makefile.sun4x_55 b/src/config/Makefile.sun4x_55 index a02e8b681b..b69193d54c 100644 --- a/src/config/Makefile.sun4x_55 +++ b/src/config/Makefile.sun4x_55 @@ -32,7 +32,6 @@ AS=as 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 @@ -40,7 +39,8 @@ MV=mv 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 diff --git a/src/config/Makefile.sun4x_56 b/src/config/Makefile.sun4x_56 index f048a0efd7..74e144e4bc 100644 --- a/src/config/Makefile.sun4x_56 +++ b/src/config/Makefile.sun4x_56 @@ -36,7 +36,6 @@ AS=as 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 @@ -44,7 +43,8 @@ MV=mv 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 diff --git a/src/config/Makefile.sun4x_57 b/src/config/Makefile.sun4x_57 index bcc4897142..0003637bfd 100644 --- a/src/config/Makefile.sun4x_57 +++ b/src/config/Makefile.sun4x_57 @@ -40,7 +40,6 @@ AS=as 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 @@ -48,7 +47,8 @@ MV=mv 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 diff --git a/src/config/Makefile.sun4x_58 b/src/config/Makefile.sun4x_58 index 3701bfda60..5d07dfbe48 100644 --- a/src/config/Makefile.sun4x_58 +++ b/src/config/Makefile.sun4x_58 @@ -33,7 +33,6 @@ AS=as 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 @@ -41,7 +40,8 @@ MV=mv 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 diff --git a/src/config/Makefile.sunx86_54 b/src/config/Makefile.sunx86_54 index 51c15e4978..ab8e0cf589 100644 --- a/src/config/Makefile.sunx86_54 +++ b/src/config/Makefile.sunx86_54 @@ -18,3 +18,5 @@ AR = /usr/ccs/bin/ar LD = /usr/ccs/bin/ld LORDER = /usr/ccs/bin/lorder STRIP= /usr/ccs/bin/strip +WASHTOOL=${DESTDIR}bin/washtool +INSTALL=${DESTDIR}bin/install diff --git a/src/config/afs_sysnames.h b/src/config/afs_sysnames.h index ab155f4a3c..ad80007ac4 100644 --- a/src/config/afs_sysnames.h +++ b/src/config/afs_sysnames.h @@ -47,6 +47,8 @@ #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 diff --git a/src/config/mkvers.c b/src/config/mkvers.c index f785b7269b..0eb60b0434 100644 --- a/src/config/mkvers.c +++ b/src/config/mkvers.c @@ -16,7 +16,9 @@ #include #include #include +#ifndef __APPLE_CC__ #include +#endif #include #include diff --git a/src/config/param.ppc_darwin_12.h b/src/config/param.ppc_darwin_12.h new file mode 100644 index 0000000000..1640e9ba08 --- /dev/null +++ b/src/config/param.ppc_darwin_12.h @@ -0,0 +1,58 @@ +#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 + +#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 +#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_ diff --git a/src/config/param.ppc_darwin_12_usr.h b/src/config/param.ppc_darwin_12_usr.h new file mode 100644 index 0000000000..6402debc39 --- /dev/null +++ b/src/config/param.ppc_darwin_12_usr.h @@ -0,0 +1,46 @@ +#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 +#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_ diff --git a/src/config/param.ppc_darwin_13.h b/src/config/param.ppc_darwin_13.h new file mode 100644 index 0000000000..1afb00bd55 --- /dev/null +++ b/src/config/param.ppc_darwin_13.h @@ -0,0 +1,60 @@ +#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 + +#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 +#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_ diff --git a/src/config/param.ppc_darwin_13_usr.h b/src/config/param.ppc_darwin_13_usr.h new file mode 100644 index 0000000000..ec6f03dfda --- /dev/null +++ b/src/config/param.ppc_darwin_13_usr.h @@ -0,0 +1,48 @@ +#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 +#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_ diff --git a/src/dauth/Makefile b/src/dauth/Makefile index 27ac5bd971..9fd72fc923 100644 --- a/src/dauth/Makefile +++ b/src/dauth/Makefile @@ -9,7 +9,6 @@ SHELL = /bin/sh COMPONENT= dauth include ../config/Makefile.${SYS_NAME} -INSTALL= ${SRCDIR}bin/install COMPILE_ET = ${SRCDIR}bin/compile_et OPTMZ= -g @@ -17,11 +16,11 @@ CFLAGS = ${OPTMZ} -I${SRCDIR}include ${XCFLAGS} 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 @@ -71,7 +70,7 @@ dpass: dpass.o $(VERSION) $(LIBS) dlog_test: dlog.c $(OBJS) $(LIBS) $(CC) $(LDFLAGS) -DDLOG_TEST -o dlog_test dlog.c $(OBJS) \ $(LIBS) ${XLIBS} - + system: install ${DESTDIR}bin/dlog: dlog diff --git a/src/des/Makefile b/src/des/Makefile index 3d58d53807..5e7dd75b0f 100644 --- a/src/des/Makefile +++ b/src/des/Makefile @@ -26,7 +26,6 @@ SHELL = /bin/sh include ../config/Makefile.${SYS_NAME} UKERNELDIR=../libuafs/ -INSTALL=${SRCDIR}bin/install SRC =. MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 diff --git a/src/des/andrew-conf.h b/src/des/andrew-conf.h index 25bee7410e..0f9d238e47 100644 --- a/src/des/andrew-conf.h +++ b/src/des/andrew-conf.h @@ -63,8 +63,12 @@ #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 */ diff --git a/src/des/conf-ppc-darwin.h b/src/des/conf-ppc-darwin.h new file mode 100644 index 0000000000..6d30c2ad5f --- /dev/null +++ b/src/des/conf-ppc-darwin.h @@ -0,0 +1,6 @@ +#define BITS32 +#define BIG +#undef BSDUNIX +#define MSBFIRST +#define MUSTALIGN + diff --git a/src/des/new_rnd_key.c b/src/des/new_rnd_key.c index 98f2ec8d89..56deae1533 100644 --- a/src/des/new_rnd_key.c +++ b/src/des/new_rnd_key.c @@ -93,7 +93,7 @@ des_random_key(key) * * 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 diff --git a/src/des/read_pssword.c b/src/des/read_pssword.c index d632f18f01..e0817221f7 100644 --- a/src/des/read_pssword.c +++ b/src/des/read_pssword.c @@ -33,7 +33,7 @@ #include #endif -#if defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) +#if defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) #include #endif @@ -48,6 +48,9 @@ static int intrupt; #include #endif +#ifdef AFS_DARWIN_ENV +#include +#endif #ifdef AFS_NT40_ENV #include #endif @@ -99,7 +102,7 @@ lose: 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 @@ -121,11 +124,14 @@ des_read_pw_string(s,maxa,prompt,verify) { 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; @@ -156,7 +162,7 @@ des_read_pw_string(s,maxa,prompt,verify) 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. */ @@ -382,7 +388,7 @@ sig_restore() #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) { diff --git a/src/des_stub/Makefile b/src/des_stub/Makefile index 9ac3745cd0..c1ce9904af 100644 --- a/src/des_stub/Makefile +++ b/src/des_stub/Makefile @@ -14,7 +14,6 @@ include ../config/Makefile.${SYS_NAME} RM = /bin/rm UKERNELDIR=../libuafs/ -INSTALL=${SRCDIR}bin/install SRC =. DESPAR =../../../DESLIB/dest/ DESINC =${DESPAR}include/ diff --git a/src/dir/Makefile b/src/dir/Makefile index d2c60b66d7..69e9aa33fb 100644 --- a/src/dir/Makefile +++ b/src/dir/Makefile @@ -11,7 +11,6 @@ include ../config/Makefile.${SYS_NAME} KERNELDIR = ../libafs/ UKERNELDIR = ../libuafs/ -INSTALL = ${SRCDIR}bin/install MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 INCDIRS= -I${DESTDIR}include ${XINCLS} diff --git a/src/export/Makefile b/src/export/Makefile index a1d9389d19..039b36abd9 100644 --- a/src/export/Makefile +++ b/src/export/Makefile @@ -13,7 +13,6 @@ COMPONENT=export include ../config/Makefile.${SYS_NAME} - INSTALL = ${SRCDIR}bin/install KERNELDIR = ../libafs/ UKERNELDIR = ../libuafs/ DEFS = diff --git a/src/fsint/Makefile b/src/fsint/Makefile index 375eb3aaaa..ee8288e1fb 100644 --- a/src/fsint/Makefile +++ b/src/fsint/Makefile @@ -10,7 +10,6 @@ include ../config/Makefile.${SYS_NAME} 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 diff --git a/src/fsint/afsaux.c b/src/fsint/afsaux.c index a97394d99d..ce8c592a2a 100644 --- a/src/fsint/afsaux.c +++ b/src/fsint/afsaux.c @@ -16,7 +16,7 @@ #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 @@ -57,12 +57,13 @@ static afs_int32 bslosers = 0; /* 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. */ @@ -145,6 +146,7 @@ xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem) } return(TRUE); } +#endif #endif /* KERNEL */ #ifndef KERNEL diff --git a/src/fsprobe/Makefile b/src/fsprobe/Makefile index 39fb6b8f88..a91c240d3f 100644 --- a/src/fsprobe/Makefile +++ b/src/fsprobe/Makefile @@ -12,8 +12,6 @@ SHELL = /bin/sh COMPONENT=fsprobe include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install - CFLAGS=-g -I. \ -I${SRCDIR}include \ -I${SRCDIR}include/afs \ diff --git a/src/gtx/Makefile b/src/gtx/Makefile index 8196c90a0d..ce627b301b 100644 --- a/src/gtx/Makefile +++ b/src/gtx/Makefile @@ -12,7 +12,6 @@ SHELL=/bin/sh 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} diff --git a/src/gtx/curseswindows.c b/src/gtx/curseswindows.c index 8ae20cecd9..0757bd0049 100644 --- a/src/gtx/curseswindows.c +++ b/src/gtx/curseswindows.c @@ -754,8 +754,13 @@ int gator_cursesgwin_getdimensions(gwp, aparms) 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); diff --git a/src/inetd/Makefile b/src/inetd/Makefile index 853a6ed239..531847a700 100644 --- a/src/inetd/Makefile +++ b/src/inetd/Makefile @@ -4,7 +4,6 @@ include ../config/Makefile.${SYS_NAME} 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 \ diff --git a/src/kauth/Makefile b/src/kauth/Makefile index 92d1ff1227..27f28d8f64 100644 --- a/src/kauth/Makefile +++ b/src/kauth/Makefile @@ -13,7 +13,6 @@ COMPONENT=kauth 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 @@ -190,8 +189,7 @@ kpwvalid: kpwvalid.o $(LIBS) ${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 diff --git a/src/kauth/kaserver.c b/src/kauth/kaserver.c index 3bb2cf37bb..3de02c9a07 100644 --- a/src/kauth/kaserver.c +++ b/src/kauth/kaserver.c @@ -63,7 +63,7 @@ int MinHours = 0; int npwSums = KA_NPWSUMS; /* needs to be variable sometime */ #include -#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 diff --git a/src/kauth/klogin.c b/src/kauth/klogin.c index 34988c8088..85e1b559fc 100644 --- a/src/kauth/klogin.c +++ b/src/kauth/klogin.c @@ -29,7 +29,7 @@ static char sccsid[] = "@(#)login.c 5.15 (Berkeley) 4/12/86"; * login -h hostname (for telnetd, etc.) */ #include -#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 #define quota(a,b,c,d) 0 diff --git a/src/libacl/Makefile b/src/libacl/Makefile index 6be8a6514f..116a66aa03 100644 --- a/src/libacl/Makefile +++ b/src/libacl/Makefile @@ -9,7 +9,6 @@ SHELL = /bin/sh 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/ @@ -26,7 +25,7 @@ libacl.a: $(LIBOBJS) AFS_component_version_number.o 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 diff --git a/src/libafs/Makefile.common b/src/libafs/Makefile.common index 9d83cabc60..69d3011230 100644 --- a/src/libafs/Makefile.common +++ b/src/libafs/Makefile.common @@ -10,7 +10,6 @@ SHELL=/bin/sh DESTDIR = DEST/ SRCDIR = DEST/ -INSTALL = $(DESTDIR)bin/install INCLUDE= -I. -I/usr/include Aobj=COMMON Dobj=DYNEL diff --git a/src/libafs/MakefileProto.DARWIN b/src/libafs/MakefileProto.DARWIN new file mode 100644 index 0000000000..56897e05e8 --- /dev/null +++ b/src/libafs/MakefileProto.DARWIN @@ -0,0 +1,115 @@ +#/* 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); + diff --git a/src/libafsauthent/Makefile b/src/libafsauthent/Makefile index 304260c6a2..33be0bcd9b 100644 --- a/src/libafsauthent/Makefile +++ b/src/libafsauthent/Makefile @@ -12,7 +12,6 @@ COMPONENT=libafsauthent include ../config/Makefile.${SYS_NAME} CC=${MT_CC} -INSTALL = ${SRCDIR}bin/install CFLAGS = ${OPTMZ} ${DBG} -I${SRCDIR}include ${MT_CFLAGS} CCRULE = ${CC} ${CFLAGS} -c $? diff --git a/src/libafsrpc/Makefile b/src/libafsrpc/Makefile index fbc116a084..add1ed181d 100644 --- a/src/libafsrpc/Makefile +++ b/src/libafsrpc/Makefile @@ -11,7 +11,6 @@ SHELL = /bin/sh 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} @@ -321,7 +320,7 @@ syscall.o: ${SYS}/syscall.s /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; \ diff --git a/src/libuafs/Makefile.common b/src/libuafs/Makefile.common index 3957c7faac..607b387352 100644 --- a/src/libuafs/Makefile.common +++ b/src/libuafs/Makefile.common @@ -9,7 +9,6 @@ # SHELL=/bin/sh -INSTALL = ${SRCDIR}bin/install INCLUDE= -I. -I/usr/include UOBJ =../UAFS WEBOBJ =../AFSWEB @@ -28,15 +27,19 @@ webinstall: AFSWEB/$(LIBAFSWEB) AFSWEB/$(LIBAFSWEBKRB) ${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 $? diff --git a/src/libuafs/MakefileProto.DARWIN b/src/libuafs/MakefileProto.DARWIN new file mode 100644 index 0000000000..e11103f0f7 --- /dev/null +++ b/src/libuafs/MakefileProto.DARWIN @@ -0,0 +1,82 @@ +# 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) diff --git a/src/log/Makefile b/src/log/Makefile index b15bee887c..f053437d3c 100644 --- a/src/log/Makefile +++ b/src/log/Makefile @@ -15,9 +15,6 @@ CFLAGS = ${OPTMZ} ${INCDIRS} ${XCFLAGS} ${DBUG} 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 diff --git a/src/login/Makefile b/src/login/Makefile index c14e56ecca..53f1bc672b 100644 --- a/src/login/Makefile +++ b/src/login/Makefile @@ -21,7 +21,6 @@ COMPONENT=login 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 \ diff --git a/src/lwp/Makefile b/src/lwp/Makefile index 4111dc4689..022145fe83 100644 --- a/src/lwp/Makefile +++ b/src/lwp/Makefile @@ -9,9 +9,6 @@ SHELL = /bin/sh 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} @@ -70,6 +67,8 @@ process.o : process.s process.c /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_*) \ diff --git a/src/lwp/lwp.c b/src/lwp/lwp.c index a70dfa6b53..04a053ac10 100644 --- a/src/lwp/lwp.c +++ b/src/lwp/lwp.c @@ -343,7 +343,7 @@ int LWP_CreateProcess(ep, stacksize, priority, parm, name, pid) #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*/ @@ -485,7 +485,7 @@ int LWP_DestroyProcess(pid) /* destroy a lightweight process */ 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 diff --git a/src/lwp/preempt.c b/src/lwp/preempt.c index e2bcc61d25..e95dacb412 100644 --- a/src/lwp/preempt.c +++ b/src/lwp/preempt.c @@ -17,7 +17,7 @@ \*******************************************************************/ #include -#ifdef AFS_LINUX20_ENV +#if defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) int PRE_Block = 0; #else #include diff --git a/src/lwp/process.c b/src/lwp/process.c index a9d1d25b18..155d60b051 100644 --- a/src/lwp/process.c +++ b/src/lwp/process.c @@ -50,6 +50,8 @@ extern char PRE_Block; /* used in lwp.c and process.s */ #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 diff --git a/src/lwp/process.s b/src/lwp/process.s index 899e3842c6..7863db664b 100644 --- a/src/lwp/process.s +++ b/src/lwp/process.s @@ -1231,4 +1231,159 @@ returnto: #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 + diff --git a/src/lwp/waitkey.c b/src/lwp/waitkey.c index 74d58bc9b6..fd9f615122 100644 --- a/src/lwp/waitkey.c +++ b/src/lwp/waitkey.c @@ -153,10 +153,15 @@ int LWP_WaitForKeystroke(int seconds) #ifdef AFS_LINUX20_ENV 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); diff --git a/src/mpp/Makefile b/src/mpp/Makefile index 13bd903b0d..403dbdddfe 100644 --- a/src/mpp/Makefile +++ b/src/mpp/Makefile @@ -5,7 +5,6 @@ SHELL = /bin/sh DESTDIR=DEST/ SRCDIR=DEST/ CFLAGS= ${OPTMZ} ${XCFLAGS} -INSTALL=${SRCDIR}bin/install LIBS = ${XLIBS} PROGRAM=mpp diff --git a/src/ntp/Makefile b/src/ntp/Makefile index ff773628f1..93fd206ef9 100644 --- a/src/ntp/Makefile +++ b/src/ntp/Makefile @@ -9,7 +9,6 @@ SHELL = /bin/sh COMPONENT=ntp include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install INCPATH= -I${DESTDIR}include BINDIR=/usr/local/etc LINKDIR=/etc diff --git a/src/null/Makefile b/src/null/Makefile index 513c7c3fd4..7ab2cda573 100644 --- a/src/null/Makefile +++ b/src/null/Makefile @@ -8,7 +8,6 @@ # Makefile for the null library. DESTDIR=DEST/ SRCDIR=DEST/ -INSTALL=${SRCDIR}bin/install SHELL=/bin/sh COMPONENT=null diff --git a/src/package/Makefile b/src/package/Makefile index 606607341a..2cfcbdff85 100644 --- a/src/package/Makefile +++ b/src/package/Makefile @@ -15,7 +15,6 @@ CFLAGS = ${DBUG} -DKFLAG -DANDREW -DVICE $(DBGFLAG) $(INCLUDES) $(XCFLAGS) YFLAGS = -vd #LFLAGS = -ll LINT = lint -hp -INSTALL = ${SRCDIR}bin/install HFILES = package.h \ validupdates.h \ diff --git a/src/pam/Makefile b/src/pam/Makefile index 03d0d4c212..eb37016a21 100644 --- a/src/pam/Makefile +++ b/src/pam/Makefile @@ -6,14 +6,12 @@ # 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 \ diff --git a/src/pinstall/Makefile b/src/pinstall/Makefile index 165bbe4a4f..d5d3b5723a 100644 --- a/src/pinstall/Makefile +++ b/src/pinstall/Makefile @@ -47,7 +47,12 @@ pinstall: install.c AFS_component_version_number.c - [ -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 diff --git a/src/pinstall/install.c b/src/pinstall/install.c index 004a9c1107..e9f811c3d4 100644 --- a/src/pinstall/install.c +++ b/src/pinstall/install.c @@ -66,9 +66,14 @@ Generic install command. Options are: #include #include #else +#ifdef AFS_DARWIN_ENV +#include +#include +#else #include #include #endif +#endif #ifdef AFS_HPUX_ENV #include #endif @@ -77,10 +82,10 @@ struct stat istat, ostat; 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 @@ -144,7 +149,7 @@ atoo(astr) 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. @@ -211,7 +216,7 @@ char *iname, *oname; { 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" @@ -671,7 +676,7 @@ main (argc, argv) 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])) diff --git a/src/procmgmt/Makefile b/src/procmgmt/Makefile index 058aa1701f..82c35dbdd0 100644 --- a/src/procmgmt/Makefile +++ b/src/procmgmt/Makefile @@ -8,7 +8,6 @@ include ../config/Makefile.${SYS_NAME} include ../config/Makefile.version -INSTALL=${SRCDIR}bin/install CFLAGS = $(DBUG) -I${SRCDIR}include ${XCFLAGS} ######################################################################## diff --git a/src/ptserver/Makefile b/src/ptserver/Makefile index af05c4eab5..3b9b19dae7 100644 --- a/src/ptserver/Makefile +++ b/src/ptserver/Makefile @@ -10,7 +10,6 @@ COMPONENT=ptserver 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 @@ -125,7 +124,12 @@ readpwd: readpwd.o libprot.a $(LIBS) 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 diff --git a/src/rcp/Makefile b/src/rcp/Makefile index 9525c20241..2fbf5ccebc 100644 --- a/src/rcp/Makefile +++ b/src/rcp/Makefile @@ -24,7 +24,6 @@ SRCS= rcp.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\ diff --git a/src/rcp/rcp.c b/src/rcp/rcp.c index 951efe244f..bf7db5b703 100644 --- a/src/rcp/rcp.c +++ b/src/rcp/rcp.c @@ -78,7 +78,7 @@ static char sccsid[] = "@(#)rcp.c 5.11 (Berkeley) 9/22/88"; 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(); diff --git a/src/rlogind/Makefile b/src/rlogind/Makefile index 1b399bf288..7d8f9fa261 100644 --- a/src/rlogind/Makefile +++ b/src/rlogind/Makefile @@ -25,7 +25,6 @@ LIBC= /lib/libc.a 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 \ diff --git a/src/rsh/Makefile b/src/rsh/Makefile index a76f108316..e85445e2ea 100644 --- a/src/rsh/Makefile +++ b/src/rsh/Makefile @@ -20,7 +20,6 @@ SHELL=/bin/sh COMPONENT=rsh include ../config/Makefile.${SYS_NAME} -INSTALL = ${SRCDIR}bin/install LIBDIR = ${DESTDIR}lib/ INCLUDES= -I${SRCDIR}include CFLAGS= ${DBUG} ${INCLUDES} ${XCFLAGS} diff --git a/src/rsh/herror.c b/src/rsh/herror.c index 1ce5e57b88..eebe2c686f 100644 --- a/src/rsh/herror.c +++ b/src/rsh/herror.c @@ -20,6 +20,7 @@ static char sccsid[] = "@(#)herror.c 6.4 (Berkeley) 10/30/88"; #endif /* LIBC_SCCS and not lint */ #include +#ifndef AFS_DARWIN_ENV #include #include @@ -64,3 +65,4 @@ herror(s) v->iov_len = 1; writev(2, iov, (v - iov) + 1); } +#endif diff --git a/src/rsh/rcmd.c b/src/rsh/rcmd.c index 9772e04392..9109b96eb7 100644 --- a/src/rsh/rcmd.c +++ b/src/rsh/rcmd.c @@ -97,7 +97,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p) #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; @@ -359,7 +359,7 @@ rresvport(alport) 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; diff --git a/src/rx/DARWIN/rx_kmutex.h b/src/rx/DARWIN/rx_kmutex.h new file mode 100644 index 0000000000..530b3ceba8 --- /dev/null +++ b/src/rx/DARWIN/rx_kmutex.h @@ -0,0 +1,107 @@ +/* + * 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 +#include +#include + +#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_ */ + diff --git a/src/rx/DARWIN/rx_knet.c b/src/rx/DARWIN/rx_knet.c new file mode 100644 index 0000000000..dafa3d4e95 --- /dev/null +++ b/src/rx/DARWIN/rx_knet.c @@ -0,0 +1,163 @@ +/* + * 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; +} diff --git a/src/rx/Makefile b/src/rx/Makefile index f4af352526..bae07f5834 100644 --- a/src/rx/Makefile +++ b/src/rx/Makefile @@ -11,7 +11,6 @@ include ../config/Makefile.${SYS_NAME} KERNELDIR = ../libafs/ UKERNELDIR = ../libuafs/ -INSTALL=${SRCDIR}bin/install MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 #CC=pcc @@ -82,8 +81,8 @@ rx_trace.o: rx_trace.h 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 @@ -131,6 +130,8 @@ kinstall: includes $(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;; \ * ) \ diff --git a/src/rx/rx_getaddr.c b/src/rx/rx_getaddr.c index 37381895f6..5a0c41a2bc 100644 --- a/src/rx/rx_getaddr.c +++ b/src/rx/rx_getaddr.c @@ -20,6 +20,11 @@ #include #include #include +#ifdef AFS_DARWIN_ENV +#include +#include +#include +#endif /* * By including this, we get any system dependencies. In particular, * the pthreads for solaris requires the socket call to be mapped. @@ -100,12 +105,219 @@ afs_int32 rxi_getaddr () #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; @@ -125,13 +337,18 @@ int maxSize; /* sizeof of buffer in afs_int32 units */ 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) { @@ -258,6 +475,7 @@ int rxi_getAllAddrMaskMtu (addrBuffer, maskBuffer, mtuBuffer, maxSize) return count; #endif /* AFS_USERSPACE_IP_ADDR */ } +#endif #endif /* ! AFS_NT40_ENV */ #endif /* !KERNEL || UKERNEL */ diff --git a/src/rx/rx_kcommon.c b/src/rx/rx_kcommon.c index 005664ddc9..a07dad1fc3 100644 --- a/src/rx/rx_kcommon.c +++ b/src/rx/rx_kcommon.c @@ -423,7 +423,7 @@ register struct rx_peer *pp; */ -#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. */ @@ -548,7 +548,7 @@ afs_int32 rxi_Findcbi(addr) #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) @@ -569,10 +569,20 @@ int rxi_GetIFInfo() 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) { @@ -626,14 +636,26 @@ rxi_FindIfnet(addr, pifad) /* 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); @@ -691,6 +713,9 @@ struct osi_socket *rxk_NewSocket(short aport) #endif AFS_STATCNT(osi_NewSocket); +#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL) + thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL); +#endif #if defined(AFS_HPUX102_ENV) #if defined(AFS_HPUX110_ENV) /* blocking socket */ @@ -705,7 +730,7 @@ struct osi_socket *rxk_NewSocket(short aport) code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0); #endif /* AFS_SGI65_ENV */ #endif /* AFS_HPUX102_ENV */ - if (code) return (struct osi_socket *) 0; + if (code) goto bad; myaddr.sin_family = AF_INET; myaddr.sin_port = aport; @@ -715,7 +740,7 @@ struct osi_socket *rxk_NewSocket(short aport) bindnam = allocb_wait((addrsize+SO_MSGOFFSET+1), BPRI_MED); if (!bindnam) { setuerror(ENOBUFS); - return(struct osi_socket *) 0; + goto bad; } bcopy((caddr_t)&myaddr, (caddr_t)bindnam->b_rptr+SO_MSGOFFSET, addrsize); bindnam->b_wptr = bindnam->b_rptr + (addrsize+SO_MSGOFFSET+1); @@ -724,7 +749,7 @@ struct osi_socket *rxk_NewSocket(short aport) if (code) { soclose(newSocket); m_freem(nam); - return(struct osi_socket *) 0; + goto bad; } freeb(bindnam); @@ -735,6 +760,15 @@ struct osi_socket *rxk_NewSocket(short aport) if (code) osi_Panic("osi_NewSocket: last attempt to reserve 32K failed!\n"); } +#ifdef AFS_DARWIN_ENV + myaddr.sin_len = sizeof(myaddr); + code = sobind(newSocket, (struct sockaddr *)&myaddr); + if (code) { + printf("sobind fails\n"); + soclose(newSocket); + goto bad; + } +#else #ifdef AFS_OSF_ENV nam = m_getclr(M_WAIT, MT_SONAME); #else /* AFS_OSF_ENV */ @@ -744,7 +778,7 @@ struct osi_socket *rxk_NewSocket(short aport) #if !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_SGI64_ENV) setuerror(ENOBUFS); #endif - return (struct osi_socket *) 0; + goto bad; } nam->m_len = sizeof(myaddr); #ifdef AFS_OSF_ENV @@ -763,11 +797,21 @@ struct osi_socket *rxk_NewSocket(short aport) #ifndef AFS_SGI65_ENV m_freem(nam); #endif - return (struct osi_socket *) 0; + goto bad; } +#endif /* else AFS_DARWIN_ENV */ #endif /* else AFS_HPUX110_ENV */ +#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL) + thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL); +#endif return (struct osi_socket *) newSocket; + +bad: +#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL) + thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL); +#endif + return (struct osi_socket *) 0; } @@ -776,7 +820,13 @@ int rxk_FreeSocket(asocket) register struct socket *asocket; { AFS_STATCNT(osi_FreeSocket); +#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL) + thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL); +#endif soclose(asocket); +#if defined(AFS_DARWIN_ENV) && defined(KERNEL_FUNNEL) + thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL); +#endif return 0; } #endif /* !SUN5 && !LINUX20 */ @@ -938,6 +988,9 @@ void rxk_Listener(void) #ifdef AFS_SUN5_ENV rxk_ListenerPid = ttoproc(curthread)->p_pidp->pid_id; #endif /* AFS_SUN5_ENV */ +#ifdef AFS_DARWIN_ENV + rxk_ListenerPid = current_proc()->p_pid; +#endif #if defined(RX_ENABLE_LOCKS) && !defined(AFS_SUN5_ENV) AFS_GUNLOCK(); #endif /* RX_ENABLE_LOCKS && !AFS_SUN5_ENV */ @@ -977,7 +1030,7 @@ void rxk_Listener(void) #endif /* AFS_SUN5_ENV */ } -#if !defined(AFS_LINUX20_ENV) && !defined(AFS_SUN5_ENV) +#if !defined(AFS_LINUX20_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_DARWIN_ENV) /* The manner of stopping the rx listener thread may vary. Most unix's should * be able to call soclose. */ diff --git a/src/rx/rx_kcommon.h b/src/rx/rx_kcommon.h index 7f99e4b4db..9f011163c2 100644 --- a/src/rx/rx_kcommon.h +++ b/src/rx/rx_kcommon.h @@ -14,6 +14,12 @@ #ifndef _RX_KCOMMON_H_ #define _RX_KCOMMON_H_ +#ifdef AFS_DARWIN_ENV +#ifndef _MACH_ETAP_H_ +#define _MACH_ETAP_H_ +typedef unsigned short etap_event_t; +#endif +#endif #include "../h/types.h" #include "../h/param.h" #ifndef AFS_LINUX22_ENV diff --git a/src/rx/rx_packet.h b/src/rx/rx_packet.h index 6323b49a2a..6b2af42869 100644 --- a/src/rx/rx_packet.h +++ b/src/rx/rx_packet.h @@ -40,7 +40,9 @@ #define MAX(a,b) ((a)>(b)?(a):(b)) #endif #else /* AFS_NT40_ENV */ +#if !defined(AFS_DARWIN_ENV) && !defined(AFS_USR_DARWIN_ENV) #include /* MIN, MAX on Solaris */ +#endif #include /* MIN, MAX elsewhere */ #endif /* AFS_NT40_ENV */ diff --git a/src/rx/rx_rdwr.c b/src/rx/rx_rdwr.c index b1bbadd13a..0685433c2c 100644 --- a/src/rx/rx_rdwr.c +++ b/src/rx/rx_rdwr.c @@ -1,4 +1,4 @@ -/* + /* * Copyright 2000, International Business Machines Corporation and others. * All Rights Reserved. * @@ -10,6 +10,9 @@ #ifdef KERNEL #include "../afs/param.h" #ifndef UKERNEL +#ifdef AFS_DARWIN_ENV +#include "../afs/sysincludes.h" +#else #include "../h/types.h" #include "../h/time.h" #include "../h/stat.h" @@ -23,6 +26,7 @@ #if defined(AFS_SGI_ENV) #include "../afs/sysincludes.h" #endif +#endif #include "../afs/afs_args.h" #include "../afs/afs_osi.h" #if (defined(AFS_AUX_ENV) || defined(AFS_AIX_ENV)) @@ -34,7 +38,6 @@ #ifdef RXDEBUG #undef RXDEBUG /* turn off debugging */ #endif /* RXDEBUG */ -#include "../afsint/afsint.h" #include "../rx/rx_kmutex.h" #include "../rx/rx_kernel.h" diff --git a/src/rxgen/Makefile b/src/rxgen/Makefile index 4cb495ccc7..830f527ef9 100644 --- a/src/rxgen/Makefile +++ b/src/rxgen/Makefile @@ -9,7 +9,6 @@ COMPONENT=rxgen include ../config/Makefile.${SYS_NAME} UKERNELDIR=../libuafs/ -INSTALL =${SRCDIR}bin/install MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 SRCS= rpc_main.c rpc_hout.c rpc_cout.c rpc_parse.c rpc_scan.c rpc_util.c \ diff --git a/src/rxgen/rpc_main.c b/src/rxgen/rpc_main.c index 15d771ff99..b4a6bccc0a 100644 --- a/src/rxgen/rpc_main.c +++ b/src/rxgen/rpc_main.c @@ -90,6 +90,8 @@ static char *cmdname; static char CPP[] = "/usr/ccs/lib/cpp"; #elif defined(AFS_NT40_ENV) static char CPP[MAXCMDLINE]; +#elif defined(AFS_DARWIN_ENV) +static char CPP[] = "cc -E"; #else static char CPP[] = "/lib/cpp"; #endif diff --git a/src/rxkad/Makefile b/src/rxkad/Makefile index 0c2a7b9542..bb933fc0bf 100644 --- a/src/rxkad/Makefile +++ b/src/rxkad/Makefile @@ -14,7 +14,6 @@ include ../config/Makefile.${SYS_NAME} KERNELDIR = ../libafs/ UKERNELDIR = ../libuafs/ -INSTALL=${SRCDIR}bin/install COMPILE_ET = ${SRCDIR}bin/compile_et MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 diff --git a/src/rxkad/rxkad_common.c b/src/rxkad/rxkad_common.c index 2991f1d9bc..196f42fe84 100644 --- a/src/rxkad/rxkad_common.c +++ b/src/rxkad/rxkad_common.c @@ -19,7 +19,6 @@ #endif #include "../h/types.h" #include "../h/time.h" -#include "../netinet/in.h" #ifndef AFS_LINUX22_ENV #include "../rpc/types.h" #include "../rpc/xdr.h" diff --git a/src/rxstat/Makefile b/src/rxstat/Makefile index c07f38557b..8f81ed8a29 100644 --- a/src/rxstat/Makefile +++ b/src/rxstat/Makefile @@ -11,7 +11,6 @@ include ../config/Makefile.version KERNELDIR = ../libafs/ UKERNELDIR = ../libuafs/ -INSTALL=${SRCDIR}bin/install RXGEN=${SRCDIR}bin/rxgen MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 diff --git a/src/scout/Makefile b/src/scout/Makefile index 87395535fd..83006ed528 100644 --- a/src/scout/Makefile +++ b/src/scout/Makefile @@ -10,8 +10,6 @@ SHELL = /bin/sh COMPONENT=scout include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install - CFLAGS= ${DBUG} -I. \ -I${SRCDIR}include \ -I${SRCDIR}include/afs \ diff --git a/src/sgistuff/Makefile b/src/sgistuff/Makefile index 8ec1c4c980..5a42979ac2 100644 --- a/src/sgistuff/Makefile +++ b/src/sgistuff/Makefile @@ -17,7 +17,6 @@ OPTIMIZE=-g CFLAGS = ${OPTIMIZE} -I${SRCDIR}include ${XCFLAGS} LDFLAGS = ${OPTIMIZE} ${XLDFLAGS} 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 \ diff --git a/src/sia/Makefile b/src/sia/Makefile index 856d7cebb0..74403e8661 100644 --- a/src/sia/Makefile +++ b/src/sia/Makefile @@ -27,8 +27,6 @@ KLIBS = ${DESTDIR}/lib/afs/libkauth.krb.a ${LIBS1} ${DESTDIR}/lib/afs/libauth.kr all: test-reauth ${DESTDIR}/lib/afs/libafssiad.so ${DESTDIR}/lib/afs/libafssiad.krb.so -INSTALL=${SRCDIR}bin/install - CFLAGS = $(DEBUG) -I${SRCDIR}include ${XCFLAGS} ${DESTDIR}/lib/afs/libafssiad.so: libafssiad.so diff --git a/src/sys/Makefile b/src/sys/Makefile index d94d9040e2..22c1672f2a 100644 --- a/src/sys/Makefile +++ b/src/sys/Makefile @@ -14,7 +14,6 @@ include ../config/Makefile.${SYS_NAME} MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 UKERNELDIR=../libuafs/ -INSTALL = ${SRCDIR}bin/install CFLAGS= ${DBUG} -I${SRCDIR}include ${XCFLAGS} ${DBG_DEFS} SFLAGS=-P -I${SRCDIR}include LIBS= libsys.a ${SRCDIR}lib/librx.a libsys.a ${SRCDIR}lib/liblwp.a ${SRCDIR}lib/afs/util.a ${XLIBS} @@ -80,7 +79,7 @@ syscall.o: syscall.s /usr/ccs/lib/cpp ${SFLAGS} syscall.s syscall.ss; \ as -o syscall.o syscall.ss; \ rm syscall.ss;; \ - sgi_* ) \ + sgi_* |ppc_darwin* ) \ ${CC} ${CFLAGS} -c syscall.s;; \ alpha_osf1 | alpha_osf20 | alpha_osf30 | alpha_osf32 | alpha_osf32c | alpha_dux?? ) \ ${AS} -P ${CFLAGS} -D_NO_PROTO -DMACH -DOSF -nostdinc -traditional -DASSEMBLER syscall.s; \ diff --git a/src/tbutc/Makefile b/src/tbutc/Makefile index 47615cd40a..dfd2516c75 100644 --- a/src/tbutc/Makefile +++ b/src/tbutc/Makefile @@ -15,7 +15,6 @@ COMPONENT=tbutc include ../config/Makefile.${SYS_NAME} CC =${MT_CC} -INSTALL =${SRCDIR}bin/install CFLAGS = ${DBG} -w ${MT_CFLAGS} LDFLAGS = ${DBG} ${XLDFLAGS} diff --git a/src/tsm41/Makefile b/src/tsm41/Makefile index e5550c70cd..efb9f64fd5 100644 --- a/src/tsm41/Makefile +++ b/src/tsm41/Makefile @@ -9,7 +9,6 @@ include ../config/Makefile.${SYS_NAME} OPTIMIZE=-g CFLAGS = ${OPTIMIZE} -I${SRCDIR}include ${XCFLAGS} 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 \ diff --git a/src/tviced/Makefile b/src/tviced/Makefile index 0d37a57367..f84b15b950 100644 --- a/src/tviced/Makefile +++ b/src/tviced/Makefile @@ -10,7 +10,6 @@ COMPONENT=tviced include ../config/Makefile.${SYS_NAME} CC=${MT_CC} -INSTALL=${SRCDIR}bin/install INCLUDES=-I. -I.. -I${SRCDIR}include -I${SRCDIR}include/afs CFLAGS=${DBG} ${OPTMZ} -DNINTERFACE ${INCLUDES} ${MT_CFLAGS} -DRXDEBUG LDFLAGS=${DBG} ${XLDFLAGS} diff --git a/src/ubik/Makefile b/src/ubik/Makefile index db4ea42855..bd16f8024e 100644 --- a/src/ubik/Makefile +++ b/src/ubik/Makefile @@ -12,7 +12,6 @@ MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 CFLAGS=${OPTMZ} -I./ -I${SRCDIR}include ${XCFLAGS} UKERNELDIR=../libuafs/ -INSTALL=${SRCDIR}bin/install LIBOBJS=disk.o remote.o beacon.o recovery.o ubik.o vote.o lock.o phys.o \ ubik_int.cs.o ubik_int.ss.o ubik_int.xdr.o ubikcmd.o \ ubikclient.o uerrors.o diff --git a/src/update/Makefile b/src/update/Makefile index 447d7f4e48..19d6b921dc 100644 --- a/src/update/Makefile +++ b/src/update/Makefile @@ -9,7 +9,6 @@ SHELL = /bin/sh COMPONENT=update include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install LIBRX=${SRCDIR}lib/librx.a LIBS = ${SRCDIR}lib/afs/libauth.a ${SRCDIR}lib/librxkad.a \ ${SRCDIR}lib/libdes.a ${LIBRX} ${SRCDIR}lib/liblwp.a \ diff --git a/src/usd/Makefile b/src/usd/Makefile index bee2956dc2..fa048526b1 100644 --- a/src/usd/Makefile +++ b/src/usd/Makefile @@ -9,7 +9,6 @@ SHELL = /bin/sh COMPONENT=ptserver include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install RXGEN=${SRCDIR}bin/rxgen COMPILE_ET = ${SRCDIR}bin/compile_et diff --git a/src/usd/usd_file.c b/src/usd/usd_file.c index a2b497349e..fb08d4f773 100644 --- a/src/usd/usd_file.c +++ b/src/usd/usd_file.c @@ -17,6 +17,9 @@ #include #include #else +#ifdef AFS_DARWIN_ENV +#include +#endif #include #endif /* AFS_AIX_ENV */ #ifdef AFS_DUX40_ENV @@ -333,8 +336,10 @@ static int usd_FileOpen( oflags = (flags & USD_OPEN_RDWR) ? O_RDWR : O_RDONLY; +#ifdef O_SYNC /* AFS_DARWIN_ENV XXX */ if (flags & USD_OPEN_SYNC) oflags |= O_SYNC; +#endif if (flags & USD_OPEN_CREATE) oflags |= O_CREAT; diff --git a/src/uss/Makefile b/src/uss/Makefile index 7dbb0a4ef0..1e979e46f3 100644 --- a/src/uss/Makefile +++ b/src/uss/Makefile @@ -12,8 +12,6 @@ SHELL=/bin/sh COMPONENT=uss include ../config/Makefile.${SYS_NAME} -INSTALL = ${SRCDIR}bin/install - # # This makefile creates the following things: # diff --git a/src/uss/uss_common.h b/src/uss/uss_common.h index 1d681ca3a2..ee9a2ad7c3 100644 --- a/src/uss/uss_common.h +++ b/src/uss/uss_common.h @@ -60,7 +60,7 @@ #define uss_VolumeLen 300 #define uss_DirPoolLen 300 -#ifndef AFS_LINUX20_ENV +#if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) extern char *sys_errlist[]; #endif diff --git a/src/util/Makefile b/src/util/Makefile index 86eadede21..30abb0b803 100644 --- a/src/util/Makefile +++ b/src/util/Makefile @@ -11,12 +11,11 @@ include ../config/Makefile.${SYS_NAME} CFLAGS = ${OPTMZ} -I$(SRCDIR)include ${XCFLAGS} LDFLAGS = ${OPTMZ} ${XLDFLAGS} -INSTALL = ${SRCDIR}bin/install objects = assert.o base64.o casestrcpy.o ktime.o volparse.o hostparse.o \ hputil.o kreltime.o isathing.o get_krbrlm.o uuid.o serverLog.o \ dirpath.o fileutil.o netutils.o flipbase64.o \ - afs_atomlist.o afs_lhash.o snprintf.o + afs_atomlist.o afs_lhash.o snprintf.o ${REGEX_OBJ} headers = assert.h potpourri.h itc.h errors.h afsutil.h pthread_glock.h \ dirpath.h afs_atomlist.h afs_lhash.h @@ -61,10 +60,10 @@ ukinstall webinstall: install0 ${DESTDIR}include/afs/dirpath.h: dirpath.h ${INSTALL} dirpath.h ${DESTDIR}include/afs - + ${DESTDIR}include/afs/pthread_nosigs.h: pthread_nosigs.h ${INSTALL} pthread_nosigs.h ${DESTDIR}include/afs - + doc: echo no documents in this directory diff --git a/src/util/dirpath.c b/src/util/dirpath.c index 78613df49e..1f8b14da19 100644 --- a/src/util/dirpath.c +++ b/src/util/dirpath.c @@ -26,6 +26,9 @@ static pthread_once_t dirInit_once = PTHREAD_ONCE_INIT; #include #include #endif +#ifdef AFS_DARWIN_ENV +#include +#endif /* local vars */ /* static storage for path strings */ @@ -153,6 +156,11 @@ static void initDirPathArray(void) strcpy(afsSrvDirPath, AFSDIR_CANONICAL_SERVER_AFS_DIRPATH); /* setup the root client directory path */ +#ifdef AFS_DARWIN_ENV + if (access(AFSDIR_ALTERNATE_CLIENT_VICE_DIRPATH, F_OK) == 0) + strcpy(afsClntDirPath, AFSDIR_ALTERNATE_CLIENT_VICE_DIRPATH); + else +#endif strcpy(afsClntDirPath, AFSDIR_CANONICAL_CLIENT_VICE_DIRPATH); /* setup top level dirpath; valid for both server and client */ diff --git a/src/util/dirpath.h b/src/util/dirpath.h index 7829abddc8..76249bd97f 100644 --- a/src/util/dirpath.h +++ b/src/util/dirpath.h @@ -160,6 +160,9 @@ ConstructLocalLogPath(const char *cpath, #define AFSDIR_CANONICAL_USR_DIRPATH "/usr" #define AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/usr/afs" #define AFSDIR_CANONICAL_CLIENT_VICE_DIRPATH "/usr/vice" +#ifdef AFS_DARWIN_ENV +#define AFSDIR_ALTERNATE_CLIENT_VICE_DIRPATH "/var/db/openafs" +#endif #define AFSDIR_CANONICAL_SERVER_BIN_DIRPATH \ AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/" AFSDIR_BIN_DIR diff --git a/src/util/netutils.c b/src/util/netutils.c index c10a4e1c01..9d29757cc1 100644 --- a/src/util/netutils.c +++ b/src/util/netutils.c @@ -14,14 +14,14 @@ #include #include -#include -#include #ifdef KERNEL #include "../afs/param.h" #include "../afs/sysincludes.h" #include "../afs/afsincludes.h" #else #include +#include +#include #endif #include "assert.h" diff --git a/src/venus/Makefile b/src/venus/Makefile index 326a5913a9..c7d7a9d25d 100644 --- a/src/venus/Makefile +++ b/src/venus/Makefile @@ -10,8 +10,7 @@ COMPONENT=venus LINUX_VERS=dummy include ../config/Makefile.${SYS_NAME} -INSTALL = ${DESTDIR}bin/install -INSTALLex = ${DESTDIR}bin/install -m 755 +INSTALLex = ${INSTALL} -m 755 CCXPG2= /usr/xpg2bin/cc CFLAGS = ${OPTMZ} -I${DESTDIR}include -I${SRCDIR}include ${XCFLAGS} diff --git a/src/venus/fstrace.c b/src/venus/fstrace.c index 08c9835599..e7541e2fb8 100644 --- a/src/venus/fstrace.c +++ b/src/venus/fstrace.c @@ -13,7 +13,7 @@ #include #include #include -#if !defined(AFS_SUN3_ENV) && !defined(sys_vax_ul43) +#if !defined(AFS_SUN3_ENV) && !defined(sys_vax_ul43) && !defined(AFS_DARWIN_ENV) #include /*#ifdef AFS_AIX_ENV*/ #include diff --git a/src/venus/kdump.c b/src/venus/kdump.c index e9db1db71f..72099d8ad8 100644 --- a/src/venus/kdump.c +++ b/src/venus/kdump.c @@ -195,6 +195,13 @@ typedef struct adaptive_mutex2 adaptive_mutex2_t; #include #include #else /* AFS_MACH_ENV */ +#ifdef AFS_DARWIN_ENV +#include +#include +#include +#include +#include +#else #include "sys/vfs.h" #ifdef AFS_LINUX20_ENV #define UIO_MAXIOV 1 /* don't care */ @@ -280,6 +287,7 @@ typedef enum _spustate { /* FROM /etc/conf/h/_types.h */ #endif #endif #endif +#endif #endif /* AFS_MACH_ENV */ #include #endif @@ -930,6 +938,7 @@ int cnt, size; #endif /*AFS_KDUMP_LIB */ #endif +#ifndef AFS_DARWIN_ENV int findsym( char *sname, off_t *offset ) { @@ -994,12 +1003,16 @@ findsym( char *sname, off_t *offset ) } #endif /* defined(AFS_SUN5_ENV) */ } +#endif #define CBHTSIZE 128 kdump() { int cell, cnt, cnt1; +#ifdef AFS_DARWIN_ENV + printf("Kdump not supported\n"); +#else #ifndef AFS_KDUMP_LIB kmem = opencore(core); @@ -1129,9 +1142,11 @@ kdump() if (Dgcpags || Dall) { print_gcpags(1); } +#endif return 0; } +#ifndef AFS_DARWIN_ENV int Sum_cellnames=0, Sum_userstp=0, Sum_volnames=0, Sum_exps=0, Sum_nfssysnames=0; int Sum_vcachemvids=0, Sum_vcachelinkData=0, Sum_vcacheacc=0, Sum_vcachelocks=0; @@ -4016,6 +4031,7 @@ void print_cmstats(cmp) #endif } +#endif #if 0 #define OffsetOf(s,mem) ((long)(&(((s *)0)->mem))) #define SizeOf(s,mem) ((long)sizeof(((s *)0)->mem)) diff --git a/src/venus/up.c b/src/venus/up.c index f1bc646ec6..9b0b614404 100644 --- a/src/venus/up.c +++ b/src/venus/up.c @@ -42,7 +42,7 @@ extern char *index (); extern char *rindex (); -#ifndef AFS_LINUX20_ENV +#if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) extern sys_nerr; extern char *sys_errlist[]; #endif diff --git a/src/vfsck/Makefile b/src/vfsck/Makefile index a040798baf..fd97f8213d 100644 --- a/src/vfsck/Makefile +++ b/src/vfsck/Makefile @@ -19,7 +19,6 @@ COMPONENT=vfsck include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install CFLAGS= ${DBUG} -w -I${SRCDIR}include ${XCFLAGS} LIBC= /lib/libc.a SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \ @@ -44,7 +43,7 @@ ${OBJS}: ${SRCS} ${CC} -o vfsck -I/usr/old/usr/include ${DBUG} -w -I${SRCDIR}include ${SRCS} ${NON_SHARED} +DA1.0 -Wl,-a,archive -D_FILE64 \ ;; \ hp?00_ux101 | hp_ux10? ) \ - ${CC} -o vfsck ${CFLAGS} ${SRCS} ${NON_SHARED} ${XLIBS} -D_FILE64\ + ${CC} -o vfsck ${CFLAGS} ${SRCS} ${NON_SHARED} ${XLIBS} -D_FILE64\ ;; \ * ) \ ${CC} -o vfsck ${CFLAGS} ${SRCS} ${NON_SHARED} ${XLIBS}\ diff --git a/src/viced/Makefile b/src/viced/Makefile index e17d1d34f9..d9f42f7e06 100644 --- a/src/viced/Makefile +++ b/src/viced/Makefile @@ -10,7 +10,6 @@ COMPONENT=viced include ../config/Makefile.${SYS_NAME} DBUG = -g -INSTALL = ${SRCDIR}bin/install CFLAGS = -DNINTERFACE ${DBUG} -I. -I${SRCDIR}include -I${SRCDIR}include/afs \ ${XCFLAGS} ${DBG_DEFS} -DRXDEBUG LDFLAGS = ${DBUG} ${XLDFLAGS} @@ -70,7 +69,7 @@ viced.o: AFS_component_version_number.o check_sysid: check_sysid.c ${CC} ${CFLAGS} -IDEST/include -o check_sysid check_sysid.c -fileserver: callback_clean1 viced.o ${objects} ${headers} ${LIBS} +fileserver: viced.o ${objects} ${headers} ${LIBS} set -x; \ case ${SYS_NAME} in \ *linux*) \ @@ -84,10 +83,17 @@ fileserver: callback_clean1 viced.o ${objects} ${headers} ${LIBS} ${auditlib} ${LIBS} ${XLIBS} ;; \ esac -fsprobe: fsprobe.c AFS_component_version_number.c - ${CC} ${CFLAGS} -DINTERPRET_DUMP -o fsprobe fsprobe.c ${LIBS} ${XLIBS} -cbd: callback_clean2 callback.c AFS_component_version_number.c - ${CC} ${CFLAGS} -DINTERPRET_DUMP -o cbd callback.c ${LIBS} ${XLIBS} +fsprobe.o: fsprobe.c AFS_component_version_number.c + ${CC} ${CFLAGS} -DINTERPRET_DUMP -c fsprobe.c + +fsprobe: fsprobe.o + ${CC} ${CFLAGS} -o fsprobe fsprobe.o ${LIBS} ${XLIBS} + +cbd.o: callback.c AFS_component_version_number.c + ${CC} ${CFLAGS} -DINTERPRET_DUMP -c -o cbd.o callback.c + +cbd: cbd.o + ${CC} ${CFLAGS} -DINTERPRET_DUMP -o cbd cbd.o ${LIBS} ${XLIBS} lint: lint -uvn -I${SRCDIR}include viced.c afsfileprocs.c host.c physio.c callback.c ${SRCDIR}lib/afs/llib-lutil.ln @@ -106,13 +112,6 @@ install: all ${DESTDIR}root.server/usr/afs/bin/fileserver system: install -callback_clean1 callback_clean2: - case ${SYS_NAME} in \ - ncrx86_*) \ - ${RM} -f callback.o;\ - echo ${RM} callback.o;;\ - esac; - clean: rm -f *.o llib-lvice.ln fileserver core AFS_component_version_number.c diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index b3e232b086..75aadd9711 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -74,7 +74,7 @@ #include #include #include -#if ! defined(AFS_SGI_ENV) && ! defined(AFS_AIX32_ENV) && ! defined(AFS_NT40_ENV) && ! defined(AFS_LINUX20_ENV) +#if ! defined(AFS_SGI_ENV) && ! defined(AFS_AIX32_ENV) && ! defined(AFS_NT40_ENV) && ! defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) #include #endif #if !defined(AFS_NT40_ENV) @@ -85,7 +85,7 @@ #include #include #else -#if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) +#if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) #include #endif #endif diff --git a/src/vlserver/Makefile b/src/vlserver/Makefile index c1caf2326b..aefc0a786d 100644 --- a/src/vlserver/Makefile +++ b/src/vlserver/Makefile @@ -12,7 +12,6 @@ MKDIR_IF_NEEDED=[ -d $$1 ] || mkdir -p $$1 KERNELDIR=../libafs/ UKERNELDIR=../libuafs/ -INSTALL=${SRCDIR}bin/install COMPILE_ET = ${SRCDIR}bin/compile_et CFLAGS = ${DBUG} -I. -I.. -I${SRCDIR}include ${XCFLAGS} diff --git a/src/vol/Makefile b/src/vol/Makefile index 711de2b776..5c2d1791ca 100644 --- a/src/vol/Makefile +++ b/src/vol/Makefile @@ -11,7 +11,6 @@ include ../config/Makefile.${SYS_NAME} include ../config/Makefile.version INCDIRS= -I. -I${DESTDIR}include ${FSINCLUDES} -INSTALL = ${SRCDIR}bin/install LDFLAGS = ${OPTMZ} ${PROF} ${LDIRS} ${XLDFLAGS} LIBS= ${DESTDIR}lib/afs/libcmd.a vlib.a ${SRCDIR}lib/afs/util.a \ diff --git a/src/vol/devname.c b/src/vol/devname.c index 1dc4309112..6e020a133d 100644 --- a/src/vol/devname.c +++ b/src/vol/devname.c @@ -21,8 +21,13 @@ #ifdef AFS_SUN5_ENV #include #else +#ifdef AFS_DARWIN_ENV +#include +#include +#else #include #endif +#endif #else /* AFS_VFSINCL_ENV */ #if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX22_ENV) #include diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c index 8e9bf01a61..2ba70e7431 100644 --- a/src/vol/listinodes.c +++ b/src/vol/listinodes.c @@ -49,8 +49,14 @@ int *forcep, forceR; #ifdef AFS_SUN5_ENV #include #else +#ifdef AFS_DARWIN_ENV +#include +#include +#define itod ino_to_fsba +#else #include #endif +#endif #else /* AFS_VFSINCL_ENV */ #ifdef AFS_AIX_ENV #include @@ -65,8 +71,10 @@ int *forcep, forceR; #ifdef AFS_SUN5_ENV #include #else +#ifndef AFS_DARWIN_ENV #include #endif +#endif #else /* AFS_VFSINCL_ENV */ #ifdef AFS_DEC_ENV #include @@ -1243,7 +1251,7 @@ int ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, force if ( (super.fs.fs_magic != FS_MAGIC) || (super.fs.fs_ncg < 1) -#if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) +#if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || (super.fs.fs_cpg < 1) #else || (super.fs.fs_cpg < 1 || super.fs.fs_cpg > MAXCPG) @@ -1279,8 +1287,12 @@ int ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, force #else for (c = 0; c < super.fs.fs_ncg; c++) { daddr_t dblk1; -#ifdef AFS_SUN5_ENV +#if defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV) daddr_t f1; +#if defined(AFS_DARWIN_ENV) +#define offset_t off_t +#define llseek lseek +#endif offset_t off; #endif /* AFS_SUN5_ENV */ i = c*super.fs.fs_ipg; e = i+super.fs.fs_ipg; @@ -1288,7 +1300,7 @@ int ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, force dblk1 = fsbtodb(&super.fs, itod(&super.fs, i)); if (lseek(pfd, (off_t) ((off_t)dblk1 * DEV_BSIZE), L_SET) == -1) { #else -#ifdef AFS_SUN5_ENV +#if defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV) f1 = fsbtodb(&super.fs,itod(&super.fs,i)); off = (offset_t)f1 << DEV_BSHIFT; if (llseek(pfd, off, L_SET) == -1) { @@ -1445,6 +1457,11 @@ out1: #endif /* !AFS_SGI_ENV */ #endif /* !AFS_AIX31_ENV */ +#ifdef AFS_DARWIN_ENV +#undef dbtob +#define dbtob(db) ((unsigned)(db) << DEV_BSHIFT) +#endif + int bread(fd, buf, blk, size) int fd; char *buf; diff --git a/src/vol/partition.c b/src/vol/partition.c index 2a0d9603ec..d773d2ba14 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -28,6 +28,9 @@ #if AFS_HAVE_STATVFS #include #endif /* AFS_HAVE_STATVFS */ +#ifdef AFS_DARWIN_ENV +#include +#endif #if !defined(AFS_SGI_ENV) #ifdef AFS_OSF_ENV @@ -39,10 +42,15 @@ #ifdef AFS_SUN5_ENV #include #else +#ifdef AFS_DARWIN_ENV +#include +#include +#else #include #endif +#endif #else /* AFS_VFSINCL_ENV */ -#if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX22_ENV) +#if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) #include #endif #endif /* AFS_VFSINCL_ENV */ @@ -409,7 +417,7 @@ int VAttachPartitions(void) } #endif -#ifdef AFS_DUX40_ENV +#if defined(AFS_DUX40_ENV) || defined(AFS_DARWIN_ENV) int VAttachPartitions(void) { int errors = 0; diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 1d8a25d14f..500eeb4c5e 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -120,8 +120,13 @@ Vnodes with 0 inode pointers in RW volumes are now deleted. #ifdef AFS_SUN5_ENV #include #else +#ifdef AFS_DARWIN_ENV +#include +#include +#else #include #endif +#endif #else /* AFS_VFSINCL_ENV */ #ifdef AFS_OSF_ENV #include @@ -745,7 +750,11 @@ void ObtainSalvageLock(void) #else salvageLock = open(AFSDIR_SERVER_SLVGLOCK_FILEPATH, O_CREAT|O_RDWR, 0666); assert(salvageLock >= 0); +#ifdef AFS_DARWIN_ENV + if (flock(salvageLock, LOCK_EX) == -1) { +#else if (lockf(salvageLock, F_LOCK, 0) == -1) { +#endif fprintf(stderr, "salvager: There appears to be another salvager running! Aborted.\n"); Exit(1); diff --git a/src/vol/volume.c b/src/vol/volume.c index 87398c4b91..fc452014aa 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -33,8 +33,13 @@ #ifdef AFS_SUN5_ENV #include #else +#ifdef AFS_DARWIN_ENV +#include +#include +#else #include #endif +#endif #else /* AFS_VFSINCL_ENV */ #if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX20_ENV) #include diff --git a/src/volser/Makefile b/src/volser/Makefile index 95b909c6aa..fb63eb63a8 100644 --- a/src/volser/Makefile +++ b/src/volser/Makefile @@ -9,8 +9,6 @@ SHELL=/bin/sh COMPONENT=volser include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install - COMPILE_ET=${SRCDIR}bin/compile_et CFLAGS=${DBG} ${OPTMZ} -I${SRCDIR}include ${XCFLAGS} ${DBG_DEFS} LDFLAGS=${DBG} ${OPTMZ} ${XLDFLAGS} diff --git a/src/xstat/Makefile b/src/xstat/Makefile index d481018fd5..5d487b6a86 100644 --- a/src/xstat/Makefile +++ b/src/xstat/Makefile @@ -10,7 +10,6 @@ SHELL = /bin/sh COMPONENT=xstat include ../config/Makefile.${SYS_NAME} -INSTALL=${SRCDIR}bin/install CFLAGS= ${DBUG} -I. \ -I${SRCDIR}include \