Merge branch 'master' into stdio
diff --git a/Makefile b/Makefile
index d2cd577..25d32dc 100644
--- a/Makefile
+++ b/Makefile
@@ -130,12 +130,12 @@
 	@echo	'test		- Run klibc tests'
 	@echo
 	@echo	'Build options:'
-	@echo	'KLIBCKERNELSRC - Path to a configured linux-2.6 tree'
+	@echo	'KLIBCKERNELSRC - Path to a configured linux tree'
 	@echo	'KLIBCKERNELOBJ - Path to kernel output dir (defaults to KLIBCKERNELSRC)'
 	@echo	'make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
 	@echo
 	@echo	'Sample invocation:'
-	@echo	'make  KLIBCKERNELSRC=`pwd`/../linux-2.6'
+	@echo	'make  KLIBCKERNELSRC=`pwd`/../linux'
 
 ###
 # allow one to say make dir/file.o
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 5b68980..fed4c7f 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -123,14 +123,13 @@
 char *depfile;
 char *cmdline;
 
-void usage(void)
-
+static void usage(void)
 {
 	fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
 	exit(1);
 }
 
-void print_cmdline(void)
+static void print_cmdline(void)
 {
 	printf("cmd_%s := %s\n\n", target, cmdline);
 }
@@ -143,7 +142,7 @@
  * Grow the configuration string to a desired length.
  * Usually the first growth is plenty.
  */
-void grow_config(int len)
+static void grow_config(int len)
 {
 	while (len_config + len > size_config) {
 		if (size_config == 0)
@@ -159,7 +158,7 @@
 /*
  * Lookup a value in the configuration string.
  */
-int is_defined_config(const char * name, int len)
+static int is_defined_config(const char *name, int len)
 {
 	const char * pconfig;
 	const char * plast = str_config + len_config - len;
@@ -175,7 +174,7 @@
 /*
  * Add a new value to the configuration string.
  */
-void define_config(const char * name, int len)
+static void define_config(const char *name, int len)
 {
 	grow_config(len + 1);
 
@@ -187,7 +186,7 @@
 /*
  * Clear the set of configuration strings.
  */
-void clear_config(void)
+static void clear_config(void)
 {
 	len_config = 0;
 	define_config("", 0);
@@ -196,7 +195,7 @@
 /*
  * Record the use of a CONFIG_* word.
  */
-void use_config(char *m, int slen)
+static void use_config(char *m, int slen)
 {
 	char s[PATH_MAX];
 	char *p;
@@ -217,7 +216,7 @@
 	printf("    $(wildcard include/config/%s.h) \\\n", s);
 }
 
-void parse_config_file(char *map, size_t len)
+static void parse_config_file(char *map, size_t len)
 {
 	int *end = (int *) (map + len);
 	/* start at +1, so that p can never be < map */
@@ -247,7 +246,7 @@
 }
 
 /* test is s ends in sub */
-int strrcmp(char *s, char *sub)
+static int strrcmp(char *s, char *sub)
 {
 	int slen = strlen(s);
 	int sublen = strlen(sub);
@@ -258,7 +257,7 @@
 	return memcmp(s + slen - sublen, sub, sublen);
 }
 
-void do_config_file(char *filename)
+static void do_config_file(char *filename)
 {
 	struct stat st;
 	int fd;
@@ -289,7 +288,7 @@
 	close(fd);
 }
 
-void parse_dep_file(void *map, size_t len)
+static void parse_dep_file(void *map, size_t len)
 {
 	char *m = map;
 	char *end = m + len;
@@ -329,7 +328,7 @@
 	printf("$(deps_%s):\n", target);
 }
 
-void print_deps(void)
+static void print_deps(void)
 {
 	struct stat st;
 	int fd;
@@ -361,7 +360,7 @@
 	close(fd);
 }
 
-void traps(void)
+static void traps(void)
 {
 	static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
 	int *p = (int *)test;
diff --git a/usr/include/limits.h b/usr/include/limits.h
index 0d1069b..8a2c6c0 100644
--- a/usr/include/limits.h
+++ b/usr/include/limits.h
@@ -5,6 +5,8 @@
 #ifndef _LIMITS_H
 #define _LIMITS_H
 
+#define OPEN_MAX        20
+
 #define CHAR_BIT	8
 #define SHRT_BIT	16
 #define INT_BIT		32
diff --git a/usr/include/sys/file.h b/usr/include/sys/file.h
new file mode 100644
index 0000000..7b580f3
--- /dev/null
+++ b/usr/include/sys/file.h
@@ -0,0 +1,9 @@
+#ifndef _SYS_FILE_H
+#define _SYS_FILE_H
+
+/* LOCK_ definitions */
+#include <fcntl.h>
+
+__extern int flock(int, int);
+
+#endif /* _SYS_FILE_H */
diff --git a/usr/include/sys/types.h b/usr/include/sys/types.h
index 6780ed1..3a4c738 100644
--- a/usr/include/sys/types.h
+++ b/usr/include/sys/types.h
@@ -100,6 +100,10 @@
 typedef uint32_t __sum32;
 typedef uint64_t __sum64;
 
+#define __aligned_u64 __u64 __attribute__((aligned(8)))
+#define __aligned_be64 __be64 __attribute__((aligned(8)))
+#define __aligned_le64 __le64 __attribute__((aligned(8)))
+
 /*
  * Some headers seem to require this...
  */
diff --git a/usr/include/unistd.h b/usr/include/unistd.h
index f286c33..3eaeaee 100644
--- a/usr/include/unistd.h
+++ b/usr/include/unistd.h
@@ -105,7 +105,6 @@
 __extern int dup2(int, int);
 __extern int fcntl(int, int, ...);
 __extern int ioctl(int, int, void *);
-__extern int flock(int, int);
 __extern int ftruncate(int, off_t);
 
 /*
diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index 8782ae7..37ca573 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
@@ -408,7 +408,7 @@
 			prev = now;
 			gettimeofday(&now, NULL);
 
-			if ((fds[0].revents & POLLRDNORM)) {
+			if ((nr > 0) && (fds[0].revents & POLLRDNORM)) {
 				if (do_pkt_recv(pkt_fd, now.tv_sec) == 1)
 					break;
 			}
diff --git a/usr/klibc/vsscanf.c b/usr/klibc/vsscanf.c
index 51e50f7..b8f068c 100644
--- a/usr/klibc/vsscanf.c
+++ b/usr/klibc/vsscanf.c
@@ -88,7 +88,6 @@
 	} state = st_normal;
 	char *sarg = NULL;	/* %s %c or %[ string argument */
 	enum bail bail = bail_none;
-	int sign;
 	int converted = 0;	/* Successful conversions */
 	unsigned long matchmap[((1 << CHAR_BIT) + (LONG_BIT - 1)) / LONG_BIT];
 	int matchinv = 0;	/* Is match map inverted? */
@@ -177,33 +176,27 @@
 				case 'p':	/* Pointer */
 					rank = rank_ptr;
 					base = 0;
-					sign = 0;
 					goto scan_int;
 
 				case 'i':	/* Base-independent integer */
 					base = 0;
-					sign = 1;
 					goto scan_int;
 
 				case 'd':	/* Decimal integer */
 					base = 10;
-					sign = 1;
 					goto scan_int;
 
 				case 'o':	/* Octal integer */
 					base = 8;
-					sign = 0;
 					goto scan_int;
 
 				case 'u':	/* Unsigned decimal integer */
 					base = 10;
-					sign = 0;
 					goto scan_int;
 
 				case 'x':	/* Hexadecimal integer */
 				case 'X':
 					base = 16;
-					sign = 0;
 					goto scan_int;
 
 				case 'n':	/* # of characters consumed */