diff -ru lsof-33/lsof/Configure lsof-33+iPhone/lsof/Configure
--- lsof-33/lsof/Configure	2007-05-26 01:18:17.000000000 +0000
+++ lsof-33+iPhone/lsof/Configure	2008-04-18 09:22:40.000000000 +0000
@@ -892,12 +892,7 @@
 
     if test "X$DARWIN_BASE" = "X"	# {
     then
-      if test -r ${LSOF_INCLUDE}/../local/include/libproc.h -a $LSOF_VERS -ge 800 	# {
-      then
 	DARWIN_BASE="libproc"
-      else
-	DARWIN_BASE="/dev/kmem"
-      fi	# }
     fi	# }
     if test "X$DARWIN_BASE" = "Xlibproc"	# {
     then
@@ -934,62 +929,6 @@
 
     # Make sure Darwin XNU kernel headers are present.
 
-    LSOF_TMP5=""
-    for i in $LSOF_TMP1	# {
-    do
-      LSOF_TMP6=0
-      for j in $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4 $LSOF_INCLUDE	# {
-      do
-	if test "X${j}" != "X" -a -r ${j}/${i}  # {
-	then
-	  LSOF_TMP6=1
-	  break
-	fi	# }
-      done	# }
-      if test $LSOF_TMP6 -ne 1	# {
-      then
-	if test "X$LSOF_TMP5" = "X"	# {
-	then
-	  LSOF_TMP5=$i
-	else
-	  LSOF_TMP5="$LSOF_TMP5 $i"
-	fi	# }
-      fi			# }
-    done	# }
-    if test "X$LSOF_TMP5" != "X"	# {
-    then
-
-    # If any Darwin XNU kernel header files are missing, call the
-    # get-hdr-loc.sh script to find the path.
-
-      LSOF_TMP6=`pwd`/dialects/darwin/get-hdr-loc.sh
-      if test ! -x $LSOF_TMP6	# {
-      then
-	echo "FATAL: can't execute: $LSOF_TMP6"
-	rm -f $LSOF_HLP
-	exit 1
-      fi	# }
-      DARWIN_XNUDIR=`$LSOF_TMP6 $LSOF_TMP5`
-      if test $? -ne 0	# {
-      then
-	echo "FATAL: $LSOF_TMP6 returns: $DARWIN_XNUDIR"
-	rm -f $LSOF_HLP
-	exit 1
-      fi	# }
-      LSOF_TMP2="${DARWIN_XNUDIR}/bsd"
-      LSOF_TMP3="${DARWIN_XNUDIR}/osfmk"
-      LSOF_TMP4=""
-    fi	# }
-
-    # Add header file paths.
-
-    for i in $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4 $LSOF_INCLUDE	# {
-    do
-      if test -d $i -a "X$i" != "X/usr/include"	# {
-      then
-	LSOF_DINC="$LSOF_DINC -I${i}"
-      fi	# }
-    done	# }
     if test "X$DARWIN_BASE" = "X/dev/kmem"	# {
     then
 
diff -ru lsof-33/lsof/dialects/darwin/kmem/dfile.c lsof-33+iPhone/lsof/dialects/darwin/kmem/dfile.c
--- lsof-33/lsof/dialects/darwin/kmem/dfile.c	2007-05-24 22:35:11.000000000 +0000
+++ lsof-33+iPhone/lsof/dialects/darwin/kmem/dfile.c	2008-04-18 08:46:17.000000000 +0000
@@ -44,6 +44,7 @@
  */
 
 #if	DARWINV>=800
+#include <sys/file_internal.h>
 #define	file		fileglob
 #define	f_flag		fg_flag
 #define	f_type		fg_type
diff -ru lsof-33/lsof/dialects/darwin/kmem/dlsof.h lsof-33+iPhone/lsof/dialects/darwin/kmem/dlsof.h
--- lsof-33/lsof/dialects/darwin/kmem/dlsof.h	2007-05-24 22:35:11.000000000 +0000
+++ lsof-33+iPhone/lsof/dialects/darwin/kmem/dlsof.h	2008-04-18 09:04:15.000000000 +0000
@@ -38,6 +38,11 @@
 #if	!defined(DARWIN_LSOF_H)
 #define	DARWIN_LSOF_H	1
 
+#define KERNEL
+#define	KERNEL_PRIVATE
+#include <sys/select.h>
+#undef KERNEL_PRIVATE
+#undef KERNEL
 #include <stdlib.h>
 #include <dirent.h>
 #include <nlist.h>
@@ -52,7 +57,13 @@
 #include <sys/mount.h>
 #define	m_stat	mnt_stat
 #else	/* DARWINV>=800 */
+#include <machine/locks.h>
+#define KERNEL
+#include <sys/mount.h>
+#undef KERNEL
+#define PRIVATE
 #include <sys/mount_internal.h>
+#undef PRIVATE
 #define	m_stat	mnt_vfsstat
 #endif	/* DARWINV>=800 */
 
@@ -60,7 +71,9 @@
 #include <sys/uio.h>
 #include <sys/vnode.h>
 #else	/* DARWINV>=800 */
+#define KERNEL
 #include <sys/vnode.h>
+#undef KERNEL
 #define	_SYS_SYSTM_H_
 struct nameidata { int dummy; };	/* to satisfy function  prototypes */
 #include <sys/vnode_internal.h>
@@ -70,20 +83,32 @@
 #define	KERNEL_PRIVATE
 #include <sys/socketvar.h>
 #undef	KERNEL_PRIVATE
+#define PRIVATE
 #include <sys/protosw.h>
+#undef PRIVATE
 #include <sys/socket.h>
 #include <sys/un.h>
+#define KERNEL
+#define PRIVATE
 #include <sys/unpcb.h>
+#undef PRIVATE
+#undef KERNEL
 
 # if	defined(AF_NDRV)
+#define PRIVATE
 #include <net/if_var.h>
+#undef PRIVATE
 #define	KERNEL
+#define PRIVATE
 #include <sys/kern_event.h>
+#undef PRIVATE
 #undef	KERNEL
 #include <net/ndrv.h>
 #  if	DARWINV>=530
 #define	KERNEL        1
+#define PRIVATE
 #include <net/ndrv_var.h>
+#undef PRIVATE
 #undef  KERNEL
 #  endif	/* DARWINV>=530 */
 # endif	/* defined(AF_NDRV) */
@@ -91,16 +116,24 @@
 # if	defined(AF_SYSTEM)
 #include <sys/queue.h>
 #define	KERNEL
+#define PRIVATE
 #include <sys/kern_event.h>
+#undef PRIVATE
 #undef	KERNEL
 # endif	/* defined(AF_SYSTEM) */
 
+#define PRIVATE
 #include <netinet/in.h>
+#undef PRIVATE
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
+#define PRIVATE
 #include <net/route.h>
+#undef PRIVATE
 #include <netinet6/ipsec.h>
+#define KERNEL_PRIVATE
 #include <netinet/in_pcb.h>
+#undef KERNEL_PRIVATE
 #include <netinet/ip_var.h>
 #include <netinet/tcp.h>
 #include <netinet/tcpip.h>
@@ -109,7 +142,9 @@
 #include <netinet/tcp_var.h>
 #include <arpa/inet.h>
 #include <net/raw_cb.h>
+#define PRIVATE
 #include <sys/domain.h>
+#undef PRIVATE
 #define	pmap	RPC_pmap
 #include <rpc/rpc.h>
 #include <rpc/pmap_prot.h>
@@ -168,7 +203,7 @@
 # if	DARWINV<800
 #include <sys/sysctl.h>
 # else	/* DARWINV>=800 */
-#include "/usr/include/sys/sysctl.h"
+#include "sys/sysctl.h"
 # endif	/* DARWINV<800 */
 
 # if	DARWINV<800
@@ -177,8 +212,10 @@
 #include <sys/file.h>
 #undef	KERNEL
 # else	/* DARWINV>=800 */
+#define KERNEL
 #include <sys/fcntl.h>
 #include <sys/file_internal.h>
+#undef KERNEL
 # endif	/* DARWINV<800 */
 
 # if	defined(HASKQUEUE)
diff -ru lsof-33/lsof/dialects/darwin/kmem/machine.h lsof-33+iPhone/lsof/dialects/darwin/kmem/machine.h
--- lsof-33/lsof/dialects/darwin/kmem/machine.h	2007-05-24 22:35:11.000000000 +0000
+++ lsof-33+iPhone/lsof/dialects/darwin/kmem/machine.h	2008-04-18 07:27:27.000000000 +0000
@@ -43,7 +43,7 @@
 #include <sys/param.h>
 
 # if	DARWINV>=800
-#include "/usr/include/string.h"
+#include "string.h"
 # endif	/* DARWINV>=800 */
 
 
diff -ru lsof-33/lsof/dialects/darwin/libproc/machine.h lsof-33+iPhone/lsof/dialects/darwin/libproc/machine.h
--- lsof-33/lsof/dialects/darwin/libproc/machine.h	2006-03-23 21:28:26.000000000 +0000
+++ lsof-33+iPhone/lsof/dialects/darwin/libproc/machine.h	2008-04-18 09:23:12.000000000 +0000
@@ -46,7 +46,7 @@
 #include <sys/types.h>
 #include <sys/param.h>
 
-#include "/usr/include/string.h"
+#include "string.h"
 
 
 /*
diff -ru lsof-33/lsof/lsof.h lsof-33+iPhone/lsof/lsof.h
--- lsof-33/lsof/lsof.h	2007-05-24 22:35:11.000000000 +0000
+++ lsof-33+iPhone/lsof/lsof.h	2008-04-18 09:05:04.000000000 +0000
@@ -46,6 +46,11 @@
 
 #include "lsof_fields.h"
 
+#define KERNEL
+#include <mach/port.h>
+#undef KERNEL
+#define _MACH_PORT_T
+
 #include <ctype.h>
 #include <errno.h>
 
@@ -53,7 +58,9 @@
 #include <locale.h>
 # endif	/* defined(HASSETLOCALE) */
 
+#define PRIVATE
 #include <netdb.h>
+#undef PRIVATE
 #include <pwd.h>
 #include <stdio.h>