Merge with git+ssh://master.kernel.org/pub/scm/libs/klibc/klibc.git
diff --git a/klibc/tests/mmaptest.c b/klibc/tests/mmaptest.c
index a654aff..9565c10 100644
--- a/klibc/tests/mmaptest.c
+++ b/klibc/tests/mmaptest.c
@@ -11,18 +11,64 @@
 #include <stdint.h>
 #include <sys/syscall.h>
 
+static void make_test_file(int fd)
+{
+  unsigned long v;
+  FILE *f = fdopen(fd, "wb");
+
+  for (v = 0; v < 262144; v += sizeof(v))
+    _fwrite(&v, sizeof(v), f);
+}
+
 int main(int argc, char *argv[])
 {
   void *foo;
-
-  (void)argc; (void)argv;
-
+  char *test_file = (argc > 1) ? argv[1] : "/tmp/mmaptest.tmp";
+  int rv, fd;
+  unsigned long q;
+  
   /* Important case, this is how we get memory for malloc() */
   errno = 0;
-  foo = mmap(0, 65536, PROT_READ|PROT_WRITE,
+  foo = mmap(NULL, 65536, PROT_READ|PROT_WRITE,
 	     MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
-
+  
   printf("mmap() returned %p, errno = %d\n", foo, errno);
+  if (foo == MAP_FAILED)
+    return 1;
+  
+  rv = munmap(foo, 65536);
+  printf("munmap() returned %d, errno = %d\n", rv, errno);
+  if (rv)
+    return 1;
+  
+  /* Create test file */
+  fd = open(test_file, O_RDWR|O_CREAT|O_TRUNC, 0666);
+  if (fd < 0) {
+    perror(test_file);
+    return 1;
+  }
+
+  make_test_file(fd);
+
+  /* Map test file */
+  foo = mmap(NULL, 65536, PROT_READ, MAP_SHARED, fd, 131072);
+  printf("mmap() returned %p, errno = %d\n", foo, errno);
+  if (foo == MAP_FAILED)
+    return 1;
+
+  if (*(unsigned long *)foo != 131072) {
+    printf("mmap() with offset returned the wrong offset %ld!\n",
+	   *(unsigned long *)foo);
+    return 1;
+  }
+
+  if (munmap(foo, 65536)) {
+    printf("munmap() returned nonzero, errno = %d\n", errno);
+    return 1;
+  }
+
+  close(fd);
+  unlink(test_file);
 
   return 0;
 }
diff --git a/usr/kinit/do_mounts.c b/usr/kinit/do_mounts.c
index b0a8bfc..97b81a6 100644
--- a/usr/kinit/do_mounts.c
+++ b/usr/kinit/do_mounts.c
@@ -26,6 +26,7 @@
 	char path[BUF_SZ];
 	char buf[BUF_SZ];
 	int range;
+	unsigned int major, minor;
 	dev_t res;
 	char *s;
 	int len;
@@ -42,9 +43,13 @@
 	if (len <= 0 || len == BUF_SZ || buf[len - 1] != '\n')
 		goto fail;
 	buf[len - 1] = '\0';
-	res = (dev_t) strtoul(buf, &s, 16);
+	major = strtoul(buf, &s, 10);
+	if (*s != ':')
+		goto fail;
+	minor = strtoul(s+1, &s, 10);
 	if (*s)
 		goto fail;
+	res = makedev(major, minor);
 
 	/* if it's there and we are not looking for a partition - that's it */
 	if (!part)