Whamcloud - gitweb
LU-2675 build: remove Darwin "support" 23/11423/2
authorJohn L. Hammond <john.hammond@intel.com>
Tue, 12 Aug 2014 14:11:29 +0000 (09:11 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 15 Aug 2014 16:26:33 +0000 (16:26 +0000)
Remove the Darwin "support" code. It's not maintained or used.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I56ee7788d55465495815c4f8655e986dd5a51d00
Reviewed-on: http://review.whamcloud.com/11423
Reviewed-by: frank zago <fzago@cray.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Jenkins
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
126 files changed:
build/doxyfile.api
build/doxyfile.ref
build/osxpack/License.txt [deleted file]
build/osxpack/ReadMe.txt [deleted file]
build/osxpack/Welcome.txt [deleted file]
build/osxpack/packlustre.sh [deleted file]
build/osxpack/postflight [deleted file]
build/osxpack/preflight [deleted file]
build/osxpack/sysctl.conf [deleted file]
build/osxpack/uninstall_lustre [deleted file]
build/osxpack/unload_lustre [deleted file]
config/Makefile.am
config/lustre-build-darwin.m4 [deleted file]
config/lustre-build.m4
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/Makefile.am
libcfs/include/libcfs/darwin/.gitignore [deleted file]
libcfs/include/libcfs/darwin/Makefile.am [deleted file]
libcfs/include/libcfs/darwin/darwin-fs.h [deleted file]
libcfs/include/libcfs/darwin/darwin-lock.h [deleted file]
libcfs/include/libcfs/darwin/darwin-mem.h [deleted file]
libcfs/include/libcfs/darwin/darwin-prim.h [deleted file]
libcfs/include/libcfs/darwin/darwin-sync.h [deleted file]
libcfs/include/libcfs/darwin/darwin-tcpip.h [deleted file]
libcfs/include/libcfs/darwin/darwin-time.h [deleted file]
libcfs/include/libcfs/darwin/darwin-types.h [deleted file]
libcfs/include/libcfs/darwin/darwin-utils.h [deleted file]
libcfs/include/libcfs/darwin/kp30.h [deleted file]
libcfs/include/libcfs/darwin/libcfs.h [deleted file]
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_debug.h
libcfs/include/libcfs/posix/libcfs.h
libcfs/include/libcfs/util/platform.h
libcfs/libcfs/Info.plist [deleted file]
libcfs/libcfs/autoMakefile.am
libcfs/libcfs/darwin/.gitignore [deleted file]
libcfs/libcfs/darwin/Makefile.am [deleted file]
libcfs/libcfs/darwin/darwin-curproc.c [deleted file]
libcfs/libcfs/darwin/darwin-debug.c [deleted file]
libcfs/libcfs/darwin/darwin-fs.c [deleted file]
libcfs/libcfs/darwin/darwin-internal.h [deleted file]
libcfs/libcfs/darwin/darwin-mem.c [deleted file]
libcfs/libcfs/darwin/darwin-module.c [deleted file]
libcfs/libcfs/darwin/darwin-prim.c [deleted file]
libcfs/libcfs/darwin/darwin-proc.c [deleted file]
libcfs/libcfs/darwin/darwin-sync.c [deleted file]
libcfs/libcfs/darwin/darwin-tcpip.c [deleted file]
libcfs/libcfs/darwin/darwin-tracefile.c [deleted file]
libcfs/libcfs/darwin/darwin-utils.c [deleted file]
libcfs/libcfs/libcfs.xcode/project.pbxproj [deleted file]
libcfs/libcfs/user-mem.c
libcfs/libcfs/user-tcpip.c
lnet/autoconf/lustre-lnet.m4
lnet/include/lnet/Makefile.am
lnet/include/lnet/api-support.h
lnet/include/lnet/darwin/.gitignore [deleted file]
lnet/include/lnet/darwin/Makefile.am [deleted file]
lnet/include/lnet/darwin/api-support.h [deleted file]
lnet/include/lnet/darwin/lib-lnet.h [deleted file]
lnet/include/lnet/darwin/lib-types.h [deleted file]
lnet/include/lnet/darwin/lnet.h [deleted file]
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-types.h
lnet/include/lnet/lnet.h
lnet/klnds/socklnd/Info.plist [deleted file]
lnet/klnds/socklnd/autoMakefile.am
lnet/klnds/socklnd/ksocklnd.xcode/project.pbxproj [deleted file]
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lnet/klnds/socklnd/socklnd_lib-darwin.c [deleted file]
lnet/klnds/socklnd/socklnd_lib-darwin.h [deleted file]
lnet/klnds/socklnd/socklnd_modparams.c
lnet/lnet/Info.plist [deleted file]
lnet/lnet/autoMakefile.am
lnet/selftest/autoMakefile.am
lnet/utils/debug.c
lustre/autoconf/lustre-core.m4
lustre/fid/autoMakefile.am
lustre/include/Makefile.am
lustre/include/darwin/.gitignore [deleted file]
lustre/include/darwin/Makefile.am [deleted file]
lustre/include/darwin/lprocfs_status.h [deleted file]
lustre/include/darwin/lustre_compat.h [deleted file]
lustre/include/darwin/lustre_debug.h [deleted file]
lustre/include/darwin/lustre_dlm.h [deleted file]
lustre/include/darwin/lustre_handles.h [deleted file]
lustre/include/darwin/lustre_lib.h [deleted file]
lustre/include/darwin/lustre_lite.h [deleted file]
lustre/include/darwin/lustre_log.h [deleted file]
lustre/include/darwin/lustre_mds.h [deleted file]
lustre/include/darwin/lustre_net.h [deleted file]
lustre/include/darwin/lustre_quota.h [deleted file]
lustre/include/darwin/lustre_user.h [deleted file]
lustre/include/darwin/lvfs.h [deleted file]
lustre/include/darwin/obd.h [deleted file]
lustre/include/darwin/obd_cksum.h [deleted file]
lustre/include/darwin/obd_class.h [deleted file]
lustre/include/darwin/obd_support.h [deleted file]
lustre/include/lprocfs_status.h
lustre/include/lustre/lustre_user.h
lustre/include/lustre_acl.h
lustre/include/lustre_debug.h
lustre/include/lustre_dlm.h
lustre/include/lustre_handles.h
lustre/include/lustre_lib.h
lustre/include/lustre_lite.h
lustre/include/lustre_log.h
lustre/include/lustre_net.h
lustre/include/lustre_quota.h
lustre/include/lvfs.h
lustre/include/obd.h
lustre/include/obd_class.h
lustre/include/obd_support.h
lustre/lov/autoMakefile.am
lustre/obdclass/Info.plist [deleted file]
lustre/obdclass/autoMakefile.am
lustre/obdclass/darwin/.gitignore [deleted file]
lustre/obdclass/darwin/Makefile.am [deleted file]
lustre/obdclass/darwin/darwin-module.c [deleted file]
lustre/obdclass/darwin/darwin-sysctl.c [deleted file]
lustre/obdecho/Info.plist [deleted file]
lustre/obdecho/autoMakefile.am
lustre/osc/Info.plist [deleted file]
lustre/osc/autoMakefile.am
lustre/ptlrpc/Info.plist [deleted file]
lustre/ptlrpc/autoMakefile.am

index 9df11fc..86f6b47 100644 (file)
@@ -112,7 +112,7 @@ EXCLUDE                = lnet/klnds/ciblnd/ \
                         lnet/klnds/ralnd/ \
                         lnet/klnds/viblnd/
 EXCLUDE_SYMLINKS       = NO
-EXCLUDE_PATTERNS       = */darwin/*
+EXCLUDE_PATTERNS       =
 EXCLUDE_SYMBOLS        = EXPORT_SYMBOL*
 EXAMPLE_PATH           =
 EXAMPLE_PATTERNS       = *
index 4b0602a..70135dd 100644 (file)
@@ -112,7 +112,7 @@ EXCLUDE                = lnet/klnds/ciblnd/ \
                         lnet/klnds/ralnd/ \
                         lnet/klnds/viblnd/
 EXCLUDE_SYMLINKS       = NO
-EXCLUDE_PATTERNS       = */darwin/*
+EXCLUDE_PATTERNS       =
 EXCLUDE_SYMBOLS        = EXPORT_SYMBOL*
 EXAMPLE_PATH           =
 EXAMPLE_PATTERNS       = *
diff --git a/build/osxpack/License.txt b/build/osxpack/License.txt
deleted file mode 100644 (file)
index 3b8ff2b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-Lustre(R) for OS X
-
-This software is a proprietary product of Sun Microsystems, Inc. which owns all intellectual property rights to this software.
-
-You must obtain a license from Sun Microsystems, Inc. and agree to its terms before using this software.  Contact http://www.lustre.org/
-
-This software is beta software modifying and running kernel code.  Back up all systems before use.  This software is provided to you without any warranty, without even the implied warranty of merchantability, or fitness for a particular purpose.  Consult your license agreement for more details.
-
diff --git a/build/osxpack/ReadMe.txt b/build/osxpack/ReadMe.txt
deleted file mode 100644 (file)
index 06555ba..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-This is release 0.9.2 Beta of the Lustre OS X client.
-
-This is not a production quality release, so use it with care, and on non-production systems.  The installation will overwrite the OS X kernel on your system.  Un-installing this package will restore your current kernel.
-
diff --git a/build/osxpack/Welcome.txt b/build/osxpack/Welcome.txt
deleted file mode 100644 (file)
index f6fa0ce..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Welcome to the Lustre OS X client installation  
-
-You will be guided through the steps necessary to install this software.  During installation you will be required to reboot your Mac, so make sure you have saved all your data and closed applications before continuing the installation.
-
diff --git a/build/osxpack/packlustre.sh b/build/osxpack/packlustre.sh
deleted file mode 100755 (executable)
index 7392c0e..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-#
-# This script is used to create package directory tree used
-# by PackageMaker in OS X.
-
-PREFIX=$1
-STAGE=$2
-
-RESOURCE=$PWD/build/osxpack
-if ! [ -d $RESOURCE ]; then
-       echo "Your tree seems to be missing $RESOURCE." >&2
-fi
-
-if [ "x$PREFIX" == "x" ]; then
-       PREFIX=/home/cfs/package
-fi
-
-if [ "x$STAGE" == "x" ]; then
-       STAGE=/System/Library/Extensions
-fi
-
-if ! [ -d $STAGE/llite.kext ]; then
-       echo "Sorry, cannot find stage files for package"
-       exit 1
-fi
-
-if ! [ -d $PREFIX ]; then
-       mkdir -p $PREFIX
-fi
-
-if ! [ -d $PREFIX/Install_resources ]; then
-       mkdir -p $PREFIX/Install_resources
-fi
-
-if ! [ -d $PREFIX/Package_contents ]; then
-       mkdir -p $PREFIX/Package_contents
-fi
-
-CONTENTS=$PREFIX/Package_contents
-
-if ! [ -d $CONTENTS/System/Libraray/Extensions ]; then
-       mkdir -p $CONTENTS/System/Library/Extensions
-fi
-# IMPORTANT
-# /etc is symlink of /private/etc in OS X, if we 
-# just use $CONTENTS/etc, it will OVERWRITE /etc in
-# installation target, that means all files in /etc 
-# will be lost, the system will be corrupted.
-if ! [ -d $CONTENTS/private/etc ]; then
-       mkdir -p $CONTENTS/private/etc
-fi
-
-if ! [ -d $CONTENTS/sbin ]; then
-       mkdir -p $CONTENTS/sbin
-fi
-
-cp -f $RESOURCE/*.txt $PREFIX/Install_resources/
-cp -f $RESOURCE/*flight $PREFIX/Install_resources/
-cp -f $RESOURCE/sysctl.conf $CONTENTS/private/etc
-cp -f $RESOURCE/uninstall_lustre $CONTENTS/sbin
-cp -f $RESOURCE/unload_lustre $CONTENTS/sbin
-cp -rf $STAGE/llite.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/mdc.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/lov.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/osc.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/ptlrpc.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/ptlrpcs.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/obdclass.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/lvfs.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/ksocknal.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/portals.kext $CONTENTS/System/Library/Extensions
-cp -rf $STAGE/libcfs.kext $CONTENTS/System/Library/Extensions
diff --git a/build/osxpack/postflight b/build/osxpack/postflight
deleted file mode 100755 (executable)
index a4e6633..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-/usr/sbin/nvram boot-args="debug=0xe zsize=256"
-
-# Delete cache files
-if [ -f /System/Library/Extensions.kextcache ]; then
-       rm -f /System/Library/Extensions.kextcache
-fi
-
-if [ -d /System/Library/Caches/com.apple.kernelcaches ]; then
-       rm -rf /System/Library/Caches/com.apple.kernelcaches
-fi
-
-touch /System/Library
diff --git a/build/osxpack/preflight b/build/osxpack/preflight
deleted file mode 100755 (executable)
index 582aea3..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-
-date=`date +%Y%m%d_%H%M`
-
-backpath=/System/LustreBackup
-if ! [ -d $backpath ]; then
-       mkdir -p $backpath
-fi
-
-backdir=${backpath}/SystemBackup
-
-# If system has been backed up, just exit
-if [ -d ${backdir} ]; then
-       exit 0
-fi
-
-mkdir $backdir
-chmod 700 $backdir
-
-# create backup directory
-mkdir -p $backdir/System/Library/Frameworks
-mkdir -p $backdir/System/Library/Extensions
-mkdir -p $backdir/usr/lib
-mkdir -p $backdir/usr/include
-mkdir -p $backdir/private/etc
-
-# backup the old system
-cp /mach_kernel $backdir/
-cp -rf /System/Library/Frameworks/IOKit.framework $backdir/System/Library/Frameworks/
-cp -rf /System/Library/Frameworks/Kernel.framework $backdir/System/Library/Frameworks/
-cp -rf /System/Library/Frameworks/System.framework $backdir/System/Library/Frameworks/
-cp -rf /System/Library/Extensions/System.kext $backdir/System/Library/Extensions/
-cp -rf /usr/include/bsm $backdir/usr/include/bsm
-cp -rf /usr/include/default_pager $backdir/usr/include/default_pager
-cp -rf /usr/include/dev $backdir/usr/include/dev
-cp -rf /usr/include/device $backdir/usr/include/device
-cp -rf /usr/include/drivers $backdir/usr/include/drivers
-cp -rf /usr/include/hfs $backdir/usr/include/hfs
-cp -rf /usr/include/isofs $backdir/usr/include/isofs
-cp -rf /usr/include/libkern $backdir/usr/include/libkern
-cp -rf /usr/include/mach $backdir/usr/include/mach
-cp -rf /usr/include/mach_debug $backdir/usr/include/mach_debug
-cp -rf /usr/include/machine $backdir/usr/include/machine
-cp -rf /usr/include/miscfs $backdir/usr/include/miscfs
-cp -rf /usr/include/net $backdir/usr/include/net
-cp -rf /usr/include/netat $backdir/usr/include/netat
-cp -rf /usr/include/netinet $backdir/usr/include/netinet
-cp -rf /usr/include/netinet6 $backdir/usr/include/netinet6
-cp -rf /usr/include/netkey $backdir/usr/include/netkey
-cp -rf /usr/include/nfs $backdir/usr/include/nfs
-cp -rf /usr/include/pexpert $backdir/usr/include/pexpert
-cp -rf /usr/include/ppc $backdir/usr/include/ppc
-cp -rf /usr/include/profile $backdir/usr/include/profile
-cp -rf /usr/include/sys $backdir/usr/include/sys
-cp -rf /usr/include/ufs $backdir/usr/include/ufs
-cp -rf /usr/include/vfs $backdir/usr/include/vfs
-cp -f /usr/lib/libIOKit.A.dylib $backdir/usr/lib/libIOKit.A.dylib
-cp -f /usr/lib/libIOKit.dylib $backdir/usr/lib/libIOKit.dylib
-cp -f /usr/lib/libkmod.a $backdir/usr/lib/libkmod.a
-cp -f /usr/lib/libkmodc++.a $backdir/usr/lib/libkmodc++.a
-if [ -f /private/etc/sysctl.conf ]; then
-       cp -f /private/etc/sysctl.conf $backdir/private/etc/sysctl.conf
-fi
-
-# record sysctem backup path of current installation 
-# echo $backdir >> $backpath/lustre-current
-# echo $date > $backdir/install_date
diff --git a/build/osxpack/sysctl.conf b/build/osxpack/sysctl.conf
deleted file mode 100644 (file)
index f8d2cc2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-# nmbclusters can not be modified by sysctl(it's read only)
-# so we have to change it in kernel patch
-## kern.ipc.nmbclusters=32768
-
-# Keep a long enough reassembly queue. 
-net.inet.tcp.reass.maxsegments=4096
-
-# max permited sockbuf
-kern.ipc.maxsockbuf=8388608
-
-# XXX 
-net.inet.tcp.sendspace=3217968
-net.inet.tcp.recvspace=3217968
-
-kern.maxvnodes=65536
diff --git a/build/osxpack/uninstall_lustre b/build/osxpack/uninstall_lustre
deleted file mode 100755 (executable)
index d2624d2..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/sh
-#
-# It's the uninstall programe of lustre
-
-mount | grep lustre > /dev/null
-if [ $? -eq 0 ]; then
-        echo "Please unmount Lustre before uninstall Lustre."
-        exit 1
-fi
-
-echo "unloading modules......"
-/sbin/unload_lustre 2 > /dev/null
-
-backdir=/System/LustreBackup/SystemBackup
-if ! [ -d $backdir ]; then
-       echo "No backup directory is found, you have not installed lustre or uninstall failed!"
-       exit 1
-fi
-
-# if ! [ -f $backpath/lustre-current ]; then
-#      echo "No version information of Lustre installation, you have uninstalled or uninstall failed!"
-#      exit 2
-# fi
-#
-# get information of the the backup system
-#
-# backdir=`tail -1 $backpath/lustre-current`
-# if ! [ -d $backdir ]; then
-#      echo "Miss backup directory, uninstall failed!"
-#      exit 3
-# fi
-
-# recover the old system
-echo "recover orignal kernel......"
-cp -f $backdir/mach_kernel /mach_kernel
-echo "recover orignal frameworks......"
-cp -rf $backdir/System/Library/Frameworks/IOKit.framework /System/Library/Frameworks/
-cp -rf $backdir/System/Library/Frameworks/Kernel.framework /System/Library/Frameworks/
-cp -rf $backdir/System/Library/Frameworks/System.framework /System/Library/Frameworks/
-echo "recover orignal kernel extensions......"
-cp -rf $backdir/System/Library/Extensions/System.kext /System/Library/Extensions/
-echo "recover orignal system headers......"
-cp -rf $backdir/usr/include/bsm /usr/include/bsm
-cp -rf $backdir/usr/include/default_pager /usr/include/default_pager
-cp -rf $backdir/usr/include/dev /usr/include/dev
-cp -rf $backdir/usr/include/device /usr/include/device
-cp -rf $backdir/usr/include/drivers /usr/include/drivers
-cp -rf $backdir/usr/include/hfs /usr/include/hfs
-cp -rf $backdir/usr/include/isofs /usr/include/isofs
-cp -rf $backdir/usr/include/libkern /usr/include/libkern
-cp -rf $backdir/usr/include/mach /usr/include/mach
-cp -rf $backdir/usr/include/mach_debug /usr/include/mach_debug
-cp -rf $backdir/usr/include/machine /usr/include/machine
-cp -rf $backdir/usr/include/miscfs /usr/include/miscfs
-cp -rf $backdir/usr/include/net /usr/include/net
-cp -rf $backdir/usr/include/netat /usr/include/netat
-cp -rf $backdir/usr/include/netinet /usr/include/netinet
-cp -rf $backdir/usr/include/netinet6 /usr/include/netinet6
-cp -rf $backdir/usr/include/netkey /usr/include/netkey
-cp -rf $backdir/usr/include/nfs /usr/include/nfs
-cp -rf $backdir/usr/include/pexpert /usr/include/pexpert
-cp -rf $backdir/usr/include/ppc /usr/include/ppc
-cp -rf $backdir/usr/include/profile /usr/include/profile
-cp -rf $backdir/usr/include/sys /usr/include/sys
-cp -rf $backdir/usr/include/ufs /usr/include/ufs
-cp -rf $backdir/usr/include/vfs /usr/include/vfs
-echo "recover orignal system libraries......"
-cp -f $backdir/usr/lib/libIOKit.A.dylib /usr/lib/libIOKit.A.dylib
-cp -f $backdir/usr/lib/libIOKit.dylib /usr/lib/libIOKit.dylib
-cp -f $backdir/usr/lib/libkmod.a /usr/lib/libkmod.a
-cp -f $backdir/usr/lib/libkmodc++.a /usr/lib/libkmodc++.a
-if [ -f $backdir/private/etc/sysctl.conf ]; then
-       cp -f $backdir/private/etc/sysctl.conf /private/etc/sysctl.conf
-else
-       rm -f /private/etc/sysctl.conf
-fi
-
-# 
-# cp $backpath/lustre-current /tmp/lustre-v
-# count=`grep "SystemBackup" /tmp/lustre-v|wc -l`
-# count=`expr $count - 1`
-# if [ $count -gt 0 ]; then
-#      head -$count /tmp/lustre-v > $backpath/lustre-current
-# else
-#      # The file should be empty now, it's the last uninstall
-#      rm -f $backpath/lustre-current
-# fi
-# rm -f /tmp/lustre-v
-
-# remove unused files
-echo "uninstall lustre modules and utilities......"
-rm -rf $backdir
-rm -f /sbin/lctl
-rm -f /sbin/mount_lustre
-rm -f /sbin/unload_lustre
-rm -rf /System/Library/Extensions/libcfs.kext
-rm -rf /System/Library/Extensions/portals.kext
-rm -rf /System/Library/Extensions/ksocknal.kext
-rm -rf /System/Library/Extensions/lvfs.kext
-rm -rf /System/Library/Extensions/obdclass.kext
-rm -rf /System/Library/Extensions/ptlrpc.kext
-rm -rf /System/Library/Extensions/ptlrpcs.kext
-rm -rf /System/Library/Extensions/osc.kext
-rm -rf /System/Library/Extensions/lov.kext
-rm -rf /System/Library/Extensions/obdecho.kext
-rm -rf /System/Library/Extensions/mdc.kext
-rm -rf /System/Library/Extensions/llite.kext
-
-# disable kernel cache by touch /System/Library
-touch /System/Library
-echo "Uninstall Lustre successfully, please reboot your computer!"
diff --git a/build/osxpack/unload_lustre b/build/osxpack/unload_lustre
deleted file mode 100755 (executable)
index 54404c1..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-mount | grep lustre > /dev/null
-if [ $? -eq 0 ]; then
-       echo "Please unmount lustre before unload modules."
-       exit 1
-fi
-kextunload /System/Library/Extensions/llite.kext
-kextunload /System/Library/Extensions/mdc.kext
-kextunload /System/Library/Extensions/lov.kext
-kextunload /System/Library/Extensions/osc.kext
-kextunload /System/Library/Extensions/ptlrpc.kext
-kextunload /System/Library/Extensions/ptlrpcs.kext
-kextunload /System/Library/Extensions/obdclass.kext
-kextunload /System/Library/Extensions/lvfs.kext
-kextunload /System/Library/Extensions/ksocknal.kext
-kextunload /System/Library/Extensions/portals.kext
-kextunload /System/Library/Extensions/libcfs.kext
index 8822fe2..63804c6 100644 (file)
@@ -1,2 +1,2 @@
-EXTRA_DIST  = lustre-build.m4 lustre-build-linux.m4 lustre-build-darwin.m4
+EXTRA_DIST  = lustre-build.m4 lustre-build-linux.m4
 EXTRA_DIST += lustre-build-ldiskfs.m4 lustre-build-zfs.m4
diff --git a/config/lustre-build-darwin.m4 b/config/lustre-build-darwin.m4
deleted file mode 100644 (file)
index eeb9393..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-#
-# LB_DARWIN_CHECK_FUNCS
-#
-# check for functions in the darwin kernel
-# Note that this is broken for cross compiling
-#
-AC_DEFUN([LB_DARWIN_CHECK_FUNCS],
-[AC_FOREACH([AC_Func], [$1],
-  [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func),
-               [Define to 1 if you have the `]AC_Func[' function.])])dnl
-for ac_func in $1
-do
-AC_MSG_CHECKING([for $1])
-AS_IF([AC_TRY_COMMAND(nm /mach | grep "[$1]" >/dev/null 2>/dev/null)],[
-       AC_MSG_RESULT([yes])
-       AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2
-],[
-       AC_MSG_RESULT([no]) $3
-])
-done
-])
-
-#
-# LB_DARWIN_CONDITIONALS
-#
-# AM_CONDITIONALs for darwin
-#
-AC_DEFUN([LB_DARWIN_CONDITIONALS],
-[
-])
-
-#
-# LB_PROG_DARWIN
-#
-# darwin tests
-#
-AC_DEFUN([LB_PROG_DARWIN],
-[kernel_framework="/System/Library/Frameworks/Kernel.framework"
-#
-# FIXME: there should be a better way to get these than hard coding them
-#
-case $target_cpu in 
-       powerpc*)
-               EXTRA_KCFLAGS="$EXTRA_KCFLAGS -arch ppc -mtune=G4 -mlong-branch"
-               EXTRA_KLDFLAGS="-arch ppc"
-               ;;
-       i?86 | x86_64)
-               EXTRA_KCFLAGS="$EXTRA_KCFLAGS -arch i386"
-               EXTRA_KLDFLAGS="-arch i386"
-               ;;
-esac
-
-# Kernel of OS X is not 64bits(even in Tiger), but -m64 can be taken by gcc in Tiger
-# (Tiger can support 64bits applications), so we have to eliminate -m64 while 
-# building kextensions for and OS X.
-CC=`echo $CC | sed -e "s/\-m64//g"`
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -x c -pipe -Wno-trigraphs -fasm-blocks -g -O0"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Wno-four-char-constants -Wmost -O0"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -fmessage-length=0"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/Headers"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/Headers/bsd"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/PrivateHeaders"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -fno-common -nostdinc -fno-builtin"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -finline -fno-keep-inline-functions"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -force_cpusubtype_ALL -fno-exceptions"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -msoft-float -static"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -DKERNEL -DKERNEL_PRIVATE"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -DDRIVER_PRIVATE -DAPPLE -DNeXT"
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -D__KERNEL__ -D__DARWIN__"
-#
-# C flags for Panther/Tiger
-#
-case $target_os in
-        darwin8*)
-                EXTRA_KCFLAGS="$EXTRA_KCFLAGS -D__DARWIN8__"
-       ;;
-        darwin7*)
-                EXTRA_KCFLAGS="$EXTRA_KCFLAGS -ffix-and-continue"
-        ;;
-esac
-
-#
-# Debugging flags. Remove!
-#
-EXTRA_KCFLAGS="$EXTRA_KCFLAGS -O0 -DMACH_ASSERT=1"
-EXTRA_KLDFLAGS="$EXTRA_KLDFLAGS -static -nostdlib -r"
-EXTRA_KLIBS="-lkmodc++ -lkmod -lcc_kext"
-KMODEXT=""
-
-AC_SUBST(EXTRA_KLDFLAGS)
-AC_SUBST(EXTRA_KLIBS)
-
-kextdir='/System/Library/Extensions/$(firstword $(macos_PROGRAMS)).kext'
-plistdir='$(kextdir)/Contents'
-macosdir='$(plistdir)/MacOS'
-
-AC_SUBST(kextdir)
-AC_SUBST(plistdir)
-AC_SUBST(macosdir)
-
-LN_PROG_DARWIN
-
-LP_PROG_DARWIN
-
-LC_PROG_DARWIN
-])
index aa75c04..32b3861 100644 (file)
@@ -18,12 +18,6 @@ case $target_os in
        linux*)
                lb_target_os="linux"
                ;;
-       darwin*)
-               lb_target_os="darwin"
-               ;;
-       solaris*)
-               lb_target_os="SunOS"
-               ;;
 esac
 AC_SUBST(lb_target_os)
 ]) # LB_CANONICAL_SYSTEM
@@ -239,9 +233,6 @@ AS_IF([test "x$enable_modules" = xyes], [
                        LN_PROG_LINUX
                        AS_IF([test "x$enable_server" != xno], [LB_EXT4_SRC_DIR])
                        LC_PROG_LINUX
-               ], [darwin*], [
-                       LB_PROG_DARWIN
-                       LIBCFS_PROG_DARWIN
                ], [*], [
                        # This is strange - Lustre supports a target we don't
                        AC_MSG_ERROR([Modules are not supported on $target_os])
@@ -433,8 +424,6 @@ AM_CONDITIONAL([TESTS], [test x$enable_tests = xyes])
 AM_CONDITIONAL([DOC], [test x$ENABLE_DOC = x1])
 AM_CONDITIONAL([INIT_SCRIPTS], [test x$ENABLE_INIT_SCRIPTS = x1])
 AM_CONDITIONAL([LINUX], [test x$lb_target_os = xlinux])
-AM_CONDITIONAL([DARWIN], [test x$lb_target_os = xdarwin])
-AM_CONDITIONAL([SUNOS], [test x$lb_target_os = xSunOS])
 AM_CONDITIONAL([USES_DPKG], [test x$uses_dpkg = xyes])
 AM_CONDITIONAL([USE_QUILT], [test x$use_quilt = xyes])
 
@@ -447,8 +436,6 @@ AM_CONDITIONAL(HAVE_PCLMULQDQ, test x$target_cpu = "xx86_64" -a x$target_vendor
 AS_IF([test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om"],
        [AC_DEFINE(HAVE_PCLMULQDQ, 1, [have PCLMULQDQ instruction])])
 
-LB_DARWIN_CONDITIONALS
-
 LIBCFS_CONDITIONALS
 LN_CONDITIONALS
 LC_CONDITIONALS
index 1889814..90bb1c1 100644 (file)
@@ -340,15 +340,6 @@ LIBCFS_SHRINKER_COUNT
 ]) # LIBCFS_PROG_LINUX
 
 #
-# LIBCFS_PROG_DARWIN
-#
-# Darwin checks
-#
-AC_DEFUN([LIBCFS_PROG_DARWIN], [
-LB_DARWIN_CHECK_FUNCS([get_preemption_level])
-]) # LIBCFS_PROG_DARWIN
-
-#
 # LIBCFS_PATH_DEFAULTS
 #
 # default paths for installed files
@@ -460,7 +451,5 @@ libcfs/libcfs/autoMakefile
 libcfs/libcfs/linux/Makefile
 libcfs/libcfs/posix/Makefile
 libcfs/libcfs/util/Makefile
-libcfs/include/libcfs/darwin/Makefile
-libcfs/libcfs/darwin/Makefile
 ])
 ]) # LIBCFS_CONFIG_FILES
index edae41a..2244baa 100644 (file)
@@ -1,8 +1,5 @@
 SUBDIRS = linux posix util
-if DARWIN
-SUBDIRS += darwin
-endif
-DIST_SUBDIRS = linux posix util darwin
+DIST_SUBDIRS = linux posix util
 
 libcfsdir = $(includedir)/libcfs
 
diff --git a/libcfs/include/libcfs/darwin/.gitignore b/libcfs/include/libcfs/darwin/.gitignore
deleted file mode 100644 (file)
index 10a7e8d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/Makefile.in
diff --git a/libcfs/include/libcfs/darwin/Makefile.am b/libcfs/include/libcfs/darwin/Makefile.am
deleted file mode 100644 (file)
index 3ccd204..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-EXTRA_DIST = darwin-mem.h darwin-types.h libcfs.h                      \
-       darwin-fs.h darwin-prim.h darwin-utils.h                        \
-       darwin-lock.h darwin-sync.h darwin-tcpip.h kp30.h
diff --git a/libcfs/include/libcfs/darwin/darwin-fs.h b/libcfs/include/libcfs/darwin/darwin-fs.h
deleted file mode 100644 (file)
index e88ceae..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/darwin/darwin-fs.h
- *
- * Implementation of standard file system interfaces for XNU kernel.
- */
-
-#ifndef __LIBCFS_DARWIN_FS_H__
-#define __LIBCFS_DARWIN_FS_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#ifdef __KERNEL__
-
-#include <sys/types.h>
-#include <sys/systm.h>
-
-#include <sys/kernel.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/filedesc.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/ubc.h>
-#include <sys/mbuf.h>
-#include <sys/namei.h>
-#include <sys/fcntl.h>
-#include <sys/lockf.h>
-#include <stdarg.h>
-
-#include <mach/mach_types.h>
-#include <mach/time_value.h>
-#include <kern/clock.h>
-#include <sys/param.h>
-#include <IOKit/system.h>
-
-#include <libcfs/darwin/darwin-types.h>
-#include <libcfs/darwin/darwin-lock.h>
-#include <libcfs/darwin/darwin-mem.h>
-#include <libcfs/list.h>
-
-/*
- * File operating APIs in kernel
- */
-#ifdef __DARWIN8__
-/*
- * Kernel file descriptor
- */
-struct file {
-       unsigned        f_flags;
-       vnode_t         f_vp;
-       vfs_context_t   f_ctxt;
-};
-#endif
-
-int kern_file_size(struct file *fp, off_t *size);
-#define filp_size(fp)                          \
-       ({                                      \
-               off_t           __size;         \
-               kern_file_size((fp), &__size);  \
-               __size;                         \
-        })
-#define filp_poff(fp)               (NULL)
-
-struct file *kern_file_open(const char *name, int flags, int mode);
-int kern_file_close(struct file *fp);
-int kern_file_read(struct file *fp, void *buf, size_t nbytes, off_t *pos);
-int kern_file_write(struct file *fp, void *buf, size_t nbytes, off_t *pos);
-int kern_file_sync(struct file *fp);
-
-#define filp_open(n, f, m)             kern_file_open(n, f, m)
-#define filp_close(f, i)               kern_file_close(f)
-#define filp_read(f, b, n, p)          kern_file_read(f, b, n, p)
-#define filp_write(f, b, n, p)         kern_file_write(f, b, n, p)
-#define filp_fsync(f, s, e)            kern_file_sync(f)
-
-int ref_file(struct file *fp);
-int rele_file(struct file *fp);
-int file_count(struct file *fp);
-#define get_file(f)                    ref_file(f)
-#define fput(f)                                rele_file(f)
-
-#define INT_LIMIT(x)                   (~((x)1 << (sizeof(x)*8 - 1)))
-#define OFFSET_MAX                     INT_LIMIT(loff_t)
-
-#define file_lock                      flock
-#define flock_type(fl)                 ((fl)->l_type)
-#define flock_set_type(fl, type)       do { (fl)->l_type = (type); } while (0)
-#define flock_pid(fl)                  ((fl)->l_pid)
-#define flock_set_pid(fl, pid)         do { (fl)->l_pid = (pid); } while (0)
-#define flock_start(fl)                        ((fl)->l_start)
-#define flock_set_start(fl, st)                do { (fl)->l_start = (st); } while (0)
-
-static inline loff_t flock_end(struct file_lock *fl)
-{
-       return (fl->l_len == 0 ? OFFSET_MAX : (fl->l_start + fl->l_len));
-}
-
-static inline void flock_set_end(struct file_lock *fl, loff_t end)
-{
-       if (end == OFFSET_MAX)
-               fl->l_len = 0;
-       else
-               fl->l_len = end - fl->l_start;
-}
-
-#define ATTR_MODE       0x0001
-#define ATTR_UID        0x0002
-#define ATTR_GID        0x0004
-#define ATTR_SIZE       0x0008
-#define ATTR_ATIME      0x0010
-#define ATTR_MTIME      0x0020
-#define ATTR_CTIME      0x0040
-#define ATTR_ATIME_SET  0x0080
-#define ATTR_MTIME_SET  0x0100
-#define ATTR_FORCE      0x0200  /* Not a change, but a change it */
-#define ATTR_ATTR_FLAG  0x0400
-#define ATTR_RAW        0x0800  /* file system, not vfs will massage attrs */
-#define ATTR_FROM_OPEN  0x1000  /* called from open path, ie O_TRUNC */
-#define ATTR_CTIME_SET  0x2000
-#define ATTR_BLOCKS     0x4000
-#define ATTR_KILL_SUID  0
-#define ATTR_KILL_SGID  0
-
-#define in_group_p(x)  (0)
-
-struct posix_acl_entry {
-        short                   e_tag;
-        unsigned short          e_perm;
-        unsigned int            e_id;
-};
-
-struct posix_acl {
-        atomic_t                a_refcount;
-        unsigned int            a_count;
-        struct posix_acl_entry  a_entries[0];
-};
-
-struct posix_acl *posix_acl_alloc(int count, int flags);
-static inline struct posix_acl *posix_acl_from_xattr(const void *value,
-                                                     size_t size)
-{
-        return posix_acl_alloc(0, 0);
-}
-#define posix_acl_from_xattr(a,b,c) posix_acl_from_xattr(b,c)
-
-static inline void posix_acl_release(struct posix_acl *acl) {};
-static inline int posix_acl_valid(const struct posix_acl *acl) { return 0; }
-static inline struct posix_acl * posix_acl_dup(struct posix_acl *acl) 
-{ 
-        return acl;
-}
-#endif /* END __KERNEL__ */
-
-struct dentry {
-       void    *d;
-};
-
-#ifndef O_SYNC
-#define O_SYNC                                 0
-#endif
-#ifndef O_DIRECTORY
-#define O_DIRECTORY                            0
-#endif
-#ifndef O_LARGEFILE
-#define O_LARGEFILE                            0
-#endif
-
-#endif
diff --git a/libcfs/include/libcfs/darwin/darwin-lock.h b/libcfs/include/libcfs/darwin/darwin-lock.h
deleted file mode 100644 (file)
index ac80e7a..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_DARWIN_CFS_LOCK_H__
-#define __LIBCFS_DARWIN_CFS_LOCK_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#ifdef __KERNEL__
-#include <mach/sync_policy.h>
-#include <mach/task.h>
-#include <mach/semaphore.h>
-#include <kern/assert.h>
-#include <kern/thread.h>
-
-#include <libcfs/darwin/darwin-types.h>
-#include <libcfs/darwin/darwin-sync.h>
-
-/*
- * spin_lock (use Linux kernel's primitives)
- *
- * - spin_lock_init(x)
- * - spin_lock(x)
- * - spin_unlock(x)
- * - spin_trylock(x)
- *
- * - spin_lock_irqsave(x, f)
- * - spin_unlock_irqrestore(x, f)
- */
-struct spin_lock {
-       struct kspin spin;
-};
-
-typedef struct spin_lock spinlock_t;
-
-static inline void spin_lock_init(spinlock_t *lock)
-{
-       kspin_init(&lock->spin);
-}
-
-static inline void spin_lock(spinlock_t *lock)
-{
-       kspin_lock(&lock->spin);
-}
-
-static inline void spin_unlock(spinlock_t *lock)
-{
-       kspin_unlock(&lock->spin);
-}
-
-static inline int spin_trylock(spinlock_t *lock)
-{
-       return kspin_trylock(&lock->spin);
-}
-
-static inline void spin_lock_done(spinlock_t *lock)
-{
-       kspin_done(&lock->spin);
-}
-
-#error "does this lock out timer callbacks?"
-#define spin_lock_bh(x)                spin_lock(x)
-#define spin_unlock_bh(x)      spin_unlock(x)
-#define spin_lock_bh_init(x)   spin_lock_init(x)
-
-extern boolean_t ml_set_interrupts_enabled(boolean_t enable);
-#define __disable_irq()         ml_set_interrupts_enabled(FALSE)
-#define __enable_irq(x)         (void) ml_set_interrupts_enabled(x)
-
-#define spin_lock_irqsave(s, f)                do{                     \
-                                       f = __disable_irq();    \
-                                       spin_lock(s);   }while(0)
-
-#define spin_unlock_irqrestore(s, f)   do{                     \
-                                       spin_unlock(s);         \
-                                       __enable_irq(f);}while(0)
-
-/* 
- * Semaphore
- *
- * - sema_init(x, v)
- * - __down(x)
- * - __up(x)
- */
-struct semaphore {
-       struct ksem sem;
-};
-
-static inline void sema_init(struct semaphore *s, int val)
-{
-       ksem_init(&s->sem, val);
-}
-
-static inline void __down(struct semaphore *s)
-{
-       ksem_down(&s->sem, 1);
-}
-
-static inline void __up(struct semaphore *s)
-{
-       ksem_up(&s->sem, 1);
-}
-
-/*
- * Mutex:
- *
- * - init_mutex(x)
- * - init_mutex_locked(x)
- * - mutex_up(x)
- * - mutex_down(x)
- */
-
-#define mutex_up(s)                    __up(s)
-#define mutex_down(s)                  __down(s)
-
-#define init_mutex(x)                  sema_init(x, 1)
-#define init_mutex_locked(x)           sema_init(x, 0)
-
-/*
- * Completion:
- *
- * - init_completion(c)
- * - complete(c)
- * - wait_for_completion(c)
- */
-struct completion {
-       /*
-        * Emulate completion by semaphore for now.
-        *
-        * XXX nikita: this is not safe if completion is used to synchronize
-        * exit from kernel daemon thread and kext unloading. In this case
-        * some core function (a la complete_and_exit()) is needed.
-        */
-       struct ksem sem;
-};
-
-static inline void init_completion(struct completion *c)
-{
-       ksem_init(&c->sem, 0);
-}
-
-static inline void complete(struct completion *c)
-{
-       ksem_up(&c->sem, 1);
-}
-
-static inline void wait_for_completion(struct completion *c)
-{
-       ksem_down(&c->sem, 1);
-}
-
-/*
- * rw_semaphore:
- *
- * - DECLARE_RWSEM(x)
- * - init_rwsem(x)
- * - down_read(x)
- * - up_read(x)
- * - down_write(x)
- * - up_write(x)
- */
-struct rw_semaphore {
-       struct krw_sem s;
-};
-
-static inline void init_rwsem(struct rw_semaphore *s)
-{
-       krw_sem_init(&s->s);
-}
-
-static inline void fini_rwsem(struct rw_semaphore *s)
-{
-       krw_sem_done(&s->s);
-}
-
-static inline void down_read(struct rw_semaphore *s)
-{
-       krw_sem_down_r(&s->s);
-}
-
-static inline int down_read_trylock(struct rw_semaphore *s)
-{
-       int ret = krw_sem_down_r_try(&s->s);
-       return ret == 0;
-}
-
-static inline void down_write(struct rw_semaphore *s)
-{
-       krw_sem_down_w(&s->s);
-}
-
-static inline int down_write_trylock(struct rw_semaphore *s)
-{
-       int ret = krw_sem_down_w_try(&s->s);
-       return ret == 0;
-}
-
-static inline void up_read(struct rw_semaphore *s)
-{
-       krw_sem_up_r(&s->s);
-}
-
-static inline void up_write(struct rw_semaphore *s)
-{
-       krw_sem_up_w(&s->s);
-}
-
-/* 
- * read-write lock : Need to be investigated more!!
- *
- * - DECLARE_RWLOCK(l)
- * - rwlock_init(x)
- * - read_lock(x)
- * - read_unlock(x)
- * - write_lock(x)
- * - write_unlock(x)
- */
-typedef struct krw_spin rwlock_t;
-
-#define rwlock_init(pl)                        krw_spin_init(pl)
-
-#define read_lock(l)                   krw_spin_down_r(l)
-#define read_unlock(l)                 krw_spin_up_r(l)
-#define write_lock(l)                  krw_spin_down_w(l)
-#define write_unlock(l)                        krw_spin_up_w(l)
-
-#define write_lock_irqsave(l, f)       do{                     \
-                                       f = __disable_irq();    \
-                                       write_lock(l);  }while(0)
-
-#define write_unlock_irqrestore(l, f)  do{                     \
-                                       write_unlock(l);        \
-                                       __enable_irq(f);}while(0)
-
-#define read_lock_irqsave(l, f)                do{                     \
-                                       f = __disable_irq();    \
-                                       read_lock(l);   }while(0)
-
-#define read_unlock_irqrestore(l, f)   do{                     \
-                                       read_unlock(l);         \
-                                       __enable_irq(f);}while(0)
-/*
- * Funnel: 
- *
- * Safe funnel in/out
- */
-#ifdef __DARWIN8__
-
-#define CFS_DECL_FUNNEL_DATA
-#define CFS_DECL_CONE_DATA              DECLARE_FUNNEL_DATA
-#define CFS_DECL_NET_DATA               DECLARE_FUNNEL_DATA
-#define CFS_CONE_IN                     do {} while(0)
-#define CFS_CONE_EX                     do {} while(0)
-
-#define CFS_NET_IN                      do {} while(0)
-#define CFS_NET_EX                      do {} while(0)
-
-#else
-
-#define CFS_DECL_FUNNEL_DATA                   \
-        boolean_t    __funnel_state = FALSE;   \
-        funnel_t    *__funnel
-#define CFS_DECL_CONE_DATA             CFS_DECL_FUNNEL_DATA
-#define CFS_DECL_NET_DATA              CFS_DECL_FUNNEL_DATA
-
-void lustre_cone_in(boolean_t *state, funnel_t **cone);
-void lustre_cone_ex(boolean_t state, funnel_t *cone);
-
-#define CFS_CONE_IN lustre_cone_in(&__funnel_state, &__funnel)
-#define CFS_CONE_EX lustre_cone_ex(__funnel_state, __funnel)
-
-void lustre_net_in(boolean_t *state, funnel_t **cone);
-void lustre_net_ex(boolean_t state, funnel_t *cone);
-
-#define CFS_NET_IN  lustre_net_in(&__funnel_state, &__funnel)
-#define CFS_NET_EX  lustre_net_ex(__funnel_state, __funnel)
-
-#endif
-
-#else
-#include <libcfs/user-lock.h>
-#endif /* __KERNEL__ */
-
-/* __XNU_CFS_LOCK_H */
-#endif
diff --git a/libcfs/include/libcfs/darwin/darwin-mem.h b/libcfs/include/libcfs/darwin/darwin-mem.h
deleted file mode 100644 (file)
index b1a6cd5..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_DARWIN_CFS_MEM_H__
-#define __LIBCFS_DARWIN_CFS_MEM_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#ifdef __KERNEL__
-
-#include <sys/types.h>
-#include <sys/systm.h>
-
-#include <sys/vm.h>
-#include <sys/kernel.h>
-#include <sys/ubc.h>
-#include <sys/uio.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/lockf.h>
-
-#include <mach/mach_types.h>
-#include <mach/vm_types.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <mach/machine/vm_param.h>
-#include <kern/thread_call.h>
-#include <sys/param.h>
-#include <sys/vm.h>
-
-#include <libcfs/darwin/darwin-types.h>
-#include <libcfs/darwin/darwin-sync.h>
-#include <libcfs/darwin/darwin-lock.h>
-#include <libcfs/list.h>
-
-/*
- * Basic xnu_page struct, should be binary compatibility with
- * all page types in xnu (we have only xnu_raw_page, xll_page now)
- */
-
-/* Variable sized pages are not supported */
-
-#ifdef PAGE_SHIFT
-#define PAGE_CACHE_SHIFT       PAGE_SHIFT
-#else
-#define PAGE_CACHE_SHIFT       12
-#endif
-
-#define PAGE_CACHE_SIZE        (1UL << PAGE_CACHE_SHIFT)
-
-#define CFS_PAGE_MASK  (~((__u64)PAGE_CACHE_SIZE - 1))
-
-enum {
-       XNU_PAGE_RAW,
-       XNU_PAGE_XLL,
-       XNU_PAGE_NTYPES
-};
-
-typedef __u32 page_off_t;
-
-/*
- * For XNU we have our own page cache built on top of underlying BSD/MACH
- * infrastructure. In particular, we have two disjoint types of pages:
- *
- *    - "raw" pages (XNU_PAGE_RAW): these are just buffers mapped into KVM,
- *    based on UPLs, and
- *
- *    - "xll" pages (XNU_PAGE_XLL): these are used by file system to cache
- *    file data, owned by file system objects, hashed, lrued, etc.
- *
- * struct page has to cover both of them, because core Lustre code is based on
- * the Linux assumption that page is _both_ memory buffer and file system
- * caching entity.
- *
- * To achieve this, all types of pages supported on XNU has to start from
- * common header that contains only "page type". Common struct page operations
- * dispatch through operation vector based on page type.
- *
- */
-typedef struct xnu_page {
-       int type;
-} struct page;
-
-struct xnu_page_ops {
-       void *(*page_map)        (struct page *);
-       void  (*page_unmap)      (struct page *);
-       void *(*page_address)    (struct page *);
-};
-
-void xnu_page_ops_register(int type, struct xnu_page_ops *ops);
-void xnu_page_ops_unregister(int type);
-
-/*
- * raw page, no cache object, just like buffer
- */
-struct xnu_raw_page {
-       struct xnu_page  header;
-       void            *virtual;
-       atomic_t         count;
-       struct list_head link;
-};
-
-/*
- * Public interface to lustre
- *
- * - alloc_page(f)
- * - __free_page(p)
- * - kmap(p)
- * - kunmap(p)
- * - page_address(p)
- */
-
-/*
- * Of all functions above only kmap(), kunmap(), and
- * page_address() can be called on file system pages. The rest is for raw
- * pages only.
- */
-
-struct page *alloc_page(u_int32_t flags);
-void __free_page(struct page *page);
-void get_page(struct page *page);
-int cfs_put_page_testzero(struct page *page);
-int page_count(struct page *page);
-#define page_index(pg) (0)
-
-void *page_address(struct page *pg);
-void *kmap(struct page *pg);
-void kunmap(struct page *pg);
-
-/*
- * Memory allocator
- */
-
-void *kmalloc(size_t nr_bytes, u_int32_t flags);
-void  kfree(void *addr);
-
-void *vmalloc(size_t nr_bytes);
-void  vfree(void *addr);
-
-extern int get_preemption_level(void);
-
-/*
- * Universal memory allocator API
- */
-enum cfs_alloc_flags {
-       /* allocation is not allowed to block */
-       GFP_ATOMIC = 0x1,
-       /* allocation is allowed to block */
-       __GFP_WAIT   = 0x2,
-       /* allocation should return zeroed memory */
-       __GFP_ZERO   = 0x4,
-       /* allocation is allowed to call file-system code to free/clean
-        * memory */
-       __GFP_FS     = 0x8,
-       /* allocation is allowed to do io to free/clean memory */
-       __GFP_IO     = 0x10,
-       /* don't report allocation failure to the console */
-       __GFP_NOWARN = 0x20,
-       /* standard allocator flag combination */
-       GFP_IOFS    = __GFP_FS | __GFP_IO,
-       GFP_USER   = __GFP_WAIT | __GFP_FS | __GFP_IO,
-       GFP_NOFS   = __GFP_WAIT | __GFP_IO,
-       GFP_KERNEL = __GFP_WAIT | __GFP_IO | __GFP_FS,
-};
-
-/* flags for cfs_page_alloc() in addition to enum cfs_alloc_flags */
-enum cfs_alloc_page_flags {
-       /* allow to return page beyond KVM. It has to be mapped into KVM by
-        * kmap() and unmapped with kunmap(). */
-       __GFP_HIGHMEM  = 0x40,
-       GFP_HIGHUSER = __GFP_WAIT | __GFP_FS | __GFP_IO |
-                            __GFP_HIGHMEM,
-};
-
-#define ALLOC_ATOMIC_TRY                                    \
-       (get_preemption_level() != 0 ? GFP_ATOMIC : 0)
-
-#define memory_pressure_get() (0)
-#define memory_pressure_set() do {} while (0)
-#define memory_pressure_clr() do {} while (0)
-
-/*
- * Slab:
- *
- * No slab in OSX, use zone allocator to simulate slab
- */
-#define SLAB_HWCACHE_ALIGN             0
-
-#ifdef __DARWIN8__
-/* 
- * In Darwin8, we cannot use zalloc_noblock(not exported by kernel),
- * also, direct using of zone allocator is not recommended.
- */
-#define CFS_INDIVIDUAL_ZONE     (0)
-
-#if !CFS_INDIVIDUAL_ZONE
-#include <libkern/OSMalloc.h>
-typedef        OSMallocTag     mem_cache_t;
-#else
-typedef                void*           zone_t;
-typedef                zone_t          mem_cache_t;
-#endif
-
-#else /* !__DARWIN8__ */
-
-#define CFS_INDIVIDUAL_ZONE     (1)
-
-typedef        zone_t          mem_cache_t;
-
-#endif /* !__DARWIN8__ */
-
-#define MC_NAME_MAX_LEN                64
-
-struct kmem_cache {
-       int                     mc_size;
-       mem_cache_t             mc_cache;
-       struct list_head        mc_link;
-       char                    mc_name [MC_NAME_MAX_LEN];
-};
-
-#define KMEM_CACHE_MAX_COUNT   64
-#define KMEM_MAX_ZONE          8192
-
-struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
-                                    unsigned long, void *);
-void kmem_cache_destroy(struct kmem_cache *);
-void *kmem_cache_alloc(struct kmem_cache *, int);
-void kmem_cache_free(struct kmem_cache *, void *);
-
-/*
- * Misc
- */
-/* XXX Liang: totalram_pages... fix me */
-#define totalram_pages                 (64 * 1024)
-#define NUM_CACHEPAGES         totalram_pages
-
-#define DECL_MMSPACE
-#define MMSPACE_OPEN           do {} while (0)
-#define MMSPACE_CLOSE          do {} while (0)
-
-#define copy_from_user(kaddr, uaddr, size)     copyin(CAST_USER_ADDR_T(uaddr), (caddr_t)kaddr, size)
-#define copy_to_user(uaddr, kaddr, size)       copyout((caddr_t)kaddr, CAST_USER_ADDR_T(uaddr), size)
-
-#if 0
-static inline int strncpy_from_user(char *kaddr, char *uaddr, int size)
-{
-       size_t count;
-       return copyinstr((const user_addr_t)uaddr, (void *)kaddr, size, &count);
-}
-#endif
-
-#if defined (__ppc__)
-#define mb()  __asm__ __volatile__ ("sync" : : : "memory")
-#define rmb()  __asm__ __volatile__ ("sync" : : : "memory")
-#define wmb()  __asm__ __volatile__ ("eieio" : : : "memory")
-#elif defined (__i386__)
-#define mb()    __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
-#define rmb()   mb()
-#define wmb()   __asm__ __volatile__ ("": : :"memory")
-#else
-#error architecture not supported
-#endif
-
-#else  /* !__KERNEL__ */
-
-#define CFS_CACHE_SHIFT 12
-#define PAGE_CACHE_SIZE (1 << CFS_CACHE_SHIFT)
-#include <libcfs/user-prim.h>
-
-#endif /* __KERNEL__ */
-
-#endif /* __XNU_CFS_MEM_H__ */
diff --git a/libcfs/include/libcfs/darwin/darwin-prim.h b/libcfs/include/libcfs/darwin/darwin-prim.h
deleted file mode 100644 (file)
index c456e3f..0000000
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_DARWIN_CFS_PRIM_H__
-#define __LIBCFS_DARWIN_CFS_PRIM_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#ifndef EXPORT_SYMBOL
-# define EXPORT_SYMBOL(s)
-#endif
-
-#ifdef __KERNEL__
-#include <sys/types.h>
-#include <sys/systm.h>
-
-#ifndef __DARWIN8__
-# ifndef __APPLE_API_PRIVATE
-#  define __APPLE_API_PRIVATE
-#  include <sys/user.h>
-#  undef __APPLE_API_PRIVATE
-# else
-#  include <sys/user.h>
-# endif
-# include <mach/mach_traps.h>
-# include <mach/thread_switch.h>
-# include <machine/cpu_number.h>
-#endif /* !__DARWIN8__ */
-
-#include <sys/kernel.h>
-
-#include <mach/thread_act.h>
-#include <mach/mach_types.h>
-#include <mach/time_value.h>
-#include <kern/sched_prim.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <mach/machine/vm_param.h>
-#include <machine/machine_routines.h>
-#include <kern/clock.h>
-#include <kern/thread_call.h>
-#include <sys/param.h>
-#include <sys/vm.h>
-
-#include <libcfs/darwin/darwin-types.h>
-#include <libcfs/darwin/darwin-utils.h>
-#include <libcfs/darwin/darwin-lock.h>
-
-/*
- * Symbol functions for libcfs
- *
- * OSX has no facility for use to register symbol.
- * So we have to implement it.
- */
-#define CFS_SYMBOL_LEN     64
-
-struct  cfs_symbol {
-       char    name[CFS_SYMBOL_LEN];
-       void    *value;
-       int     ref;
-       struct  list_head sym_list;
-};
-
-extern kern_return_t            cfs_symbol_register(const char *, const void *);
-extern kern_return_t            cfs_symbol_unregister(const char *);
-extern void *                   cfs_symbol_get(const char *);
-extern kern_return_t            cfs_symbol_put(const char *);
-
-/*
- * sysctl typedef
- *
- * User can register/unregister a list of sysctl_oids
- * sysctl_oid is data struct of osx's sysctl-entry
- */
-#define        CONFIG_SYSCTL   1
-
-#define ctl_table sysctl_oid
-struct ctl_table *register_sysctl_table(struct ctl_table *table);
-void unregister_sysctl_table(struct ctl_table *table);
-
-/*
- * Proc file system APIs, no /proc fs support in OSX
- */
-typedef struct cfs_proc_dir_entry {
-       void            *data;
-} cfs_proc_dir_entry_t;
-
-cfs_proc_dir_entry_t * cfs_create_proc_entry(char *name, int mod,
-                                         cfs_proc_dir_entry_t *parent);
-void cfs_free_proc_entry(cfs_proc_dir_entry_t *de);
-void cfs_remove_proc_entry(char *name, cfs_proc_dir_entry_t *entry);
-
-typedef int (read_proc_t)(char *page, char **start, off_t off,
-                         int count, int *eof, void *data);
-typedef int (write_proc_t)(struct file *file, const char *buffer,
-                          unsigned long count, void *data);
-
-/*
- * cfs pseudo device
- *
- * struct miscdevice
- * misc_register:
- * misc_deregister:
- */
-struct miscdevice{
-       int             index;
-       void            *handle;
-       const char      *name;
-       struct cdevsw   *devsw;
-       void            *private;
-};
-
-extern kern_return_t            misc_register(struct miscdevice *);
-extern kern_return_t            misc_deregister(struct miscdevice *);
-
-/*
- * Task struct and ...
- *
- * Using BSD current_proc in Darwin
- */
-extern boolean_t        assert_wait_possible(void);
-extern void             *get_bsdtask_info(task_t);
-
-#ifdef __DARWIN8__
-
-typedef struct task_struct {};
-#define current                ((struct task_struct *)current_thread())
-#else  /* !__DARWIN8__ */
-
-#define task_struct uthread
-
-#define current_uthread()       ((struct uthread *)get_bsdthread_info(current_act()))
-#define current                current_uthread()
-
-#endif /* !__DARWIN8__ */
-
-#define task_lock(t)   do {;} while (0)
-#define task_unlock(t) do {;} while (0)
-
-#define set_current_state(s)   do {;} while (0)
-
-#define DECL_JOURNAL_DATA
-#define PUSH_JOURNAL   do {;} while(0)
-#define POP_JOURNAL            do {;} while(0)
-
-/*
- * Kernel thread:
- *
- * OSX kernel thread can not be created with args,
- * so we have to implement new APIs to create thread with args
- */
-
-typedef int (*cfs_thread_t)(void *);
-
-extern task_t  kernel_task;
-
-/*
- * cloning flags, no use in OSX, just copy them from Linux
- */
-#define CSIGNAL         0x000000ff      /* signal mask to be sent at exit */
-#define CLONE_VM        0x00000100      /* set if VM shared between processes */
-#define CLONE_FS        0x00000200      /* set if fs info shared between processes */
-#define CLONE_FILES     0x00000400      /* set if open files shared between processes */
-#define CLONE_SIGHAND   0x00000800      /* set if signal handlers and blocked signals shared */
-#define CLONE_PID       0x00001000      /* set if pid shared */
-#define CLONE_PTRACE    0x00002000      /* set if we want to let tracing continue on the child too */
-#define CLONE_VFORK     0x00004000      /* set if the parent wants the child to wake it up on mm_release */
-#define CLONE_PARENT    0x00008000      /* set if we want to have the same parent as the cloner */
-#define CLONE_THREAD    0x00010000      /* Same thread group? */
-#define CLONE_NEWNS     0x00020000      /* New namespace group? */
-
-#define CLONE_SIGNAL    (CLONE_SIGHAND | CLONE_THREAD)
-
-extern struct task_struct kthread_run(cfs_thread_t func, void *arg,
-                             const char namefmt[], ...);
-
-/*
- * Wait Queue implementation
- *
- * Like wait_queue in Linux
- */
-typedef struct cfs_waitq {
-       struct ksleep_chan wq_ksleep_chan;
-} wait_queue_head_t;
-
-typedef struct cfs_waitlink {
-       struct cfs_waitq   *wl_waitq;
-       struct ksleep_link  wl_ksleep_link;
-} wait_queue_t;
-
-#define TASK_INTERRUPTIBLE     THREAD_ABORTSAFE
-#define TASK_UNINTERRUPTIBLE           THREAD_UNINT
-
-void init_waitqueue_head(struct cfs_waitq *waitq);
-void init_waitqueue_entry_current(struct cfs_waitlink *link);
-
-void add_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-void add_wait_queue_exclusive(struct cfs_waitq *waitq,
-                            struct cfs_waitlink *link);
-void remove_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-int  waitqueue_active(struct cfs_waitq *waitq);
-
-void wake_up(struct cfs_waitq *waitq);
-void wake_up_nr(struct cfs_waitq *waitq, int nr);
-void wake_up_all(struct cfs_waitq *waitq);
-
-void waitq_wait(struct cfs_waitlink *link, long state);
-cfs_duration_t waitq_timedwait(struct cfs_waitlink *link,
-                                  long state,
-                                  cfs_duration_t timeout);
-
-/*
- * Thread schedule APIs.
- */
-#define MAX_SCHEDULE_TIMEOUT    ((long)(~0UL>>12))
-extern void thread_set_timer_deadline(__u64 deadline);
-extern void thread_cancel_timer(void);
-
-static inline int schedule_timeout(int state, int64_t timeout)
-{
-       int          result;
-       
-#ifdef __DARWIN8__
-       result = assert_wait((event_t)current_thread(), state);
-#else
-       result = assert_wait((event_t)current_uthread(), state);
-#endif
-       if (timeout > 0) {
-               __u64 expire;
-               nanoseconds_to_absolutetime(timeout, &expire);
-               clock_absolutetime_interval_to_deadline(expire, &expire);
-               thread_set_timer_deadline(expire);
-       }
-       if (result == THREAD_WAITING)
-               result = thread_block(THREAD_CONTINUE_NULL);
-       if (timeout > 0)
-               thread_cancel_timer();
-       if (result == THREAD_TIMED_OUT)
-               result = 0;
-       else
-               result = 1;
-       return result;
-}
-
-#define schedule()     schedule_timeout(TASK_UNINTERRUPTIBLE, CFS_TICK)
-#define cfs_pause(tick)        schedule_timeout(TASK_UNINTERRUPTIBLE, tick)
-
-#define __wait_event(wq, condition)                            \
-do {                                                           \
-       struct cfs_waitlink __wait;                             \
-                                                               \
-       init_waitqueue_entry_current(&__wait);                  \
-       for (;;) {                                              \
-               add_wait_queue(&wq, &__wait);                   \
-               if (condition)                                  \
-                       break;                                  \
-               waitq_wait(&__wait, TASK_UNINTERRUPTIBLE);      \
-               remove_wait_queue(&wq, &__wait);                \
-       }                                                       \
-       remove_wait_queue(&wq, &__wait);                        \
-} while (0)
-
-#define wait_event(wq, condition)                              \
-do {                                                           \
-       if (condition)                                          \
-               break;                                          \
-       __wait_event(wq, condition);                            \
-} while (0)
-
-#define __wait_event_interruptible(wq, condition, ex, ret)     \
-do {                                                           \
-       struct cfs_waitlink __wait;                             \
-                                                               \
-       init_waitqueue_entry_current(&__wait);                  \
-       for (;;) {                                              \
-               if (ex == 0)                                    \
-                       add_wait_queue(&wq, &__wait);           \
-               else                                            \
-                       add_wait_queue_exclusive(&wq, &__wait); \
-               if (condition)                                  \
-                       break;                                  \
-               if (!cfs_signal_pending()) {                    \
-                       waitq_wait(&__wait,                     \
-                                      TASK_INTERRUPTIBLE);     \
-                       remove_wait_queue(&wq, &__wait);        \
-                       continue;                               \
-               }                                               \
-               ret = -ERESTARTSYS;                             \
-               break;                                          \
-       }                                                       \
-       remove_wait_queue(&wq, &__wait);                        \
-} while (0)
-
-#define wait_event_interruptible(wq, condition)                        \
-({                                                             \
-       int __ret = 0;                                          \
-       if (!condition)                                         \
-               __wait_event_interruptible(wq, condition,       \
-                                          0, __ret);           \
-       __ret;                                                  \
-})
-
-#define wait_event_interruptible_exclusive(wq, condition)      \
-({                                                             \
-       int __ret = 0;                                          \
-       if (!condition)                                         \
-               __wait_event_interruptible(wq, condition,       \
-                                          1, __ret);           \
-       __ret;                                                  \
-})
-
-#ifndef __DARWIN8__
-extern void    wakeup_one __P((void * chan));
-#endif
-/* only used in tests */
-#define wake_up_process(p)                                     \
-       do {                                                    \
-               wakeup_one((caddr_t)p);                         \
-       } while (0)
-       
-/* used in couple of places */
-static inline void sleep_on(wait_queue_head_t *waitq)
-{
-       wait_queue_t link;
-       
-       init_waitqueue_entry_current(&link);
-       add_wait_queue(waitq, &link);
-       waitq_wait(&link, TASK_UNINTERRUPTIBLE);
-       remove_wait_queue(waitq, &link);
-}
-
-/*
- * Signal
- */
-
-/*
- * Timer
- */
-struct timer_list {
-       struct ktimer t;
-};
-
-#define cfs_init_timer(t)      do {} while(0)
-void cfs_timer_init(struct timer_list *t, void (*func)(unsigned long), void *arg);
-void cfs_timer_done(struct timer_list *t);
-void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline);
-void cfs_timer_disarm(struct timer_list *t);
-int  cfs_timer_is_armed(struct timer_list *t);
-
-cfs_time_t cfs_timer_deadline(struct timer_list *t);
-
-/*
- * Ioctl
- * We don't need to copy out everything in osx
- */
-#define cfs_ioctl_data_out(a, d, l)                    \
-       ({                                              \
-               int __size;                             \
-               int __rc = 0;                           \
-               assert((l) >= sizeof(*d));              \
-               __size = (l) - sizeof(*d);              \
-               if (__size > 0)                         \
-                       __rc = copy_to_user((void *)a + __size, \
-                            (void *)d + __size,        \
-                            __size);                   \
-               __rc;                                   \
-       })
-
-/*
- * CPU
- */
-/* Run in PowerG5 who is PPC64 */
-#define SMP_CACHE_BYTES                         128
-#define __cacheline_aligned                     __attribute__((__aligned__(SMP_CACHE_BYTES)))
-#define NR_CPUS                                        2
-
-/* 
- * XXX Liang: patch xnu and export current_processor()?
- *
- * #define smp_processor_id()                  current_processor()
- */
-#define smp_processor_id()                     0
-/* XXX smp_call_function is not supported in xnu */
-#define smp_call_function(f, a, n, w)          do {} while(0)
-int cfs_online_cpus(void);
-
-/*
- * Misc
- */
-extern int is_suser(void);
-
-#ifndef likely
-#define likely(exp) (exp)
-#endif
-#ifndef unlikely
-#define unlikely(exp) (exp)
-#endif
-
-#define lock_kernel()                                  do {} while(0)
-#define unlock_kernel()                                        do {} while(0)
-
-#define call_usermodehelper(path, argv, envp, 1)       (0)
-
-#define cfs_module(name, version, init, fini)                          \
-extern kern_return_t _start(kmod_info_t *ki, void *data);              \
-extern kern_return_t _stop(kmod_info_t *ki, void *data);               \
-__private_extern__ kern_return_t name##_start(kmod_info_t *ki, void *data); \
-__private_extern__ kern_return_t name##_stop(kmod_info_t *ki, void *data); \
-                                                                       \
-kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1,               \
-                               { "com.clusterfs.lustre." #name }, { version }, \
-                               -1, 0, 0, 0, 0, name##_start, name##_stop }; \
-                                                                       \
-__private_extern__ kmod_start_func_t *_realmain = name##_start;                \
-__private_extern__ kmod_stop_func_t *_antimain = name##_stop;          \
-__private_extern__ int _kext_apple_cc = __APPLE_CC__ ;                 \
-                                                                       \
-kern_return_t name##_start(kmod_info_t *ki, void *d)                   \
-{                                                                      \
-       return init();                                                  \
-}                                                                      \
-                                                                       \
-kern_return_t name##_stop(kmod_info_t *ki, void *d)                    \
-{                                                                      \
-        fini();                                                                \
-        return KERN_SUCCESS;                                           \
-}                                                                      \
-                                                                       \
-/*                                                                     \
- * to allow semicolon after cfs_module(...)                            \
- */                                                                    \
-struct __dummy_ ## name ## _struct {}
-
-#define inter_module_get(n)                    cfs_symbol_get(n)
-#define inter_module_put(n)                    cfs_symbol_put(n)
-
-static inline int request_module(const char *name, ...)
-{
-       return (-EINVAL);
-}
-
-#ifndef __exit
-#define __exit
-#endif
-#ifndef __init
-#define __init
-#endif
-
-#define MODULE_AUTHOR(s)
-#define MODULE_DESCRIPTION(s)
-#define MODULE_LICENSE(s)
-#define MODULE_PARM(a, b)
-#define MODULE_PARM_DESC(a, b)
-
-#define NR_IRQS                                512
-#define in_interrupt()                 ml_at_interrupt_context()
-
-#define KERN_EMERG      "<0>"   /* system is unusable                   */
-#define KERN_ALERT      "<1>"   /* action must be taken immediately     */
-#define KERN_CRIT       "<2>"   /* critical conditions                  */
-#define KERN_ERR        "<3>"   /* error conditions                     */
-#define KERN_WARNING    "<4>"   /* warning conditions                   */
-#define KERN_NOTICE     "<5>"   /* normal but significant condition     */
-#define KERN_INFO       "<6>"   /* informational                        */
-#define KERN_DEBUG      "<7>"   /* debug-level messages                 */
-
-#else  /* !__KERNEL__ */
-
-typedef struct cfs_proc_dir_entry {
-       void            *data;
-} cfs_proc_dir_entry_t;
-
-#include <libcfs/user-prim.h>
-#define __WORDSIZE     32
-
-#endif /* END __KERNEL__ */
-/*
- * Error number
- */
-#ifndef EPROTO
-#define EPROTO          EPROTOTYPE
-#endif
-#ifndef EBADR
-#define EBADR          EBADRPC
-#endif
-#ifndef ERESTARTSYS
-#define ERESTARTSYS    512
-#endif
-#ifndef EDEADLOCK
-#define EDEADLOCK      EDEADLK
-#endif
-#ifndef ECOMM
-#define ECOMM          EINVAL
-#endif
-#ifndef ENODATA
-#define ENODATA                EINVAL
-#endif
-#ifndef ENOTSUPP
-#define ENOTSUPP       EINVAL
-#endif
-
-#if BYTE_ORDER == BIG_ENDIAN
-# define __BIG_ENDIAN
-#else
-# define __LITTLE_ENDIAN
-#endif
-
-#endif /* __LIBCFS_DARWIN_CFS_PRIM_H__ */
diff --git a/libcfs/include/libcfs/darwin/darwin-sync.h b/libcfs/include/libcfs/darwin/darwin-sync.h
deleted file mode 100644 (file)
index 10e471a..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/darwin/darwin-sync.h
- *
- * Prototypes of XNU synchronization primitives.
- */
-
-#ifndef __LIBCFS_DARWIN_XNU_SYNC_H__
-#define __LIBCFS_DARWIN_XNU_SYNC_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#define XNU_SYNC_DEBUG (1)
-
-#if XNU_SYNC_DEBUG
-#define ON_SYNC_DEBUG(e) e
-#else
-#define ON_SYNC_DEBUG(e)
-#endif
-
-enum {
-        /* "egrep -i '^(o?x)?[abcdeflo]*$' /usr/dict/words" is your friend */
-       KMUT_MAGIC  = 0x0bac0cab, /* [a, [b, c]] = b (a, c) - c (a, b) */
-       KSEM_MAGIC  = 0x1abe11ed,
-       KCOND_MAGIC = 0xb01dface,
-       KRW_MAGIC   = 0xdabb1edd,
-       KSPIN_MAGIC = 0xca11ab1e,
-        KRW_SPIN_MAGIC    = 0xbabeface,
-       KSLEEP_CHAN_MAGIC = 0x0debac1e,
-       KSLEEP_LINK_MAGIC = 0xacc01ade,
-       KTIMER_MAGIC      = 0xbefadd1e
-};
-
-/* ------------------------- spin lock ------------------------- */
-
-/*
- * XXX nikita: don't use NCPUS it's hardcoded to (1) in cpus.h
- */
-#define SMP (1)
-
-#include <libcfs/list.h>
-
-#ifdef __DARWIN8__
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <kern/locks.h>
-
-/*
- * hw_lock is not available in Darwin8 (hw_lock_* are not exported at all), 
- * so use lck_spin_t. we can hack out lck_spin_t easily, it's the only 
- * hacking in Darwin8.x. We did so because it'll take a lot of time to 
- * add lock_done for all locks, maybe it should be done in the future.
- * If lock_done for all locks were added, we can:
- *
- * typedef lck_spin_t      *xnu_spin_t;
- */
-#if defined (__ppc__)
-typedef struct {
-        unsigned int    opaque[3];
-} xnu_spin_t;
-#elif defined (__i386__)
-typedef struct {
-        unsigned int    opaque[10];
-} xnu_spin_t;
-#endif
-
-/* 
- * wait_queue is not available in Darwin8 (wait_queue_* are not exported), 
- * use assert_wait/wakeup/wake_one (wait_queue in kernel hash).
- */
-typedef void * xnu_wait_queue_t;
-
-/* DARWIN8 */
-#else
-
-#include <mach/mach_types.h>
-#include <sys/types.h>
-#include <kern/simple_lock.h>
-
-typedef hw_lock_data_t          xnu_spin_t;
-typedef struct wait_queue       xnu_wait_queue_t;
-
-/* DARWIN8 */
-#endif
-
-struct kspin {
-#if SMP
-       xnu_spin_t      lock;
-#endif
-#if XNU_SYNC_DEBUG
-       unsigned        magic;
-       thread_t        owner;
-#endif
-};
-
-void kspin_init(struct kspin *spin);
-void kspin_done(struct kspin *spin);
-void kspin_lock(struct kspin *spin);
-void kspin_unlock(struct kspin *spin);
-int  kspin_trylock(struct kspin *spin);
-
-#if XNU_SYNC_DEBUG
-/*
- * two functions below are for use in assertions
- */
-/* true, iff spin-lock is locked by the current thread */
-int kspin_islocked(struct kspin *spin);
-/* true, iff spin-lock is not locked by the current thread */
-int kspin_isnotlocked(struct kspin *spin);
-#else
-#define kspin_islocked(s) (1)
-#define kspin_isnotlocked(s) (1)
-#endif
-
-/* ------------------------- rw spinlock ----------------------- */
-struct krw_spin {
-        struct kspin      guard;
-        int               count;
-#if XNU_SYNC_DEBUG
-        unsigned          magic;
-#endif
-};
-
-void krw_spin_init(struct krw_spin *sem);
-void krw_spin_done(struct krw_spin *sem);
-void krw_spin_down_r(struct krw_spin *sem);
-void krw_spin_down_w(struct krw_spin *sem);
-void krw_spin_up_r(struct krw_spin *sem);
-void krw_spin_up_w(struct krw_spin *sem);
-
-/* ------------------------- semaphore ------------------------- */
-
-struct ksem {
-        struct kspin      guard;
-        xnu_wait_queue_t  q;
-        int               value;
-#if XNU_SYNC_DEBUG
-        unsigned          magic;
-#endif
-};
-
-void ksem_init(struct ksem *sem, int value);
-void ksem_done(struct ksem *sem);
-int  ksem_up  (struct ksem *sem, int value);
-void ksem_down(struct ksem *sem, int value);
-int  ksem_trydown(struct ksem *sem, int value);
-
-/* ------------------------- mutex ------------------------- */
-
-struct kmut {
-       struct ksem s;
-#if XNU_SYNC_DEBUG
-        unsigned    magic;
-        thread_t    owner;
-#endif
-};
-
-void kmut_init(struct kmut *mut);
-void kmut_done(struct kmut *mut);
-
-void kmut_lock   (struct kmut *mut);
-void kmut_unlock (struct kmut *mut);
-int  kmut_trylock(struct kmut *mut);
-
-#if XNU_SYNC_DEBUG
-/*
- * two functions below are for use in assertions
- */
-/* true, iff mutex is locked by the current thread */
-int kmut_islocked(struct kmut *mut);
-/* true, iff mutex is not locked by the current thread */
-int kmut_isnotlocked(struct kmut *mut);
-#else
-#define kmut_islocked(m) (1)
-#define kmut_isnotlocked(m) (1)
-#endif
-
-/* ------------------------- condition variable ------------------------- */
-
-struct kcond_link {
-       struct kcond_link *next;
-        struct ksem        sem;
-};
-
-struct kcond {
-        struct kspin       guard;
-        struct kcond_link *waiters;
-#if XNU_SYNC_DEBUG
-        unsigned           magic;
-#endif
-};
-
-void kcond_init(struct kcond *cond);
-void kcond_done(struct kcond *cond);
-void kcond_wait(struct kcond *cond, struct kspin *lock);
-void kcond_signal(struct kcond *cond);
-void kcond_broadcast(struct kcond *cond);
-
-void kcond_wait_guard(struct kcond *cond);
-void kcond_signal_guard(struct kcond *cond);
-void kcond_broadcast_guard(struct kcond *cond);
-
-/* ------------------------- read-write semaphore ------------------------- */
-
-struct krw_sem {
-       int          count;
-       struct kcond cond;
-#if XNU_SYNC_DEBUG
-       unsigned     magic;
-#endif
-};
-
-void krw_sem_init(struct krw_sem *sem);
-void krw_sem_done(struct krw_sem *sem);
-void krw_sem_down_r(struct krw_sem *sem);
-int krw_sem_down_r_try(struct krw_sem *sem);
-void krw_sem_down_w(struct krw_sem *sem);
-int krw_sem_down_w_try(struct krw_sem *sem);
-void krw_sem_up_r(struct krw_sem *sem);
-void krw_sem_up_w(struct krw_sem *sem);
-
-/* ------------------------- sleep-channel ------------------------- */
-
-struct ksleep_chan {
-       struct kspin     guard;
-       struct list_head waiters;
-#if XNU_SYNC_DEBUG
-       unsigned     magic;
-#endif
-};
-
-#define KSLEEP_CHAN_INITIALIZER         {{{0}}}
-
-struct ksleep_link {
-       int                 flags;
-       event_t             event;
-       int                 hits;
-       struct ksleep_chan *forward;
-       struct list_head    linkage;
-#if XNU_SYNC_DEBUG
-       unsigned     magic;
-#endif
-};
-
-enum {
-       KSLEEP_EXCLUSIVE = 1
-};
-
-void ksleep_chan_init(struct ksleep_chan *chan);
-void ksleep_chan_done(struct ksleep_chan *chan);
-
-void ksleep_link_init(struct ksleep_link *link);
-void ksleep_link_done(struct ksleep_link *link);
-
-void ksleep_add(struct ksleep_chan *chan, struct ksleep_link *link);
-void ksleep_del(struct ksleep_chan *chan, struct ksleep_link *link);
-
-void ksleep_wait(struct ksleep_chan *chan, int state);
-int64_t  ksleep_timedwait(struct ksleep_chan *chan, int state, __u64 timeout);
-
-void ksleep_wake(struct ksleep_chan *chan);
-void ksleep_wake_all(struct ksleep_chan *chan);
-void ksleep_wake_nr(struct ksleep_chan *chan, int nr);
-
-#define KSLEEP_LINK_DECLARE(name)               \
-{                                               \
-       .flags   = 0,                           \
-       .event   = 0,                           \
-       .hits    = 0,                           \
-       .linkage = LIST_HEAD_INIT(name.linkage),\
-       .magic   = KSLEEP_LINK_MAGIC            \
-}
-
-/* ------------------------- timer ------------------------- */
-
-struct ktimer {
-       struct kspin   guard;
-       void         (*func)(void *);
-       void          *arg;
-       u_int64_t      deadline; /* timer deadline in absolute nanoseconds */
-       int            armed;
-#if XNU_SYNC_DEBUG
-       unsigned     magic;
-#endif
-};
-
-void ktimer_init(struct ktimer *t, void (*func)(void *), void *arg);
-void ktimer_done(struct ktimer *t);
-void ktimer_arm(struct ktimer *t, u_int64_t deadline);
-void ktimer_disarm(struct ktimer *t);
-int  ktimer_is_armed(struct ktimer *t);
-
-u_int64_t ktimer_deadline(struct ktimer *t);
-
-/* __XNU_SYNC_H__ */
-#endif
-
-/*
- * Local variables:
- * c-indentation-style: "K&R"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
diff --git a/libcfs/include/libcfs/darwin/darwin-tcpip.h b/libcfs/include/libcfs/darwin/darwin-tcpip.h
deleted file mode 100644 (file)
index 49c21f0..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/darwin/darwin-tcpip.h
- *
- * Basic library routines.
- */
-
-#ifndef __LIBCFS_DARWIN_TCPIP_H__
-#define __LIBCFS_DARWIN_TCPIP_H__
-
-#ifdef __KERNEL__
-#include <sys/socket.h>
-
-#ifdef __DARWIN8__
-
-struct socket;
-
-typedef void    (*so_upcall)(socket_t sock, void* arg, int waitf);
-
-#define CFS_SOCK_UPCALL         0x1
-#define CFS_SOCK_DOWN           0x2
-
-#define CFS_SOCK_MAGIC          0xbabeface
-
-typedef struct cfs_socket {
-        socket_t        s_so;
-        int             s_magic;
-        int             s_flags;
-        so_upcall       s_upcall;
-        void           *s_upcallarg;
-} cfs_socket_t;
-
-
-/* cfs_socket_t to bsd socket */
-#define C2B_SOCK(s)             ((s)->s_so)     
-
-static inline int get_sock_intopt(socket_t so, int opt)
-{
-        int     val, len;
-        int     rc;
-
-        /*
-         * sock_getsockopt will take a lock(mutex) for socket,
-         * so it can be blocked. So be careful while using 
-         * them.
-         */
-        len = sizeof(val);
-        rc = sock_getsockopt(so, SOL_SOCKET, opt, &val, &len);
-        assert(rc == 0);
-        return val;
-}
-
-#define SOCK_ERROR(s)           get_sock_intopt(C2B_SOCK(s), SO_ERROR)        
-/* #define SOCK_WMEM_QUEUED(s)     (0) */
-#define SOCK_WMEM_QUEUED(s)     get_sock_intopt(C2B_SOCK(s), SO_NWRITE)
-/* XXX Liang: no reliable way to get it in Darwin8.x */
-#define SOCK_TEST_NOSPACE(s)    (0)
-
-void libcfs_sock_set_cb(cfs_socket_t *sock, so_upcall callback, void *arg);
-void libcfs_sock_reset_cb(cfs_socket_t *sock);
-
-#else /* !__DARWIN8__ */
-
-#define SOCK_WMEM_QUEUED(so)    ((so)->so_snd.sb_cc)
-#define SOCK_ERROR(so)          ((so)->so_error)
-
-#define SOCK_TEST_NOSPACE(so)   (sbspace(&(so)->so_snd) < (so)->so_snd.sb_lowat)
-
-#endif /* !__DARWIN8__ */
-
-#endif /* __KERNEL END */
-
-#endif  /* __XNU_CFS_TYPES_H__ */
diff --git a/libcfs/include/libcfs/darwin/darwin-time.h b/libcfs/include/libcfs/darwin/darwin-time.h
deleted file mode 100644 (file)
index c22b138..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/darwin/darwin-time.h
- *
- * Implementation of portable time API for XNU kernel
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_DARWIN_DARWIN_TIME_H__
-#define __LIBCFS_DARWIN_DARWIN_TIME_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-/* Portable time API */
-
-/*
- * Platform provides three opaque data-types:
- *
- *  cfs_time_t        represents point in time. This is internal kernel
- *                    time rather than "wall clock". This time bears no
- *                    relation to gettimeofday().
- *
- *  cfs_duration_t    represents time interval with resolution of internal
- *                    platform clock
- *
- *  cfs_fs_time_t     represents instance in world-visible time. This is
- *                    used in file-system time-stamps
- *
- *  cfs_time_t     cfs_time_current(void);
- *  cfs_time_t     cfs_time_add    (cfs_time_t, cfs_duration_t);
- *  cfs_duration_t cfs_time_sub    (cfs_time_t, cfs_time_t);
- *  int            cfs_time_before (cfs_time_t, cfs_time_t);
- *  int            cfs_time_beforeq(cfs_time_t, cfs_time_t);
- *
- *  cfs_duration_t cfs_duration_build(int64_t);
- *
- *  time_t         cfs_duration_sec (cfs_duration_t);
- *  void           cfs_duration_usec(cfs_duration_t, struct timeval *);
- *  void           cfs_duration_nsec(cfs_duration_t, struct timespec *);
- *
- *  void           cfs_fs_time_current(cfs_fs_time_t *);
- *  time_t         cfs_fs_time_sec    (cfs_fs_time_t *);
- *  void           cfs_fs_time_usec   (cfs_fs_time_t *, struct timeval *);
- *  void           cfs_fs_time_nsec   (cfs_fs_time_t *, struct timespec *);
- *  int            cfs_fs_time_before (cfs_fs_time_t *, cfs_fs_time_t *);
- *  int            cfs_fs_time_beforeq(cfs_fs_time_t *, cfs_fs_time_t *);
- *
- *  CFS_TIME_FORMAT
- *  CFS_DURATION_FORMAT
- *
- */
-
-#define ONE_BILLION ((u_int64_t)1000000000)
-#define ONE_MILLION 1000000
-
-#ifdef __KERNEL__
-#include <sys/types.h>
-#include <sys/systm.h>
-
-#include <sys/kernel.h>
-
-#include <mach/mach_types.h>
-#include <mach/time_value.h>
-#include <kern/clock.h>
-#include <sys/param.h>
-
-#include <libcfs/darwin/darwin-types.h>
-#include <libcfs/darwin/darwin-utils.h>
-#include <libcfs/darwin/darwin-lock.h>
-
-/*
- * There are three way to measure time in OS X:
- * 1. nanoseconds
- * 2. absolute time (abstime unit equal to the length of one bus cycle),
- *    schedule of thread/timer are counted by absolute time, but abstime
- *    in different mac can be different also, so we wouldn't use it.
- * 3. clock interval (1sec = 100hz). But clock interval only taken by KPI
- *    like tsleep().
- *
- * We use nanoseconds (uptime, not calendar time)
- *
- * clock_get_uptime()   :get absolute time since bootup.
- * nanouptime()         :get nanoseconds since bootup
- * microuptime()        :get microseonds since bootup
- * nanotime()           :get nanoseconds since epoch
- * microtime()          :get microseconds since epoch
- */
-typedef u_int64_t cfs_time_t; /* nanoseconds */
-typedef int64_t cfs_duration_t;
-
-#define CFS_TIME_T             "%llu"
-#define CFS_DURATION_T         "%lld"
-
-typedef struct timeval cfs_fs_time_t;
-
-static inline cfs_time_t cfs_time_current(void)
-{
-        struct timespec instant;
-
-        nanouptime(&instant);
-        return ((u_int64_t)instant.tv_sec) * NSEC_PER_SEC + instant.tv_nsec;
-}
-
-static inline time_t cfs_time_current_sec(void)
-{
-        struct timespec instant;
-
-        nanouptime(&instant);
-       return instant.tv_sec;
-}
-
-static inline cfs_time_t cfs_time_add(cfs_time_t t, cfs_duration_t d)
-{
-        return t + d;
-}
-
-static inline cfs_duration_t cfs_time_sub(cfs_time_t t1, cfs_time_t t2)
-{
-        return t1 - t2;
-}
-
-static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2)
-{
-        return (int64_t)t1 - (int64_t)t2 < 0;
-}
-
-static inline int cfs_time_beforeq(cfs_time_t t1, cfs_time_t t2)
-{
-        return (int64_t)t1 - (int64_t)t2 <= 0;
-}
-
-static inline void cfs_fs_time_current(cfs_fs_time_t *t)
-{
-        microtime((struct timeval *)t);
-}
-
-static inline time_t cfs_fs_time_sec(cfs_fs_time_t *t)
-{
-        return t->tv_sec;
-}
-
-static inline void cfs_fs_time_usec(cfs_fs_time_t *t, struct timeval *v)
-{
-        *v = *t;
-}
-
-static inline void cfs_fs_time_nsec(cfs_fs_time_t *t, struct timespec *s)
-{
-        s->tv_sec  = t->tv_sec;
-        s->tv_nsec = t->tv_usec * NSEC_PER_USEC;
-}
-
-static inline cfs_duration_t cfs_time_seconds(int seconds)
-{
-       return (NSEC_PER_SEC * (int64_t)seconds);
-}
-
-/*
- * internal helper function used by cfs_fs_time_before*()
- */
-static inline int64_t __cfs_fs_time_flat(cfs_fs_time_t *t)
-{
-        return ((int64_t)t->tv_sec)*NSEC_PER_SEC + t->tv_usec*NSEC_PER_USEC;
-}
-
-static inline int cfs_fs_time_before(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
-{
-        return __cfs_fs_time_flat(t1) - __cfs_fs_time_flat(t2) < 0;
-}
-
-static inline int cfs_fs_time_beforeq(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
-{
-        return __cfs_fs_time_flat(t1) - __cfs_fs_time_flat(t2) <= 0;
-}
-
-static inline time_t cfs_duration_sec(cfs_duration_t d)
-{
-        return d / NSEC_PER_SEC;
-}
-
-static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s)
-{
-        s->tv_sec = d / NSEC_PER_SEC;
-        s->tv_usec = (d - ((int64_t)s->tv_sec) * NSEC_PER_SEC) / NSEC_PER_USEC;
-}
-
-static inline void cfs_duration_nsec(cfs_duration_t d, struct timespec *s)
-{
-        s->tv_sec = d / NSEC_PER_SEC;
-        s->tv_nsec = d - ((int64_t)s->tv_sec) * NSEC_PER_SEC;
-}
-
-#define cfs_time_current_64 cfs_time_current
-#define cfs_time_add_64     cfs_time_add
-#define cfs_time_shift_64   cfs_time_shift
-#define cfs_time_before_64  cfs_time_before
-#define cfs_time_beforeq_64 cfs_time_beforeq
-
-/* 
- * One jiffy (in nanoseconds)
- *
- * osfmk/kern/sched_prim.c
- * #define DEFAULT_PREEMPTION_RATE      100
- */
-#define CFS_TICK               (NSEC_PER_SEC / (u_int64_t)100)
-
-#define LTIME_S(t)             (t)
-
-/* __KERNEL__ */
-#else
-
-/*
- * User level
- */
-#include <libcfs/user-time.h>
-
-/* __KERNEL__ */
-#endif
-
-/* __LIBCFS_DARWIN_DARWIN_TIME_H__ */
-#endif
-/*
- * Local variables:
- * c-indentation-style: "K&R"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
diff --git a/libcfs/include/libcfs/darwin/darwin-types.h b/libcfs/include/libcfs/darwin/darwin-types.h
deleted file mode 100644 (file)
index 4a11fdd..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/darwin/darwin-types.h
- *
- * Basic library routines.
- */
-
-#ifndef __LIBCFS_DARWIN_XNU_TYPES_H__
-#define __LIBCFS_DARWIN_XNU_TYPES_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#include <mach/mach_types.h>
-#include <sys/types.h>
-
-#ifndef _BLKID_TYPES_H
-#define _BLKID_TYPES_H
-#endif
-
-typedef u_int8_t        __u8;
-typedef u_int16_t       __u16;
-typedef u_int32_t       __u32;
-typedef u_int64_t       __u64;
-typedef int8_t          __s8;
-typedef int16_t         __s16;
-typedef int32_t         __s32;
-typedef int64_t         __s64;
-
-/* long integer with size equal to pointer */
-typedef unsigned long ulong_ptr_t;
-typedef long long_ptr_t;
-
-#ifdef __KERNEL__
-
-#include <kern/kern_types.h>
-
-
-typedef struct { int e; }              event_chan_t;
-
-/*
- * Atmoic define
- */
-#include <libkern/OSAtomic.h>
-
-typedef struct { volatile uint32_t counter; }  atomic_t;
-
-#define ATOMIC_INIT(i)                 { (i) }
-#define atomic_read(a)                 ((a)->counter)
-#define atomic_set(a, v)               (((a)->counter) = (v))
-#ifdef __DARWIN8__
-/* OS*Atomic return the value before the operation */
-#define atomic_add(v, a)               OSAddAtomic(v, (SInt32 *)&((a)->counter))
-#define atomic_sub(v, a)               OSAddAtomic(-(v), (SInt32 *)&((a)->counter))
-#define atomic_inc(a)                  OSIncrementAtomic((SInt32 *)&((a)->counter))
-#define atomic_dec(a)                  OSDecrementAtomic((SInt32 *)&((a)->counter))
-#else /* !__DARWIN8__ */
-#define atomic_add(v, a)               hw_atomic_add((__u32 *)&((a)->counter), v)
-#define atomic_sub(v, a)               hw_atomic_sub((__u32 *)&((a)->counter), v)
-#define atomic_inc(a)                  atomic_add(1, a)
-#define atomic_dec(a)                  atomic_sub(1, a)
-#endif /* !__DARWIN8__ */
-#define atomic_sub_and_test(v, a)       (atomic_sub(v, a) == (v))
-#define atomic_dec_and_test(a)          (atomic_dec(a) == 1)
-#define atomic_inc_return(a)            (atomic_inc(a) + 1)
-#define atomic_dec_return(a)            (atomic_dec(a) - 1)
-
-#include <libsa/mach/mach.h>
-typedef off_t                          loff_t;
-
-#else  /* !__KERNEL__ */
-
-#include <stdint.h>
-
-typedef off_t                          loff_t;
-
-#endif /* __KERNEL END */
-typedef unsigned short                  umode_t;
-
-#endif  /* __XNU_CFS_TYPES_H__ */
diff --git a/libcfs/include/libcfs/darwin/darwin-utils.h b/libcfs/include/libcfs/darwin/darwin-utils.h
deleted file mode 100644 (file)
index 98e0cc8..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_DARWIN_UTILS_H__
-#define __LIBCFS_DARWIN_UTILS_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#include <sys/random.h> 
-
-#ifdef __KERNEL__
-inline int isspace(char c);
-char *strpbrk(const char *cs, const char *ct);
-char * strsep(char **s, const char *ct);
-size_t strnlen(const char * s, size_t count);
-char * strstr(const char *in, const char *str);
-char * strrchr(const char *p, int ch);
-char * ul2dstr(unsigned long address, char *buf, int len);
-
-#define simple_strtol(a1, a2, a3)               strtol(a1, a2, a3)
-#define simple_strtoul(a1, a2, a3)              strtoul(a1, a2, a3)
-#define simple_strtoll(a1, a2, a3)              strtoq(a1, a2, a3)
-#define simple_strtoull(a1, a2, a3)             strtouq(a1, a2, a3)
-
-#define test_bit(i, a)                          isset(a, i)
-#define set_bit(i, a)                           setbit(a, i)
-#define clear_bit(i, a)                         clrbit(a, i)
-
-#define get_random_bytes(buf, len)     read_random(buf, len)
-
-#endif  /* __KERNEL__ */
-
-#ifndef min_t
-#define min_t(type,x,y) \
-       ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
-#endif
-#ifndef max_t
-#define max_t(type,x,y) \
-       ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
-#endif
-
-#define do_div(n,base)                          \
-       ({                                      \
-        __u64 __n = (n);                       \
-        __u32 __base = (base);                 \
-        __u32 __mod;                           \
-                                               \
-        __mod = __n % __base;                  \
-        n = __n / __base;                      \
-        __mod;                                 \
-        })
-
-#define NIPQUAD(addr)                  \
-       ((unsigned char *)&addr)[0],    \
-       ((unsigned char *)&addr)[1],    \
-       ((unsigned char *)&addr)[2],    \
-       ((unsigned char *)&addr)[3]
-
-#define HIPQUAD NIPQUAD
-
-#ifndef LIST_CIRCLE
-#define LIST_CIRCLE(elm, field)                                 \
-       do {                                                    \
-               (elm)->field.le_prev = &(elm)->field.le_next;   \
-       } while (0)
-#endif
-
-#endif /* __XNU_UTILS_H__ */
diff --git a/libcfs/include/libcfs/darwin/kp30.h b/libcfs/include/libcfs/darwin/kp30.h
deleted file mode 100644 (file)
index 3484df6..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_DARWIN_KP30__
-#define __LIBCFS_DARWIN_KP30__
-
-#ifdef __KERNEL__
-
-#include <sys/types.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-#include <mach/mach_types.h>
-#include <string.h>
-#include <sys/file.h>
-#include <sys/conf.h>
-#include <miscfs/devfs/devfs.h>
-#include <stdarg.h>
-
-#include <libcfs/darwin/darwin-lock.h>
-#include <libcfs/darwin/darwin-prim.h>
-#include <lnet/lnet.h>
-
-#error libcfs_register_panic_notifier() missing
-#error libcfs_unregister_panic_notifier() missing
-
-/* --------------------------------------------------------------------- */
-#define num_online_cpus()                       cfs_online_cpus()
-
-/******************************************************************************/
-/* XXX Liang: There is no module parameter supporting in OSX */
-#define CFS_MODULE_PARM(name, t, type, perm, desc)
-
-#define CFS_SYSFS_MODULE_PARM    0 /* no sysfs access to module parameters */
-/******************************************************************************/
-
-#else  /* !__KERNEL__ */
-# include <stdio.h>
-# include <stdlib.h>
-# include <stdint.h>
-# include <unistd.h>
-# include <time.h>
-# include <machine/limits.h>
-# include <sys/types.h>
-#endif
-
-#define BITS_PER_LONG   LONG_BIT
-
-#define IOCTL_LIBCFS_TYPE struct libcfs_ioctl_data
-
-#define LPO64 "%#llo"
-#define LPU64 "%llu"
-#define LPD64 "%lld"
-#define LPX64 "%#llx"
-# define LI_POISON ((int)0x5a5a5a5a)
-# define LL_POISON ((long)0x5a5a5a5a)
-# define LP_POISON ((void *)(long)0x5a5a5a5a)
-
-/*
- * long_ptr_t & ulong_ptr_t, same to "long" for gcc
- */
-# define LPLU "%lu"
-# define LPLD "%ld"
-# define LPLX "%#lx"
-
-/*
- * pid_t
- */
-# define LPPID "%d"
-
-#endif
diff --git a/libcfs/include/libcfs/darwin/libcfs.h b/libcfs/include/libcfs/darwin/libcfs.h
deleted file mode 100644 (file)
index 37e0710..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_DARWIN_LIBCFS_H__
-#define __LIBCFS_DARWIN_LIBCFS_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
-#endif
-
-#include <mach/mach_types.h>
-#include <sys/errno.h>
-#include <string.h>
-#include <libcfs/darwin/darwin-types.h>
-#include <libcfs/darwin/darwin-time.h>
-#include <libcfs/darwin/darwin-prim.h>
-#include <libcfs/darwin/darwin-mem.h>
-#include <libcfs/darwin/darwin-lock.h>
-#include <libcfs/darwin/darwin-fs.h>
-#include <libcfs/darwin/darwin-tcpip.h>
-#include <libcfs/darwin/kp30.h>
-
-#ifdef __KERNEL__
-# include <sys/types.h>
-# include <sys/time.h>
-# define do_gettimeofday(tv) microuptime(tv)
-#else
-# include <sys/time.h>
-# define do_gettimeofday(tv) gettimeofday(tv, NULL);
-typedef unsigned long long cycles_t;
-#endif
-
-#define __cpu_to_le64(x)                        OSSwapHostToLittleInt64(x)
-#define __cpu_to_le32(x)                        OSSwapHostToLittleInt32(x)
-#define __cpu_to_le16(x)                        OSSwapHostToLittleInt16(x)
-
-#define __le16_to_cpu(x)                        OSSwapLittleToHostInt16(x)
-#define __le32_to_cpu(x)                        OSSwapLittleToHostInt32(x)
-#define __le64_to_cpu(x)                        OSSwapLittleToHostInt64(x)
-
-#define cpu_to_le64(x)                          __cpu_to_le64(x)
-#define cpu_to_le32(x)                          __cpu_to_le32(x)
-#define cpu_to_le16(x)                          __cpu_to_le16(x)
-
-#define le64_to_cpu(x)                          __le64_to_cpu(x)
-#define le32_to_cpu(x)                          __le32_to_cpu(x)
-#define le16_to_cpu(x)                          __le16_to_cpu(x)
-
-#define __swab16(x)                             OSSwapInt16(x)
-#define __swab32(x)                             OSSwapInt32(x)
-#define __swab64(x)                             OSSwapInt64(x)
-#define __swab16s(x)                            do { *(x) = __swab16(*(x)); } while (0)
-#define __swab32s(x)                            do { *(x) = __swab32(*(x)); } while (0)
-#define __swab64s(x)                            do { *(x) = __swab64(*(x)); } while (0)
-
-
-#ifdef __KERNEL__
-# include <sys/systm.h>
-# include <pexpert/pexpert.h>
-/* Fix me */
-# define THREAD_SIZE 8192
-#else
-# define THREAD_SIZE 8192
-#endif
-
-#define CHECK_STACK(msgdata, mask, cdls) do {} while(0)
-#define CDEBUG_STACK() (0L)
-
-/* Darwin has defined RETURN, so we have to undef it in lustre */
-#ifdef RETURN
-#undef RETURN
-#endif
-
-/*
- * When this is enabled debugging messages are indented according to the
- * current "nesting level". Nesting level in increased when ENTRY macro
- * is executed, and decreased on EXIT and RETURN.
- */
-#ifdef __KERNEL__
-#define ENTRY_NESTING_SUPPORT (0)
-#endif
-
-#if ENTRY_NESTING_SUPPORT
-
-/*
- * Currently ENTRY_NESTING_SUPPORT is only supported for XNU port. Basic
- * idea is to keep per-thread pointer to small data structure (struct
- * cfs_debug_data) describing current nesting level. In XNU unused
- * proc->p_wmegs field in hijacked for this. On Linux
- * current->journal_info can be used. In user space
- * pthread_{g,s}etspecific().
- *
- * ENTRY macro allocates new cfs_debug_data on stack, and installs it as
- * a current nesting level, storing old data in cfs_debug_data it just
- * created.
- *
- * EXIT pops old value back.
- *
- */
-
-/*
- * One problem with this approach is that there is a lot of code that
- * does ENTRY and then escapes scope without doing EXIT/RETURN. In this
- * case per-thread current nesting level pointer is dangling (it points
- * to the stack area that is possible already overridden). To detect
- * such cases, we add two magic fields to the cfs_debug_data and check
- * them whenever current nesting level pointer is dereferenced. While
- * looking flaky this works because stack is always consumed
- * "continously".
- */
-enum {
-        CDD_MAGIC1 = 0x02128506,
-        CDD_MAGIC2 = 0x42424242
-};
-
-struct cfs_debug_data {
-        unsigned int           magic1;
-        struct cfs_debug_data *parent;
-        int                    nesting_level;
-        unsigned int           magic2;
-};
-
-void __entry_nesting(struct cfs_debug_data *child);
-void __exit_nesting(struct cfs_debug_data *child);
-unsigned int __current_nesting_level(void);
-
-#define ENTRY_NESTING                                           \
-struct cfs_debug_data __cdd = { .magic1        = CDD_MAGIC1,    \
-                                .parent        = NULL,          \
-                                .nesting_level = 0,             \
-                                .magic2        = CDD_MAGIC2 };  \
-__entry_nesting(&__cdd);
-
-#define EXIT_NESTING __exit_nesting(&__cdd)
-
-/* ENTRY_NESTING_SUPPORT */
-#else
-
-#define ENTRY_NESTING   do {;} while (0)
-#define EXIT_NESTING   do {;} while (0)
-#define __current_nesting_level() (0)
-
-/* ENTRY_NESTING_SUPPORT */
-#endif
-
-#define LUSTRE_LNET_PID          12345
-
-#define _XNU_LIBCFS_H
-
-/*
- * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
- *
- * Implementation is in darwin-curproc.c
- */
-#define CFS_CURPROC_COMM_MAX    MAXCOMLEN
-/*
- * XNU has no capabilities
- */
-typedef __u32 kernel_cap_t;
-
-#ifdef __KERNEL__
-enum {
-        /* if you change this, update darwin-util.c:cfs_stack_trace_fill() */
-        CFS_STACK_TRACE_DEPTH = 16
-};
-
-struct cfs_stack_trace {
-        void *frame[CFS_STACK_TRACE_DEPTH];
-};
-
-#define printk(format, args...)                 printf(format, ## args)
-
-#ifdef WITH_WATCHDOG
-#undef WITH_WATCHDOG
-#endif
-
-/*
- * Portable API to access common characteristics of "current" UNIX process.
- */
-uid_t  current_uid(void);
-gid_t  current_gid(void);
-uid_t  current_euid(void);
-gid_t  current_egid(void);
-uid_t  current_fsuid(void);
-gid_t  current_fsgid(void);
-pid_t  current_pid(void);
-int    in_group_p(gid_t group);
-mode_t current_umask(void);
-char  *current_comm(void);
-
-/* check if task is running in compat mode.*/
-int current_is_32bit(void);
-
-#endif /* __KERNEL__ */
-
-#endif /* _XNU_LIBCFS_H */
index e85731d..2fbab09 100644 (file)
@@ -47,8 +47,6 @@
 #include <libcfs/posix/libcfs.h>
 #elif defined(__linux__)
 #include <libcfs/linux/libcfs.h>
-#elif defined(__APPLE__)
-#include <libcfs/darwin/libcfs.h>
 #else
 #error Unsupported operating system.
 #endif
index 28c7c57..009e63a 100644 (file)
@@ -299,10 +299,6 @@ do {                                                                       \
        goto label;                                                     \
 } while (0)
 
-/*
- * if rc == NULL, we need to code as RETURN((void *)NULL), otherwise
- * there will be a warning in osx.
- */
 #if defined(__GNUC__)
 
 long libcfs_log_return(struct libcfs_debug_msg_data *, long rc);
index da04cfd..d19d12f 100644 (file)
@@ -162,29 +162,6 @@ typedef unsigned long long cfs_cycles_t;
 #   error "Unknown byte order"
 #  endif /* __BIG_ENDIAN */
 # endif /* __LITTLE_ENDIAN */
-#elif __APPLE__
-#define __cpu_to_le64(x)                        OSSwapHostToLittleInt64(x)
-#define __cpu_to_le32(x)                        OSSwapHostToLittleInt32(x)
-#define __cpu_to_le16(x)                        OSSwapHostToLittleInt16(x)
-
-#define __le16_to_cpu(x)                        OSSwapLittleToHostInt16(x)
-#define __le32_to_cpu(x)                        OSSwapLittleToHostInt32(x)
-#define __le64_to_cpu(x)                        OSSwapLittleToHostInt64(x)
-
-#define cpu_to_le64(x)                          __cpu_to_le64(x)
-#define cpu_to_le32(x)                          __cpu_to_le32(x)
-#define cpu_to_le16(x)                          __cpu_to_le16(x)
-
-#define le64_to_cpu(x)                          __le64_to_cpu(x)
-#define le32_to_cpu(x)                          __le32_to_cpu(x)
-#define le16_to_cpu(x)                          __le16_to_cpu(x)
-
-#define __swab16(x)                             OSSwapInt16(x)
-#define __swab32(x)                             OSSwapInt32(x)
-#define __swab64(x)                             OSSwapInt64(x)
-#define __swab16s(x)                            do { *(x) = __swab16(*(x)); } while (0)
-#define __swab32s(x)                            do { *(x) = __swab32(*(x)); } while (0)
-#define __swab64s(x)                            do { *(x) = __swab64(*(x)); } while (0)
 #endif
 
 # ifndef THREAD_SIZE /* x86_64 linux has THREAD_SIZE in userspace */
index cd85563..c2154e1 100644 (file)
@@ -73,171 +73,6 @@ typedef pthread_cond_t      l_cond_t;
 #define l_cond_wait(c, s)      pthread_cond_wait(c, s)
 #endif
 
-#elif __APPLE__
-
-#ifdef HAVE_LIBREADLINE
-#define READLINE_LIBRARY
-#include <readline/readline.h>
-typedef VFunction       rl_vintfunc_t;
-typedef VFunction       rl_voidfunc_t;
-#endif /* HAVE_LIBREADLINE */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <sys/shm.h>
-#include <sys/semaphore.h>
-
-/*
- * POSIX compliant inter-process synchronization aren't supported well
- * in Darwin, pthread_mutex_t and pthread_cond_t can only work as
- * inter-thread synchronization, they wouldn't work even being put in
- * shared memory for multi-process. PTHREAD_PROCESS_SHARED is not 
- * supported by Darwin also (pthread_mutexattr_setpshared() with the 
- * PTHREAD_PROCESS_SHARED attribute will return EINVAL). 
- *
- * The only inter-process sychronization mechanism can be used in Darwin
- * is POSIX NAMED semaphores and file lock, here we use NAMED semaphore
- * to implement mutex and condition. 
- *
- * XXX Liang:
- * They are just proto-type now, more tests are needed. 
- */
-#define L_LOCK_DEBUG           (0)             
-
-#define L_SEM_NAMESIZE         32
-
-typedef struct {
-       sem_t           *s_sem;
-#if L_LOCK_DEBUG
-       char            s_name[L_SEM_NAMESIZE];
-#endif
-} l_sem_t;
-
-typedef l_sem_t         l_mutex_t;
-
-typedef struct {
-       l_mutex_t       c_guard;
-       int             c_count;
-       l_sem_t         c_waiter;
-} l_cond_t;
-
-static inline int l_sem_init(l_sem_t *sem, int val)
-{
-       char *s_name;
-#if L_LOCK_DEBUG
-       s_name = sem->s_name;
-#else
-       char buf[L_SEM_NAMESIZE];
-       s_name = buf;
-#endif
-       /* get an unique name for named semaphore */
-       snprintf(s_name, L_SEM_NAMESIZE, "%d-%p", (int)getpid(), sem);
-       sem->s_sem = sem_open(s_name, O_CREAT, 0600, val);
-       if ((int)sem->s_sem == SEM_FAILED) {
-               fprintf(stderr, "lock %s creating fail: %d, %d!\n",
-                               s_name, (int)sem->s_sem, errno);
-               return -1;
-       } else {
-#if L_LOCK_DEBUG
-               printf("open lock: %s\n", s_name);
-#endif
-       }
-       return 0;
-}
-
-static inline void l_sem_done(l_sem_t *sem)
-{
-#if L_LOCK_DEBUG
-       printf("close lock: %s.\n", sem->s_name);
-#endif
-       sem_close(sem->s_sem);
-}
-
-static inline void l_sem_down(l_sem_t *sem)
-{
-#if L_LOCK_DEBUG
-       printf("sem down :%s\n", sem->s_name);
-#endif
-       sem_wait(sem->s_sem);
-}
-
-static inline void l_sem_up(l_sem_t *sem)
-{
-#if L_LOCK_DEBUG
-       printf("sem up  :%s\n", sem->s_name);
-#endif
-       sem_post(sem->s_sem);
-}
-
-static inline void l_mutex_init(l_mutex_t *mutex)
-{
-       l_sem_init((l_sem_t *)mutex, 1);
-}
-
-static inline void l_mutex_init_locked(l_mutex_t *mutex)
-{
-       l_sem_init((l_sem_t *)mutex, 0);
-}
-
-static inline void l_mutex_done(l_mutex_t *mutex)
-{
-       l_sem_done((l_sem_t *)mutex);
-}
-
-static inline void l_mutex_lock(l_mutex_t *mutex)
-{
-#if L_LOCK_DEBUG
-       printf("lock cfs_mutex  :%s\n", mutex->s_name);
-#endif
-       sem_wait(mutex->s_sem);
-}
-
-static inline void l_mutex_unlock(l_mutex_t *mutex)
-{
-#if L_LOCK_DEBUG
-       printf("unlock cfs_mutex: %s\n", mutex->s_name);
-#endif
-       sem_post(mutex->s_sem);
-}
-
-static inline void l_cond_init(l_cond_t *cond)
-{
-       l_mutex_init(&cond->c_guard);
-       l_sem_init(&cond->c_waiter, 0);
-       cond->c_count = 0;
-}
-
-static inline void l_cond_done(l_cond_t *cond)
-{
-       if (cond->c_count != 0)
-               fprintf(stderr, "your waiter list is not empty: %d!\n", cond->c_count);
-       l_mutex_done(&cond->c_guard);
-       l_sem_done(&cond->c_waiter);
-}
-
-static inline void l_cond_wait(l_cond_t *cond, l_mutex_t *lock)
-{
-       l_mutex_lock(&cond->c_guard);
-       cond->c_count --;
-       l_mutex_unlock(&cond->c_guard);
-       l_mutex_unlock(lock);
-       l_sem_down(&cond->c_waiter);
-       l_mutex_lock(lock);
-}
-
-static inline void l_cond_broadcast(l_cond_t *cond)
-{
-       l_mutex_lock(&cond->c_guard);
-       while (cond->c_count < 0) {
-               l_sem_up(&cond->c_waiter);
-               cond->c_count ++;
-       }
-       l_mutex_unlock(&cond->c_guard);
-}
-
 #else /* other platform */
 
 #ifdef HAVE_LIBREADLINE
diff --git a/libcfs/libcfs/Info.plist b/libcfs/libcfs/Info.plist
deleted file mode 100644 (file)
index aaf9b2f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>CFBundleDevelopmentRegion</key>
-       <string>English</string>
-       <key>CFBundleExecutable</key>
-       <string>libcfs</string>
-       <key>CFBundleIconFile</key>
-       <string></string>
-       <key>CFBundleIdentifier</key>
-       <string>com.clusterfs.lustre.libcfs</string>
-       <key>CFBundleInfoDictionaryVersion</key>
-       <string>6.0</string>
-       <key>CFBundlePackageType</key>
-       <string>KEXT</string>
-       <key>CFBundleSignature</key>
-       <string>????</string>
-       <key>CFBundleVersion</key>
-       <string>1.0.1</string>
-       <key>OSBundleCompatibleVersion</key>
-       <string>1.0.0</string>
-       <key>OSBundleLibraries</key>
-       <dict>
-               <key>com.apple.kpi.bsd</key>
-               <string>8.0.0b1</string>
-               <key>com.apple.kpi.libkern</key>
-               <string>8.0.0b1</string>
-               <key>com.apple.kpi.mach</key>
-               <string>8.0.0b1</string>
-               <key>com.apple.kpi.unsupported</key>
-               <string>8.0.0b1</string>
-       </dict>
-</dict>
-</plist>
index 82e903e..252a199 100644 (file)
 #
 
 SUBDIRS = linux util posix
-if DARWIN
-SUBDIRS += darwin
-endif
-DIST_SUBDIRS = linux util posix darwin
+DIST_SUBDIRS = linux util posix
 
 noinst_LIBRARIES= libcfs.a
 libcfs_a_SOURCES= posix/posix-debug.c user-prim.c user-lock.c user-tcpip.c  \
@@ -70,33 +67,10 @@ if LINUX
 modulenet_DATA := libcfs$(KMODEXT)
 endif
 
-if DARWIN
-macos_PROGRAMS = libcfs
-
-nodist_libcfs_SOURCES = darwin/darwin-sync.c darwin/darwin-mem.c       \
-       darwin/darwin-prim.c darwin/darwin-fs.c darwin/darwin-curproc.c \
-       darwin/darwin-tcpip.c darwin/darwin-utils.c                     \
-       darwin/darwin-debug.c darwin/darwin-proc.c                      \
-       darwin/darwin-tracefile.c darwin/darwin-module.c                \
-       posix/posix-debug.c module.c tracefile.c nidstrings.c watchdog.c \
-       kernel_user_comm.c hash.c posix/rbtree.c heap.c
-
-libcfs_CFLAGS := $(EXTRA_KCFLAGS)
-libcfs_LDFLAGS := $(EXTRA_KLDFLAGS)
-libcfs_LDADD := $(EXTRA_KLIBS)
-
-plist_DATA = Info.plist
-
-install_data_hook = fix-kext-ownership
-
-endif
-
 endif
 
-install-data-hook: $(install_data_hook)
-
-MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux-*.c linux/*.o darwin/*.o libcfs
-EXTRA_DIST := $(libcfs-all-objs:%.o=%.c) Info.plist tracefile.h prng.c \
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux-*.c linux/*.o libcfs
+EXTRA_DIST := $(libcfs-all-objs:%.o=%.c) tracefile.h prng.c \
              user-lock.c user-tcpip.c user-bitops.c user-prim.c workitem.c \
              user-mem.c kernel_user_comm.c fail.c libcfs_cpu.c heap.c \
              libcfs_mem.c libcfs_lock.c user-string.c linux/linux-tracefile.h
diff --git a/libcfs/libcfs/darwin/.gitignore b/libcfs/libcfs/darwin/.gitignore
deleted file mode 100644 (file)
index 10a7e8d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/Makefile.in
diff --git a/libcfs/libcfs/darwin/Makefile.am b/libcfs/libcfs/darwin/Makefile.am
deleted file mode 100644 (file)
index a389486..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-EXTRA_DIST = \
-       darwin-mem.c \
-       darwin-proc.c \
-       darwin-utils.c \
-       darwin-debug.c \
-       darwin-module.c \
-       darwin-sync.c \
-       darwin-fs.c \
-       darwin-prim.c \
-       darwin-tracefile.c \
-       darwin-curproc.c \
-       darwin-tcpip.c
diff --git a/libcfs/libcfs/darwin/darwin-curproc.c b/libcfs/libcfs/darwin/darwin-curproc.c
deleted file mode 100644 (file)
index b0ac7ad..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/darwin/darwin-curproc.c
- *
- * Lustre curproc API implementation for XNU kernel
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <libcfs/libcfs.h>
-
-/*
- * Implementation of cfs_curproc API (see lnet/include/libcfs/curproc.h)
- * for XNU kernel.
- */
-
-static inline struct ucred *curproc_ucred(void)
-{
-#ifdef __DARWIN8__
-        return proc_ucred(current_proc());
-#else
-        return current_proc()->p_cred->pc_ucred;
-#endif
-}
-
-uid_t  current_uid(void)
-{
-        return curproc_ucred()->cr_uid;
-}
-
-gid_t  current_gid(void)
-{
-        LASSERT(curproc_ucred()->cr_ngroups > 0);
-        return curproc_ucred()->cr_groups[0];
-}
-
-uid_t  current_fsuid(void)
-{
-#ifdef __DARWIN8__
-        return curproc_ucred()->cr_ruid;
-#else
-        return current_proc()->p_cred->p_ruid;
-#endif
-}
-
-gid_t  current_fsgid(void)
-{
-#ifdef __DARWIN8__
-        return curproc_ucred()->cr_rgid;
-#else
-        return current_proc()->p_cred->p_rgid;
-#endif
-}
-
-pid_t  current_pid(void)
-{
-#ifdef __DARWIN8__
-        /* no pid for each thread, return address of thread struct */
-        return (pid_t)current_thread();
-#else
-        return current_proc()->p_pid;
-#endif
-}
-
-int    in_group_p(gid_t gid)
-{
-        int i;
-        struct ucred *cr;
-
-        cr = curproc_ucred();
-        LASSERT(cr != NULL);
-
-        for (i = 0; i < cr->cr_ngroups; ++ i) {
-                if (cr->cr_groups[i] == gid)
-                        return 1;
-        }
-        return 0;
-}
-
-mode_t current_umask(void)
-{
-#ifdef __DARWIN8__
-        /*
-         * XXX Liang:
-         *
-         * fd_cmask is not available in kexts, so we just assume 
-         * verything is permited.
-         */
-        return -1;
-#else
-        return current_proc()->p_fd->fd_cmask;
-#endif
-}
-
-char  *current_comm(void)
-{
-#ifdef __DARWIN8__
-        /*
-         * Writing to proc->p_comm is not permited in Darwin8,
-         * because proc_selfname() only return a copy of proc->p_comm,
-         * so this function is not really working while user try to 
-         * change comm of current process.
-         */
-        static char     pcomm[MAXCOMLEN+1];
-
-        proc_selfname(pcomm, MAXCOMLEN+1);
-        return pcomm;
-#else
-        return current_proc()->p_comm;
-#endif
-}
-
-struct user_namespace init_user_ns __read_mostly;
-EXPORT_SYMBOL(init_user_ns);
-
-void cfs_cap_raise(cfs_cap_t cap) {}
-void cfs_cap_lower(cfs_cap_t cap) {}
-
-int cfs_cap_raised(cfs_cap_t cap)
-{
-        return 1;
-}
-
-cfs_cap_t cfs_curproc_cap_pack(void) {
-        return -1;
-}
-
-void cfs_curproc_cap_unpack(cfs_cap_t cap) {
-}
-
-int cfs_capable(cfs_cap_t cap)
-{
-        return cap == CFS_CAP_SYS_BOOT ? is_suser(): is_suser1();
-}
-
-/*
- * Local variables:
- * c-indentation-style: "K&R"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
diff --git a/libcfs/libcfs/darwin/darwin-debug.c b/libcfs/libcfs/darwin/darwin-debug.c
deleted file mode 100644 (file)
index 9b1894a..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-# define DEBUG_SUBSYSTEM S_LNET
-
-#include <libcfs/libcfs.h>
-#include "tracefile.h"
-
-void libcfs_debug_dumpstack(struct task_struct *tsk)
-{
-       return;
-}
-
-void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata)
-{
-}
-
-void lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
-{
-       libcfs_catastrophe = 1;
-       CEMERG("LBUG: pid: %u thread: %#x\n",
-              (unsigned)current_pid(), (unsigned)current_thread());
-       libcfs_debug_dumplog();
-       libcfs_run_lbug_upcall(msgdata);
-       while (1)
-               schedule();
-
-       /* panic("lbug_with_loc(%s, %s, %d)", file, func, line) */
-}
-
-#if ENTRY_NESTING_SUPPORT
-
-static inline struct cfs_debug_data *__current_cdd(void)
-{
-       struct cfs_debug_data *cdd;
-
-       cdd = (struct cfs_debug_data *)current_uthread()->uu_nlminfo;
-       if (cdd != NULL &&
-           cdd->magic1 == CDD_MAGIC1 && cdd->magic2 == CDD_MAGIC2 &&
-           cdd->nesting_level < 1000)
-               return cdd;
-       else
-               return NULL;
-}
-
-static inline void __current_cdd_set(struct cfs_debug_data *cdd)
-{
-       current_uthread()->uu_nlminfo = (void *)cdd;
-}
-
-void __entry_nesting(struct cfs_debug_data *child)
-{
-       struct cfs_debug_data *parent;
-
-       parent = __current_cdd();
-       if (parent != NULL) {
-               child->parent        = parent;
-               child->nesting_level = parent->nesting_level + 1;
-       }
-       __current_cdd_set(child);
-}
-
-void __exit_nesting(struct cfs_debug_data *child)
-{
-       __current_cdd_set(child->parent);
-}
-
-unsigned int __current_nesting_level(void)
-{
-       struct cfs_debug_data *cdd;
-
-       cdd = __current_cdd();
-       if (cdd != NULL)
-               return cdd->nesting_level;
-       else
-               return 0;
-}
-/* ENTRY_NESTING_SUPPORT */
-#endif
diff --git a/libcfs/libcfs/darwin/darwin-fs.c b/libcfs/libcfs/darwin/darwin-fs.c
deleted file mode 100644 (file)
index 09b103b..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/darwin/darwin-fs.c
- *
- * Darwin porting library
- * Make things easy to port
- *
- * Author: Phil Schwan <phil@clusterfs.com>
- */
-
-#include <mach/mach_types.h>
-#include <string.h>
-#include <sys/file.h>
-#include <sys/malloc.h>
-#include <sys/conf.h>
-#include <sys/mount.h>
-#include <sys/uio.h>
-#include <sys/filedesc.h>
-#include <sys/namei.h>
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <libcfs/libcfs.h>
-
-/*
- * Kernel APIs for file system in xnu
- *
- * Public functions
- */
-
-#ifdef __DARWIN8__
-#include <sys/vnode.h>
-
-extern int vn_rdwr(enum uio_rw, vnode_t, caddr_t, int, off_t, enum uio_seg, int, kauth_cred_t, int *, proc_t);
-
-/* vnode_size() is not exported */
-static errno_t
-vnode_size(vnode_t vp, off_t *sizep, vfs_context_t ctx)
-{
-        struct vnode_attr       va;
-        int                     error; 
-        
-        VATTR_INIT(&va);
-        VATTR_WANTED(&va, va_data_size);
-        error = vnode_getattr(vp, &va, ctx);
-        if (!error)
-                *sizep = va.va_data_size;
-        return(error);
-}
-
-/*
- * XXX Liang:
- *
- * kern_file_*() are not safe for multi-threads now,
- * however, we need them only for tracefiled, so it's
- * not so important to implement for MT.
- */
-int
-kern_file_size(struct cfs_kern_file *fp, off_t *psize)
-{
-       int     error;
-       off_t   size;
-
-       error = vnode_size(fp->f_vp, &size, fp->f_ctxt);
-       if (error)
-               return error;
-
-       if (psize)
-               *psize = size;
-       return 0;
-}
-
-struct cfs_kern_file *
-kern_file_open(const char *filename, int uflags, int mode)
-{
-       struct cfs_kern_file    *fp;
-       vnode_t                 vp;
-       int                     error;
-
-       fp = (struct cfs_kern_file *)_MALLOC(sizeof(struct cfs_kern_file),
-                                            M_TEMP, M_WAITOK);
-       if (fp == NULL)
-               return ERR_PTR(-ENOMEM);
-
-       fp->f_flags = FFLAGS(uflags);
-       fp->f_ctxt = vfs_context_create(NULL);
-
-       error = vnode_open(filename, fp->f_flags, mode, 0, &vp, fp->f_ctxt);
-       if (error != 0) {
-               _FREE(fp, M_TEMP);
-               return ERR_PTR(-error);
-       } else {
-               fp->f_vp = vp;
-       }
-
-       return fp;
-}
-
-int
-kern_file_close(struct cfs_kern_file *fp)
-{
-        vnode_close(fp->f_vp, fp->f_flags, fp->f_ctxt);
-        vfs_context_rele(fp->f_ctxt);
-        _FREE(fp, M_TEMP);
-
-        return 0;
-}
-
-int
-kern_file_read(struct cfs_kern_file *fp, void *buf, size_t nbytes, loff_t *pos)
-{
-        struct proc *p = current_proc();
-        int     resid;
-        int     error;
-
-        assert(buf != NULL);
-        assert(fp != NULL && fp->f_vp != NULL);
-
-        error = vn_rdwr(UIO_READ, fp->f_vp, buf, nbytes, *pos, 
-                        UIO_SYSSPACE32, 0, vfs_context_ucred(fp->f_ctxt), &resid, p);
-        if ((error) || (nbytes == resid)) {
-                if (!error)
-                        error = -EINVAL;
-                return error;
-        }
-        *pos += nbytes - resid;
-
-        return (int)(nbytes - resid);
-}
-
-int
-kern_file_write(struct cfs_kern_file *fp, void *buf, size_t nbytes, loff_t *pos)
-{
-        struct proc *p = current_proc();
-        int     resid;
-        int     error;
-
-        assert(buf != NULL);
-        assert(fp != NULL && fp->f_vp != NULL);
-
-        error = vn_rdwr(UIO_WRITE, fp->f_vp, buf, nbytes, *pos, 
-                        UIO_SYSSPACE32, 0, vfs_context_ucred(fp->f_ctxt), &resid, p);
-        if ((error) || (nbytes == resid)) {
-                if (!error)
-                        error = -EINVAL;
-                return error;
-        }
-        *pos += nbytes - resid;
-
-        return (int)(nbytes - resid);
-
-}
-
-int
-kern_file_sync (struct cfs_kern_file *fp)
-{
-        return VNOP_FSYNC(fp->f_vp, MNT_WAIT, fp->f_ctxt);
-}
-
-#else  /* !__DARWIN8__ */
-
-int
-kern_file_size(struct file *fp, off_t *size)
-{
-        struct vnode *vp = (struct vnode *)fp->f_data;
-        struct stat sb;
-        int     rc;
-
-        rc = vn_stat(vp, &sb, current_proc());
-        if (rc) {
-                *size = 0;
-                return rc;
-        }
-        *size = sb.st_size;
-        return 0;
-}
-
-struct file *
-kern_file_open(const char *filename, int flags, int mode)
-{
-       struct nameidata        nd;
-       struct file             *fp;
-       register struct vnode   *vp;
-       int                     rc;
-       extern struct fileops   vnops;
-       extern int nfiles;
-       CFS_DECL_CONE_DATA;
-
-       CFS_CONE_IN;
-       nfiles++;
-       MALLOC_ZONE(fp, struct file *, sizeof(file_t), M_FILE, M_WAITOK|M_ZERO);
-       bzero(fp, sizeof(*fp));
-       fp->f_count = 1;
-       LIST_CIRCLE(fp, f_list);
-       NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, (char *)filename, current_proc());
-       if ((rc = vn_open(&nd, flags, mode)) != 0){
-               printf("filp_open failed at (%d)\n", rc);
-               FREE_ZONE(fp, sizeof(*fp), M_FILE);
-               CFS_CONE_EX;
-               return ERR_PTR(rc);
-       }
-       vp = nd.ni_vp;
-       fp->f_flag = flags & FMASK;
-       fp->f_type = DTYPE_VNODE;
-       fp->f_ops = &vnops;
-       fp->f_data = (caddr_t)vp;
-       fp->f_cred = current_proc()->p_ucred;
-       /*
-        * Hold cred to increase reference
-        */
-       crhold(fp->f_cred);
-       /*
-        * vnode is locked inside vn_open for lookup,
-        * we should release the lock before return
-        */
-       VOP_UNLOCK(vp, 0, current_proc());
-       CFS_CONE_EX;
-
-       return fp;
-}
-
-static int
-frele_internal(struct file *fp)
-{
-       if (fp->f_count == (short)0xffff)
-               panic("frele of lustre: stale");
-       if (--fp->f_count < 0)
-               panic("frele of lustre: count < 0");
-       return ((int)fp->f_count);
-}
-
-int
-kern_file_close(struct file *fp)
-{
-       struct vnode    *vp;
-       CFS_DECL_CONE_DATA;
-       
-       if (fp == NULL)
-               return 0;
-
-        CFS_CONE_IN;
-       if (frele_internal(fp) > 0)
-                goto out;
-       vp = (struct vnode *)fp->f_data;
-       (void )vn_close(vp, fp->f_flag, fp->f_cred, current_proc());
-        /*
-        * ffree(fp);
-         * Dont use ffree to release fp!!!!
-         * ffree will call LIST_REMOVE(fp),
-         * but fp is not in any list, this will
-         * cause kernel panic
-         */
-        struct ucred *cred;
-        cred = fp->f_cred;
-        if (cred != NOCRED) {
-                fp->f_cred = NOCRED;
-                crfree(cred);
-        }
-        extern int nfiles;
-        nfiles--;
-        memset(fp, 0xff, sizeof *fp);
-        fp->f_count = (short)0xffff;
-        FREE_ZONE(fp, sizeof *fp, M_FILE);
-out:
-        CFS_CONE_EX;
-       return 0;
-}
-
-extern void bwillwrite(void);
-
-/*
- * Write buffer to filp inside kernel
- */
-int
-kern_file_write(struct file *fp, void *buf, size_t nbyte, loff_t *pos)
-{
-       struct uio auio;
-       struct iovec aiov;
-       struct proc *p = current_proc();
-       long cnt, error = 0;
-        int flags = 0;
-        CFS_DECL_CONE_DATA;
-
-       aiov.iov_base = (void *)(uintptr_t)buf;
-       aiov.iov_len = nbyte;
-       auio.uio_iov = &aiov;
-       auio.uio_iovcnt = 1;
-        if (pos != NULL) {
-               auio.uio_offset = *pos;
-                /* 
-                 * Liang: If don't set FOF_OFFSET, vn_write()
-                 * will use fp->f_offset as the the real offset.
-                 * Same in vn_read()
-                 */
-                flags |= FOF_OFFSET;
-        } else
-                auio.uio_offset = (off_t)-1;
-       if (nbyte > INT_MAX)
-               return (EINVAL);
-       auio.uio_resid = nbyte;
-       auio.uio_rw = UIO_WRITE;
-       auio.uio_segflg = UIO_SYSSPACE;
-       auio.uio_procp = p;
-
-       cnt = nbyte;
-        CFS_CONE_IN;
-       if (fp->f_type == DTYPE_VNODE)
-               bwillwrite();   /* empty stuff now */
-       if ((error = fo_write(fp, &auio, fp->f_cred, flags, p))) {
-               if (auio.uio_resid != cnt && (error == ERESTART ||\
-                   error == EINTR || error == EWOULDBLOCK))
-                       error = 0;
-               /* The socket layer handles SIGPIPE */
-               if (error == EPIPE && fp->f_type != DTYPE_SOCKET)
-                       psignal(p, SIGPIPE);
-       }
-        CFS_CONE_EX;
-       if (error != 0)
-               cnt = -error;
-       else
-               cnt -= auio.uio_resid;
-        if (pos != NULL)
-                *pos += cnt;
-       return cnt;
-}
-
-/*
- * Read from filp inside kernel
- */
-int
-kern_file_read(struct file *fp, void *buf, size_t nbyte, loff_t *pos)
-{
-       struct uio auio;
-       struct iovec aiov;
-       struct proc *p = current_proc();
-       long cnt, error = 0;
-        int  flags = 0;
-        CFS_DECL_CONE_DATA;
-
-       aiov.iov_base = (caddr_t)buf;
-       aiov.iov_len = nbyte;
-       auio.uio_iov = &aiov;
-       auio.uio_iovcnt = 1;
-        if (pos != NULL) {
-               auio.uio_offset = *pos;
-                flags |= FOF_OFFSET;
-        } else
-                auio.uio_offset = (off_t)-1;
-       if (nbyte > INT_MAX)
-               return (EINVAL);
-       auio.uio_resid = nbyte;
-       auio.uio_rw = UIO_READ;
-       auio.uio_segflg = UIO_SYSSPACE;
-       auio.uio_procp = p;
-
-       cnt = nbyte;
-        CFS_CONE_IN;
-       if ((error = fo_read(fp, &auio, fp->f_cred, flags, p)) != 0) {
-               if (auio.uio_resid != cnt && (error == ERESTART ||
-                   error == EINTR || error == EWOULDBLOCK))
-                       error = 0;
-       }
-        CFS_CONE_EX;
-       if (error != 0)
-               cnt = -error;
-       else
-               cnt -= auio.uio_resid;
-        if (pos != NULL)
-                *pos += cnt;
-
-       return cnt;
-}
-
-int
-kern_file_sync(struct file *fp)
-{
-       struct vnode *vp = (struct vnode *)fp->f_data;
-       struct proc *p = current_proc();
-       int error = 0;
-        CFS_DECL_CONE_DATA;
-       
-        CFS_CONE_IN;
-       if (fref(fp) == -1) {
-                CFS_CONE_EX;
-               return (-EBADF);
-        }
-       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
-       error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p);
-       VOP_UNLOCK(vp, 0, p);
-       frele(fp);
-        CFS_CONE_EX;
-
-       return error;
-}
-
-#endif /* !__DARWIN8__ */
-
-struct posix_acl *posix_acl_alloc(int count, int flags)
-{
-        static struct posix_acl acl;
-        return &acl;
-}
diff --git a/libcfs/libcfs/darwin/darwin-internal.h b/libcfs/libcfs/darwin/darwin-internal.h
deleted file mode 100644 (file)
index 7d62514..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#ifndef __LIBCFS_DARWIN_INTERNAL_H__
-#define __LIBCFS_DARWIN_INTERNAL_H__
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-#include <sys/sysctl.h>
-
-int cfs_sysctl_isvalid(void);
-struct sysctl_oid *cfs_alloc_sysctl_node(struct sysctl_oid_list *parent, int nbr, int access,
-                                        const char *name, int (*handler) SYSCTL_HANDLER_ARGS);
-struct sysctl_oid *cfs_alloc_sysctl_int(struct sysctl_oid_list *parent, int n,
-                                       const char *name, int *ptr, int val);
-struct sysctl_oid * cfs_alloc_sysctl_long(struct sysctl_oid_list *parent, int nbr, int access,
-                                         const char *name, int *ptr, int val);
-struct sysctl_oid * cfs_alloc_sysctl_string(struct sysctl_oid_list *parent, int nbr, int access,
-                                           const char *name, char *ptr, int len);
-struct sysctl_oid * cfs_alloc_sysctl_struct(struct sysctl_oid_list *parent, int nbr, int access,
-                                           const char *name, void *ptr, int size);
-
-#endif
diff --git a/libcfs/libcfs/darwin/darwin-mem.c b/libcfs/libcfs/darwin/darwin-mem.c
deleted file mode 100644 (file)
index 4a30bec..0000000
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/darwin/darwin-mem.c
- *
- * Author: Liang Zhen <liangzhen@clusterfs.com>
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <mach/mach_types.h>
-#include <string.h>
-#include <sys/malloc.h>
-
-#include <libcfs/libcfs.h>
-#include "darwin-internal.h"
-
-#if CFS_INDIVIDUAL_ZONE
-extern zone_t zinit( vm_size_t, vm_size_t, vm_size_t, const char *);
-extern void * zalloc(zone_t zone);
-extern void *zalloc_noblock(zone_t zone);
-extern void zfree(zone_t zone, void *addr);
-
-struct cfs_zone_nob {
-       struct list_head        *z_nob; /* Pointer to z_link */
-       struct list_head        z_link; /* Do NOT access it directly */
-};
-
-static struct cfs_zone_nob      cfs_zone_nob;
-static spinlock_t              cfs_zone_guard;
-
-struct kmem_cache *mem_cache_find(const char *name, size_t objsize)
-{
-       struct kmem_cache               *walker = NULL;
-
-       LASSERT(cfs_zone_nob.z_nob != NULL);
-
-       spin_lock(&cfs_zone_guard);
-       list_for_each_entry(walker, cfs_zone_nob.z_nob, mc_link) {
-               if (!strcmp(walker->mc_name, name) && \
-                   walker->mc_size == objsize)
-                       break;
-       }
-       spin_unlock(&cfs_zone_guard);
-
-       return walker;
-}
-
-/*
- * our wrapper around kern/zalloc.c:zinit()
- *
- * Creates copy of name and calls zinit() to do real work. Needed because zone
- * survives kext unloading, so that @name cannot be just static string
- * embedded into kext image.
- */
-struct kmem_cache *mem_cache_create(vm_size_t objsize, const char *name)
-{
-       struct kmem_cache       *mc = NULL;
-        char *cname;
-
-       MALLOC(mc, struct kmem_cache *, sizeof(struct kmem_cache), M_TEMP, M_WAITOK|M_ZERO);
-       if (mc == NULL){
-               CERROR("cfs_mem_cache created fail!\n");
-               return NULL;
-       }
-
-       cname = _MALLOC(strlen(name) + 1, M_TEMP, M_WAITOK);
-       LASSERT(cname != NULL);
-       mc->mc_cache = zinit(objsize, (KMEM_MAX_ZONE * objsize), 0, strcpy(cname, name));
-       mc->mc_size = objsize;
-       INIT_LIST_HEAD(&mc->mc_link);
-       strncpy(mc->mc_name, name, 1 + strlen(name));
-       return mc;
-}
-
-void mem_cache_destroy(struct kmem_cache *mc)
-{
-       /*
-        * zone can NOT be destroyed after creating,
-        * so just keep it in list.
-        *
-        * We will not lost a zone after we unload
-        * libcfs, it can be found by from libcfs.zone
-        */
-       return;
-}
-
-#define mem_cache_alloc(mc)     zalloc((mc)->mc_cache)
-#ifdef __DARWIN8__
-# define mem_cache_alloc_nb(mc) zalloc((mc)->mc_cache)
-#else
-/* XXX Liang: Tiger doesn't export zalloc_noblock() */
-# define mem_cache_alloc_nb(mc) zalloc_noblock((mc)->mc_cache)
-#endif
-#define mem_cache_free(mc, p)   zfree((mc)->mc_cache, p)
-
-#else  /* !CFS_INDIVIDUAL_ZONE */
-
-struct kmem_cache *
-mem_cache_find(const char *name, size_t objsize)
-{
-        return NULL;
-}
-
-struct kmem_cache *mem_cache_create(vm_size_t size, const char *name)
-{
-       struct kmem_cache *mc = NULL;
-
-       MALLOC(mc, struct kmem_cache *, sizeof(struct kmem_cache), M_TEMP, M_WAITOK|M_ZERO);
-       if (mc == NULL){
-               CERROR("cfs_mem_cache created fail!\n");
-               return NULL;
-       }
-        mc->mc_cache = OSMalloc_Tagalloc(name, OSMT_DEFAULT);
-        mc->mc_size = size;
-        return mc;
-}
-
-void mem_cache_destroy(struct kmem_cache *mc)
-{
-        OSMalloc_Tagfree(mc->mc_cache);
-        FREE(mc, M_TEMP);
-}
-
-#define mem_cache_alloc(mc)     OSMalloc((mc)->mc_size, (mc)->mc_cache)
-#define mem_cache_alloc_nb(mc)  OSMalloc_noblock((mc)->mc_size, (mc)->mc_cache)
-#define mem_cache_free(mc, p)   OSFree(p, (mc)->mc_size, (mc)->mc_cache)
-
-#endif /* !CFS_INDIVIDUAL_ZONE */
-
-struct kmem_cache *
-kmem_cache_create(const char *name, size_t objsize, size_t off,
-                 unsigned long arg1, void *ctro)
-{
-       struct kmem_cache *mc;
-
-       mc = mem_cache_find(name, objsize);
-       if (mc)
-               return mc;
-       mc = mem_cache_create(objsize, name);
-       return mc;
-}
-
-kmem_cache_destroy (struct kmem_cache *cachep)
-{
-       mem_cache_destroy(cachep);
-       return 0;
-}
-
-void *kmem_cache_alloc (struct kmem_cache *cachep, int flags)
-{
-       void *result;
-
-       /* zalloc_canblock() is not exported... Emulate it. */
-       if (flags & GFP_ATOMIC) {
-               result = (void *)mem_cache_alloc_nb(cachep);
-       } else {
-               LASSERT(get_preemption_level() == 0);
-               result = (void *)mem_cache_alloc(cachep);
-       }
-       if (result != NULL && (flags & __GFP_ZERO))
-               memset(result, 0, cachep->mc_size);
-
-       return result;
-}
-
-void kmem_cache_free (struct kmem_cache *cachep, void *objp)
-{
-       mem_cache_free(cachep, objp);
-}
-
-/* ---------------------------------------------------------------------------
- * Page operations
- *
- * --------------------------------------------------------------------------- */
-
-/*
- * "Raw" pages
- */
-
-static unsigned int raw_pages;
-static struct kmem_cache  *raw_page_cache;
-
-static struct xnu_page_ops raw_page_ops;
-static struct xnu_page_ops *page_ops[XNU_PAGE_NTYPES] = {
-        [XNU_PAGE_RAW] = &raw_page_ops
-};
-
-#if defined(LIBCFS_DEBUG)
-static int page_type_is_valid(struct page *page)
-{
-       LASSERT(page != NULL);
-       return 0 <= page->type && page->type < XNU_PAGE_NTYPES;
-}
-
-static int page_is_raw(struct page *page)
-{
-       return page->type == XNU_PAGE_RAW;
-}
-#endif
-
-static struct xnu_raw_page *as_raw(struct page *page)
-{
-       LASSERT(page_is_raw(page));
-       return list_entry(page, struct xnu_raw_page, header);
-}
-
-static void *raw_page_address(struct page *pg)
-{
-       return (void *)as_raw(pg)->virtual;
-}
-
-static void *raw_page_map(struct page *pg)
-{
-       return (void *)as_raw(pg)->virtual;
-}
-
-static void raw_page_unmap(struct page *pg)
-{
-}
-
-static struct xnu_page_ops raw_page_ops = {
-        .page_map       = raw_page_map,
-        .page_unmap     = raw_page_unmap,
-        .page_address   = raw_page_address
-};
-
-extern int get_preemption_level(void);
-
-struct list_head page_death_row;
-spinlock_t page_death_row_phylax;
-
-static void raw_page_finish(struct xnu_raw_page *pg)
-{
-       --raw_pages;
-       if (pg->virtual != NULL)
-               kmem_cache_free(raw_page_cache, pg->virtual);
-       kfree(pg);
-}
-
-void raw_page_death_row_clean(void)
-{
-       struct xnu_raw_page *pg;
-
-       spin_lock(&page_death_row_phylax);
-       while (!list_empty(&page_death_row)) {
-               pg = container_of(page_death_row.next,
-                                 struct xnu_raw_page, link);
-               list_del(&pg->link);
-               spin_unlock(&page_death_row_phylax);
-               raw_page_finish(pg);
-               spin_lock(&page_death_row_phylax);
-       }
-       spin_unlock(&page_death_row_phylax);
-}
-
-/* Free a "page" */
-void free_raw_page(struct xnu_raw_page *pg)
-{
-       if (!atomic_dec_and_test(&pg->count))
-               return;
-       /*
-        * kmem_free()->vm_map_remove()->vm_map_delete()->lock_write() may
-        * block. (raw_page_done()->upl_abort() can block too) On the other
-        * hand, __free_page() may be called in non-blockable context. To
-        * work around this, park pages on global list when cannot block.
-        */
-       if (get_preemption_level() > 0) {
-               spin_lock(&page_death_row_phylax);
-               list_add(&pg->link, &page_death_row);
-               spin_unlock(&page_death_row_phylax);
-       } else {
-               raw_page_finish(pg);
-               raw_page_death_row_clean();
-       }
-}
-
-struct page *alloc_page(u_int32_t flags)
-{
-       struct xnu_raw_page *page;
-
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-
-       page = kmalloc(sizeof *page, flags);
-       if (page != NULL) {
-               page->virtual = kmem_cache_alloc(raw_page_cache, flags);
-               if (page->virtual != NULL) {
-                       ++raw_pages;
-                       page->header.type = XNU_PAGE_RAW;
-                       atomic_set(&page->count, 1);
-               } else {
-                       kfree(page);
-                       page = NULL;
-               }
-       }
-       return page != NULL ? &page->header : NULL;
-}
-
-void __free_page(struct page *pages)
-{
-       free_raw_page(as_raw(pages));
-}
-
-void get_page(struct page *p)
-{
-       atomic_inc(&as_raw(p)->count);
-}
-
-int cfs_put_page_testzero(struct page *p)
-{
-       return atomic_dec_and_test(&as_raw(p)->count);
-}
-
-int page_count(struct page *p)
-{
-       return atomic_read(&as_raw(p)->count);
-}
-
-/*
- * Generic page operations
- */
-
-void *page_address(struct page *pg)
-{
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-       LASSERT(page_type_is_valid(pg));
-       return page_ops[pg->type]->page_address(pg);
-}
-
-void *kmap(struct page *pg)
-{
-       LASSERT(page_type_is_valid(pg));
-       return page_ops[pg->type]->page_map(pg);
-}
-
-void kunmap(struct page *pg)
-{
-       LASSERT(page_type_is_valid(pg));
-       page_ops[pg->type]->page_unmap(pg);
-}
-
-void xnu_page_ops_register(int type, struct xnu_page_ops *ops)
-{
-        LASSERT(0 <= type && type < XNU_PAGE_NTYPES);
-        LASSERT(ops != NULL);
-        LASSERT(page_ops[type] == NULL);
-
-        page_ops[type] = ops;
-}
-
-void xnu_page_ops_unregister(int type)
-{
-        LASSERT(0 <= type && type < XNU_PAGE_NTYPES);
-        LASSERT(page_ops[type] != NULL);
-
-        page_ops[type] = NULL;
-}
-
-/*
- * Portable memory allocator API
- */
-#ifdef HAVE_GET_PREEMPTION_LEVEL
-extern int get_preemption_level(void);
-#else
-#define get_preemption_level() (0)
-#endif
-
-void *kmalloc(size_t nr_bytes, u_int32_t flags)
-{
-       int mflags;
-
-       mflags = 0;
-       if (flags & GFP_ATOMIC) {
-               mflags |= M_NOWAIT;
-       } else {
-               LASSERT(get_preemption_level() == 0);
-               mflags |= M_WAITOK;
-       }
-
-       if (flags & __GFP_ZERO)
-               mflags |= M_ZERO;
-
-       return _MALLOC(nr_bytes, M_TEMP, mflags);
-}
-
-void kfree(void *addr)
-{
-       return _FREE(addr, M_TEMP);
-}
-
-void *vmalloc(size_t nr_bytes)
-{
-       LASSERT(get_preemption_level() == 0);
-       return _MALLOC(nr_bytes, M_TEMP, M_WAITOK);
-}
-
-void  vfree(void *addr)
-{
-       LASSERT(get_preemption_level() == 0);
-       return _FREE(addr, M_TEMP);
-}
-
-/*
- * Lookup cfs_zone_nob by sysctl.zone, if it cannot be 
- * found (first load of * libcfs since boot), allocate 
- * sysctl libcfs.zone.
- */
-int cfs_mem_init(void)
-{
-#if     CFS_INDIVIDUAL_ZONE
-        int     rc;
-        size_t  len;
-
-        len = sizeof(struct cfs_zone_nob);
-        rc = sysctlbyname("libcfs.zone",
-                          (void *)&cfs_zone_nob, &len, NULL, 0);
-        if (rc == ENOENT) {
-                /* zone_nob is not register in libcfs_sysctl */
-                struct cfs_zone_nob  *nob;
-                struct sysctl_oid       *oid;
-
-                assert(cfs_sysctl_isvalid());
-
-               nob = _MALLOC(sizeof(struct cfs_zone_nob),
-                               M_TEMP, M_WAITOK | M_ZERO);
-               INIT_LIST_HEAD(&nob->z_link);
-               nob->z_nob = &nob->z_link;
-               oid = cfs_alloc_sysctl_struct(NULL, OID_AUTO, CTLFLAG_RD | CTLFLAG_KERN,
-                                               "zone", nob, sizeof(struct cfs_zone_nob));
-               if (oid == NULL) {
-                       _FREE(nob, M_TEMP);
-                       return -ENOMEM;
-               }
-               sysctl_register_oid(oid);
-
-               cfs_zone_nob.z_nob = nob->z_nob;
-       }
-       spin_lock_init(&cfs_zone_guard);
-#endif
-       INIT_LIST_HEAD(&page_death_row);
-       spin_lock_init(&page_death_row_phylax);
-       raw_page_cache = kmem_cache_create("raw-page", PAGE_CACHE_SIZE,
-                                               0, 0, NULL);
-       return 0;
-}
-
-void cfs_mem_fini(void)
-{
-       raw_page_death_row_clean();
-       spin_lock_done(&page_death_row_phylax);
-       kmem_cache_destroy(raw_page_cache);
-
-#if CFS_INDIVIDUAL_ZONE
-       cfs_zone_nob.z_nob = NULL;
-       spin_lock_done(&cfs_zone_guard);
-#endif
-}
diff --git a/libcfs/libcfs/darwin/darwin-module.c b/libcfs/libcfs/darwin/darwin-module.c
deleted file mode 100644 (file)
index deea373..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <mach/mach_types.h>
-#include <string.h>
-#include <sys/file.h>
-#include <sys/conf.h>
-#include <miscfs/devfs/devfs.h>
-
-#define DEBUG_SUBSYSTEM S_LNET
-#include <libcfs/libcfs.h>
-
-int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
-{
-        struct libcfs_ioctl_hdr *hdr;
-        struct libcfs_ioctl_data *data;
-        int err = 0;
-        ENTRY;
-
-        hdr = (struct libcfs_ioctl_hdr *)buf;
-        data = (struct libcfs_ioctl_data *)buf;
-       /* libcfs_ioctl_data has been copied in by ioctl of osx */
-       memcpy(buf, arg, sizeof(struct libcfs_ioctl_data));
-
-        if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) {
-                CERROR("LIBCFS: version mismatch kernel vs application\n");
-                RETURN(-EINVAL);
-        }
-
-        if (hdr->ioc_len + buf >= end) {
-                CERROR("LIBCFS: user buffer exceeds kernel buffer\n");
-                RETURN(-EINVAL);
-        }
-
-        if (hdr->ioc_len < sizeof(struct libcfs_ioctl_data)) {
-                CERROR("LIBCFS: user buffer too small for ioctl\n");
-                RETURN(-EINVAL);
-        }
-       buf += size_round(sizeof(*data));
-
-        if (data->ioc_inllen1) {
-                err = copy_from_user(buf, data->ioc_inlbuf1, size_round(data->ioc_inllen1));
-               if (err)
-                       RETURN(err);
-                data->ioc_inlbuf1 = buf;
-                buf += size_round(data->ioc_inllen1);
-        }
-
-        if (data->ioc_inllen2) {
-                copy_from_user(buf, data->ioc_inlbuf2, size_round(data->ioc_inllen2));
-               if (err)
-                       RETURN(err);
-                data->ioc_inlbuf2 = buf;
-        }
-
-        RETURN(err);
-}
-
-int libcfs_ioctl_popdata(void *arg, void *data, int size)
-{
-       /* 
-        * system call will copy out ioctl arg to user space
-        */
-       memcpy(arg, data, size);
-       return 0;
-}
-
-extern struct cfs_psdev_ops            libcfs_psdev_ops;
-struct libcfs_device_userstate         *mdev_state[16];
-
-static int
-libcfs_psdev_open(dev_t dev, int flags, int devtype, struct proc *p)
-{
-       struct  libcfs_device_userstate *mstat = NULL;
-       int     rc = 0;
-       int     devid;
-       devid = minor(dev);
-
-       if (devid > 16) return (ENXIO);
-
-       if (libcfs_psdev_ops.p_open != NULL)
-               rc = -libcfs_psdev_ops.p_open(0, &mstat);
-       else
-               rc = EPERM;
-       if (rc == 0)
-               mdev_state[devid] = mstat;
-       return rc;
-}
-
-static int
-libcfs_psdev_close(dev_t dev, int flags, int mode, struct proc *p)
-{
-       int     devid;
-       devid = minor(dev);
-       int     rc = 0;
-
-       if (devid > 16) return (ENXIO);
-
-       if (libcfs_psdev_ops.p_close != NULL)
-               rc = -libcfs_psdev_ops.p_close(0, mdev_state[devid]);
-       else
-               rc = EPERM;
-       if (rc == 0)
-               mdev_state[devid] = NULL;
-       return rc;
-}
-
-static int
-libcfs_ioctl (dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
-{
-       int rc = 0;
-        struct cfs_psdev_file    pfile;
-       int     devid;
-       devid = minor(dev);
-       
-       if (devid > 16) return (ENXIO);
-
-       if (!is_suser())
-               return (EPERM);
-       
-       pfile.off = 0;
-       pfile.private_data = mdev_state[devid];
-
-       if (libcfs_psdev_ops.p_ioctl != NULL)
-               rc = -libcfs_psdev_ops.p_ioctl(&pfile, cmd, (void *)arg);
-       else
-               rc = EPERM;
-       return rc;
-}
-
-static struct cdevsw libcfs_devsw =
-{
-       .d_open     = libcfs_psdev_open,
-       .d_close    = libcfs_psdev_close,
-       .d_read     = eno_rdwrt,
-       .d_write    = eno_rdwrt,
-       .d_ioctl    = libcfs_ioctl,
-       .d_stop     = eno_stop,
-       .d_reset    = eno_reset,
-       .d_ttys     = NULL,
-       .d_select   = eno_select,
-       .d_mmap     = eno_mmap,
-       .d_strategy = eno_strat,
-       .d_getc     = eno_getc,
-       .d_putc     = eno_putc,
-       .d_type     = 0
-};
-
-struct miscdevice libcfs_dev = {
-       -1,
-       NULL,
-       "lnet",
-       &libcfs_devsw,
-       NULL
-};
-
-extern spinlock_t trace_cpu_serializer;
-extern void cfs_sync_init(void);
-extern void cfs_sync_fini(void);
-extern int cfs_sysctl_init(void);
-extern void cfs_sysctl_fini(void);
-extern int cfs_mem_init(void);
-extern int cfs_mem_fini(void);
-extern void raw_page_death_row_clean(void);
-extern void cfs_thread_agent_init(void);
-extern void cfs_thread_agent_fini(void);
-extern void cfs_symbol_init(void);
-extern void cfs_symbol_fini(void);
-
-int libcfs_arch_init(void)
-{
-       cfs_sync_init();
-       cfs_sysctl_init();
-       cfs_mem_init();
-       cfs_thread_agent_init();
-       cfs_symbol_init();
-
-       spin_lock_init(&trace_cpu_serializer);
-
-       return 0;
-}
-
-void libcfs_arch_cleanup(void)
-{
-       spin_lock_done(&trace_cpu_serializer);
-
-       cfs_symbol_fini();
-       cfs_thread_agent_fini();
-       cfs_mem_fini();
-       cfs_sysctl_fini();
-       cfs_sync_fini();
-}
diff --git a/libcfs/libcfs/darwin/darwin-prim.c b/libcfs/libcfs/darwin/darwin-prim.c
deleted file mode 100644 (file)
index 22ff5a9..0000000
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/darwin/darwin-prim.c
- *
- * Darwin porting library
- * Make things easy to port
- *
- * Author: Phil Schwan <phil@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <mach/mach_types.h>
-#include <string.h>
-#include <sys/file.h>
-#include <sys/conf.h>
-#include <sys/uio.h>
-#include <sys/filedesc.h>
-#include <sys/namei.h>
-#include <miscfs/devfs/devfs.h>
-#include <kern/thread.h>
-
-#include <libcfs/libcfs.h>
-
-/*
- * cfs pseudo device, actually pseudo char device in darwin
- */
-#define KLNET_MAJOR  -1
-
-kern_return_t  misc_register(struct miscdevice *dev) {
-       dev->index = cdevsw_add(KLNET_MAJOR, dev->devsw);
-       if (dev->index < 0) {
-               printf("libcfs_init: failed to allocate a major number!\n");
-               return KERN_FAILURE;
-       }
-       dev->handle = devfs_make_node(makedev (dev->index, 0),
-                                      DEVFS_CHAR, UID_ROOT,
-                                      GID_WHEEL, 0666, (char *)dev->name, 0);
-       return KERN_SUCCESS;
-}
-
-kern_return_t  misc_deregister(struct miscdevice *dev) {
-       devfs_remove(dev->handle);
-       cdevsw_remove(dev->index, dev->devsw);
-       return KERN_SUCCESS;
-}
-
-/*
- * KPortal symbol register / unregister support
- */
-struct rw_semaphore             cfs_symbol_lock;
-struct list_head                cfs_symbol_list;
-
-void *
-cfs_symbol_get(const char *name)
-{
-        struct list_head    *walker;
-        struct cfs_symbol   *sym = NULL;
-
-        down_read(&cfs_symbol_lock);
-        list_for_each(walker, &cfs_symbol_list) {
-                sym = list_entry (walker, struct cfs_symbol, sym_list);
-                if (!strcmp(sym->name, name)) {
-                        sym->ref ++;
-                        break;
-                }
-        }
-        up_read(&cfs_symbol_lock);
-        if (sym != NULL)
-                return sym->value;
-        return NULL;
-}
-
-kern_return_t
-cfs_symbol_put(const char *name)
-{
-        struct list_head    *walker;
-        struct cfs_symbol   *sym = NULL;
-
-        down_read(&cfs_symbol_lock);
-        list_for_each(walker, &cfs_symbol_list) {
-                sym = list_entry (walker, struct cfs_symbol, sym_list);
-                if (!strcmp(sym->name, name)) {
-                        sym->ref --;
-                        LASSERT(sym->ref >= 0);
-                        break;
-                }
-        }
-        up_read(&cfs_symbol_lock);
-        LASSERT(sym != NULL);
-
-        return 0;
-}
-
-kern_return_t
-cfs_symbol_register(const char *name, const void *value)
-{
-        struct list_head    *walker;
-        struct cfs_symbol   *sym = NULL;
-        struct cfs_symbol   *new = NULL;
-
-       MALLOC(new, struct cfs_symbol *, sizeof(struct cfs_symbol), M_TEMP, M_WAITOK|M_ZERO);
-       strncpy(new->name, name, CFS_SYMBOL_LEN);
-       new->value = (void *)value;
-       new->ref = 0;
-       INIT_LIST_HEAD(&new->sym_list);
-
-       down_write(&cfs_symbol_lock);
-       list_for_each(walker, &cfs_symbol_list) {
-               sym = list_entry (walker, struct cfs_symbol, sym_list);
-               if (!strcmp(sym->name, name)) {
-                       up_write(&cfs_symbol_lock);
-                       FREE(new, M_TEMP);
-                       return KERN_NAME_EXISTS;
-               }
-       }
-       list_add_tail(&new->sym_list, &cfs_symbol_list);
-       up_write(&cfs_symbol_lock);
-       return KERN_SUCCESS;
-}
-
-kern_return_t
-cfs_symbol_unregister(const char *name)
-{
-       struct list_head  *walker;
-       struct list_head  *nxt;
-       struct cfs_symbol *sym = NULL;
-
-       down_write(&cfs_symbol_lock);
-       list_for_each_safe(walker, nxt, &cfs_symbol_list) {
-               sym = list_entry(walker, struct cfs_symbol, sym_list);
-               if (!strcmp(sym->name, name)) {
-                       LASSERT(sym->ref == 0);
-                       list_del(&sym->sym_list);
-                       FREE(sym, M_TEMP);
-                       break;
-               }
-       }
-       up_write(&cfs_symbol_lock);
-
-       return KERN_SUCCESS;
-}
-
-void
-cfs_symbol_init()
-{
-       INIT_LIST_HEAD(&cfs_symbol_list);
-       init_rwsem(&cfs_symbol_lock);
-}
-
-void
-cfs_symbol_fini()
-{
-       struct list_head  *walker;
-       struct cfs_symbol *sym = NULL;
-
-       down_write(&cfs_symbol_lock);
-       list_for_each(walker, &cfs_symbol_list) {
-               sym = list_entry(walker, struct cfs_symbol, sym_list);
-               LASSERT(sym->ref == 0);
-               list_del(&sym->sym_list);
-               FREE(sym, M_TEMP);
-       }
-       up_write(&cfs_symbol_lock);
-
-       fini_rwsem(&cfs_symbol_lock);
-       return;
-}
-
-struct kernel_thread_arg
-{
-       spinlock_t      lock;
-       atomic_t        inuse;
-       cfs_thread_t    func;
-       void            *arg;
-};
-
-struct kernel_thread_arg cfs_thread_arg;
-
-#define THREAD_ARG_FREE                        0
-#define THREAD_ARG_HOLD                        1
-#define THREAD_ARG_RECV                        2
-
-#define set_targ_stat(a, v)            atomic_set(&(a)->inuse, v)
-#define get_targ_stat(a)               atomic_read(&(a)->inuse)
-
-/*
- * Hold the thread argument and set the status of thread_status
- * to THREAD_ARG_HOLD, if the thread argument is held by other
- * threads (It's THREAD_ARG_HOLD already), current-thread has to wait.
- */
-#define thread_arg_hold(pta, _func, _arg)                      \
-       do {                                                    \
-               spin_lock(&(pta)->lock);                        \
-               if (get_targ_stat(pta) == THREAD_ARG_FREE) {    \
-                       set_targ_stat((pta), THREAD_ARG_HOLD);  \
-                       (pta)->arg = (void *)_arg;              \
-                       (pta)->func = _func;                    \
-                       spin_unlock(&(pta)->lock);              \
-                       break;                                  \
-               }                                               \
-               spin_unlock(&(pta)->lock);                      \
-               schedule();                                     \
-       } while(1);                                             \
-
-/*
- * Release the thread argument if the thread argument has been
- * received by the child-thread (Status of thread_args is
- * THREAD_ARG_RECV), otherwise current-thread has to wait.
- * After release, the thread_args' status will be set to
- * THREAD_ARG_FREE, and others can re-use the thread_args to
- * create new kernel_thread.
- */
-#define thread_arg_release(pta)                                        \
-       do {                                                    \
-               spin_lock(&(pta)->lock);                        \
-               if (get_targ_stat(pta) == THREAD_ARG_RECV) {    \
-                       (pta)->arg = NULL;                      \
-                       (pta)->func = NULL;                     \
-                       set_targ_stat(pta, THREAD_ARG_FREE);    \
-                       spin_unlock(&(pta)->lock);              \
-                       break;                                  \
-               }                                               \
-               spin_unlock(&(pta)->lock);                      \
-               schedule();                                     \
-       } while(1)
-
-/*
- * Receive thread argument (Used in child thread), set the status
- * of thread_args to THREAD_ARG_RECV.
- */
-#define __thread_arg_recv_fin(pta, _func, _arg, fin)           \
-       do {                                                    \
-               spin_lock(&(pta)->lock);                        \
-               if (get_targ_stat(pta) == THREAD_ARG_HOLD) {    \
-                       if (fin)                                \
-                           set_targ_stat(pta, THREAD_ARG_RECV);\
-                       _arg = (pta)->arg;                      \
-                       _func = (pta)->func;                    \
-                       spin_unlock(&(pta)->lock);              \
-                       break;                                  \
-               }                                               \
-               spin_unlock(&(pta)->lock);                      \
-               schedule();                                     \
-       } while (1);                                            \
-
-/*
- * Just set the thread_args' status to THREAD_ARG_RECV
- */
-#define thread_arg_fin(pta)                                    \
-       do {                                                    \
-               spin_lock(&(pta)->lock);                        \
-               assert( get_targ_stat(pta) == THREAD_ARG_HOLD); \
-               set_targ_stat(pta, THREAD_ARG_RECV);            \
-               spin_unlock(&(pta)->lock);                      \
-       } while(0)
-
-#define thread_arg_recv(pta, f, a)     __thread_arg_recv_fin(pta, f, a, 1)
-#define thread_arg_keep(pta, f, a)     __thread_arg_recv_fin(pta, f, a, 0)
-
-void
-cfs_thread_agent_init(void)
-{
-        set_targ_stat(&cfs_thread_arg, THREAD_ARG_FREE);
-        spin_lock_init(&cfs_thread_arg.lock);
-        cfs_thread_arg.arg = NULL;
-        cfs_thread_arg.func = NULL;
-}
-
-void
-cfs_thread_agent_fini(void)
-{
-        assert(get_targ_stat(&cfs_thread_arg) == THREAD_ARG_FREE);
-
-        spin_lock_done(&cfs_thread_arg.lock);
-}
-
-/*
- *
- * All requests to create kernel thread will create a new
- * thread instance of cfs_thread_agent, one by one.
- * cfs_thread_agent will call the caller's thread function
- * with argument supplied by caller.
- */
-void
-cfs_thread_agent (void)
-{
-        cfs_thread_t           func = NULL;
-        void                   *arg = NULL;
-
-        thread_arg_recv(&cfs_thread_arg, func, arg);
-        /* printf("entry of thread agent (func: %08lx).\n", (void *)func); */
-        assert(func != NULL);
-        func(arg);
-        /* printf("thread agent exit. (func: %08lx)\n", (void *)func); */
-        (void) thread_terminate(current_thread());
-}
-
-extern thread_t kernel_thread(task_t task, void (*start)(void));
-
-struct task_struct
-kthread_run(cfs_thread_t func, void *arg, const char namefmt[], ...)
-{
-       int ret = 0;
-       thread_t th = NULL;
-
-       thread_arg_hold(&cfs_thread_arg, func, arg);
-       th = kernel_thread(kernel_task, cfs_thread_agent);
-       thread_arg_release(&cfs_thread_arg);
-       if (th != THREAD_NULL) {
-               /*
-                * FIXME: change child thread name...
-                * current_comm() is already broken. So it is left as is...
-               va_list args;
-               va_start(args, namefmt);
-               snprintf(current_comm(), CFS_CURPROC_COMM_MAX,
-                        namefmt, args);
-               va_end(args);
-                */
-       } else {
-                ret = -1;
-       }
-       return (struct task_struct)((long)ret);
-}
-
-/*
- * XXX Liang: kexts cannot access sigmask in Darwin8.
- * it's almost impossible for us to get/set signal mask
- * without patching kernel.
- * Should we provide these functions in xnu?
- *
- * These signal functions almost do nothing now, we
- * need to investigate more about signal in Darwin.
- */
-
-extern int block_procsigmask(struct proc *p,  int bit);
-
-sigset_t cfs_block_allsigs()
-{
-       sigset_t    old = 0;
-#ifdef __DARWIN8__
-#else
-       block_procsigmask(current_proc(), -1);
-#endif
-       return old;
-}
-
-sigset_t cfs_block_sigs(unsigned long sigs)
-{
-       sigset_t    old = 0;
-#ifdef __DARWIN8__
-#else
-       block_procsigmask(current_proc(), sigs);
-#endif
-       return old;
-}
-
-/* Block all signals except for the @sigs. It's only used in
- * Linux kernel, just a dummy here. */
-sigset_t cfs_block_sigsinv(unsigned long sigs)
-{
-       sigset_t old = 0;
-       return old;
-}
-
-void cfs_restore_sigs(sigset_t old)
-{
-}
-
-int cfs_signal_pending(void)
-
-{
-#ifdef __DARWIN8__
-       extern int thread_issignal(proc_t, thread_t, sigset_t);
-       return thread_issignal(current_proc(), current_thread(), (sigset_t)-1);
-#else
-       return SHOULDissignal(current_proc(), current_uthread())
-#endif
-}
-
-void cfs_clear_sigpending(void)
-{
-#ifdef __DARWIN8__
-#else
-       clear_procsiglist(current_proc(), -1);
-#endif
-}
-
-#ifdef __DARWIN8__
-
-#else /* !__DARWIN8__ */
-
-void lustre_cone_in(boolean_t *state, funnel_t **cone)
-{
-       *cone = thread_funnel_get();
-       if (*cone == network_flock)
-               thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
-       else if (*cone == NULL)
-               *state = thread_funnel_set(kernel_flock, TRUE);
-}
-
-void lustre_cone_ex(boolean_t state, funnel_t *cone)
-{
-       if (cone == network_flock)
-               thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
-       else if (cone == NULL)
-               (void) thread_funnel_set(kernel_flock, state);
-}
-
-void lustre_net_in(boolean_t *state, funnel_t **cone)
-{
-       *cone = thread_funnel_get();
-       if (*cone == kernel_flock)
-               thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
-       else if (*cone == NULL)
-               *state = thread_funnel_set(network_flock, TRUE);
-}
-
-void lustre_net_ex(boolean_t state, funnel_t *cone)
-{
-       if (cone == kernel_flock)
-               thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
-       else if (cone == NULL)
-               (void) thread_funnel_set(network_flock, state);
-}
-#endif /* !__DARWIN8__ */
-
-void init_waitqueue_head(struct cfs_waitq *waitq)
-{
-       ksleep_chan_init(&waitq->wq_ksleep_chan);
-}
-
-void init_waitqueue_entry_current(struct cfs_waitlink *link)
-{
-       ksleep_link_init(&link->wl_ksleep_link);
-}
-
-void add_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link)
-{
-       link->wl_waitq = waitq;
-       ksleep_add(&waitq->wq_ksleep_chan, &link->wl_ksleep_link);
-}
-
-void add_wait_queue_exclusive(struct cfs_waitq *waitq,
-                             struct cfs_waitlink *link)
-{
-       link->wl_waitq = waitq;
-       link->wl_ksleep_link.flags |= KSLEEP_EXCLUSIVE;
-       ksleep_add(&waitq->wq_ksleep_chan, &link->wl_ksleep_link);
-}
-
-void remove_wait_queue(struct cfs_waitq *waitq,
-                  struct cfs_waitlink *link)
-{
-       ksleep_del(&waitq->wq_ksleep_chan, &link->wl_ksleep_link);
-}
-
-int waitqueue_active(struct cfs_waitq *waitq)
-{
-       return (1);
-}
-
-void wake_up(struct cfs_waitq *waitq)
-{
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-       ksleep_wake(&waitq->wq_ksleep_chan);
-}
-
-void wake_up_nr(struct cfs_waitq *waitq, int nr)
-{
-       ksleep_wake_nr(&waitq->wq_ksleep_chan, nr);
-}
-
-void wake_up_all(struct cfs_waitq *waitq)
-{
-       ksleep_wake_all(&waitq->wq_ksleep_chan);
-}
-
-void waitq_wait(struct cfs_waitlink *link, long state)
-{
-       ksleep_wait(&link->wl_waitq->wq_ksleep_chan, state);
-}
-
-cfs_duration_t  waitq_timedwait(struct cfs_waitlink *link,
-                                   long state,
-                                   cfs_duration_t timeout)
-{
-       return ksleep_timedwait(&link->wl_waitq->wq_ksleep_chan,
-                               state, timeout);
-}
-
-typedef  void (*ktimer_func_t)(void *);
-void cfs_timer_init(struct timer_list *t, void (* func)(unsigned long), void *arg)
-{
-       ktimer_init(&t->t, (ktimer_func_t)func, arg);
-}
-
-void cfs_timer_done(struct cfs_timer *t)
-{
-       ktimer_done(&t->t);
-}
-
-void cfs_timer_arm(struct cfs_timer *t, cfs_time_t deadline)
-{
-       ktimer_arm(&t->t, deadline);
-}
-
-void cfs_timer_disarm(struct cfs_timer *t)
-{
-       ktimer_disarm(&t->t);
-}
-
-int  cfs_timer_is_armed(struct cfs_timer *t)
-{
-       return ktimer_is_armed(&t->t);
-}
-
-cfs_time_t cfs_timer_deadline(struct cfs_timer *t)
-{
-       return ktimer_deadline(&t->t);
-}
-
-void cfs_enter_debugger(void)
-{
-#ifdef __DARWIN8__
-       extern void Debugger(const char * reason);
-       Debugger("CFS");
-#else
-       extern void PE_enter_debugger(char *cause);
-       PE_enter_debugger("CFS");
-#endif
-}
-
-int cfs_online_cpus(void)
-{
-       int     activecpu;
-       size_t  size;
-
-#ifdef __DARWIN8__
-       size = sizeof(int);
-       sysctlbyname("hw.activecpu", &activecpu, &size, NULL, 0);
-       return activecpu;
-#else
-       host_basic_info_data_t hinfo;
-       kern_return_t kret;
-       int count = HOST_BASIC_INFO_COUNT;
-#define BSD_HOST 1
-       kret = host_info(BSD_HOST, HOST_BASIC_INFO, &hinfo, &count);
-       if (kret == KERN_SUCCESS)
-               return (hinfo.avail_cpus);
-       return(-EINVAL);
-#endif
-}
-
-int cfs_ncpus(void)
-{
-       int     ncpu;
-       size_t  size;
-
-       size = sizeof(int);
-
-       sysctlbyname("hw.ncpu", &ncpu, &size, NULL, 0);
-       return ncpu;
-}
diff --git a/libcfs/libcfs/darwin/darwin-proc.c b/libcfs/libcfs/darwin/darwin-proc.c
deleted file mode 100644 (file)
index aacc66b..0000000
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
-#include <sys/unistd.h>
-#include <mach/mach_types.h>
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <libcfs/libcfs.h>
-
-#define LIBCFS_SYSCTL           "libcfs"
-#define LIBCFS_SYSCTL_SPRITE    "sprite"
-#define LIBCFS_SYSCTL_MAGIC     0xbabeface
-
-static struct libcfs_sysctl_sprite {
-        int                     ss_magic;
-        struct sysctl_oid_list  *ss_link;
-} libcfs_sysctl_sprite = { 0, NULL };
-
-static struct ctl_table_header *libcfs_table_header = NULL;
-extern unsigned int libcfs_debug;
-extern unsigned int libcfs_subsystem_debug;
-extern unsigned int libcfs_printk;
-extern unsigned int libcfs_console_ratelimit;
-extern unsigned int libcfs_catastrophe;
-extern atomic_t libcfs_kmemory;
-
-static int sysctl_debug_kernel SYSCTL_HANDLER_ARGS
-{
-#error "Check me"
-        const int  maxstr = 1024;
-        char      *str;
-        int        error;
-
-        if (req->newptr == USER_ADDR_NULL) {
-                /* read request */
-                return -EINVAL;
-        }
-
-        /* write request */
-        error = trace_allocate_string_buffer(&str, maxstr + 1);
-        if (error != 0)
-                return error;
-
-       error = SYSCTL_IN(req, str, maxstr);
-
-        /* NB str guaranteed terminted */
-        if (error == 0)
-                error = tracefile_dump_all_pages(str);
-
-        trace_free_string_buffer(str, maxstr + 1);
-        return error;
-}
-
-static int sysctl_daemon_file SYSCTL_HANDLER_ARGS
-{
-#error "Check me"
-       int   error;
-       char *str;
-
-        if (req->newptr == USER_ADDR_NULL) {
-                /* a read */
-               tracefile_read_lock();
-
-                /* include terminating '\0' */
-               error = SYSCTL_OUT(req, tracefile, strlen(tracefile) + 1);
-
-               tracefile_read_unlock();
-                return error;
-        }
-        
-        /* write request */
-        error = trace_allocate_string_buffer(&str, TRACEFILE_NAME_SIZE);
-        if (error != 0)
-                return error;
-
-       error = SYSCTL_IN(req, str, TRACEFILE_NAME_SIZE - 1);
-
-        /* NB str guaranteed terminted */
-       if (error == 0)
-               error = trace_daemon_command(str);
-
-        trace_free_string_buffer(str, TRACEFILE_NAME_SIZE);
-       return error;
-}
-
-
-static int sysctl_debug_mb SYSCTL_HANDLER_ARGS
-{
-#error "Check me"
-       long mb;
-       int  error;
-       
-       if (req->newptr == USER_ADDR_NULL) {
-               /* read */
-               mb = trace_get_debug_mb();
-               error = SYSCTL_OUT(req, &mb, sizeof(mb));
-       } else {
-               /* write */
-               error = SYSCTL_IN(req, &mb, sizeof(mb));
-               if (error == 0)
-                       error = trace_set_debug_mb(mb);
-       }
-       
-       return error;
-}
-
-static int proc_fail_loc SYSCTL_HANDLER_ARGS
-{
-       int error = 0;
-       long old_fail_loc = cfs_fail_loc;
-
-       error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
-       if (!error && req->newptr != USER_ADDR_NULL) {
-               if (old_fail_loc != cfs_fail_loc)
-                       wake_up(&cfs_race_waitq);
-       } else  if (req->newptr != USER_ADDR_NULL) {
-               /* Something was wrong with the write request */
-               printf ("sysctl fail loc fault: %d.\n", error);
-       } else {
-               /* Read request */
-               error = SYSCTL_OUT(req, &cfs_fail_loc, sizeof cfs_fail_loc);
-       }
-       return error;
-}
-
-/*
- * sysctl table for lnet
- */
-
-SYSCTL_NODE (,                 OID_AUTO,       lnet,   CTLFLAG_RW,
-            0,                 "lnet sysctl top");
-
-SYSCTL_INT(_lnet,                      OID_AUTO,       debug,
-            CTLTYPE_INT | CTLFLAG_RW ,                 &libcfs_debug,
-            0,         "debug");
-SYSCTL_INT(_lnet,                      OID_AUTO,       subsystem_debug,
-            CTLTYPE_INT | CTLFLAG_RW,                  &libcfs_subsystem_debug,
-            0,         "subsystem debug");
-SYSCTL_INT(_lnet,                      OID_AUTO,       printk,
-            CTLTYPE_INT | CTLFLAG_RW,                  &libcfs_printk,
-            0,         "printk");
-SYSCTL_INT(_lnet,                      OID_AUTO,       console_ratelimit,
-            CTLTYPE_INT | CTLFLAG_RW,                  &libcfs_console_ratelimit,
-            0,         "console_ratelimit");
-SYSCTL_STRING(_lnet,                   OID_AUTO,       debug_path,
-            CTLTYPE_STRING | CTLFLAG_RW,               debug_file_path,
-            1024,      "debug path");
-SYSCTL_INT(_lnet,                      OID_AUTO,       memused,
-            CTLTYPE_INT | CTLFLAG_RW,                  (int *)&libcfs_kmemory.counter,
-            0,         "memused");
-SYSCTL_INT(_lnet,                      OID_AUTO,       catastrophe,
-            CTLTYPE_INT | CTLFLAG_RW,                  (int *)&libcfs_catastrophe,
-            0,         "catastrophe");
-
-#error "check me"
-SYSCTL_PROC(_lnet,                     OID_AUTO,       debug_kernel,
-            CTLTYPE_STRING | CTLFLAG_W,                0,
-            0,         &sysctl_debug_kernel,           "A",    "debug_kernel");
-SYSCTL_PROC(_lnet,                     OID_AUTO,       daemon_file,
-            CTLTYPE_STRING | CTLFLAG_RW,               0,
-            0,         &sysctl_daemon_file,            "A",    "daemon_file");
-SYSCTL_PROC(_lnet,                     OID_AUTO,       debug_mb,
-            CTLTYPE_INT | CTLFLAG_RW,                  0,
-            0,         &sysctl_debug_mb,               "L",    "debug_mb");
-SYSCTL_PROC(_lnet,                      OID_AUTO,       fail_loc, 
-             CTLTYPE_INT | CTLFLAG_RW ,                 &cfs_fail_loc,
-             0,         &proc_fail_loc,                 "I",    "cfs_fail_loc");
-
-static struct ctl_table        top_table[] = {
-       &sysctl__lnet,
-       &sysctl__lnet_debug,
-       &sysctl__lnet_subsystem_debug,
-       &sysctl__lnet_printk,
-       &sysctl__lnet_console_ratelimit,
-       &sysctl__lnet_debug_path,
-       &sysctl__lnet_memused,
-       &sysctl__lnet_catastrophe,
-       &sysctl__lnet_debug_kernel,
-       &sysctl__lnet_daemon_file,
-       &sysctl__lnet_debug_mb,
-        &sysctl__lnet_cfs_fail_loc
-       NULL
-};
-
-/*
- * Register sysctl table
- */
-struct ctl_table_header *
-register_sysctl_table(struct ctl_table *table, int arg)
-{
-       struct ctl_table      item;
-       int i = 0;
-
-       while ((item = table[i++]) != NULL)
-               sysctl_register_oid(item);
-       return table;
-}
-
-/*
- * Unregister sysctl table
- */
-void unregister_sysctl_table(struct ctl_table_header *table)
-{
-       int i = 0;
-       struct ctl_table      item;
-
-       while ((item = table[i++]) != NULL)
-               sysctl_unregister_oid(item);
-       return;
-}
-
-/*
- * Allocate a sysctl oid. 
- */
-static struct sysctl_oid *
-cfs_alloc_sysctl(struct sysctl_oid_list *parent, int nbr, int access,
-                 const char *name, void *arg1, int arg2, const char *fmt,
-                 int (*handler) SYSCTL_HANDLER_ARGS)
-{
-        struct sysctl_oid *oid;
-        char    *sname = NULL;
-        char    *sfmt = NULL;
-
-        if (strlen(name) + 1 > CTL_MAXNAME) {
-                printf("libcfs: sysctl name: %s is too long.\n", name);
-                return NULL;
-        }
-        oid = (struct sysctl_oid*)_MALLOC(sizeof(struct sysctl_oid), 
-                                          M_TEMP, M_WAITOK | M_ZERO);
-        if (oid == NULL) 
-                return NULL;
-
-        sname = (char *)_MALLOC(sizeof(CTL_MAXNAME), 
-                                M_TEMP, M_WAITOK | M_ZERO);
-        if (sname == NULL) 
-                goto error;
-        strcpy(sname, name);
-
-        sfmt = (char *)_MALLOC(4, M_TEMP, M_WAITOK | M_ZERO);
-        if (sfmt == NULL) 
-                goto error;
-        strcpy(sfmt, fmt);
-
-        if (parent == NULL)
-                oid->oid_parent = &sysctl__children;
-        else
-                oid->oid_parent = parent;
-        oid->oid_number = nbr;
-        oid->oid_kind = access;
-        oid->oid_name = sname;
-        oid->oid_handler = handler;
-        oid->oid_fmt = sfmt;
-
-        if ((access & CTLTYPE) == CTLTYPE_NODE){
-                /* It's a sysctl node */
-                struct sysctl_oid_list *link;
-
-                link = (struct sysctl_oid_list *)_MALLOC(sizeof(struct sysctl_oid_list), 
-                                                         M_TEMP, M_WAITOK | M_ZERO);
-                if (link == NULL)
-                        goto error;
-                oid->oid_arg1 = link;
-                oid->oid_arg2 = 0;
-        } else {
-                oid->oid_arg1 = arg1;
-                oid->oid_arg2 = arg2;
-        }
-
-        return oid;
-error:
-        if (sfmt != NULL)
-                _FREE(sfmt, M_TEMP);
-        if (sname != NULL)
-                _FREE(sname, M_TEMP);
-        if (oid != NULL)
-                _FREE(oid, M_TEMP);
-        return NULL;
-}
-
-void cfs_free_sysctl(struct sysctl_oid *oid)
-{
-        if (oid->oid_name != NULL)
-                _FREE((void *)oid->oid_name, M_TEMP);
-        if (oid->oid_fmt != NULL)
-                _FREE((void *)oid->oid_fmt, M_TEMP);
-        if ((oid->oid_kind & CTLTYPE_NODE != 0) && oid->oid_arg1)
-                /* XXX Liang: need to assert the list is empty */
-                _FREE(oid->oid_arg1, M_TEMP);
-        _FREE(oid, M_TEMP);
-}
-
-#define CFS_SYSCTL_ISVALID ((libcfs_sysctl_sprite.ss_magic == LIBCFS_SYSCTL_MAGIC) && \
-                            (libcfs_sysctl_sprite.ss_link != NULL))       
-
-int
-cfs_sysctl_isvalid(void)
-{
-        return CFS_SYSCTL_ISVALID;
-}
-
-struct sysctl_oid *
-cfs_alloc_sysctl_node(struct sysctl_oid_list *parent, int nbr, int access,
-                      const char *name, int (*handler) SYSCTL_HANDLER_ARGS)
-{
-        if (parent == NULL && CFS_SYSCTL_ISVALID)
-                parent = libcfs_sysctl_sprite.ss_link;
-        return cfs_alloc_sysctl(parent, nbr, CTLTYPE_NODE | access, name,
-                                NULL, 0, "N", handler);
-}
-
-struct sysctl_oid *
-cfs_alloc_sysctl_int(struct sysctl_oid_list *parent, int nbr, int access,
-                     const char *name, int *ptr, int val)
-{
-        if (parent == NULL && CFS_SYSCTL_ISVALID)
-                parent = libcfs_sysctl_sprite.ss_link;
-        return cfs_alloc_sysctl(parent, nbr, CTLTYPE_INT | access, name, 
-                                ptr, val, "I", sysctl_handle_int);
-}
-
-struct sysctl_oid *
-cfs_alloc_sysctl_long(struct sysctl_oid_list *parent, int nbr, int access,
-                      const char *name, int *ptr, int val)
-{
-        if (parent == NULL && CFS_SYSCTL_ISVALID)
-                parent = libcfs_sysctl_sprite.ss_link;
-        return cfs_alloc_sysctl(parent, nbr, CTLTYPE_INT | access, name, 
-                                ptr, val, "L", sysctl_handle_long);
-}
-
-struct sysctl_oid *
-cfs_alloc_sysctl_string(struct sysctl_oid_list *parent, int nbr, int access,
-                        const char *name, char *ptr, int len)
-{
-        if (parent == NULL && CFS_SYSCTL_ISVALID)
-                parent = libcfs_sysctl_sprite.ss_link;
-        return cfs_alloc_sysctl(parent, nbr, CTLTYPE_STRING | access, name, 
-                                ptr, len, "A", sysctl_handle_string);
-}
-
-struct sysctl_oid *
-cfs_alloc_sysctl_struct(struct sysctl_oid_list *parent, int nbr, int access,
-                        const char *name, void *ptr, int size)
-{
-        if (parent == NULL && CFS_SYSCTL_ISVALID)
-                parent = libcfs_sysctl_sprite.ss_link;
-        return cfs_alloc_sysctl(parent, nbr, CTLTYPE_OPAQUE | access, name,
-                                ptr, size, "S", sysctl_handle_opaque);
-}
-
-/* no proc in osx */
-cfs_proc_dir_entry_t *
-cfs_create_proc_entry(char *name, int mod, cfs_proc_dir_entry_t *parent)
-{
-       cfs_proc_dir_entry_t *entry;
-       MALLOC(entry, cfs_proc_dir_entry_t *, sizeof(cfs_proc_dir_entry_t), M_TEMP, M_WAITOK|M_ZERO);
-
-       return  entry;
-}
-
-void
-cfs_free_proc_entry(cfs_proc_dir_entry_t *de){
-       FREE(de, M_TEMP);
-       return;
-};
-
-void
-cfs_remove_proc_entry(char *name, cfs_proc_dir_entry_t *entry)
-{
-       cfs_free_proc_entry(entry);
-       return;
-}
-
-int
-insert_proc(void)
-{
-#if 1
-       if (!libcfs_table_header)
-               libcfs_table_header = register_sysctl_table(top_table);
-#endif
-       return 0;
-}
-
-void
-remove_proc(void)
-{
-#if 1
-       if (libcfs_table_header != NULL)
-               unregister_sysctl_table(libcfs_table_header);
-       libcfs_table_header = NULL;
-#endif
-       return;
-}
-
-int
-cfs_sysctl_init(void)
-{
-        struct sysctl_oid               *oid_root;
-        struct sysctl_oid               *oid_sprite;
-        struct libcfs_sysctl_sprite     *sprite;
-        size_t  len; 
-        int     rc;
-
-        len = sizeof(struct libcfs_sysctl_sprite);
-        rc = sysctlbyname("libcfs.sprite", 
-                          (void *)&libcfs_sysctl_sprite, &len, NULL, 0);
-        if (rc == 0) {
-                /* 
-                 * XXX Liang: assert (rc == 0 || rc == ENOENT)
-                 *
-                 * libcfs.sprite has been registered by previous 
-                 * loading of libcfs 
-                 */
-                if (libcfs_sysctl_sprite.ss_magic != LIBCFS_SYSCTL_MAGIC) {
-                        printf("libcfs: magic number of libcfs.sprite "
-                               "is not right (%lx, %lx)\n", 
-                               libcfs_sysctl_sprite.ss_magic,
-                               LIBCFS_SYSCTL_MAGIC);
-                        return -1;
-                }
-                assert(libcfs_sysctl_sprite.ss_link != NULL);
-                printf("libcfs: registered libcfs.sprite found.\n");
-                return 0;
-        }
-        oid_root = cfs_alloc_sysctl_node(NULL, OID_AUTO, CTLFLAG_RD | CTLFLAG_KERN,
-                                         LIBCFS_SYSCTL, 0);
-        if (oid_root == NULL)
-                return -1;
-        sysctl_register_oid(oid_root);
-
-        sprite = (struct libcfs_sysctl_sprite *)_MALLOC(sizeof(struct libcfs_sysctl_sprite), 
-                                                        M_TEMP, M_WAITOK | M_ZERO);
-        if (sprite == NULL) {
-                sysctl_unregister_oid(oid_root);
-                cfs_free_sysctl(oid_root);
-                return -1;
-        }
-        sprite->ss_magic = LIBCFS_SYSCTL_MAGIC;
-        sprite->ss_link = (struct sysctl_oid_list *)oid_root->oid_arg1;
-        oid_sprite = cfs_alloc_sysctl_struct((struct sysctl_oid_list *)oid_root->oid_arg1, 
-                                             OID_AUTO, CTLFLAG_RD | CTLFLAG_KERN, 
-                                             LIBCFS_SYSCTL_SPRITE, sprite, 
-                                             sizeof(struct libcfs_sysctl_sprite));
-        if (oid_sprite == NULL) {
-                cfs_free_sysctl(oid_sprite);
-                sysctl_unregister_oid(oid_root);
-                cfs_free_sysctl(oid_root);
-                return -1;
-        }
-        sysctl_register_oid(oid_sprite);
-
-        libcfs_sysctl_sprite.ss_magic = sprite->ss_magic;
-        libcfs_sysctl_sprite.ss_link = sprite->ss_link;
-
-        return 0;
-}
-
-void
-cfs_sysctl_fini(void)
-{
-        libcfs_sysctl_sprite.ss_magic = 0;
-        libcfs_sysctl_sprite.ss_link = NULL;
-}
diff --git a/libcfs/libcfs/darwin/darwin-sync.c b/libcfs/libcfs/darwin/darwin-sync.c
deleted file mode 100644 (file)
index 0aaabbb..0000000
+++ /dev/null
@@ -1,1036 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/darwin/darwin-sync.c
- *
- * XNU synchronization primitives.
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-/*
- * This file contains very simplistic implementations of (saner) API for
- * basic synchronization primitives:
- *
- *     - spin-lock          (kspin)
- *
- *     - semaphore          (ksem)
- *
- *     - mutex              (kmut)
- *
- *     - condition variable (kcond)
- *
- *     - wait-queue         (ksleep_chan and ksleep_link)
- *
- *     - timer              (ktimer)
- *
- * A lot can be optimized here.
- */
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#ifdef __DARWIN8__
-# include <kern/locks.h>
-#else
-# include <mach/mach_types.h>
-# include <sys/types.h>
-# include <kern/simple_lock.h>
-#endif
-
-#include <libcfs/libcfs.h>
-
-#define SLASSERT(e) ON_SYNC_DEBUG(LASSERT(e))
-
-#ifdef HAVE_GET_PREEMPTION_LEVEL
-extern int get_preemption_level(void);
-#else
-#define get_preemption_level() (0)
-#endif
-
-#if SMP
-#ifdef __DARWIN8__
-
-static lck_grp_t       *cfs_lock_grp = NULL;
-#warning "Verify definition of lck_spin_t hasn't been changed while building!"
-
-/* hw_lock_* are not exported by Darwin8 */
-static inline void xnu_spin_init(xnu_spin_t *s)
-{
-        SLASSERT(cfs_lock_grp != NULL);
-        //*s = lck_spin_alloc_init(cfs_lock_grp, LCK_ATTR_NULL);
-        lck_spin_init((lck_spin_t *)s, cfs_lock_grp, LCK_ATTR_NULL);
-}
-
-static inline void xnu_spin_done(xnu_spin_t *s)
-{
-        SLASSERT(cfs_lock_grp != NULL);
-        //lck_spin_free(*s, cfs_lock_grp);
-        //*s = NULL;
-        lck_spin_destroy((lck_spin_t *)s, cfs_lock_grp);
-}
-
-#define xnu_spin_lock(s)        lck_spin_lock((lck_spin_t *)(s))
-#define xnu_spin_unlock(s)      lck_spin_unlock((lck_spin_t *)(s))
-
-#warning "Darwin8 does not export lck_spin_try_lock"
-#define xnu_spin_try(s)         (1)
-
-#else /* DARWIN8 */
-extern void                    hw_lock_init(hw_lock_t);
-extern void                    hw_lock_lock(hw_lock_t);
-extern void                    hw_lock_unlock(hw_lock_t);
-extern unsigned int            hw_lock_to(hw_lock_t, unsigned int);
-extern unsigned int            hw_lock_try(hw_lock_t);
-extern unsigned int            hw_lock_held(hw_lock_t);
-
-#define xnu_spin_init(s)        hw_lock_init(s)
-#define xnu_spin_done(s)        do {} while (0)
-#define xnu_spin_lock(s)        hw_lock_lock(s)
-#define xnu_spin_unlock(s)      hw_lock_unlock(s)
-#define xnu_spin_try(s)         hw_lock_try(s)
-#endif /* DARWIN8 */
-
-#else /* SMP */
-#define xnu_spin_init(s)        do {} while (0)
-#define xnu_spin_done(s)        do {} while (0)
-#define xnu_spin_lock(s)        do {} while (0)
-#define xnu_spin_unlock(s)      do {} while (0)
-#define xnu_spin_try(s)         (1)
-#endif /* SMP */
-
-/*
- * Warning: low level libcfs debugging code (libcfs_debug_msg(), for
- * example), uses spin-locks, so debugging output here may lead to nasty
- * surprises.
- *
- * In uniprocessor version of spin-lock. Only checks.
- */
-
-void kspin_init(struct kspin *spin)
-{
-       SLASSERT(spin != NULL);
-       xnu_spin_init(&spin->lock);
-       ON_SYNC_DEBUG(spin->magic = KSPIN_MAGIC);
-       ON_SYNC_DEBUG(spin->owner = NULL);
-}
-
-void kspin_done(struct kspin *spin)
-{
-       SLASSERT(spin != NULL);
-       SLASSERT(spin->magic == KSPIN_MAGIC);
-       SLASSERT(spin->owner == NULL);
-        xnu_spin_done(&spin->lock);
-}
-
-void kspin_lock(struct kspin *spin)
-{
-       SLASSERT(spin != NULL);
-       SLASSERT(spin->magic == KSPIN_MAGIC);
-       SLASSERT(spin->owner != current_thread());
-
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-
-       xnu_spin_lock(&spin->lock);
-       SLASSERT(spin->owner == NULL);
-       ON_SYNC_DEBUG(spin->owner = current_thread());
-}
-
-void kspin_unlock(struct kspin *spin)
-{
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-
-       SLASSERT(spin != NULL);
-       SLASSERT(spin->magic == KSPIN_MAGIC);
-       SLASSERT(spin->owner == current_thread());
-       ON_SYNC_DEBUG(spin->owner = NULL);
-       xnu_spin_unlock(&spin->lock);
-}
-
-int  kspin_trylock(struct kspin *spin)
-{
-       SLASSERT(spin != NULL);
-       SLASSERT(spin->magic == KSPIN_MAGIC);
-
-       if (xnu_spin_try(&spin->lock)) {
-               SLASSERT(spin->owner == NULL);
-               ON_SYNC_DEBUG(spin->owner = current_thread());
-               return 1;
-       } else
-               return 0;
-}
-
-#if XNU_SYNC_DEBUG
-int kspin_islocked(struct kspin *spin)
-{
-       SLASSERT(spin != NULL);
-       SLASSERT(spin->magic == KSPIN_MAGIC);
-       return spin->owner == current_thread();
-}
-
-int kspin_isnotlocked(struct kspin *spin)
-{
-       SLASSERT(spin != NULL);
-       SLASSERT(spin->magic == KSPIN_MAGIC);
-       return spin->owner != current_thread();
-}
-#endif
-
-/*
- * read/write spin-lock
- */
-void krw_spin_init(struct krw_spin *rwspin)
-{
-       SLASSERT(rwspin != NULL);
-
-       kspin_init(&rwspin->guard);
-       rwspin->count = 0;
-       ON_SYNC_DEBUG(rwspin->magic = KRW_SPIN_MAGIC);
-}
-
-void krw_spin_done(struct krw_spin *rwspin)
-{
-       SLASSERT(rwspin != NULL);
-       SLASSERT(rwspin->magic == KRW_SPIN_MAGIC);
-       SLASSERT(rwspin->count == 0);
-       kspin_done(&rwspin->guard);
-}
-
-void krw_spin_down_r(struct krw_spin *rwspin)
-{
-        int i;
-       SLASSERT(rwspin != NULL);
-       SLASSERT(rwspin->magic == KRW_SPIN_MAGIC);
-
-       kspin_lock(&rwspin->guard);
-        while(rwspin->count < 0) {
-                i = -1;
-               kspin_unlock(&rwspin->guard);
-                while (--i != 0 && rwspin->count < 0)
-                        continue;
-                kspin_lock(&rwspin->guard);
-        }
-       ++ rwspin->count;
-       kspin_unlock(&rwspin->guard);
-}
-
-void krw_spin_down_w(struct krw_spin *rwspin)
-{
-        int i;
-       SLASSERT(rwspin != NULL);
-       SLASSERT(rwspin->magic == KRW_SPIN_MAGIC);
-
-       kspin_lock(&rwspin->guard);
-        while (rwspin->count != 0) {
-                i = -1;
-               kspin_unlock(&rwspin->guard);
-                while (--i != 0 && rwspin->count != 0)
-                        continue;
-               kspin_lock(&rwspin->guard);
-        }
-       rwspin->count = -1;
-       kspin_unlock(&rwspin->guard);
-}
-
-void krw_spin_up_r(struct krw_spin *rwspin)
-{
-       SLASSERT(rwspin != NULL);
-       SLASSERT(rwspin->magic == KRW_SPIN_MAGIC);
-       SLASSERT(rwspin->count > 0);
-
-       kspin_lock(&rwspin->guard);
-       -- rwspin->count;
-       kspin_unlock(&rwspin->guard);
-}
-
-void krw_spin_up_w(struct krw_spin *rwspin)
-{
-       SLASSERT(rwspin != NULL);
-       SLASSERT(rwspin->magic == KRW_SPIN_MAGIC);
-       SLASSERT(rwspin->count == -1);
-
-       kspin_lock(&rwspin->guard);
-       rwspin->count = 0;
-       kspin_unlock(&rwspin->guard);
-}
-
-/*
- * semaphore 
- */
-#ifdef __DARWIN8__
-
-#define xnu_waitq_init(q, a)            do {} while (0)
-#define xnu_waitq_done(q)               do {} while (0)
-#define xnu_waitq_wakeup_one(q, e, s)   ({wakeup_one((void *)(e)); KERN_SUCCESS;})
-#define xnu_waitq_wakeup_all(q, e, s)   ({wakeup((void *)(e)); KERN_SUCCESS;})
-#define xnu_waitq_assert_wait(q, e, s)  assert_wait((e), s)
-
-#else /* DARWIN8 */
-
-#define xnu_waitq_init(q, a)            wait_queue_init((q), a)
-#define xnu_waitq_done(q)               do {} while (0)
-#define xnu_waitq_wakeup_one(q, e, s)   wait_queue_wakeup_one((q), (event_t)(e), s)
-#define xnu_waitq_wakeup_all(q, e, s)   wait_queue_wakeup_all((q), (event_t)(e), s)
-#define xnu_waitq_assert_wait(q, e, s)  wait_queue_assert_wait((q), (event_t)(e), s)
-
-#endif /* DARWIN8 */
-void ksem_init(struct ksem *sem, int value)
-{
-       SLASSERT(sem != NULL);
-       kspin_init(&sem->guard);
-       xnu_waitq_init(&sem->q, SYNC_POLICY_FIFO);
-       sem->value = value;
-       ON_SYNC_DEBUG(sem->magic = KSEM_MAGIC);
-}
-
-void ksem_done(struct ksem *sem)
-{
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KSEM_MAGIC);
-       /*
-        * XXX nikita: cannot check that &sem->q is empty because
-        * wait_queue_empty() is Apple private API.
-        */
-       kspin_done(&sem->guard);
-}
-
-int ksem_up(struct ksem *sem, int value)
-{
-       int result;
-
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KSEM_MAGIC);
-       SLASSERT(value >= 0);
-
-       kspin_lock(&sem->guard);
-       sem->value += value;
-       if (sem->value == 0)
-               result = xnu_waitq_wakeup_one(&sem->q, sem,
-                                             THREAD_AWAKENED);
-       else
-               result = xnu_waitq_wakeup_all(&sem->q, sem,
-                                             THREAD_AWAKENED);
-       kspin_unlock(&sem->guard);
-       SLASSERT(result == KERN_SUCCESS || result == KERN_NOT_WAITING);
-       return (result == KERN_SUCCESS) ? 0 : 1;
-}
-
-void ksem_down(struct ksem *sem, int value)
-{
-       int result;
-
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KSEM_MAGIC);
-       SLASSERT(value >= 0);
-       SLASSERT(get_preemption_level() == 0);
-
-       kspin_lock(&sem->guard);
-       while (sem->value < value) {
-               result = xnu_waitq_assert_wait(&sem->q, sem,
-                                              THREAD_UNINT);
-               SLASSERT(result == THREAD_AWAKENED || result == THREAD_WAITING);
-               kspin_unlock(&sem->guard);
-               if (result == THREAD_WAITING)
-                       thread_block(THREAD_CONTINUE_NULL);
-               kspin_lock(&sem->guard);
-       }
-       sem->value -= value;
-       kspin_unlock(&sem->guard);
-}
-
-int ksem_trydown(struct ksem *sem, int value)
-{
-       int result;
-
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KSEM_MAGIC);
-       SLASSERT(value >= 0);
-
-       kspin_lock(&sem->guard);
-       if (sem->value >= value) {
-               sem->value -= value;
-               result = 0;
-       } else
-               result = -EBUSY;
-       kspin_unlock(&sem->guard);
-       return result;
-}
-
-void kmut_init(struct kmut *mut)
-{
-       SLASSERT(mut != NULL);
-       ksem_init(&mut->s, 1);
-       ON_SYNC_DEBUG(mut->magic = KMUT_MAGIC);
-       ON_SYNC_DEBUG(mut->owner = NULL);
-}
-
-void kmut_done(struct kmut *mut)
-{
-       SLASSERT(mut != NULL);
-       SLASSERT(mut->magic == KMUT_MAGIC);
-       SLASSERT(mut->owner == NULL);
-       ksem_done(&mut->s);
-}
-
-void kmut_lock(struct kmut *mut)
-{
-       SLASSERT(mut != NULL);
-       SLASSERT(mut->magic == KMUT_MAGIC);
-       SLASSERT(mut->owner != current_thread());
-       SLASSERT(get_preemption_level() == 0);
-
-       ksem_down(&mut->s, 1);
-       ON_SYNC_DEBUG(mut->owner = current_thread());
-}
-
-void kmut_unlock(struct kmut *mut)
-{
-       SLASSERT(mut != NULL);
-       SLASSERT(mut->magic == KMUT_MAGIC);
-       SLASSERT(mut->owner == current_thread());
-
-       ON_SYNC_DEBUG(mut->owner = NULL);
-       ksem_up(&mut->s, 1);
-}
-
-int kmut_trylock(struct kmut *mut)
-{
-       SLASSERT(mut != NULL);
-       SLASSERT(mut->magic == KMUT_MAGIC);
-       return ksem_trydown(&mut->s, 1);
-}
-
-#if XNU_SYNC_DEBUG
-int kmut_islocked(struct kmut *mut)
-{
-       SLASSERT(mut != NULL);
-       SLASSERT(mut->magic == KMUT_MAGIC);
-       return mut->owner == current_thread();
-}
-
-int kmut_isnotlocked(struct kmut *mut)
-{
-       SLASSERT(mut != NULL);
-       SLASSERT(mut->magic == KMUT_MAGIC);
-       return mut->owner != current_thread();
-}
-#endif
-
-
-void kcond_init(struct kcond *cond)
-{
-       SLASSERT(cond != NULL);
-
-       kspin_init(&cond->guard);
-       cond->waiters = NULL;
-       ON_SYNC_DEBUG(cond->magic = KCOND_MAGIC);
-}
-
-void kcond_done(struct kcond *cond)
-{
-       SLASSERT(cond != NULL);
-       SLASSERT(cond->magic == KCOND_MAGIC);
-       SLASSERT(cond->waiters == NULL);
-       kspin_done(&cond->guard);
-}
-
-void kcond_wait(struct kcond *cond, struct kspin *lock)
-{
-       struct kcond_link link;
-
-       SLASSERT(cond != NULL);
-       SLASSERT(lock != NULL);
-       SLASSERT(cond->magic == KCOND_MAGIC);
-       SLASSERT(kspin_islocked(lock));
-
-       ksem_init(&link.sem, 0);
-       kspin_lock(&cond->guard);
-       link.next = cond->waiters;
-       cond->waiters = &link;
-       kspin_unlock(&cond->guard);
-       kspin_unlock(lock);
-
-       ksem_down(&link.sem, 1);
-
-       kspin_lock(&cond->guard);
-       kspin_unlock(&cond->guard);
-       kspin_lock(lock);
-}
-
-void kcond_wait_guard(struct kcond *cond)
-{
-       struct kcond_link link;
-
-       SLASSERT(cond != NULL);
-       SLASSERT(cond->magic == KCOND_MAGIC);
-       SLASSERT(kspin_islocked(&cond->guard));
-
-       ksem_init(&link.sem, 0);
-       link.next = cond->waiters;
-       cond->waiters = &link;
-       kspin_unlock(&cond->guard);
-
-       ksem_down(&link.sem, 1);
-
-       kspin_lock(&cond->guard);
-}
-
-void kcond_signal_guard(struct kcond *cond)
-{
-       struct kcond_link *link;
-
-       SLASSERT(cond != NULL);
-       SLASSERT(cond->magic == KCOND_MAGIC);
-       SLASSERT(kspin_islocked(&cond->guard));
-
-       link = cond->waiters;
-       if (link != NULL) {
-               cond->waiters = link->next;
-               ksem_up(&link->sem, 1);
-       }
-}
-
-void kcond_signal(struct kcond *cond)
-{
-       SLASSERT(cond != NULL);
-       SLASSERT(cond->magic == KCOND_MAGIC);
-
-       kspin_lock(&cond->guard);
-       kcond_signal_guard(cond);
-       kspin_unlock(&cond->guard);
-}
-
-void kcond_broadcast_guard(struct kcond *cond)
-{
-       struct kcond_link *link;
-
-       SLASSERT(cond != NULL);
-       SLASSERT(cond->magic == KCOND_MAGIC);
-       SLASSERT(kspin_islocked(&cond->guard));
-
-       for (link = cond->waiters; link != NULL; link = link->next)
-               ksem_up(&link->sem, 1);
-       cond->waiters = NULL;
-}
-
-void kcond_broadcast(struct kcond *cond)
-{
-       SLASSERT(cond != NULL);
-       SLASSERT(cond->magic == KCOND_MAGIC);
-
-       kspin_lock(&cond->guard);
-       kcond_broadcast_guard(cond);
-       kspin_unlock(&cond->guard);
-}
-
-void krw_sem_init(struct krw_sem *sem)
-{
-       SLASSERT(sem != NULL);
-
-       kcond_init(&sem->cond);
-       sem->count = 0;
-       ON_SYNC_DEBUG(sem->magic = KRW_MAGIC);
-}
-
-void krw_sem_done(struct krw_sem *sem)
-{
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KRW_MAGIC);
-       SLASSERT(sem->count == 0);
-       kcond_done(&sem->cond);
-}
-
-void krw_sem_down_r(struct krw_sem *sem)
-{
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KRW_MAGIC);
-       SLASSERT(get_preemption_level() == 0);
-
-       kspin_lock(&sem->cond.guard);
-       while (sem->count < 0)
-               kcond_wait_guard(&sem->cond);
-       ++ sem->count;
-       kspin_unlock(&sem->cond.guard);
-}
-
-int krw_sem_down_r_try(struct krw_sem *sem)
-{
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KRW_MAGIC);
-
-       kspin_lock(&sem->cond.guard);
-       if (sem->count < 0) {
-               kspin_unlock(&sem->cond.guard);
-                return -EBUSY;
-        }
-       ++ sem->count;
-       kspin_unlock(&sem->cond.guard);
-        return 0;
-}
-
-void krw_sem_down_w(struct krw_sem *sem)
-{
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KRW_MAGIC);
-       SLASSERT(get_preemption_level() == 0);
-
-       kspin_lock(&sem->cond.guard);
-       while (sem->count != 0)
-               kcond_wait_guard(&sem->cond);
-       sem->count = -1;
-       kspin_unlock(&sem->cond.guard);
-}
-
-int krw_sem_down_w_try(struct krw_sem *sem)
-{
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KRW_MAGIC);
-
-       kspin_lock(&sem->cond.guard);
-       if (sem->count != 0) {
-               kspin_unlock(&sem->cond.guard);
-                return -EBUSY;
-        }
-       sem->count = -1;
-       kspin_unlock(&sem->cond.guard);
-        return 0;
-}
-
-void krw_sem_up_r(struct krw_sem *sem)
-{
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KRW_MAGIC);
-       SLASSERT(sem->count > 0);
-
-       kspin_lock(&sem->cond.guard);
-       -- sem->count;
-       if (sem->count == 0)
-               kcond_broadcast_guard(&sem->cond);
-       kspin_unlock(&sem->cond.guard);
-}
-
-void krw_sem_up_w(struct krw_sem *sem)
-{
-       SLASSERT(sem != NULL);
-       SLASSERT(sem->magic == KRW_MAGIC);
-       SLASSERT(sem->count == -1);
-
-       kspin_lock(&sem->cond.guard);
-       sem->count = 0;
-       kspin_unlock(&sem->cond.guard);
-       kcond_broadcast(&sem->cond);
-}
-
-void ksleep_chan_init(struct ksleep_chan *chan)
-{
-       SLASSERT(chan != NULL);
-
-       kspin_init(&chan->guard);
-       INIT_LIST_HEAD(&chan->waiters);
-       ON_SYNC_DEBUG(chan->magic = KSLEEP_CHAN_MAGIC);
-}
-
-void ksleep_chan_done(struct ksleep_chan *chan)
-{
-       SLASSERT(chan != NULL);
-       SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC);
-       SLASSERT(list_empty(&chan->waiters));
-       kspin_done(&chan->guard);
-}
-
-void ksleep_link_init(struct ksleep_link *link)
-{
-       SLASSERT(link != NULL);
-
-       INIT_LIST_HEAD(&link->linkage);
-       link->flags = 0;
-       link->event = current_thread();
-       link->hits  = 0;
-       link->forward = NULL;
-       ON_SYNC_DEBUG(link->magic = KSLEEP_LINK_MAGIC);
-}
-
-void ksleep_link_done(struct ksleep_link *link)
-{
-       SLASSERT(link != NULL);
-       SLASSERT(link->magic == KSLEEP_LINK_MAGIC);
-       SLASSERT(list_empty(&link->linkage));
-}
-
-void ksleep_add(struct ksleep_chan *chan, struct ksleep_link *link)
-{
-       SLASSERT(chan != NULL);
-       SLASSERT(link != NULL);
-       SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC);
-       SLASSERT(link->magic == KSLEEP_LINK_MAGIC);
-       SLASSERT(list_empty(&link->linkage));
-
-       kspin_lock(&chan->guard);
-        if (link->flags & KSLEEP_EXCLUSIVE)
-                list_add_tail(&link->linkage, &chan->waiters);
-        else
-               list_add(&link->linkage, &chan->waiters);
-       kspin_unlock(&chan->guard);
-}
-
-void ksleep_del(struct ksleep_chan *chan, struct ksleep_link *link)
-{
-       SLASSERT(chan != NULL);
-       SLASSERT(link != NULL);
-       SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC);
-       SLASSERT(link->magic == KSLEEP_LINK_MAGIC);
-
-       kspin_lock(&chan->guard);
-       list_del_init(&link->linkage);
-       kspin_unlock(&chan->guard);
-}
-
-static int has_hits(struct ksleep_chan *chan, event_t event)
-{
-       struct ksleep_link *scan;
-
-       SLASSERT(kspin_islocked(&chan->guard));
-       list_for_each_entry(scan, &chan->waiters, linkage) {
-               if (scan->event == event && scan->hits > 0) {
-                       /* consume hit */
-                       -- scan->hits;
-                       return 1;
-               }
-       }
-       return 0;
-}
-
-static void add_hit(struct ksleep_chan *chan, event_t event)
-{
-       struct ksleep_link *scan;
-
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-
-       SLASSERT(kspin_islocked(&chan->guard));
-       list_for_each_entry(scan, &chan->waiters, linkage) {
-               if (scan->event == event) {
-                       ++ scan->hits;
-                       break;
-               }
-       }
-}
-
-void ksleep_wait(struct ksleep_chan *chan, long state)
-{
-       event_t event;
-       int     result;
-
-       ENTRY;
-
-       SLASSERT(chan != NULL);
-       SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC);
-       SLASSERT(get_preemption_level() == 0);
-
-       event = current_thread();
-       kspin_lock(&chan->guard);
-       if (!has_hits(chan, event)) {
-               result = assert_wait(event, state);
-               kspin_unlock(&chan->guard);
-               SLASSERT(result == THREAD_AWAKENED || result == THREAD_WAITING);
-               if (result == THREAD_WAITING)
-                       thread_block(THREAD_CONTINUE_NULL);
-       } else
-               kspin_unlock(&chan->guard);
-       EXIT;
-}
-
-/*
- * Sleep on @chan for no longer than @timeout nano-seconds. Return remaining
- * sleep time (non-zero only if thread was waken by a signal (not currently
- * implemented), or waitq was already in the "signalled" state).
- */
-int64_t ksleep_timedwait(struct ksleep_chan *chan, 
-                        long state,
-                        __u64 timeout)
-{
-       event_t event;
-
-       ENTRY;
-
-       SLASSERT(chan != NULL);
-       SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC);
-       SLASSERT(get_preemption_level() == 0);
-
-       event = current_thread();
-       kspin_lock(&chan->guard);
-       if (!has_hits(chan, event)) {
-                int      result;
-                __u64 expire;
-               result = assert_wait(event, state);
-               if (timeout > 0) {
-                       /*
-                        * arm a timer. thread_set_timer()'s first argument is
-                        * uint32_t, so we have to cook deadline ourselves.
-                        */
-                       nanoseconds_to_absolutetime(timeout, &expire);
-                        clock_absolutetime_interval_to_deadline(expire, &expire);
-                       thread_set_timer_deadline(expire);
-               }
-               kspin_unlock(&chan->guard);
-               SLASSERT(result == THREAD_AWAKENED || result == THREAD_WAITING);
-               if (result == THREAD_WAITING)
-                       result = thread_block(THREAD_CONTINUE_NULL);
-               thread_cancel_timer();
-
-               if (result == THREAD_TIMED_OUT)
-                        timeout = 0;
-               else {
-                        __u64 now;
-                        clock_get_uptime(&now);
-                        if (expire > now)
-                               absolutetime_to_nanoseconds(expire - now, &timeout);
-                        else
-                                timeout = 0;
-               }
-       } else  {
-                /* just return timeout, because I've got event and don't need to wait */
-               kspin_unlock(&chan->guard);
-        }
-
-        RETURN(timeout);
-}
-
-/*
- * wake up single exclusive waiter (plus some arbitrary number of *
- * non-exclusive)
- */
-void ksleep_wake(struct ksleep_chan *chan)
-{
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-       ksleep_wake_nr(chan, 1);
-}
-
-/*
- * wake up all waiters on @chan
- */
-void ksleep_wake_all(struct ksleep_chan *chan)
-{
-       ENTRY;
-       ksleep_wake_nr(chan, 0);
-       EXIT;
-}
-
-/*
- * wakeup no more than @nr exclusive waiters from @chan, plus some arbitrary
- * number of non-exclusive. If @nr is 0, wake up all waiters.
- */
-void ksleep_wake_nr(struct ksleep_chan *chan, int nr)
-{
-       struct ksleep_link *scan;
-       int result;
-
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-
-       SLASSERT(chan != NULL);
-       SLASSERT(chan->magic == KSLEEP_CHAN_MAGIC);
-
-       kspin_lock(&chan->guard);
-       list_for_each_entry(scan, &chan->waiters, linkage) {
-               struct ksleep_chan *forward;
-
-               forward = scan->forward;
-               if (forward != NULL)
-                       kspin_lock(&forward->guard);
-               result = thread_wakeup(scan->event);
-               SLASSERT(result == KERN_SUCCESS || result == KERN_NOT_WAITING);
-               if (result == KERN_NOT_WAITING) {
-                       ++ scan->hits;
-                       if (forward != NULL)
-                               add_hit(forward, scan->event);
-               }
-               if (forward != NULL)
-                       kspin_unlock(&forward->guard);
-               if ((scan->flags & KSLEEP_EXCLUSIVE) && --nr == 0)
-                       break;
-       }
-       kspin_unlock(&chan->guard);
-}
-
-void ktimer_init(struct ktimer *t, void (*func)(void *), void *arg)
-{
-       SLASSERT(t != NULL);
-       SLASSERT(func != NULL);
-
-       kspin_init(&t->guard);
-       t->func = func;
-       t->arg  = arg;
-       ON_SYNC_DEBUG(t->magic = KTIMER_MAGIC);
-}
-
-void ktimer_done(struct ktimer *t)
-{
-       SLASSERT(t != NULL);
-       SLASSERT(t->magic == KTIMER_MAGIC);
-       kspin_done(&t->guard);
-       ON_SYNC_DEBUG(t->magic = 0);
-}
-
-static void ktimer_actor(void *arg0, void *arg1)
-{
-       struct ktimer *t;
-       int            armed;
-
-       t = arg0;
-       /*
-        * this assumes that ktimer's are never freed.
-        */
-       SLASSERT(t != NULL);
-       SLASSERT(t->magic == KTIMER_MAGIC);
-
-       /*
-        * call actual timer function
-        */
-       kspin_lock(&t->guard);
-       armed = t->armed;
-       t->armed = 0;
-       kspin_unlock(&t->guard);
-
-       if (armed)
-               t->func(t->arg);
-}
-
-extern boolean_t thread_call_func_cancel(thread_call_func_t, thread_call_param_t, boolean_t);
-extern void thread_call_func_delayed(thread_call_func_t, thread_call_param_t, __u64);
-
-static void ktimer_disarm_locked(struct ktimer *t)
-{
-       SLASSERT(t != NULL);
-       SLASSERT(t->magic == KTIMER_MAGIC);
-
-       thread_call_func_cancel(ktimer_actor, t, FALSE);
-}
-
-/*
- * Received deadline is nanoseconds, but time checked by 
- * thread_call is absolute time (The abstime unit is equal to 
- * the length of one bus cycle, so the duration is dependent 
- * on the bus speed of the computer), so we need to convert
- * nanotime to abstime by nanoseconds_to_absolutetime().
- *
- * Refer to _delayed_call_timer(...)
- *
- * if thread_call_func_delayed is not exported in the future,
- * we can use timeout() or bsd_timeout() to replace it.
- */
-void ktimer_arm(struct ktimer *t, u_int64_t deadline)
-{
-        cfs_time_t    abstime;
-       SLASSERT(t != NULL);
-       SLASSERT(t->magic == KTIMER_MAGIC);
-
-       kspin_lock(&t->guard);
-       ktimer_disarm_locked(t);
-       t->armed = 1;
-        nanoseconds_to_absolutetime(deadline, &abstime);
-       thread_call_func_delayed(ktimer_actor, t, deadline);
-       kspin_unlock(&t->guard);
-}
-
-void ktimer_disarm(struct ktimer *t)
-{
-       SLASSERT(t != NULL);
-       SLASSERT(t->magic == KTIMER_MAGIC);
-
-       kspin_lock(&t->guard);
-       t->armed = 0;
-       ktimer_disarm_locked(t);
-       kspin_unlock(&t->guard);
-}
-
-int ktimer_is_armed(struct ktimer *t)
-{
-       SLASSERT(t != NULL);
-       SLASSERT(t->magic == KTIMER_MAGIC);
-
-       /*
-        * no locking---result is only a hint anyway.
-        */
-       return t->armed;
-}
-
-u_int64_t ktimer_deadline(struct ktimer *t)
-{
-       SLASSERT(t != NULL);
-       SLASSERT(t->magic == KTIMER_MAGIC);
-
-       return t->deadline;
-}
-
-void cfs_sync_init(void) 
-{
-#ifdef __DARWIN8__
-        /* Initialize lock group */
-        cfs_lock_grp = lck_grp_alloc_init("libcfs sync", LCK_GRP_ATTR_NULL);
-#endif
-}
-
-void cfs_sync_fini(void)
-{
-#ifdef __DARWIN8__
-        /* 
-         * XXX Liang: destroy lock group. As we haven't called lock_done
-         * for all locks, cfs_lock_grp may not be freed by kernel(reference 
-         * count > 1).
-         */
-        lck_grp_free(cfs_lock_grp);
-        cfs_lock_grp = NULL;
-#endif
-}
-/*
- * Local variables:
- * c-indentation-style: "K&R"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
diff --git a/libcfs/libcfs/darwin/darwin-tcpip.c b/libcfs/libcfs/darwin/darwin-tcpip.c
deleted file mode 100644 (file)
index 406eb7e..0000000
+++ /dev/null
@@ -1,1352 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/darwin/darwin-tcpip.c
- *
- * Darwin porting library
- * Make things easy to port
- *
- * Author: Phil Schwan <phil@clusterfs.com>
- */
-
-#include <mach/mach_types.h>
-#include <sys/file.h>
-#include <sys/mount.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/sockio.h>
-#include <sys/protosw.h>
-#include <net/if.h>
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <libcfs/libcfs.h>
-
-static __inline__ struct sockaddr_in
-blank_sin()
-{
-        struct sockaddr_in  blank = { sizeof(struct sockaddr_in), AF_INET };
-        return (blank);
-}
-
-void
-libcfs_ipif_free_enumeration (char **names, int n)
-{
-        int      i;
-
-        LASSERT (n > 0);
-
-        for (i = 0; i < n && names[i] != NULL; i++)
-                LIBCFS_FREE(names[i], IFNAMSIZ);
-                
-        LIBCFS_FREE(names, n * sizeof(*names));
-}
-
-#ifdef __DARWIN8__
-/*
- * Darwin 8.x 
- *
- * No hack kernel structre, all using KPI.
- */
-
-int
-libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
-{
-        struct ifreq    ifr;
-        socket_t        so;
-        __u32           val;
-        int             nob;
-        int             rc;
-
-        rc = -sock_socket(PF_INET, SOCK_STREAM, 0, 
-                          NULL, NULL, &so);
-        if (rc != 0) {
-                CERROR ("Can't create socket: %d\n", rc);
-                return rc;
-        }
-
-        nob = strnlen(name, IFNAMSIZ);
-        if (nob == IFNAMSIZ) {
-                CERROR("Interface name %s too long\n", name);
-                rc = -EINVAL;
-                goto out;
-        }
-
-        CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
-        bzero(&ifr, sizeof(ifr));
-        strcpy(ifr.ifr_name, name);
-        rc = -sock_ioctl (so, SIOCGIFFLAGS, &ifr);
-
-        if (rc != 0) {
-                CERROR("Can't get flags for interface %s\n", name);
-                goto out;
-        }
-        
-        if ((ifr.ifr_flags & IFF_UP) == 0) {
-                CDEBUG(D_NET, "Interface %s down\n", name);
-                *up = 0;
-                *ip = *mask = 0;
-                goto out;
-        }
-
-        *up = 1;
-
-        bzero(&ifr, sizeof(ifr));
-        strcpy(ifr.ifr_name, name);
-        *((struct sockaddr_in *)&ifr.ifr_addr) = blank_sin();
-        rc = -sock_ioctl(so, SIOCGIFADDR, &ifr);
-
-        if (rc != 0) {
-                CERROR("Can't get IP address for interface %s\n", name);
-                goto out;
-        }
-        
-        val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
-        *ip = ntohl(val);
-
-        bzero(&ifr, sizeof(ifr));
-        strcpy(ifr.ifr_name, name);
-        *((struct sockaddr_in *)&ifr.ifr_addr) = blank_sin();
-        rc = -sock_ioctl(so, SIOCGIFNETMASK, &ifr);
-
-        if (rc != 0) {
-                CERROR("Can't get netmask for interface %s\n", name);
-                goto out;
-        }
-
-        val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
-        *mask = ntohl(val);
-out:
-        sock_close(so);
-        return rc;
-}
-
-int
-libcfs_ipif_enumerate (char ***namesp)
-{
-        /* Allocate and fill in 'names', returning # interfaces/error */
-        char           **names;
-        int             toobig;
-        int             nalloc;
-        int             nfound;
-        socket_t        so;
-        struct ifreq   *ifr;
-        struct ifconf   ifc;
-        int             rc;
-        int             nob;
-        int             i;
-
-        rc = -sock_socket(PF_INET, SOCK_STREAM, 0, 
-                          NULL, NULL, &so);
-        if (rc != 0) {
-                CERROR ("Can't create socket: %d\n", rc);
-                return (rc);
-        }
-
-        nalloc = 16;    /* first guess at max interfaces */
-        toobig = 0;
-        for (;;) {
-               if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) {
-                        toobig = 1;
-                       nalloc = PAGE_CACHE_SIZE/sizeof(*ifr);
-                        CWARN("Too many interfaces: only enumerating first %d\n",
-                              nalloc);
-                }
-
-                LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr));
-                if (ifr == NULL) {
-                        CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc);
-                                rc = -ENOMEM;
-                        goto out0;
-                }
-                                
-                ifc.ifc_buf = (char *)ifr;
-                ifc.ifc_len = nalloc * sizeof(*ifr);
-                                        
-#if 1
-                /*
-                 * XXX Liang:
-                 * sock_ioctl(..., SIOCGIFCONF, ...) is not supposed to be used in
-                 * kernel space because it always try to copy result to userspace. 
-                 * So we can't get interfaces name by sock_ioctl(...,SIOCGIFCONF,...).
-                 * I've created a bug for Apple, let's wait...
-                 */
-                nfound = 0;
-                for (i = 0; i < 16; i++) {
-                        struct ifreq    en;
-                        bzero(&en, sizeof(en));
-                        snprintf(en.ifr_name, IFNAMSIZ, "en%d", i);
-                        rc = -sock_ioctl (so, SIOCGIFFLAGS, &en);
-                        if (rc != 0)
-                                continue;
-                        strcpy(ifr[nfound++].ifr_name, en.ifr_name);
-                }
-
-#else           /* NOT in using now */
-                rc = -sock_ioctl(so, SIOCGIFCONF, (caddr_t)&ifc);
-                                
-                if (rc < 0) {
-                        CERROR ("Error %d enumerating interfaces\n", rc);
-                        goto out1;
-                }
-
-                nfound = ifc.ifc_len/sizeof(*ifr);
-                LASSERT (nfound <= nalloc);
-#endif
-
-                if (nfound < nalloc || toobig)
-                        break;
-
-                LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
-                nalloc *= 2;
-        }
-        if (nfound == 0)
-                goto out1;
-
-        LIBCFS_ALLOC(names, nfound * sizeof(*names));
-        if (names == NULL) {
-                rc = -ENOMEM;
-                goto out1;
-        }
-        /* NULL out all names[i] */
-        memset (names, 0, nfound * sizeof(*names));
-
-        for (i = 0; i < nfound; i++) {
-
-                nob = strnlen (ifr[i].ifr_name, IFNAMSIZ);
-                if (nob == IFNAMSIZ) {
-                        /* no space for terminating NULL */
-                        CERROR("interface name %.*s too long (%d max)\n",
-                               nob, ifr[i].ifr_name, IFNAMSIZ);
-                        rc = -ENAMETOOLONG;
-                        goto out2;
-                }
-
-                LIBCFS_ALLOC(names[i], IFNAMSIZ);
-                if (names[i] == NULL) {
-                        rc = -ENOMEM;
-                        goto out2;
-                }
-
-                memcpy(names[i], ifr[i].ifr_name, nob);
-                names[i][nob] = 0;
-        }
-
-        *namesp = names;
-        rc = nfound;
-
-out2:
-        if (rc < 0)
-                libcfs_ipif_free_enumeration(names, nfound);
-out1:
-        LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
-out0:
-        sock_close(so);
-        return rc;
-
-}
-
-/*
- * Public entry of socket upcall.
- *
- * so_upcall can only be installed while create/accept of socket in 
- * Darwin 8.0, so we setup libcfs_sock_upcall() as upcall for all 
- * sockets in creat/accept, it will call upcall provided by user 
- * which can be setup after create/accept of socket.
- */
-static void libcfs_sock_upcall(socket_t so, void* arg, int waitf)
-{
-        cfs_socket_t    *sock;
-
-        sock = (cfs_socket_t *)arg;
-        LASSERT(sock->s_magic == CFS_SOCK_MAGIC);
-
-        if ((sock->s_flags & CFS_SOCK_UPCALL) != 0 && sock->s_upcall != NULL)
-                sock->s_upcall(so, sock->s_upcallarg, waitf);
-        return;
-}
-
-void libcfs_sock_set_cb(cfs_socket_t *sock, so_upcall callback, void *arg)
-{
-        sock->s_upcall = callback;
-        sock->s_upcallarg = arg;
-        sock->s_flags |= CFS_SOCK_UPCALL;
-        return;
-}
-
-void libcfs_sock_reset_cb(cfs_socket_t *sock)
-{
-        sock->s_flags &= ~CFS_SOCK_UPCALL;
-        sock->s_upcall = NULL;
-        sock->s_upcallarg = NULL;
-        return;
-}
-
-static int
-libcfs_sock_create (cfs_socket_t **sockp, int *fatal,
-                    __u32 local_ip, int local_port)
-{
-        struct sockaddr_in  locaddr;
-        cfs_socket_t    *sock;
-        int             option;
-        int             optlen;
-        int             rc;
-
-        /* All errors are fatal except bind failure if the port is in use */
-        *fatal = 1;
-
-        sock = _MALLOC(sizeof(cfs_socket_t), M_TEMP, M_WAITOK|M_ZERO);
-        if (!sock) {
-                CERROR("Can't allocate cfs_socket.\n");
-                return -ENOMEM;
-        }
-        *sockp = sock;
-        sock->s_magic = CFS_SOCK_MAGIC;
-
-        rc = -sock_socket(PF_INET, SOCK_STREAM, 0, 
-                          libcfs_sock_upcall, sock, &C2B_SOCK(sock));
-        if (rc != 0) 
-                goto out;
-        option = 1;
-        optlen = sizeof(option);
-        rc = -sock_setsockopt(C2B_SOCK(sock), SOL_SOCKET, 
-                              SO_REUSEADDR, &option, optlen);
-        if (rc != 0)
-                goto out;
-
-        /* can't specify a local port without a local IP */
-        LASSERT (local_ip == 0 || local_port != 0);
-
-        if (local_ip != 0 || local_port != 0) {
-                bzero (&locaddr, sizeof (locaddr));
-                locaddr.sin_len = sizeof(struct sockaddr_in);
-                locaddr.sin_family = AF_INET;
-                locaddr.sin_port = htons (local_port);
-                locaddr.sin_addr.s_addr = (local_ip != 0) ? htonl(local_ip) : INADDR_ANY;
-                rc = -sock_bind(C2B_SOCK(sock), (struct sockaddr *)&locaddr);
-                if (rc == -EADDRINUSE) {
-                        CDEBUG(D_NET, "Port %d already in use\n", local_port);
-                        *fatal = 0;
-                        goto out;
-                }
-                if (rc != 0) {
-                        CERROR("Error trying to bind to port %d: %d\n",
-                               local_port, rc);
-                        goto out;
-                }
-        }
-        return 0;
-out:
-        if (C2B_SOCK(sock) != NULL) 
-                sock_close(C2B_SOCK(sock));
-        FREE(sock, M_TEMP);
-        return rc;
-}
-
-int
-libcfs_sock_listen (cfs_socket_t **sockp,
-                   __u32 local_ip, int local_port, int backlog)
-{
-        cfs_socket_t    *sock;
-        int             fatal;
-        int             rc;
-
-        rc = libcfs_sock_create(&sock, &fatal, local_ip, local_port);
-        if (rc != 0)  {
-                if (!fatal)
-                        CERROR("Can't create socket: port %d already in use\n",
-                                local_port);
-                return rc;
-
-        }
-        rc = -sock_listen(C2B_SOCK(sock), backlog);
-        if (rc == 0) {
-                *sockp = sock;
-                return 0;
-        }
-
-        if (C2B_SOCK(sock) != NULL) 
-                sock_close(C2B_SOCK(sock));
-        FREE(sock, M_TEMP);
-        return rc;
-}
-
-int
-libcfs_sock_accept (cfs_socket_t **newsockp, cfs_socket_t *sock)
-{
-        cfs_socket_t   *newsock;
-        int             rc;
-
-        newsock = _MALLOC(sizeof(cfs_socket_t), M_TEMP, M_WAITOK|M_ZERO);
-        if (!newsock) {
-                CERROR("Can't allocate cfs_socket.\n");
-                return -ENOMEM;
-        }
-        newsock->s_magic = CFS_SOCK_MAGIC;
-        /*
-         * thread will sleep in sock_accept by calling of msleep(), 
-         * it can be interrupted because msleep() use PCATCH as argument.
-         */
-        rc = -sock_accept(C2B_SOCK(sock), NULL, 0, 0, 
-                          libcfs_sock_upcall, newsock, &C2B_SOCK(newsock));
-        if (rc) {
-                if (C2B_SOCK(newsock) != NULL) 
-                        sock_close(C2B_SOCK(newsock));
-                FREE(newsock, M_TEMP);
-                if ((sock->s_flags & CFS_SOCK_DOWN) != 0)
-                        /* shutdown by libcfs_sock_abort_accept(), fake 
-                         * error number for lnet_acceptor() */
-                        rc = -EAGAIN;
-                return rc;
-        }
-        *newsockp = newsock;
-        return 0;
-}
-
-void
-libcfs_sock_abort_accept (cfs_socket_t *sock)
-{
-        /*
-         * XXX Liang: 
-         *
-         * we want to wakeup thread blocked by sock_accept, but we don't
-         * know the address where thread is sleeping on, so we cannot 
-         * wakeup it directly.
-         * The thread slept in sock_accept will be waken up while:
-         * 1. interrupt by signal
-         * 2. new connection is coming (sonewconn)
-         * 3. disconnecting of the socket (soisconnected)
-         * 
-         * Cause we can't send signal to a thread directly(no KPI), so the 
-         * only thing can be done here is disconnect the socket (by 
-         * sock_shutdown() or sth else? ).
-         *
-         * Shutdown request of socket with SHUT_WR or SHUT_RDWR will
-         * be issured to the protocol.
-         * sock_shutdown()->tcp_usr_shutdown()->tcp_usrclosed()->
-         * tcp_close()->soisdisconnected(), it will wakeup thread by
-         * wakeup((caddr_t)&so->so_timeo);
-         */
-        sock->s_flags |= CFS_SOCK_DOWN;
-        sock_shutdown(C2B_SOCK(sock), SHUT_RDWR);
-}
-
-int
-libcfs_sock_read (cfs_socket_t *sock, void *buffer, int nob, int timeout)
-{
-        size_t          rcvlen;
-        int             rc;
-        cfs_duration_t  to = cfs_time_seconds(timeout);
-        cfs_time_t      then;
-        struct timeval  tv;
-
-        LASSERT(nob > 0);
-
-        for (;;) {
-                struct iovec  iov = {
-                        .iov_base = buffer,
-                        .iov_len  = nob
-                };
-                struct  msghdr  msg = {
-                        .msg_name       = NULL,
-                        .msg_namelen    = 0,
-                        .msg_iov        = &iov,
-                        .msg_iovlen     = 1,
-                        .msg_control    = NULL,
-                        .msg_controllen = 0,
-                        .msg_flags      = 0,
-                };
-                cfs_duration_usec(to, &tv);
-                rc = -sock_setsockopt(C2B_SOCK(sock), SOL_SOCKET, SO_RCVTIMEO,
-                                      &tv, sizeof(tv));
-                if (rc != 0) {
-                        CERROR("Can't set socket recv timeout "
-                                        "%ld.%06d: %d\n",
-                                        (long)tv.tv_sec, (int)tv.tv_usec, rc);
-                        return rc;
-                }
-
-                then = cfs_time_current();
-                rc = -sock_receive(C2B_SOCK(sock), &msg, 0, &rcvlen);
-                to -= cfs_time_current() - then;
-
-                if (rc != 0 && rc != -EWOULDBLOCK)
-                        return rc;
-                if (rcvlen == nob)
-                        return 0;
-
-                if (to <= 0)
-                        return -EAGAIN;
-
-                buffer = ((char *)buffer) + rcvlen;
-                nob -= rcvlen;
-        }
-        return 0;
-}
-
-int
-libcfs_sock_write (cfs_socket_t *sock, void *buffer, int nob, int timeout)
-{
-        size_t          sndlen;
-        int             rc;
-        cfs_duration_t  to = cfs_time_seconds(timeout);
-        cfs_time_t      then;
-        struct timeval  tv;
-
-        LASSERT(nob > 0);
-
-        for (;;) {
-                struct iovec  iov = {
-                        .iov_base = buffer,
-                        .iov_len  = nob
-                };
-                struct  msghdr  msg = {
-                        .msg_name       = NULL,
-                        .msg_namelen    = 0,
-                        .msg_iov        = &iov,
-                        .msg_iovlen     = 1,
-                        .msg_control    = NULL,
-                        .msg_controllen = 0,
-                        .msg_flags      = (timeout == 0) ? MSG_DONTWAIT : 0,
-                };
-
-                if (timeout != 0) {
-                        cfs_duration_usec(to, &tv);
-                        rc = -sock_setsockopt(C2B_SOCK(sock), SOL_SOCKET, SO_SNDTIMEO,
-                                              &tv, sizeof(tv));
-                        if (rc != 0) {
-                                CERROR("Can't set socket send timeout "
-                                       "%ld.%06d: %d\n",
-                                       (long)tv.tv_sec, (int)tv.tv_usec, rc);
-                                return rc;
-                        }
-                }
-
-                then = cfs_time_current();
-                rc = -sock_send(C2B_SOCK(sock), &msg, 
-                                ((timeout == 0) ? MSG_DONTWAIT : 0), &sndlen);
-                to -= cfs_time_current() - then;
-
-                if (rc != 0 && rc != -EWOULDBLOCK)
-                        return rc;
-                if (sndlen == nob)
-                        return 0;
-
-                if (to <= 0)
-                        return -EAGAIN;
-                buffer = ((char *)buffer) + sndlen;
-                nob -= sndlen;
-        }
-        return 0;
-
-}
-
-int
-libcfs_sock_getaddr (cfs_socket_t *sock, int remote, __u32 *ip, int *port)
-{
-        struct sockaddr_in sin;
-        int                rc;
-
-        if (remote != 0) 
-                /* Get remote address */
-                rc = -sock_getpeername(C2B_SOCK(sock), (struct sockaddr *)&sin, sizeof(sin));
-        else 
-                /* Get local address */
-                rc = -sock_getsockname(C2B_SOCK(sock), (struct sockaddr *)&sin, sizeof(sin));
-        if (rc != 0) {
-                CERROR ("Error %d getting sock %s IP/port\n",
-                         rc, remote ? "peer" : "local");
-                return rc;
-        }
-
-        if (ip != NULL)
-                *ip = ntohl (sin.sin_addr.s_addr);
-
-        if (port != NULL)
-                *port = ntohs (sin.sin_port);
-        return 0;
-}
-
-int
-libcfs_sock_setbuf (cfs_socket_t *sock, int txbufsize, int rxbufsize)
-{
-        int                 option;
-        int                 rc;
-        
-        if (txbufsize != 0) {
-                option = txbufsize;
-                rc = -sock_setsockopt(C2B_SOCK(sock), SOL_SOCKET, SO_SNDBUF,
-                                     (char *)&option, sizeof (option));
-                if (rc != 0) {
-                        CERROR ("Can't set send buffer %d: %d\n",
-                                option, rc);
-                        return (rc);
-                } 
-        } 
-        
-        if (rxbufsize != 0) {
-                option = rxbufsize;
-                rc = -sock_setsockopt (C2B_SOCK(sock), SOL_SOCKET, SO_RCVBUF,
-                                      (char *)&option, sizeof (option));
-                if (rc != 0) {
-                        CERROR ("Can't set receive buffer %d: %d\n",
-                                option, rc);
-                        return (rc);
-                }
-        }
-        return 0;
-}
-
-int
-libcfs_sock_getbuf (cfs_socket_t *sock, int *txbufsize, int *rxbufsize)
-{
-        int                 option;
-        int                 optlen;
-        int                 rc; 
-        
-        if (txbufsize != NULL) {
-                optlen = sizeof(option);
-                rc = -sock_getsockopt(C2B_SOCK(sock), SOL_SOCKET, SO_SNDBUF,
-                                (char *)&option, &optlen);
-                if (rc != 0) {
-                        CERROR ("Can't get send buffer size: %d\n", rc);
-                        return (rc);
-                }
-                *txbufsize = option;
-        } 
-        
-        if (rxbufsize != NULL) {
-                optlen = sizeof(option);
-                rc = -sock_getsockopt (C2B_SOCK(sock), SOL_SOCKET, SO_RCVBUF,
-                                (char *)&option, &optlen);
-                if (rc != 0) {
-                        CERROR ("Can't get receive buffer size: %d\n", rc);
-                        return (rc);
-                }
-                *rxbufsize = option;
-        }
-        return 0;
-}
-
-void
-libcfs_sock_release (cfs_socket_t *sock)
-{
-        if (C2B_SOCK(sock) != NULL) {
-                sock_shutdown(C2B_SOCK(sock), 2);
-                sock_close(C2B_SOCK(sock));
-        }
-        FREE(sock, M_TEMP);
-}
-
-int
-libcfs_sock_connect (cfs_socket_t **sockp, int *fatal,
-                     __u32 local_ip, int local_port,
-                     __u32 peer_ip, int peer_port)
-{
-        cfs_socket_t       *sock;
-        struct sockaddr_in  srvaddr;
-        int                 rc; 
-        
-        rc = libcfs_sock_create(&sock, fatal, local_ip, local_port);
-        if (rc != 0)
-                return rc;
-
-        bzero(&srvaddr, sizeof(srvaddr));
-        srvaddr.sin_len = sizeof(struct sockaddr_in);
-        srvaddr.sin_family = AF_INET;
-        srvaddr.sin_port = htons(peer_port);
-        srvaddr.sin_addr.s_addr = htonl(peer_ip);
-
-        rc = -sock_connect(C2B_SOCK(sock), (struct sockaddr *)&srvaddr, 0);
-        if (rc == 0) {
-                *sockp = sock;
-                return 0;
-        }
-
-        *fatal = !(rc == -EADDRNOTAVAIL || rc == -EADDRINUSE);
-        CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET,
-               "Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc,
-               HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port);
-
-        libcfs_sock_release(sock);
-        return rc;
-}
-
-#else   /* !__DARWIN8__ */
-
-/*
- * To use bigger buffer for socket:
- * 1. Increase nmbclusters (Cannot increased by sysctl because it's ready only, so
- *    we must patch kernel).
- * 2. Increase net.inet.tcp.reass.maxsegments
- * 3. Increase net.inet.tcp.sendspace
- * 4. Increase net.inet.tcp.recvspace
- * 5. Increase kern.ipc.maxsockbuf
- */
-#define KSOCK_MAX_BUF        (1152*1024)
-
-int
-libcfs_ipif_query (char *name, int *up, __u32 *ip, __u32 *mask)
-{
-        struct socket      *so;
-        struct ifreq       ifr;
-        int                nob;
-        int                rc;
-        __u32              val;
-        CFS_DECL_FUNNEL_DATA;
-
-        CFS_NET_IN;
-        rc = socreate(PF_INET, &so, SOCK_STREAM, 0);
-        CFS_NET_EX;
-        if (rc != 0) {
-                CERROR ("Can't create socket: %d\n", rc);
-                return (-rc);
-        }
-        nob = strnlen(name, IFNAMSIZ);
-        if (nob == IFNAMSIZ) {
-                CERROR("Interface name %s too long\n", name);
-                rc = -EINVAL;
-                goto out;
-        }
-
-        CLASSERT (sizeof(ifr.ifr_name) >= IFNAMSIZ);
-        strcpy(ifr.ifr_name, name);
-        CFS_NET_IN;
-        rc = ifioctl(so, SIOCGIFFLAGS, (caddr_t)&ifr, current_proc());
-        CFS_NET_EX;
-
-        if (rc != 0) {
-                CERROR("Can't get flags for interface %s\n", name);
-                goto out;
-        }
-        if ((ifr.ifr_flags & IFF_UP) == 0) {
-                CDEBUG(D_NET, "Interface %s down\n", name);
-                *up = 0;
-                *ip = *mask = 0;
-                goto out;
-        }
-       
-        *up = 1;
-        strcpy(ifr.ifr_name, name);
-        *((struct sockaddr_in *)&ifr.ifr_addr) = blank_sin();
-        CFS_NET_IN;
-        rc = ifioctl(so, SIOCGIFADDR, (caddr_t)&ifr, current_proc());
-        CFS_NET_EX;
-
-        if (rc != 0) {
-                CERROR("Can't get IP address for interface %s\n", name);
-                goto out;
-        }
-
-        val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
-        *ip = ntohl(val);
-
-        strcpy(ifr.ifr_name, name);
-        *((struct sockaddr_in *)&ifr.ifr_addr) = blank_sin();
-        CFS_NET_IN;
-        rc = ifioctl(so, SIOCGIFNETMASK, (caddr_t)&ifr, current_proc());
-        CFS_NET_EX;
-
-        if (rc != 0) {
-                CERROR("Can't get netmask for interface %s\n", name);
-                goto out;
-        }
-
-        val = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
-        *mask = ntohl(val);
-out:
-        CFS_NET_IN;
-        soclose(so);
-        CFS_NET_EX;
-        return -rc;
-}
-
-int
-libcfs_ipif_enumerate (char ***namesp)
-{
-        /* Allocate and fill in 'names', returning # interfaces/error */
-        char           **names;
-        int             toobig;
-        int             nalloc;
-        int             nfound;
-        struct socket  *so;
-        struct ifreq   *ifr;
-        struct ifconf   ifc;
-        int             rc;
-        int             nob;
-        int             i;
-        CFS_DECL_FUNNEL_DATA;
-
-        CFS_NET_IN;
-        rc = socreate(PF_INET, &so, SOCK_STREAM, 0);
-        CFS_NET_EX;
-        if (rc != 0) {
-                CERROR ("Can't create socket: %d\n", rc);
-                return (-rc);
-        }
-
-        nalloc = 16;    /* first guess at max interfaces */
-        toobig = 0;
-        for (;;) {
-               if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) {
-                        toobig = 1;
-                       nalloc = PAGE_CACHE_SIZE/sizeof(*ifr);
-                        CWARN("Too many interfaces: only enumerating first %d\n",
-                              nalloc);
-                }
-
-                LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr));
-                if (ifr == NULL) {
-                        CERROR ("ENOMEM enumerating up to %d interfaces\n", nalloc);
-                                rc = -ENOMEM;
-                        goto out0;
-                }
-                                
-                ifc.ifc_buf = (char *)ifr;
-                ifc.ifc_len = nalloc * sizeof(*ifr);
-                                        
-                CFS_NET_IN;
-                rc = -ifioctl(so, SIOCGIFCONF, (caddr_t)&ifc, current_proc());
-                CFS_NET_EX;
-                                
-                if (rc < 0) {
-                        CERROR ("Error %d enumerating interfaces\n", rc);
-                        goto out1;
-                }
-
-                nfound = ifc.ifc_len/sizeof(*ifr);
-                LASSERT (nfound <= nalloc);
-
-                if (nfound < nalloc || toobig)
-                        break;
-
-                LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
-                nalloc *= 2;
-        }
-        if (nfound == 0)
-                goto out1;
-
-        LIBCFS_ALLOC(names, nfound * sizeof(*names));
-        if (names == NULL) {
-                rc = -ENOMEM;
-                goto out1;
-        }
-        /* NULL out all names[i] */
-        memset (names, 0, nfound * sizeof(*names));
-
-        for (i = 0; i < nfound; i++) {
-
-                nob = strnlen (ifr[i].ifr_name, IFNAMSIZ);
-                if (nob == IFNAMSIZ) {
-                        /* no space for terminating NULL */
-                        CERROR("interface name %.*s too long (%d max)\n",
-                               nob, ifr[i].ifr_name, IFNAMSIZ);
-                        rc = -ENAMETOOLONG;
-                        goto out2;
-                }
-
-                LIBCFS_ALLOC(names[i], IFNAMSIZ);
-                if (names[i] == NULL) {
-                        rc = -ENOMEM;
-                        goto out2;
-                }
-
-                memcpy(names[i], ifr[i].ifr_name, nob);
-                names[i][nob] = 0;
-        }
-
-        *namesp = names;
-        rc = nfound;
-
-out2:
-        if (rc < 0)
-                libcfs_ipif_free_enumeration(names, nfound);
-out1:
-        LIBCFS_FREE(ifr, nalloc * sizeof(*ifr));
-out0:
-        CFS_NET_IN;
-        soclose(so);
-        CFS_NET_EX;
-        return rc;
-}
-
-static int
-libcfs_sock_create (struct socket **sockp, int *fatal,
-                    __u32 local_ip, int local_port)
-{
-        struct sockaddr_in  locaddr;
-        struct socket      *so;
-        struct sockopt      sopt;
-        int                 option;
-        int                 rc;
-        CFS_DECL_FUNNEL_DATA;
-
-        *fatal = 1;
-        CFS_NET_IN;
-        rc = socreate(PF_INET, &so, SOCK_STREAM, 0);
-        CFS_NET_EX;
-        if (rc != 0) {
-                CERROR ("Can't create socket: %d\n", rc);
-                return (-rc);
-        }
-        
-        bzero(&sopt, sizeof sopt);
-        option = 1;
-        sopt.sopt_level = SOL_SOCKET;
-        sopt.sopt_name = SO_REUSEADDR;
-        sopt.sopt_val = &option;
-        sopt.sopt_valsize = sizeof(option);
-        CFS_NET_IN;
-        rc = sosetopt(so, &sopt);
-        if (rc != 0) {
-                CFS_NET_EX;
-                CERROR ("Can't set sock reuse address: %d\n", rc);
-                goto out;
-        }
-        /* can't specify a local port without a local IP */
-        LASSERT (local_ip == 0 || local_port != 0);
-
-        if (local_ip != 0 || local_port != 0) {
-                bzero (&locaddr, sizeof (locaddr));
-                locaddr.sin_len = sizeof(struct sockaddr_in);
-                locaddr.sin_family = AF_INET;
-                locaddr.sin_port = htons (local_port);
-                locaddr.sin_addr.s_addr = (local_ip != 0) ? htonl(local_ip) :
-                                                            INADDR_ANY;
-
-                rc = sobind(so, (struct sockaddr *)&locaddr);
-                if (rc == EADDRINUSE) {
-                        CFS_NET_EX;
-                        CDEBUG(D_NET, "Port %d already in use\n", local_port);
-                        *fatal = 0;
-                        goto out;
-                }
-                if (rc != 0) {
-                        CFS_NET_EX;
-                        CERROR ("Can't bind to local IP Address %u.%u.%u.%u: %d\n",
-                        HIPQUAD(local_ip), rc);
-                        goto out;
-                }
-        }
-        *sockp = so;
-        return 0;
-out:
-        CFS_NET_IN;
-        soclose(so);
-        CFS_NET_EX;
-        return -rc;
-}
-
-int
-libcfs_sock_listen (struct socket **sockp,
-                    __u32 local_ip, int local_port, int backlog)
-{
-        int      fatal;
-        int      rc;
-        CFS_DECL_FUNNEL_DATA;
-
-        rc = libcfs_sock_create(sockp, &fatal, local_ip, local_port);
-        if (rc != 0) {
-                if (!fatal)
-                        CERROR("Can't create socket: port %d already in use\n",
-                               local_port);
-                return rc;
-        }
-        CFS_NET_IN;
-        rc = solisten(*sockp, backlog);
-        CFS_NET_EX;
-        if (rc == 0)
-                return 0;
-        CERROR("Can't set listen backlog %d: %d\n", backlog, rc);
-        CFS_NET_IN;
-        soclose(*sockp);
-        CFS_NET_EX;
-        return -rc;
-}
-
-int
-libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
-{
-        struct socket *so;
-        struct sockaddr *sa;
-        int error, s;
-        CFS_DECL_FUNNEL_DATA;
-
-        CFS_NET_IN;
-        s = splnet();
-        if ((sock->so_options & SO_ACCEPTCONN) == 0) {
-                splx(s);
-                CFS_NET_EX;
-                return (-EINVAL);
-        }
-
-        if ((sock->so_state & SS_NBIO) && sock->so_comp.tqh_first == NULL) {
-                splx(s);
-                CFS_NET_EX;
-                return (-EWOULDBLOCK);
-        }
-
-        error = 0;
-        while (TAILQ_EMPTY(&sock->so_comp) && sock->so_error == 0) {
-                if (sock->so_state & SS_CANTRCVMORE) {
-                        sock->so_error = ECONNABORTED;
-                        break;
-                }
-                error = tsleep((caddr_t)&sock->so_timeo, PSOCK | PCATCH,
-                                "accept", 0);
-                if (error) {
-                        splx(s);
-                        CFS_NET_EX;
-                        return (-error);
-                }
-        }
-        if (sock->so_error) {
-                error = sock->so_error;
-                sock->so_error = 0;
-                splx(s);
-                CFS_NET_EX;
-                return (-error);
-        }
-
-        /*
-         * At this point we know that there is at least one connection
-         * ready to be accepted. Remove it from the queue prior to
-         * allocating the file descriptor for it since falloc() may
-         * block allowing another process to accept the connection
-         * instead.
-         */
-        so = TAILQ_FIRST(&sock->so_comp);
-        TAILQ_REMOVE(&sock->so_comp, so, so_list);
-        sock->so_qlen--;
-
-        so->so_state &= ~SS_COMP;
-        so->so_head = NULL;
-        sa = 0;
-        (void) soaccept(so, &sa);
-
-        *newsockp = so;
-        FREE(sa, M_SONAME);
-        splx(s);
-        CFS_NET_EX;
-        return (-error);
-}
-
-void
-libcfs_sock_abort_accept (struct socket *sock)
-{
-        wakeup(&sock->so_timeo);
-}
-
-/*
- * XXX Liang: timeout for write is not supported yet.
- */
-int
-libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
-{
-        int            rc;
-        CFS_DECL_NET_DATA;
-
-        while (nob > 0) {
-                struct iovec  iov = {
-                        .iov_base = buffer,
-                        .iov_len  = nob
-                };
-                struct  uio suio = {
-                        .uio_iov        = &iov,
-                        .uio_iovcnt     = 1,
-                        .uio_offset     = 0,
-                        .uio_resid      = nob,
-                        .uio_segflg     = UIO_SYSSPACE,
-                        .uio_rw         = UIO_WRITE,
-                        .uio_procp      = NULL
-                };
-                                
-                CFS_NET_IN;
-                rc = sosend(sock, NULL, &suio, (struct mbuf *)0, (struct mbuf *)0, 0);
-                CFS_NET_EX;
-                                
-                if (rc != 0) {
-                        if ( suio.uio_resid != nob && ( rc == ERESTART || rc == EINTR ||\
-                             rc == EWOULDBLOCK))
-                        rc = 0;
-                        if ( rc != 0 )
-                                return -rc;
-                        rc = nob - suio.uio_resid;
-                        buffer = ((char *)buffer) + rc;
-                        nob = suio.uio_resid;
-                        continue;
-                }
-                break;
-        }
-        return (0);
-}
-
-/*
- * XXX Liang: timeout for read is not supported yet.
- */
-int
-libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
-{
-        int            rc;
-        CFS_DECL_NET_DATA;
-
-        while (nob > 0) {
-                struct iovec  iov = {
-                        .iov_base = buffer,
-                        .iov_len  = nob
-                };
-                struct uio  ruio = {
-                        .uio_iov        = &iov,
-                        .uio_iovcnt     = 1,
-                        .uio_offset     = 0,
-                        .uio_resid      = nob,
-                        .uio_segflg     = UIO_SYSSPACE,
-                        .uio_rw         = UIO_READ,
-                        .uio_procp      = NULL
-                };
-                
-                CFS_NET_IN;
-                rc = soreceive(sock, (struct sockaddr **)0, &ruio, (struct mbuf **)0, (struct mbuf **)0, (int *)0);
-                CFS_NET_EX;
-                
-                if (rc != 0) {
-                        if ( ruio.uio_resid != nob && ( rc == ERESTART || rc == EINTR ||\
-                                rc == EWOULDBLOCK))
-                                rc = 0;
-                        if (rc != 0)
-                                return -rc;
-                        rc = nob - ruio.uio_resid;
-                        buffer = ((char *)buffer) + rc;
-                        nob = ruio.uio_resid;
-                        continue;
-                }
-                break;
-        }
-        return (0);
-}
-
-int
-libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize)
-{
-        struct sockopt  sopt;
-        int             rc = 0;
-        int             option;
-        CFS_DECL_NET_DATA;
-
-        bzero(&sopt, sizeof sopt);
-        sopt.sopt_dir = SOPT_SET;
-        sopt.sopt_level = SOL_SOCKET;
-        sopt.sopt_val = &option;
-        sopt.sopt_valsize = sizeof(option);
-
-        if (txbufsize != 0) {
-                option = txbufsize;
-                if (option > KSOCK_MAX_BUF)
-                        option = KSOCK_MAX_BUF;
-        
-                sopt.sopt_name = SO_SNDBUF;
-                CFS_NET_IN;
-                rc = sosetopt(sock, &sopt);
-                CFS_NET_EX;
-                if (rc != 0) {
-                        CERROR ("Can't set send buffer %d: %d\n",
-                                option, rc);
-                        
-                        return -rc;
-                }
-        }
-                
-        if (rxbufsize != 0) {
-                option = rxbufsize;
-                sopt.sopt_name = SO_RCVBUF;
-                CFS_NET_IN;
-                rc = sosetopt(sock, &sopt);
-                CFS_NET_EX;
-                if (rc != 0) {
-                        CERROR ("Can't set receive buffer %d: %d\n",
-                                option, rc);
-                        return -rc;
-                }
-        }
-        return 0;
-}
-
-int
-libcfs_sock_getaddr (struct socket *sock, int remote, __u32 *ip, int *port)
-{
-        struct sockaddr_in *sin;
-        struct sockaddr    *sa = NULL;
-        int                rc;
-        CFS_DECL_NET_DATA;
-
-        if (remote != 0) {
-                CFS_NET_IN;
-                rc = sock->so_proto->pr_usrreqs->pru_peeraddr(sock, &sa);
-                CFS_NET_EX;
-
-                if (rc != 0) {
-                        if (sa) FREE(sa, M_SONAME);
-                        CERROR ("Error %d getting sock peer IP\n", rc);
-                        return -rc;
-                }
-        } else {
-                CFS_NET_IN;
-                rc = sock->so_proto->pr_usrreqs->pru_sockaddr(sock, &sa);
-                CFS_NET_EX;
-                if (rc != 0) {
-                        if (sa) FREE(sa, M_SONAME);
-                        CERROR ("Error %d getting sock local IP\n", rc);
-                        return -rc;
-                }
-        }
-        if (sa != NULL) {
-                sin = (struct sockaddr_in *)sa;
-                if (ip != NULL)
-                        *ip = ntohl (sin->sin_addr.s_addr);
-                if (port != NULL)
-                        *port = ntohs (sin->sin_port);
-                if (sa) 
-                        FREE(sa, M_SONAME);
-        }
-        return 0;
-}
-
-int
-libcfs_sock_getbuf (struct socket *sock, int *txbufsize, int *rxbufsize)
-{
-        struct sockopt  sopt;
-        int rc;
-        CFS_DECL_NET_DATA;
-
-        bzero(&sopt, sizeof sopt);
-        sopt.sopt_dir = SOPT_GET;
-        sopt.sopt_level = SOL_SOCKET;
-
-        if (txbufsize != NULL) {
-                sopt.sopt_val = txbufsize;
-                sopt.sopt_valsize = sizeof(*txbufsize);
-                sopt.sopt_name = SO_SNDBUF;
-                CFS_NET_IN;
-                rc = sogetopt(sock, &sopt);
-                CFS_NET_EX;
-                if (rc != 0) {
-                        CERROR ("Can't get send buffer size: %d\n", rc);
-                        return -rc;
-                }
-        }
-
-        if (rxbufsize != NULL) {
-                sopt.sopt_val = rxbufsize;
-                sopt.sopt_valsize = sizeof(*rxbufsize);
-                sopt.sopt_name = SO_RCVBUF;
-                CFS_NET_IN;
-                rc = sogetopt(sock, &sopt);
-                CFS_NET_EX;
-                if (rc != 0) {
-                        CERROR ("Can't get receive buffer size: %d\n", rc);
-                        return -rc;
-                }
-        }
-        return 0;
-}
-
-int
-libcfs_sock_connect (struct socket **sockp, int *fatal,
-                     __u32 local_ip, int local_port,
-                     __u32 peer_ip, int peer_port)
-{
-        struct sockaddr_in  srvaddr;
-        struct socket      *so;
-        int                 s;
-        int                 rc; 
-        CFS_DECL_FUNNEL_DATA;
-        
-        rc = libcfs_sock_create(sockp, fatal, local_ip, local_port);
-        if (rc != 0)
-                return rc;
-        so = *sockp;
-        bzero(&srvaddr, sizeof(srvaddr));
-        srvaddr.sin_len = sizeof(struct sockaddr_in);
-        srvaddr.sin_family = AF_INET;
-        srvaddr.sin_port = htons (peer_port);
-        srvaddr.sin_addr.s_addr = htonl (peer_ip);
-
-        CFS_NET_IN;
-        rc = soconnect(so, (struct sockaddr *)&srvaddr);
-        if (rc != 0) {
-                CFS_NET_EX;
-                if (rc != EADDRNOTAVAIL && rc != EADDRINUSE)
-                        CNETERR("Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc,
-                               HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port);
-                goto out;
-        }
-        s = splnet();
-        while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
-                CDEBUG(D_NET, "ksocknal sleep for waiting auto_connect.\n");
-                (void) tsleep((caddr_t)&so->so_timeo, PSOCK, "ksocknal_conn", hz);
-        }
-        if ((rc = so->so_error) != 0) {
-                so->so_error = 0;
-                splx(s);
-                CFS_NET_EX;
-                CNETERR("Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc,
-                       HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port);
-                goto out;
-        }
-        LASSERT(so->so_state & SS_ISCONNECTED);
-        splx(s);
-        CFS_NET_EX;
-        if (sockp)
-                *sockp = so;
-        return (0);
-out:
-        CFS_NET_IN;
-        soshutdown(so, 2);
-        soclose(so);
-        CFS_NET_EX;
-        return (-rc);
-}
-
-void
-libcfs_sock_release (struct socket *sock)
-{
-        CFS_DECL_FUNNEL_DATA;
-        CFS_NET_IN;
-        soshutdown(sock, 0);
-        CFS_NET_EX;
-}
-
-#endif
diff --git a/libcfs/libcfs/darwin/darwin-tracefile.c b/libcfs/libcfs/darwin/darwin-tracefile.c
deleted file mode 100644 (file)
index 7ef1cad..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#define DEBUG_SUBSYSTEM S_LNET
-#define LUSTRE_TRACEFILE_PRIVATE
-#include <libcfs/libcfs.h>
-#include "tracefile.h"
-
-/*
- * We can't support smp tracefile currently.
- * Everything is put on one cpu.
- */
-
-#define M_TCD_MAX_PAGES (128 * 1280)
-
-static long max_permit_mb = (64 * 1024);
-
-spinlock_t trace_cpu_serializer;
-
-/*
- * thread currently executing tracefile code or NULL if none does. Used to
- * detect recursive calls to libcfs_debug_msg().
- */
-static thread_t trace_owner = NULL;
-
-extern int get_preemption_level(void);
-extern atomic_t tage_allocated;
-
-struct rw_semaphore tracefile_sem;
-
-int tracefile_init_arch() {
-    init_rwsem(&tracefile_sem);
-#error "Todo: initialise per-cpu console buffers"
-    return 0;
-}
-
-void tracefile_fini_arch() {
-    fini_rwsem(&tracefile_sem);
-}
-
-void tracefile_read_lock() {
-    down_read(&tracefile_sem);
-}
-
-void tracefile_read_unlock() {
-    up_read(&tracefile_sem);
-}
-
-void tracefile_write_lock() {
-    down_write(&tracefile_sem);
-}
-
-void tracefile_write_unlock() {
-    up_write(&tracefile_sem);
-}
-
-char *trace_get_console_buffer(void)
-{
-#error "todo: return a per-cpu/interrupt console buffer and disable pre-emption"
-}
-
-void trace_put_console_buffer(char *buffer)
-{
-#error "todo: re-enable pre-emption"
-}
-
-struct trace_cpu_data *trace_get_tcd(void)
-{
-       struct trace_cpu_data *tcd;
-       int nr_pages;
-       struct list_head pages;
-
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-
-       /*
-        * debugging check for recursive call to libcfs_debug_msg()
-        */
-       if (trace_owner == current_thread()) {
-               /*
-                * Cannot assert here.
-                */
-               printk(KERN_EMERG "recursive call to %s", __FUNCTION__);
-               /*
-                * "The death of God left the angels in a strange position."
-                */
-               cfs_enter_debugger();
-       }
-       tcd = &trace_data[0].tcd;
-       INIT_LIST_HEAD(&pages);
-       if (get_preemption_level() == 0)
-               nr_pages = trace_refill_stock(tcd, GFP_IOFS, &pages);
-       else
-               nr_pages = 0;
-       spin_lock(&trace_cpu_serializer);
-       trace_owner = current_thread();
-       tcd->tcd_cur_stock_pages += nr_pages;
-       list_splice(&pages, &tcd->tcd_stock_pages);
-       return tcd;
-}
-
-extern void raw_page_death_row_clean(void);
-
-void __trace_put_tcd(struct trace_cpu_data *tcd)
-{
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-       LASSERT(trace_owner == current_thread());
-       trace_owner = NULL;
-       spin_unlock(&trace_cpu_serializer);
-       if (get_preemption_level() == 0)
-               /* purge all pending pages */
-               raw_page_death_row_clean();
-}
-
-int tcd_owns_tage(struct trace_cpu_data *tcd, struct trace_page *tage)
-{
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-       /* XNU has global tcd, and all pages are owned by it */
-       return 1;
-}
-
-void
-set_ptldebug_header(struct ptldebug_header *header, int subsys, int mask,
-                    const int line, unsigned long stack)
-{
-       struct timeval tv;
-       
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-       do_gettimeofday(&tv);
-       header->ph_subsys = subsys;
-       header->ph_mask = mask;
-       header->ph_cpu_id = smp_processor_id();
-       header->ph_type = 0;
-       header->ph_sec = (__u32)tv.tv_sec;
-       header->ph_usec = tv.tv_usec;
-       header->ph_stack = stack;
-       header->ph_pid = current_pid();
-       header->ph_line_num = line;
-       header->ph_extern_pid = (__u32)current_thread();
-}
-
-void print_to_console(struct ptldebug_header *hdr, int mask, const char *buf,
-                     int len, const char *file, const char *fn)
-{
-       char *prefix = "Lustre", *ptype = KERN_INFO;
-
-       /*
-        * XXX nikita: do NOT call libcfs_debug_msg() (CDEBUG/ENTRY/EXIT)
-        * from here: this will lead to infinite recursion.
-        */
-       if ((mask & D_EMERG) != 0) {
-               prefix = "LustreError";
-               ptype = KERN_EMERG;
-       } else if ((mask & D_ERROR) != 0) {
-               prefix = "LustreError";
-               ptype = KERN_ERR;
-       } else if ((mask & D_WARNING) != 0) {
-               prefix = "Lustre";
-               ptype = KERN_WARNING;
-       } else if ((mask & libcfs_printk) != 0 || (mask & D_CONSOLE)) {
-               prefix = "Lustre";
-               ptype = KERN_INFO;
-       }
-
-       if ((mask & D_CONSOLE) != 0) {
-               printk("%s%s: %.*s", ptype, prefix, len, buf);
-       } else {
-               printk("%s%s: %d:%d:(%s:%d:%s()) %*s",
-                      ptype, prefix, hdr->ph_pid, hdr->ph_extern_pid,
-                      file, hdr->ph_line_num, fn, len, buf);
-       }
-}
-
-int trace_max_debug_mb(void)
-{
-       return max_permit_mb;
-}
diff --git a/libcfs/libcfs/darwin/darwin-utils.c b/libcfs/libcfs/darwin/darwin-utils.c
deleted file mode 100644 (file)
index 909b586..0000000
+++ /dev/null
@@ -1,595 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/darwin/darwin-utils.c
- *
- * Darwin porting library
- * Make things easy to port
- *
- * Author: Phil Schwan <phil@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <mach/mach_types.h>
-#include <string.h>
-#include <sys/errno.h>
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <lnet/types.h>
-
-#include <libcfs/libcfs.h>
-
-#ifndef isspace
-inline int
-isspace(char c)
-{
-        return (c == ' ' || c == '\t' || c == '\n' || c == '\12');
-}
-#endif
-
-char * strpbrk(const char * cs,const char * ct)
-{
-       const char *sc1,*sc2;
-       
-       for( sc1 = cs; *sc1 != '\0'; ++sc1) {
-               for( sc2 = ct; *sc2 != '\0'; ++sc2) {
-                       if (*sc1 == *sc2)
-                               return (char *) sc1;
-               }
-       }
-       return NULL;
-}
-
-char * strsep(char **s, const char *ct)
-{
-       char *sbegin = *s, *end;
-       
-       if (sbegin == NULL)
-               return NULL;
-       end = strpbrk(sbegin, ct);
-       if (end != NULL)
-               *end++ = '\0';
-       *s = end;
-
-       return sbegin;
-}
-
-size_t strnlen(const char * s, size_t count)
-{
-       const char *sc;
-
-       for (sc = s; count-- && *sc != '\0'; ++sc)
-               /* nothing */;
-       return sc - s;
-}
-
-char *
-strstr(const char *in, const char *str)
-{
-       char c;
-       size_t len;
-       
-       c = *str++;
-       if (!c)
-               return (char *) in;     // Trivial empty string case
-       len = strlen(str);
-       do {
-               char sc;
-               do {
-                       sc = *in++;
-                       if (!sc)
-                               return (char *) 0;
-               } while (sc != c);
-       } while (strncmp(in, str, len) != 0);
-       return (char *) (in - 1);
-}
-
-char *
-strrchr(const char *p, int ch)
-{
-        const char *end = p + strlen(p);
-        do {
-                if (*end == (char)ch)
-                        return (char *)end;
-        } while (--end >= p);
-        return NULL;
-}
-
-char *
-ul2dstr(unsigned long address, char *buf, int len)
-{
-        char *pos = buf + len - 1;
-
-        if (len <= 0 || !buf)
-                return NULL;
-        *pos = 0;
-        while (address) {
-                if (!--len) break;
-                *--pos = address % 10 + '0';
-                address /= 10;
-        }
-        return pos;
-}
-
-/*
- * miscellaneous libcfs stuff
- */
-
-/*
- * Convert server error code to client format.
- * Linux errno.h.
- */