Index: BOOK/cross-tools/arm/uclibc.xml
===================================================================
--- BOOK/cross-tools/arm/uclibc.xml	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/cross-tools/arm/uclibc.xml	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -28,6 +28,5 @@
     architecture:</para>
 
-<screen os="b"><userinput>
-cp extra/Configs/Config.arm extra/Configs/Config.arm.orig
+<screen os="b"><userinput>cp extra/Configs/Config.arm extra/Configs/Config.arm.orig
 sed -e "/default/s:OABI:EABI:" \
    extra/Configs/Config.arm.orig > extra/Configs/Config.arm</userinput></screen>
@@ -36,4 +35,12 @@
   href="../x86/uclibc.xml"
   xpointer="xpointer(//*[@os='e'])"/>
+
+  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+  href="../x86/uclibc.xml"
+  xpointer="xpointer(//*[@os='p1'])"/>
+
+  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+  href="../x86/uclibc.xml"
+  xpointer="xpointer(//*[@os='p2'])"/>
 
   <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
Index: BOOK/cross-tools/mips/uclibc.xml
===================================================================
--- BOOK/cross-tools/mips/uclibc.xml	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/cross-tools/mips/uclibc.xml	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -36,4 +36,12 @@
   href="../x86/uclibc.xml"
   xpointer="xpointer(//*[@os='e'])"/>
+
+  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+  href="../x86/uclibc.xml"
+  xpointer="xpointer(//*[@os='p1'])"/>
+
+  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
+  href="../x86/uclibc.xml"
+  xpointer="xpointer(//*[@os='p2'])"/>
 
   <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
Index: BOOK/cross-tools/x86/uclibc.xml
===================================================================
--- BOOK/cross-tools/x86/uclibc.xml	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/cross-tools/x86/uclibc.xml	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -34,4 +34,9 @@
       do a more custom build for your uClibc installation.</para>
     </note>
+
+    <para os="p1">The following patch creates a condition in a header so that
+    the struct flock will not be redefined:</para>
+
+<screen os="p2"><userinput>patch -Np1 -i ../&uclibc-flock_fixes-patch;</userinput></screen>
 
     <para os="f">Create the default configuration:</para>
Index: BOOK/final-system/arm/busybox.xml
===================================================================
--- BOOK/final-system/arm/busybox.xml	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/final-system/arm/busybox.xml	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -37,8 +37,4 @@
     href="../x86/busybox.xml"
     xpointer="xpointer(//*[@os='p4'])"/>
-
-    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-    href="../x86/busybox.xml"
-    xpointer="xpointer(//*[@os='p5'])"/>
 
     <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
Index: BOOK/final-system/mips/busybox.xml
===================================================================
--- BOOK/final-system/mips/busybox.xml	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/final-system/mips/busybox.xml	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -37,8 +37,4 @@
     href="../x86/busybox.xml"
     xpointer="xpointer(//*[@os='p4'])"/>
-
-    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
-    href="../x86/busybox.xml"
-    xpointer="xpointer(//*[@os='p5'])"/>
 
     <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
Index: BOOK/final-system/x86/busybox.xml
===================================================================
--- BOOK/final-system/x86/busybox.xml	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/final-system/x86/busybox.xml	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -30,17 +30,14 @@
     <title>Installation of Busybox</title>
 
-    <para os="p1">Before you build BusyBox, you may want to check the following URL for
-    patches that the upstream maintainer of BusyBox has released to fix issues.
-    <ulink url="http://busybox.net/downloads/fixes-&busybox-version;"/></para>
-
-    <para os="p2">Here's an example of how to apply the patches from Busybox's website
-    replace {patch_name} with the name of the patch:</para>
-
-<screen os="p3" role="nodump"><userinput>patch -Np1 -i ../busybox-&busybox-version;{patch_name}</userinput></screen>
-
-    <para os="p4">The following patch fixes some issues that are related to the
+    <para os="p1">The following patch fixes some issues that are related to the
     headers we are using:</para>
 
-<screen os="p5"><userinput>patch -Np1 -i ../&busybox-fixes-patch;</userinput></screen>
+<screen os="p2"><userinput>patch -Np1 -i ../&busybox-fixes-patch;</userinput></screen>
+
+    <para os="p3">The following patch corrects some includes in
+    <filename>iptunnel.c</filename> to be compatible with the sanatized
+    kernel headers installed earlier:</para>
+
+<screen os="p4"><userinput>patch -Np1 -i ../&busybox-iptunnel_headers-patch;</userinput></screen>
 
     <para os="a">Create the default configuration:</para>
Index: BOOK/introduction/common/changelog.xml
===================================================================
--- BOOK/introduction/common/changelog.xml	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/introduction/common/changelog.xml	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -41,4 +41,7 @@
       <itemizedlist>
         <listitem>
+          <para>[jciccone] - Updated Busybox to 1.12.1.</para>
+        </listitem>
+        <listitem>
           <para>[jciccone] - Updated uClibc to 0.9.30-rc3.</para>
         </listitem>
Index: BOOK/materials/common/patches.xml
===================================================================
--- BOOK/materials/common/patches.xml	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/materials/common/patches.xml	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -38,4 +38,13 @@
 
     <varlistentry>
+      <term>Busybox Iptunnel Headers Patch - <token>&busybox-iptunnel_headers-patch-size;</token>:</term>
+      <listitem>
+        <para>Download: <ulink
+        url="&patches-root;&busybox-iptunnel_headers-patch;"/></para>
+        <para>MD5 sum: <literal>&busybox-iptunnel_headers-patch-md5;</literal></para>
+      </listitem>
+    </varlistentry>
+
+    <varlistentry>
       <term>GCC Posix Patch - <token>&gcc-posix-patch-size;</token>:</term>
       <listitem>
@@ -43,4 +52,13 @@
         url="&patches-root;&gcc-posix-patch;"/></para>
         <para>MD5 sum: <literal>&gcc-posix-patch-md5;</literal></para>
+      </listitem>
+    </varlistentry>
+
+    <varlistentry>
+      <term>uClibc Flock Fixes Patch - <token>&uclibc-flock_fixes-patch-size;</token>:</term>
+      <listitem>
+        <para>Downloads: <ulink
+        url="&patches-root;&uclibc-flock_fixes-patch;"/></para>
+        <para>MD5 sum: <literal>&uclibc-flock_fixes-patch-md5;</literal></para>
       </listitem>
     </varlistentry>
Index: BOOK/packages.ent
===================================================================
--- BOOK/packages.ent	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/packages.ent	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -11,8 +11,8 @@
 <!ENTITY binutils-home "http://sources.redhat.com/binutils/">
 
-<!ENTITY busybox-version "1.8.2">
-<!ENTITY busybox-size "1,732 KB">
+<!ENTITY busybox-version "1.12.1">
+<!ENTITY busybox-size "1,980 KB">
 <!ENTITY busybox-url "http://busybox.net/downloads/busybox-&busybox-version;.tar.bz2">
-<!ENTITY busybox-md5 "5794c6187c7cc8176c52b96af9bf2478">
+<!ENTITY busybox-md5 "dc2e5e00d6fee8229ae92884c68733a7">
 <!ENTITY busybox-home "http://www.busybox.net">
 
Index: BOOK/patches.ent
===================================================================
--- BOOK/patches.ent	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ BOOK/patches.ent	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -10,10 +10,18 @@
 
 <!ENTITY busybox-fixes-patch "busybox-&busybox-version;-fixes-1.patch">
-<!ENTITY busybox-fixes-patch-md5 "8c63ff58287e5de40a40e81145a8a1ad">
-<!ENTITY busybox-fixes-patch-size "20 KB">
+<!ENTITY busybox-fixes-patch-md5 "984f771a81475c234b1fc3f92c672b4d">
+<!ENTITY busybox-fixes-patch-size "16 KB">
+
+<!ENTITY busybox-iptunnel_headers-patch "busybox-&busybox-version;-iptunnel_headers-1.patch">
+<!ENTITY busybox-iptunnel_headers-patch-md5 "f0771cde6810a68c5459683b8c5e69b31">
+<!ENTITY busybox-iptunnel_headers-patch-size "4 KB">
 
 <!ENTITY gcc-posix-patch "gcc-&gcc-version;-posix-1.patch">
 <!ENTITY gcc-posix-patch-md5 "ed26ea522e014b2e39adf066bd44053b">
 <!ENTITY gcc-posix-patch-size "12 KB">
+
+<!ENTITY uclibc-flock_fixes-patch "uClibc-&uclibc-version;-flock_fixes-1.patch">
+<!ENTITY uclibc-flock_fixes-patch-md5 "aaff25f9503fe380f82be79f82aa04e9">
+<!ENTITY uclibc-flock_fixes-patch-size "24 KB">
 
 <!ENTITY zlib-destdir-patch "zlib-&zlib-version;-DESTDIR-1.patch">
Index: patches/busybox-1.12.1-fixes-1.patch
===================================================================
--- patches/busybox-1.12.1-fixes-1.patch	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
+++ patches/busybox-1.12.1-fixes-1.patch	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -0,0 +1,357 @@
+Submitted By: Joe Ciccone <jciccone@gmail.com>
+Date: 2008-11-08
+Origin: Busybox FTP
+Initial Package Version: 1.12.1
+Upstream Status: From Upstream
+Descriprion: Apply fixes from upstream
+                 busybox-1.12.1-basename.patch
+                 busybox-1.12.1-grep.patch
+                 busybox-1.12.1-lineedit.patch
+                 busybox-1.12.1-login.patch
+                 busybox-1.12.1-modprobe.patch
+                 busybox-1.12.1-standalone.patch
+                 busybox-1.12.1-vi.patch
+
+diff -Naur busybox-1.12.1.orig/coreutils/basename.c busybox-1.12.1/coreutils/basename.c
+--- busybox-1.12.1.orig/coreutils/basename.c	2008-09-28 14:04:18.000000000 -0400
++++ busybox-1.12.1/coreutils/basename.c	2008-11-08 09:49:16.000000000 -0500
+@@ -48,5 +48,5 @@
+ 
+ 	/* puts(s) will do, but we can do without stdio this way: */
+ 	s[m++] = '\n';
+-	return full_write(STDOUT_FILENO, s, m) == (ssize_t)m;
++	return full_write(STDOUT_FILENO, s, m) != (ssize_t)m;
+ }
+diff -Naur busybox-1.12.1.orig/coreutils/env.c busybox-1.12.1/coreutils/env.c
+--- busybox-1.12.1.orig/coreutils/env.c	2008-09-28 14:04:18.000000000 -0400
++++ busybox-1.12.1/coreutils/env.c	2008-11-08 09:49:16.000000000 -0500
+@@ -29,6 +29,8 @@
+  * - use xfunc_error_retval
+  */
+ 
++/* This is a NOEXEC applet. Be very careful! */
++
+ #include "libbb.h"
+ 
+ #if ENABLE_FEATURE_ENV_LONG_OPTIONS
+@@ -119,5 +121,3 @@
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  */
+-
+-
+diff -Naur busybox-1.12.1.orig/editors/vi.c busybox-1.12.1/editors/vi.c
+--- busybox-1.12.1.orig/editors/vi.c	2008-09-28 14:04:29.000000000 -0400
++++ busybox-1.12.1/editors/vi.c	2008-11-08 09:49:16.000000000 -0500
+@@ -291,6 +291,8 @@
+ #define INIT_G() do { \
+ 	SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+ 	last_file_modified = -1; \
++	/* "" but has space for 2 chars */ \
++	USE_FEATURE_VI_SEARCH(last_search_pattern = xzalloc(2);) \
+ } while (0)
+ 
+ 
+@@ -2974,7 +2976,7 @@
+ 	const char *msg = msg; // for compiler
+ 	char c1, *p, *q, *save_dot;
+ 	char buf[12];
+-	int dir = dir; // for compiler
++	int dir;
+ 	int cnt, i, j;
+ 
+ //	c1 = c; // quiet the compiler
+@@ -3316,7 +3318,7 @@
+ 		q = get_input_line(buf);	// get input line- use "status line"
+ 		if (q[0] && !q[1]) {
+ 			if (last_search_pattern[0])
+-			    last_search_pattern[0] = c;
++				last_search_pattern[0] = c;
+ 			goto dc3; // if no pat re-use old pat
+ 		}
+ 		if (q[0]) {       // strlen(q) > 1: new pat- save it and find
+@@ -3346,14 +3348,8 @@
+ 			do_cmd(c);
+ 		}				// repeat cnt
+  dc3:
+-		if (last_search_pattern == 0) {
+-			msg = "No previous regular expression";
+-			goto dc2;
+-		}
+-		if (last_search_pattern[0] == '/') {
+-			dir = FORWARD;	// assume FORWARD search
+-			p = dot + 1;
+-		}
++		dir = FORWARD;	// assume FORWARD search
++		p = dot + 1;
+ 		if (last_search_pattern[0] == '?') {
+ 			dir = BACK;
+ 			p = dot - 1;
+diff -Naur busybox-1.12.1.orig/findutils/grep.c busybox-1.12.1/findutils/grep.c
+--- busybox-1.12.1.orig/findutils/grep.c	2008-09-28 14:04:28.000000000 -0400
++++ busybox-1.12.1/findutils/grep.c	2008-11-08 09:49:16.000000000 -0500
+@@ -363,12 +363,22 @@
+ 						 * (unless -v: -Fov doesnt print anything at all) */
+ 						if (found)
+ 							print_line(gl->pattern, strlen(gl->pattern), linenum, ':');
+-					} else {
++					} else while (1) {
++						char old = line[gl->matched_range.rm_eo];
+ 						line[gl->matched_range.rm_eo] = '\0';
+ 						print_line(line + gl->matched_range.rm_so,
+ 								gl->matched_range.rm_eo - gl->matched_range.rm_so,
+ 								linenum, ':');
+-					}
++						line[gl->matched_range.rm_eo] = old;
++#if !ENABLE_EXTRA_COMPAT
++						break;
++#else
++						if (re_search(&gl->compiled_regex, line, line_len,
++								gl->matched_range.rm_eo, line_len - gl->matched_range.rm_eo, 
++								&gl->matched_range) < 0)
++							break;
++#endif
++					} 
+ 				} else {
+ 					print_line(line, line_len, linenum, ':');
+ 				}
+diff -Naur busybox-1.12.1.orig/include/applets.h busybox-1.12.1/include/applets.h
+--- busybox-1.12.1.orig/include/applets.h	2008-09-28 14:04:26.000000000 -0400
++++ busybox-1.12.1/include/applets.h	2008-11-08 09:49:16.000000000 -0500
+@@ -136,7 +136,7 @@
+ USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER))
+ USE_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, egrep))
+ USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+-USE_ENV(APPLET(env, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
++USE_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_NEVER, env))
+ USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir))
+ USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid))
+ USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake))
+@@ -171,7 +171,7 @@
+ USE_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_NEVER))
+ USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER))
+ USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER))
+-USE_HD(APPLET_ODDNAME(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd))
++USE_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd))
+ USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER))
+ USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
+ USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump))
+diff -Naur busybox-1.12.1.orig/libbb/getopt32.c busybox-1.12.1/libbb/getopt32.c
+--- busybox-1.12.1.orig/libbb/getopt32.c	2008-09-28 14:04:20.000000000 -0400
++++ busybox-1.12.1/libbb/getopt32.c	2008-11-08 09:49:16.000000000 -0500
+@@ -515,28 +515,6 @@
+ 		}
+ 	}
+ 
+-	/* In case getopt32 was already called:
+-	 * reset the libc getopt() function, which keeps internal state.
+-	 *
+-	 * BSD-derived getopt() functions require that optind be set to 1 in
+-	 * order to reset getopt() state.  This used to be generally accepted
+-	 * way of resetting getopt().  However, glibc's getopt()
+-	 * has additional getopt() state beyond optind, and requires that
+-	 * optind be set to zero to reset its state.  So the unfortunate state of
+-	 * affairs is that BSD-derived versions of getopt() misbehave if
+-	 * optind is set to 0 in order to reset getopt(), and glibc's getopt()
+-	 * will core dump if optind is set 1 in order to reset getopt().
+-	 *
+-	 * More modern versions of BSD require that optreset be set to 1 in
+-	 * order to reset getopt().   Sigh.  Standards, anyone?
+-	 */
+-#ifdef __GLIBC__
+-	optind = 0;
+-#else /* BSD style */
+-	optind = 1;
+-	/* optreset = 1; */
+-#endif
+-	/* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */
+ 	pargv = NULL;
+ 
+ 	/* Note: just "getopt() <= 0" will not work well for
+diff -Naur busybox-1.12.1.orig/libbb/lineedit.c busybox-1.12.1/libbb/lineedit.c
+--- busybox-1.12.1.orig/libbb/lineedit.c	2008-09-28 14:04:20.000000000 -0400
++++ busybox-1.12.1/libbb/lineedit.c	2008-11-08 09:49:16.000000000 -0500
+@@ -1415,7 +1415,8 @@
+ 	if ((state->flags & SAVE_HISTORY) && state->hist_file)
+ 		load_history(state->hist_file);
+ #endif
+-	state->cur_history = state->cnt_history;
++	if (state->flags & DO_HISTORY)
++		state->cur_history = state->cnt_history;
+ 
+ 	/* prepare before init handlers */
+ 	cmdedit_y = 0;  /* quasireal y, not true if line > xt*yt */
+diff -Naur busybox-1.12.1.orig/libbb/setup_environment.c busybox-1.12.1/libbb/setup_environment.c
+--- busybox-1.12.1.orig/libbb/setup_environment.c	2008-09-28 14:04:20.000000000 -0400
++++ busybox-1.12.1/libbb/setup_environment.c	2008-11-08 09:49:16.000000000 -0500
+@@ -32,16 +32,16 @@
+ 
+ void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw)
+ {
++	/* Change the current working directory to be the home directory
++	 * of the user */
++	if (chdir(pw->pw_dir)) {
++		xchdir("/");
++		bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
++	}
++
+ 	if (clear_env) {
+ 		const char *term;
+ 
+-		/* Change the current working directory to be the home directory
+-		 * of the user */
+-		if (chdir(pw->pw_dir)) {
+-			xchdir("/");
+-			bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
+-		}
+-
+ 		/* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
+ 		   Unset all other environment variables.  */
+ 		term = getenv("TERM");
+diff -Naur busybox-1.12.1.orig/libbb/vfork_daemon_rexec.c busybox-1.12.1/libbb/vfork_daemon_rexec.c
+--- busybox-1.12.1.orig/libbb/vfork_daemon_rexec.c	2008-09-28 14:04:20.000000000 -0400
++++ busybox-1.12.1/libbb/vfork_daemon_rexec.c	2008-11-08 09:49:16.000000000 -0500
+@@ -125,6 +125,7 @@
+ 	int rc, argc;
+ 
+ 	applet_name = APPLET_NAME(applet_no);
++
+ 	xfunc_error_retval = EXIT_FAILURE;
+ 
+ 	/* Special flag for xfunc_die(). If xfunc will "die"
+@@ -132,7 +133,30 @@
+ 	 * die_sleep and longjmp here instead. */
+ 	die_sleep = -1;
+ 
+-	/* option_mask32 = 0; - not needed */
++	/* In case getopt() or getopt32() was already called:
++	 * reset the libc getopt() function, which keeps internal state.
++	 *
++	 * BSD-derived getopt() functions require that optind be set to 1 in
++	 * order to reset getopt() state.  This used to be generally accepted
++	 * way of resetting getopt().  However, glibc's getopt()
++	 * has additional getopt() state beyond optind, and requires that
++	 * optind be set to zero to reset its state.  So the unfortunate state of
++	 * affairs is that BSD-derived versions of getopt() misbehave if
++	 * optind is set to 0 in order to reset getopt(), and glibc's getopt()
++	 * will core dump if optind is set 1 in order to reset getopt().
++	 *
++	 * More modern versions of BSD require that optreset be set to 1 in
++	 * order to reset getopt().  Sigh.  Standards, anyone?
++	 */
++#ifdef __GLIBC__
++	optind = 0;
++#else /* BSD style */
++	optind = 1;
++	/* optreset = 1; */
++#endif
++	/* optarg = NULL; opterr = 1; optopt = 63; - do we need this too? */
++	/* (values above are what they initialized to in glibc and uclibc) */
++	/* option_mask32 = 0; - not needed, no applet depends on it being 0 */
+ 
+ 	argc = 1;
+ 	while (argv[argc])
+@@ -161,8 +185,16 @@
+ 			rc = 0;
+ 	}
+ 
+-	/* Restoring globals */
++	/* Restoring some globals */
+ 	restore_nofork_data(old);
++
++	/* Other globals can be simply reset to defaults */
++#ifdef __GLIBC__
++	optind = 0;
++#else /* BSD style */
++	optind = 1;
++#endif
++
+ 	return rc & 0xff; /* don't confuse people with "exitcodes" >255 */
+ }
+ 
+diff -Naur busybox-1.12.1.orig/modutils/modprobe.c busybox-1.12.1/modutils/modprobe.c
+--- busybox-1.12.1.orig/modutils/modprobe.c	2008-09-28 14:04:15.000000000 -0400
++++ busybox-1.12.1/modutils/modprobe.c	2008-11-08 09:49:16.000000000 -0500
+@@ -263,9 +263,9 @@
+ 	return TRUE;
+ }
+ 
+-static int include_conf_recursive(struct include_conf_t *conf, const char *filename)
++static int include_conf_recursive(struct include_conf_t *conf, const char *filename, int flags)
+ {
+-	return recursive_action(filename, ACTION_RECURSE,
++	return recursive_action(filename, ACTION_RECURSE | flags,
+ 				include_conf_file_act,
+ 				include_conf_dir_act,
+ 				conf, 1);
+@@ -362,7 +362,7 @@
+ 			char *includefile;
+ 
+ 			includefile = skip_whitespace(line_buffer + 8);
+-			include_conf_recursive(conf, includefile);
++			include_conf_recursive(conf, includefile, 0);
+ 		} else if (ENABLE_FEATURE_MODPROBE_BLACKLIST &&
+ 				(is_conf_command(line_buffer, "blacklist"))) {
+ 			char *mod;
+@@ -559,7 +559,7 @@
+ 		if (ENABLE_FEATURE_2_6_MODULES) {
+ 			if (include_conf_file(&conf, "/etc/modprobe.conf"))
+ 				r = TRUE;
+-			if (include_conf_recursive(&conf, "/etc/modprobe.d"))
++			if (include_conf_recursive(&conf, "/etc/modprobe.d", ACTION_QUIET))
+ 				r = TRUE;
+ 		}
+ 		if (ENABLE_FEATURE_2_4_MODULES && !r)
+diff -Naur busybox-1.12.1.orig/shell/ash.c busybox-1.12.1/shell/ash.c
+--- busybox-1.12.1.orig/shell/ash.c	2008-09-28 14:04:18.000000000 -0400
++++ busybox-1.12.1/shell/ash.c	2008-11-08 09:49:16.000000000 -0500
+@@ -6964,8 +6964,11 @@
+ 
+ #if ENABLE_FEATURE_SH_STANDALONE
+ 	if (applet_no >= 0) {
+-		if (APPLET_IS_NOEXEC(applet_no))
++		if (APPLET_IS_NOEXEC(applet_no)) {
++			while (*envp)
++				putenv(*envp++);
+ 			run_applet_no_and_exit(applet_no, argv);
++		}
+ 		/* re-exec ourselves with the new arguments */
+ 		execve(bb_busybox_exec_path, argv, envp);
+ 		/* If they called chroot or otherwise made the binary no longer
+@@ -12014,7 +12017,7 @@
+ 	char *name;
+ 	const char *p;
+ 	char **aptr;
+-	int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT;
++	int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
+ 
+ 	if (nextopt("p") != 'p') {
+ 		aptr = argptr;
+diff -Naur busybox-1.12.1.orig/util-linux/getopt.c busybox-1.12.1/util-linux/getopt.c
+--- busybox-1.12.1.orig/util-linux/getopt.c	2008-09-28 14:04:30.000000000 -0400
++++ busybox-1.12.1/util-linux/getopt.c	2008-11-08 09:49:16.000000000 -0500
+@@ -142,7 +142,8 @@
+  * Other settings are found in global variables.
+  */
+ #if !ENABLE_GETOPT_LONG
+-#define generate_output(argv,argc,optstr,longopts) generate_output(argv,argc,optstr)
++#define generate_output(argv,argc,optstr,longopts) \
++	generate_output(argv,argc,optstr)
+ #endif
+ static int generate_output(char **argv, int argc, const char *optstr, const struct option *longopts)
+ {
+@@ -156,14 +157,6 @@
+ 	if (quiet_errors) /* No error reporting from getopt(3) */
+ 		opterr = 0;
+ 
+-	/* Reset getopt(3) (see libbb/getopt32.c for long rant) */
+-#ifdef __GLIBC__
+-	optind = 0;
+-#else /* BSD style */
+-	optind = 1;
+-	/* optreset = 1; */
+-#endif
+-
+ 	while (1) {
+ 		opt =
+ #if ENABLE_GETOPT_LONG
Index: patches/busybox-1.12.1-iptunnel_headers-1.patch
===================================================================
--- patches/busybox-1.12.1-iptunnel_headers-1.patch	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
+++ patches/busybox-1.12.1-iptunnel_headers-1.patch	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -0,0 +1,22 @@
+Submitted By: Joe Ciccone <jciccone@gmail.com>
+Date: 2008-11-08
+Origin: Joe Ciccone
+Initial Package Version: 1.8.2
+Upstream Status: Unknown
+Descriprion: Make busybox play nice with sanatized kernel headers
+
+diff -Naur busybox-1.12.1.orig/networking/libiproute/iptunnel.c busybox-1.12.1/networking/libiproute/iptunnel.c
+--- busybox-1.12.1.orig/networking/libiproute/iptunnel.c	2008-09-28 14:04:10.000000000 -0400
++++ busybox-1.12.1/networking/libiproute/iptunnel.c	2008-11-08 11:07:07.000000000 -0500
+@@ -14,9 +14,8 @@
+  * Phil Karn <karn@ka9q.ampr.org>	990408:	"pmtudisc" flag
+  */
+ 
+-#include <netinet/ip.h>
+-#include <net/if.h>
+-#include <net/if_arp.h>
++#include <linux/if.h>
++#include <linux/if_arp.h>
+ #include <asm/types.h>
+ #ifndef __constant_htons
+ #define __constant_htons htons
Index: tches/busybox-1.8.2-fixes-1.patch
===================================================================
--- patches/busybox-1.8.2-fixes-1.patch	(revision e2fbc299d7621febf26b9df6d051c4a93297a4a7)
+++ 	(revision )
@@ -1,638 +1,0 @@
-Submitted By: Tashiro Tsuramoto <tsuramoto@gmail.com>
-Date: 2008-01-05
-Initial Package Version: 1.2.2.1
-Origin: Jim Gifford
-        Tashiro Tsuramoto
-        Joe Ciccone
-Upstream Status: Unknown
-Description: Upply fixes from upstream.
-             busybox-1.8.2-arping.patch	
-             busybox-1.8.2-static.patch
-             busybox-1.8.2-vi.patch
-             And make iptunnel.c play nice with the sanatized kernel headers.
-
-diff -Naur busybox-1.8.2.orig/applets/applets.c busybox-1.8.2/applets/applets.c
---- busybox-1.8.2.orig/applets/applets.c	2007-11-09 20:40:53.000000000 -0500
-+++ busybox-1.8.2/applets/applets.c	2008-01-09 19:49:05.000000000 -0500
-@@ -17,7 +17,7 @@
- #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
- #warning Note that glibc is unsuitable for static linking anyway.
- #warning If you still want to do it, remove -Wl,--gc-sections
--#warning from top-level Makefile and remove this warning.
-+#warning from file scripts/trylink and remove this warning.
- #error Aborting compilation.
- #endif
- 
-diff -Naur busybox-1.8.2.orig/editors/vi.c busybox-1.8.2/editors/vi.c
---- busybox-1.8.2.orig/editors/vi.c	2007-11-09 20:40:54.000000000 -0500
-+++ busybox-1.8.2/editors/vi.c	2008-01-09 19:49:05.000000000 -0500
-@@ -184,6 +184,7 @@
- #if ENABLE_FEATURE_VI_COLON
- 	char *initial_cmds[3];  // currently 2 entries, NULL terminated
- #endif
-+	char readbuffer[MAX_LINELEN];
- };
- #define G (*ptr_to_globals)
- #define text           (G.text          )
-@@ -200,6 +201,10 @@
- #define term_orig      (G.term_orig     )
- #define term_vi        (G.term_vi       )
- #define initial_cmds   (G.initial_cmds  )
-+#define readbuffer     (G.readbuffer    )
-+#define INIT_G() do { \
-+	PTR_TO_GLOBALS = xzalloc(sizeof(G)); \
-+} while (0)
- 
- static int init_text_buffer(char *); // init from file or create new
- static void edit_file(char *);	// edit one file
-@@ -321,7 +326,7 @@
- 	my_pid = getpid();
- #endif
- 
--	PTR_TO_GLOBALS = xzalloc(sizeof(G));
-+	INIT_G();
- 
- #if ENABLE_FEATURE_VI_CRASHME
- 	srand((long) my_pid);
-@@ -2142,8 +2147,6 @@
- 	return safe_poll(pfd, 1, hund*10) > 0;
- }
- 
--#define readbuffer bb_common_bufsiz1
--
- static int readed_for_parse;
- 
- //----- IO Routines --------------------------------------------
-diff -Naur busybox-1.8.2.orig/networking/arping.c busybox-1.8.2/networking/arping.c
---- busybox-1.8.2.orig/networking/arping.c	2007-11-09 20:40:47.000000000 -0500
-+++ busybox-1.8.2/networking/arping.c	2008-01-09 19:49:05.000000000 -0500
-@@ -207,7 +207,8 @@
- 		}
- 
- 		if (last) {
--			printf(" %u.%03ums\n", last / 1000, last % 1000);
-+			unsigned diff = MONOTONIC_US() - last;
-+			printf(" %u.%03ums\n", diff / 1000, diff % 1000);
- 		} else {
- 			printf(" UNSOLICITED?\n");
- 		}
-diff -Naur busybox-1.8.2.orig/networking/libiproute/iptunnel.c busybox-1.8.2/networking/libiproute/iptunnel.c
---- busybox-1.8.2.orig/networking/libiproute/iptunnel.c	2007-11-09 20:40:47.000000000 -0500
-+++ busybox-1.8.2/networking/libiproute/iptunnel.c	2008-01-09 19:51:01.000000000 -0500
-@@ -14,9 +14,8 @@
-  * Phil Karn <karn@ka9q.ampr.org>	990408:	"pmtudisc" flag
-  */
- 
--#include <netinet/ip.h>
--#include <net/if.h>
--#include <net/if_arp.h>
-+#include <linux/if.h>
-+#include <linux/if_arp.h>
- #include <asm/types.h>
- #ifndef __constant_htons
- #define __constant_htons htons
-diff -Naur busybox-1.8.2.orig/networking/libiproute/iptunnel.c.orig busybox-1.8.2/networking/libiproute/iptunnel.c.orig
---- busybox-1.8.2.orig/networking/libiproute/iptunnel.c.orig	1969-12-31 19:00:00.000000000 -0500
-+++ busybox-1.8.2/networking/libiproute/iptunnel.c.orig	2007-11-09 20:40:47.000000000 -0500
-@@ -0,0 +1,541 @@
-+/* vi: set sw=4 ts=4: */
-+/*
-+ * iptunnel.c	       "ip tunnel"
-+ *
-+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
-+ *
-+ * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
-+ *
-+ *
-+ * Changes:
-+ *
-+ * Rani Assaf <rani@magic.metawire.com> 980929:	resolve addresses
-+ * Rani Assaf <rani@magic.metawire.com> 980930:	do not allow key for ipip/sit
-+ * Phil Karn <karn@ka9q.ampr.org>	990408:	"pmtudisc" flag
-+ */
-+
-+#include <netinet/ip.h>
-+#include <net/if.h>
-+#include <net/if_arp.h>
-+#include <asm/types.h>
-+#ifndef __constant_htons
-+#define __constant_htons htons
-+#endif
-+#include <linux/if_tunnel.h>
-+
-+#include "ip_common.h"  /* #include "libbb.h" is inside */
-+#include "rt_names.h"
-+#include "utils.h"
-+
-+
-+/* Dies on error */
-+static int do_ioctl_get_ifindex(char *dev)
-+{
-+	struct ifreq ifr;
-+	int fd;
-+
-+	strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
-+	fd = xsocket(AF_INET, SOCK_DGRAM, 0);
-+	xioctl(fd, SIOCGIFINDEX, &ifr);
-+	close(fd);
-+	return ifr.ifr_ifindex;
-+}
-+
-+static int do_ioctl_get_iftype(char *dev)
-+{
-+	struct ifreq ifr;
-+	int fd;
-+	int err;
-+
-+	strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
-+	fd = xsocket(AF_INET, SOCK_DGRAM, 0);
-+	err = ioctl_or_warn(fd, SIOCGIFHWADDR, &ifr);
-+	close(fd);
-+	return err ? -1 : ifr.ifr_addr.sa_family;
-+}
-+
-+static char *do_ioctl_get_ifname(int idx)
-+{
-+	struct ifreq ifr;
-+	int fd;
-+	int err;
-+
-+	ifr.ifr_ifindex = idx;
-+	fd = xsocket(AF_INET, SOCK_DGRAM, 0);
-+	err = ioctl_or_warn(fd, SIOCGIFNAME, &ifr);
-+	close(fd);
-+	return err ? NULL : xstrndup(ifr.ifr_name, sizeof(ifr.ifr_name));
-+}
-+
-+static int do_get_ioctl(const char *basedev, struct ip_tunnel_parm *p)
-+{
-+	struct ifreq ifr;
-+	int fd;
-+	int err;
-+
-+	strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
-+	ifr.ifr_ifru.ifru_data = (void*)p;
-+	fd = xsocket(AF_INET, SOCK_DGRAM, 0);
-+	err = ioctl_or_warn(fd, SIOCGETTUNNEL, &ifr);
-+	close(fd);
-+	return err;
-+}
-+
-+/* Dies on error, otherwise returns 0 */
-+static int do_add_ioctl(int cmd, const char *basedev, struct ip_tunnel_parm *p)
-+{
-+	struct ifreq ifr;
-+	int fd;
-+
-+	if (cmd == SIOCCHGTUNNEL && p->name[0]) {
-+		strncpy(ifr.ifr_name, p->name, sizeof(ifr.ifr_name));
-+	} else {
-+		strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
-+	}
-+	ifr.ifr_ifru.ifru_data = (void*)p;
-+	fd = xsocket(AF_INET, SOCK_DGRAM, 0);
-+#if ENABLE_IOCTL_HEX2STR_ERROR
-+	/* #define magic will turn ioctl# into string */
-+	if (cmd == SIOCCHGTUNNEL)
-+		xioctl(fd, SIOCCHGTUNNEL, &ifr);
-+	else
-+		xioctl(fd, SIOCADDTUNNEL, &ifr);
-+#else
-+	xioctl(fd, cmd, &ifr);
-+#endif
-+	close(fd);
-+	return 0;
-+}
-+
-+/* Dies on error, otherwise returns 0 */
-+static int do_del_ioctl(const char *basedev, struct ip_tunnel_parm *p)
-+{
-+	struct ifreq ifr;
-+	int fd;
-+
-+	if (p->name[0]) {
-+		strncpy(ifr.ifr_name, p->name, sizeof(ifr.ifr_name));
-+	} else {
-+		strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
-+	}
-+	ifr.ifr_ifru.ifru_data = (void*)p;
-+	fd = xsocket(AF_INET, SOCK_DGRAM, 0);
-+	xioctl(fd, SIOCDELTUNNEL, &ifr);
-+	close(fd);
-+	return 0;
-+}
-+
-+/* Dies on error */
-+static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
-+{
-+	static const char keywords[] ALIGN1 =
-+		"mode\0""ipip\0""ip/ip\0""gre\0""gre/ip\0""sit\0""ipv6/ip\0"
-+		"key\0""ikey\0""okey\0""seq\0""iseq\0""oseq\0"
-+		"csum\0""icsum\0""ocsum\0""nopmtudisc\0""pmtudisc\0"
-+		"remote\0""any\0""local\0""dev\0"
-+		"ttl\0""inherit\0""tos\0""dsfield\0"
-+		"name\0";
-+	enum {
-+		ARG_mode, ARG_ipip, ARG_ip_ip, ARG_gre, ARG_gre_ip, ARG_sit, ARG_ip6_ip,
-+		ARG_key, ARG_ikey, ARG_okey, ARG_seq, ARG_iseq, ARG_oseq,
-+		ARG_csum, ARG_icsum, ARG_ocsum, ARG_nopmtudisc, ARG_pmtudisc,
-+		ARG_remote, ARG_any, ARG_local, ARG_dev,
-+		ARG_ttl, ARG_inherit, ARG_tos, ARG_dsfield,
-+		ARG_name
-+	};
-+	int count = 0;
-+	char medium[IFNAMSIZ];
-+	int key;
-+
-+	memset(p, 0, sizeof(*p));
-+	memset(&medium, 0, sizeof(medium));
-+
-+	p->iph.version = 4;
-+	p->iph.ihl = 5;
-+#ifndef IP_DF
-+#define IP_DF 0x4000  /* Flag: "Don't Fragment" */
-+#endif
-+	p->iph.frag_off = htons(IP_DF);
-+
-+	while (argc > 0) {
-+		key = index_in_strings(keywords, *argv);
-+		if (key == ARG_mode) {
-+			NEXT_ARG();
-+			key = index_in_strings(keywords, *argv);
-+			if (key == ARG_ipip ||
-+			    key == ARG_ip_ip) {
-+				if (p->iph.protocol && p->iph.protocol != IPPROTO_IPIP) {
-+					bb_error_msg_and_die("you managed to ask for more than one tunnel mode");
-+				}
-+				p->iph.protocol = IPPROTO_IPIP;
-+			} else if (key == ARG_gre ||
-+				   key == ARG_gre_ip) {
-+				if (p->iph.protocol && p->iph.protocol != IPPROTO_GRE) {
-+					bb_error_msg_and_die("you managed to ask for more than one tunnel mode");
-+				}
-+				p->iph.protocol = IPPROTO_GRE;
-+			} else if (key == ARG_sit ||
-+				   key == ARG_ip6_ip) {
-+				if (p->iph.protocol && p->iph.protocol != IPPROTO_IPV6) {
-+					bb_error_msg_and_die("you managed to ask for more than one tunnel mode");
-+				}
-+				p->iph.protocol = IPPROTO_IPV6;
-+			} else {
-+				bb_error_msg_and_die("cannot guess tunnel mode");
-+			}
-+		} else if (key == ARG_key) {
-+			unsigned uval;
-+			NEXT_ARG();
-+			p->i_flags |= GRE_KEY;
-+			p->o_flags |= GRE_KEY;
-+			if (strchr(*argv, '.'))
-+				p->i_key = p->o_key = get_addr32(*argv);
-+			else {
-+				if (get_unsigned(&uval, *argv, 0)<0) {
-+					bb_error_msg_and_die("invalid value of \"key\"");
-+				}
-+				p->i_key = p->o_key = htonl(uval);
-+			}
-+		} else if (key == ARG_ikey) {
-+			unsigned uval;
-+			NEXT_ARG();
-+			p->i_flags |= GRE_KEY;
-+			if (strchr(*argv, '.'))
-+				p->o_key = get_addr32(*argv);
-+			else {
-+				if (get_unsigned(&uval, *argv, 0)<0) {
-+					bb_error_msg_and_die("invalid value of \"ikey\"");
-+				}
-+				p->i_key = htonl(uval);
-+			}
-+		} else if (key == ARG_okey) {
-+			unsigned uval;
-+			NEXT_ARG();
-+			p->o_flags |= GRE_KEY;
-+			if (strchr(*argv, '.'))
-+				p->o_key = get_addr32(*argv);
-+			else {
-+				if (get_unsigned(&uval, *argv, 0)<0) {
-+					bb_error_msg_and_die("invalid value of \"okey\"");
-+				}
-+				p->o_key = htonl(uval);
-+			}
-+		} else if (key == ARG_seq) {
-+			p->i_flags |= GRE_SEQ;
-+			p->o_flags |= GRE_SEQ;
-+		} else if (key == ARG_iseq) {
-+			p->i_flags |= GRE_SEQ;
-+		} else if (key == ARG_oseq) {
-+			p->o_flags |= GRE_SEQ;
-+		} else if (key == ARG_csum) {
-+			p->i_flags |= GRE_CSUM;
-+			p->o_flags |= GRE_CSUM;
-+		} else if (key == ARG_icsum) {
-+			p->i_flags |= GRE_CSUM;
-+		} else if (key == ARG_ocsum) {
-+			p->o_flags |= GRE_CSUM;
-+		} else if (key == ARG_nopmtudisc) {
-+			p->iph.frag_off = 0;
-+		} else if (key == ARG_pmtudisc) {
-+			p->iph.frag_off = htons(IP_DF);
-+		} else if (key == ARG_remote) {
-+			NEXT_ARG();
-+			key = index_in_strings(keywords, *argv);
-+			if (key != ARG_any)
-+				p->iph.daddr = get_addr32(*argv);
-+		} else if (key == ARG_local) {
-+			NEXT_ARG();
-+			key = index_in_strings(keywords, *argv);
-+			if (key != ARG_any)
-+				p->iph.saddr = get_addr32(*argv);
-+		} else if (key == ARG_dev) {
-+			NEXT_ARG();
-+			strncpy(medium, *argv, IFNAMSIZ-1);
-+		} else if (key == ARG_ttl) {
-+			unsigned uval;
-+			NEXT_ARG();
-+			key = index_in_strings(keywords, *argv);
-+			if (key != ARG_inherit) {
-+				if (get_unsigned(&uval, *argv, 0))
-+					invarg(*argv, "TTL");
-+				if (uval > 255)
-+					invarg(*argv, "TTL must be <=255");
-+				p->iph.ttl = uval;
-+			}
-+		} else if (key == ARG_tos ||
-+			   key == ARG_dsfield) {
-+			uint32_t uval;
-+			NEXT_ARG();
-+			key = index_in_strings(keywords, *argv);
-+			if (key != ARG_inherit) {
-+				if (rtnl_dsfield_a2n(&uval, *argv))
-+					invarg(*argv, "TOS");
-+				p->iph.tos = uval;
-+			} else
-+				p->iph.tos = 1;
-+		} else {
-+			if (key == ARG_name) {
-+				NEXT_ARG();
-+			}
-+			if (p->name[0])
-+				duparg2("name", *argv);
-+			strncpy(p->name, *argv, IFNAMSIZ);
-+			if (cmd == SIOCCHGTUNNEL && count == 0) {
-+				struct ip_tunnel_parm old_p;
-+				memset(&old_p, 0, sizeof(old_p));
-+				if (do_get_ioctl(*argv, &old_p))
-+					exit(1);
-+				*p = old_p;
-+			}
-+		}
-+		count++;
-+		argc--;
-+		argv++;
-+	}
-+
-+	if (p->iph.protocol == 0) {
-+		if (memcmp(p->name, "gre", 3) == 0)
-+			p->iph.protocol = IPPROTO_GRE;
-+		else if (memcmp(p->name, "ipip", 4) == 0)
-+			p->iph.protocol = IPPROTO_IPIP;
-+		else if (memcmp(p->name, "sit", 3) == 0)
-+			p->iph.protocol = IPPROTO_IPV6;
-+	}
-+
-+	if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) {
-+		if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) {
-+			bb_error_msg_and_die("keys are not allowed with ipip and sit");
-+		}
-+	}
-+
-+	if (medium[0]) {
-+		p->link = do_ioctl_get_ifindex(medium);
-+	}
-+
-+	if (p->i_key == 0 && IN_MULTICAST(ntohl(p->iph.daddr))) {
-+		p->i_key = p->iph.daddr;
-+		p->i_flags |= GRE_KEY;
-+	}
-+	if (p->o_key == 0 && IN_MULTICAST(ntohl(p->iph.daddr))) {
-+		p->o_key = p->iph.daddr;
-+		p->o_flags |= GRE_KEY;
-+	}
-+	if (IN_MULTICAST(ntohl(p->iph.daddr)) && !p->iph.saddr) {
-+		bb_error_msg_and_die("broadcast tunnel requires a source address");
-+	}
-+}
-+
-+
-+/* Return value becomes exitcode. It's okay to not return at all */
-+static int do_add(int cmd, int argc, char **argv)
-+{
-+	struct ip_tunnel_parm p;
-+
-+	parse_args(argc, argv, cmd, &p);
-+
-+	if (p.iph.ttl && p.iph.frag_off == 0) {
-+		bb_error_msg_and_die("ttl != 0 and noptmudisc are incompatible");
-+	}
-+
-+	switch (p.iph.protocol) {
-+	case IPPROTO_IPIP:
-+		return do_add_ioctl(cmd, "tunl0", &p);
-+	case IPPROTO_GRE:
-+		return do_add_ioctl(cmd, "gre0", &p);
-+	case IPPROTO_IPV6:
-+		return do_add_ioctl(cmd, "sit0", &p);
-+	default:
-+		bb_error_msg_and_die("cannot determine tunnel mode (ipip, gre or sit)");
-+	}
-+}
-+
-+/* Return value becomes exitcode. It's okay to not return at all */
-+static int do_del(int argc, char **argv)
-+{
-+	struct ip_tunnel_parm p;
-+
-+	parse_args(argc, argv, SIOCDELTUNNEL, &p);
-+
-+	switch (p.iph.protocol) {
-+	case IPPROTO_IPIP:
-+		return do_del_ioctl("tunl0", &p);
-+	case IPPROTO_GRE:
-+		return do_del_ioctl("gre0", &p);
-+	case IPPROTO_IPV6:
-+		return do_del_ioctl("sit0", &p);
-+	default:
-+		return do_del_ioctl(p.name, &p);
-+	}
-+}
-+
-+static void print_tunnel(struct ip_tunnel_parm *p)
-+{
-+	char s1[256];
-+	char s2[256];
-+	char s3[64];
-+	char s4[64];
-+
-+	format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1));
-+	format_host(AF_INET, 4, &p->iph.saddr, s2, sizeof(s2));
-+	inet_ntop(AF_INET, &p->i_key, s3, sizeof(s3));
-+	inet_ntop(AF_INET, &p->o_key, s4, sizeof(s4));
-+
-+	printf("%s: %s/ip  remote %s  local %s ",
-+	       p->name,
-+	       p->iph.protocol == IPPROTO_IPIP ? "ip" :
-+	       (p->iph.protocol == IPPROTO_GRE ? "gre" :
-+		(p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown")),
-+	       p->iph.daddr ? s1 : "any", p->iph.saddr ? s2 : "any");
-+	if (p->link) {
-+		char *n = do_ioctl_get_ifname(p->link);
-+		if (n) {
-+			printf(" dev %s ", n);
-+			free(n);
-+		}
-+	}
-+	if (p->iph.ttl)
-+		printf(" ttl %d ", p->iph.ttl);
-+	else
-+		printf(" ttl inherit ");
-+	if (p->iph.tos) {
-+		SPRINT_BUF(b1);
-+		printf(" tos");
-+		if (p->iph.tos & 1)
-+			printf(" inherit");
-+		if (p->iph.tos & ~1)
-+			printf("%c%s ", p->iph.tos & 1 ? '/' : ' ',
-+			       rtnl_dsfield_n2a(p->iph.tos & ~1, b1, sizeof(b1)));
-+	}
-+	if (!(p->iph.frag_off & htons(IP_DF)))
-+		printf(" nopmtudisc");
-+
-+	if ((p->i_flags & GRE_KEY) && (p->o_flags & GRE_KEY) && p->o_key == p->i_key)
-+		printf(" key %s", s3);
-+	else if ((p->i_flags | p->o_flags) & GRE_KEY) {
-+		if (p->i_flags & GRE_KEY)
-+			printf(" ikey %s ", s3);
-+		if (p->o_flags & GRE_KEY)
-+			printf(" okey %s ", s4);
-+	}
-+
-+	if (p->i_flags & GRE_SEQ)
-+		printf("%c  Drop packets out of sequence.\n", _SL_);
-+	if (p->i_flags & GRE_CSUM)
-+		printf("%c  Checksum in received packet is required.", _SL_);
-+	if (p->o_flags & GRE_SEQ)
-+		printf("%c  Sequence packets on output.", _SL_);
-+	if (p->o_flags & GRE_CSUM)
-+		printf("%c  Checksum output packets.", _SL_);
-+}
-+
-+static void do_tunnels_list(struct ip_tunnel_parm *p)
-+{
-+	char name[IFNAMSIZ];
-+	unsigned long rx_bytes, rx_packets, rx_errs, rx_drops,
-+		rx_fifo, rx_frame,
-+		tx_bytes, tx_packets, tx_errs, tx_drops,
-+		tx_fifo, tx_colls, tx_carrier, rx_multi;
-+	int type;
-+	struct ip_tunnel_parm p1;
-+	char buf[512];
-+	FILE *fp = fopen_or_warn("/proc/net/dev", "r");
-+
-+	if (fp == NULL) {
-+		return;
-+	}
-+
-+	fgets(buf, sizeof(buf), fp);
-+	fgets(buf, sizeof(buf), fp);
-+
-+	while (fgets(buf, sizeof(buf), fp) != NULL) {
-+		char *ptr;
-+
-+		/*buf[sizeof(buf) - 1] = 0; - fgets is safe anyway */
-+		ptr = strchr(buf, ':');
-+		if (ptr == NULL ||
-+		    (*ptr++ = 0, sscanf(buf, "%s", name) != 1)) {
-+			bb_error_msg("wrong format of /proc/net/dev");
-+			return;
-+		}
-+		if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*d%lu%lu%lu%lu%lu%lu%lu",
-+			   &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
-+			   &rx_fifo, &rx_frame, &rx_multi,
-+			   &tx_bytes, &tx_packets, &tx_errs, &tx_drops,
-+			   &tx_fifo, &tx_colls, &tx_carrier) != 14)
-+			continue;
-+		if (p->name[0] && strcmp(p->name, name))
-+			continue;
-+		type = do_ioctl_get_iftype(name);
-+		if (type == -1) {
-+			bb_error_msg("cannot get type of [%s]", name);
-+			continue;
-+		}
-+		if (type != ARPHRD_TUNNEL && type != ARPHRD_IPGRE && type != ARPHRD_SIT)
-+			continue;
-+		memset(&p1, 0, sizeof(p1));
-+		if (do_get_ioctl(name, &p1))
-+			continue;
-+		if ((p->link && p1.link != p->link) ||
-+		    (p->name[0] && strcmp(p1.name, p->name)) ||
-+		    (p->iph.daddr && p1.iph.daddr != p->iph.daddr) ||
-+		    (p->iph.saddr && p1.iph.saddr != p->iph.saddr) ||
-+		    (p->i_key && p1.i_key != p->i_key))
-+			continue;
-+		print_tunnel(&p1);
-+		bb_putchar('\n');
-+	}
-+}
-+
-+/* Return value becomes exitcode. It's okay to not return at all */
-+static int do_show(int argc, char **argv)
-+{
-+	int err;
-+	struct ip_tunnel_parm p;
-+
-+	parse_args(argc, argv, SIOCGETTUNNEL, &p);
-+
-+	switch (p.iph.protocol) {
-+	case IPPROTO_IPIP:
-+		err = do_get_ioctl(p.name[0] ? p.name : "tunl0", &p);
-+		break;
-+	case IPPROTO_GRE:
-+		err = do_get_ioctl(p.name[0] ? p.name : "gre0", &p);
-+		break;
-+	case IPPROTO_IPV6:
-+		err = do_get_ioctl(p.name[0] ? p.name : "sit0", &p);
-+		break;
-+	default:
-+		do_tunnels_list(&p);
-+		return 0;
-+	}
-+	if (err)
-+		return -1;
-+
-+	print_tunnel(&p);
-+	bb_putchar('\n');
-+	return 0;
-+}
-+
-+/* Return value becomes exitcode. It's okay to not return at all */
-+int do_iptunnel(int argc, char **argv)
-+{
-+	static const char keywords[] ALIGN1 =
-+		"add\0""change\0""delete\0""show\0""list\0""lst\0";
-+	enum { ARG_add = 0, ARG_change, ARG_del, ARG_show, ARG_list, ARG_lst };
-+	int key;
-+
-+	if (argc) {
-+		key = index_in_substrings(keywords, *argv);
-+		if (key < 0)
-+			bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
-+		--argc;
-+		++argv;
-+		if (key == ARG_add)
-+			return do_add(SIOCADDTUNNEL, argc, argv);
-+		if (key == ARG_change)
-+			return do_add(SIOCCHGTUNNEL, argc, argv);
-+		if (key == ARG_del)
-+			return do_del(argc, argv);
-+	}
-+	return do_show(argc, argv);
-+}
Index: patches/uClibc-0.9.30-rc3-flock_fixes-1.patch
===================================================================
--- patches/uClibc-0.9.30-rc3-flock_fixes-1.patch	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
+++ patches/uClibc-0.9.30-rc3-flock_fixes-1.patch	(revision 2567553b5f35f9d887cdc559d197dd20323180b4)
@@ -0,0 +1,696 @@
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/alpha/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/alpha/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/alpha/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/alpha/bits/fcntl.h	2008-11-08 10:12:27.000000000 -0500
+@@ -138,6 +138,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ /* We don't need to support __USE_FILE_OFFSET64.  */
+ struct flock
+   {
+@@ -147,7 +148,9 @@
+     __off_t l_len;	/* Size of the locked area; zero means until EOF.  */
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -158,6 +161,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ 
+ /* Define some more compatibility macros to be backward compatible with
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/arm/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/arm/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/arm/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/arm/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -143,6 +143,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -156,7 +157,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -167,6 +170,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/avr32/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/avr32/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/avr32/bits/fcntl.h	2008-09-17 07:45:37.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/avr32/bits/fcntl.h	2008-11-08 10:13:35.000000000 -0500
+@@ -124,6 +124,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock {
+ 	short		l_type;
+ 	short		l_whence;
+@@ -136,7 +137,9 @@
+ #endif
+ 	__pid_t		l_pid;
+ };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64 {
+ 	short		l_type;
+@@ -146,6 +149,7 @@
+ 	__pid_t		l_pid;
+ };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+  *    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/bfin/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/bfin/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/bfin/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/bfin/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -139,6 +139,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -152,7 +153,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -163,6 +166,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/cris/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/cris/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/cris/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/cris/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -140,6 +140,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -153,7 +154,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -164,6 +167,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/e1/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/e1/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/e1/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/e1/bits/fcntl.h	2008-11-08 10:06:40.000000000 -0500
+@@ -136,6 +136,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -149,7 +150,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -160,6 +163,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/frv/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/frv/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/frv/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/frv/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -118,6 +118,7 @@
+ # define LOCK_UN	8	/* remove lock */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+@@ -131,7 +132,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -142,6 +145,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/h8300/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/h8300/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/h8300/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/h8300/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -136,6 +136,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -149,7 +150,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -160,6 +163,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/hppa/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/hppa/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/hppa/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/hppa/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -130,6 +130,7 @@
+ # define DN_MULTISHOT   0x80000000      /* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+@@ -143,7 +144,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -154,6 +157,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/i386/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/i386/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/i386/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/i386/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -143,6 +143,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -156,7 +157,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -167,6 +170,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/i960/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/i960/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/i960/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/i960/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -136,6 +136,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -149,7 +150,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -160,6 +163,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/ia64/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/ia64/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/ia64/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/ia64/bits/fcntl.h	2008-11-08 10:11:31.000000000 -0500
+@@ -140,6 +140,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ /* We don't need to support __USE_FILE_OFFSET64.  */
+ struct flock
+   {
+@@ -149,7 +150,9 @@
+     __off_t l_len;	/* Size of the locked area; zero means until EOF.  */
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -160,6 +163,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ 
+ /* Define some more compatibility macros to be backward compatible with
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/m68k/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/m68k/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/m68k/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/m68k/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -139,6 +139,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -152,7 +153,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -163,6 +166,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/microblaze/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/microblaze/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/microblaze/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/microblaze/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -136,6 +136,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -149,7 +150,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -160,6 +163,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/mips/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/mips/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/mips/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/mips/bits/fcntl.h	2008-11-08 10:12:05.000000000 -0500
+@@ -152,6 +152,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -176,7 +177,9 @@
+ #endif
+   };
+ typedef struct flock flock_t;
++#endif 
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -187,6 +190,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/nios/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/nios/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/nios/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/nios/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -139,6 +139,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+@@ -152,7 +153,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -163,6 +166,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/nios2/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/nios2/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/nios2/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/nios2/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -139,6 +139,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -152,7 +153,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -163,6 +166,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/sh/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/sh/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/sh/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/sh/bits/fcntl.h	2008-11-08 10:07:07.000000000 -0500
+@@ -143,6 +143,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -156,7 +157,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -167,6 +170,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/sh64/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/sh64/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/sh64/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/sh64/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -118,6 +118,7 @@
+ # define LOCK_UN	8	/* remove lock */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+@@ -131,7 +132,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -142,6 +145,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/sparc/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/sparc/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/sparc/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/sparc/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -160,6 +160,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+@@ -174,7 +175,9 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+     short int __unused;
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -186,6 +189,7 @@
+     short int __unused;
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/v850/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/v850/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/v850/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/v850/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -136,6 +136,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -149,7 +150,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -160,6 +163,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/vax/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/vax/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/vax/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/vax/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -116,6 +116,7 @@
+ # define LOCK_UN	8	/* remove lock */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+@@ -129,7 +130,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -140,6 +143,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/x86_64/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/x86_64/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/x86_64/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/x86_64/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -157,6 +157,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -170,7 +171,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -181,6 +184,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
+diff -Naur uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/xtensa/bits/fcntl.h uClibc-0.9.30-rc3/libc/sysdeps/linux/xtensa/bits/fcntl.h
+--- uClibc-0.9.30-rc3.orig/libc/sysdeps/linux/xtensa/bits/fcntl.h	2008-09-16 10:02:54.000000000 -0400
++++ uClibc-0.9.30-rc3/libc/sysdeps/linux/xtensa/bits/fcntl.h	2008-11-08 10:10:44.000000000 -0500
+@@ -140,6 +140,7 @@
+ # define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+ #endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK
+ struct flock
+   {
+     short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
+@@ -153,7 +154,9 @@
+ #endif
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
++#endif
+ 
++#ifndef HAVE_ARCH_STRUCT_FLOCK64
+ #ifdef __USE_LARGEFILE64
+ struct flock64
+   {
+@@ -164,6 +167,7 @@
+     __pid_t l_pid;	/* Process holding the lock.  */
+   };
+ #endif
++#endif
+ 
+ /* Define some more compatibility macros to be backward compatible with
+    BSD systems which did not managed to hide these kernel macros.  */
