diff -Naurwb cramfs-1.1/linux/cramfs_fs.h cramfs-1.1.roku/linux/cramfs_fs.h
--- cramfs-1.1/linux/cramfs_fs.h	2002-02-20 00:03:32.000000000 -0800
+++ cramfs-1.1.roku/linux/cramfs_fs.h	2011-10-21 12:16:52.739702111 -0700
@@ -1,98 +1 @@
-#ifndef __CRAMFS_H
-#define __CRAMFS_H
-
-#ifndef __KERNEL__
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned int u32;
-
-#endif
-
-#define CRAMFS_MAGIC		0x28cd3d45	/* some random number */
-#define CRAMFS_SIGNATURE	"Compressed ROMFS"
-
-/*
- * Width of various bitfields in struct cramfs_inode.
- * Primarily used to generate warnings in mkcramfs.
- */
-#define CRAMFS_MODE_WIDTH 16
-#define CRAMFS_UID_WIDTH 16
-#define CRAMFS_SIZE_WIDTH 24
-#define CRAMFS_GID_WIDTH 8
-#define CRAMFS_NAMELEN_WIDTH 6
-#define CRAMFS_OFFSET_WIDTH 26
-
-/*
- * Since inode.namelen is a unsigned 6-bit number, the maximum cramfs
- * path length is 63 << 2 = 252.
- */
-#define CRAMFS_MAXPATHLEN (((1 << CRAMFS_NAMELEN_WIDTH) - 1) << 2)
-
-/*
- * Reasonably terse representation of the inode data.
- */
-struct cramfs_inode {
-	u32 mode:CRAMFS_MODE_WIDTH, uid:CRAMFS_UID_WIDTH;
-	/* SIZE for device files is i_rdev */
-	u32 size:CRAMFS_SIZE_WIDTH, gid:CRAMFS_GID_WIDTH;
-	/* NAMELEN is the length of the file name, divided by 4 and
-           rounded up.  (cramfs doesn't support hard links.) */
-	/* OFFSET: For symlinks and non-empty regular files, this
-	   contains the offset (divided by 4) of the file data in
-	   compressed form (starting with an array of block pointers;
-	   see README).  For non-empty directories it is the offset
-	   (divided by 4) of the inode of the first file in that
-	   directory.  For anything else, offset is zero. */
-	u32 namelen:CRAMFS_NAMELEN_WIDTH, offset:CRAMFS_OFFSET_WIDTH;
-};
-
-struct cramfs_info {
-	u32 crc;
-	u32 edition;
-	u32 blocks;
-	u32 files;
-};
-
-/*
- * Superblock information at the beginning of the FS.
- */
-struct cramfs_super {
-	u32 magic;			/* 0x28cd3d45 - random number */
-	u32 size;			/* length in bytes */
-	u32 flags;			/* feature flags */
-	u32 future;			/* reserved for future use */
-	u8 signature[16];		/* "Compressed ROMFS" */
-	struct cramfs_info fsid;	/* unique filesystem info */
-	u8 name[16];			/* user-defined name */
-	struct cramfs_inode root;	/* root inode data */
-};
-
-/*
- * Feature flags
- *
- * 0x00000000 - 0x000000ff: features that work for all past kernels
- * 0x00000100 - 0xffffffff: features that don't work for past kernels
- */
-#define CRAMFS_FLAG_FSID_VERSION_2	0x00000001	/* fsid version #2 */
-#define CRAMFS_FLAG_SORTED_DIRS		0x00000002	/* sorted dirs */
-#define CRAMFS_FLAG_HOLES		0x00000100	/* support for holes */
-#define CRAMFS_FLAG_WRONG_SIGNATURE	0x00000200	/* reserved */
-#define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET	0x00000400	/* shifted root fs */
-
-/*
- * Valid values in super.flags.  Currently we refuse to mount
- * if (flags & ~CRAMFS_SUPPORTED_FLAGS).  Maybe that should be
- * changed to test super.future instead.
- */
-#define CRAMFS_SUPPORTED_FLAGS	( 0x000000ff \
-				| CRAMFS_FLAG_HOLES \
-				| CRAMFS_FLAG_WRONG_SIGNATURE \
-				| CRAMFS_FLAG_SHIFTED_ROOT_OFFSET )
-
-/* Uncompression interfaces to the underlying zlib */
-int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen);
-int cramfs_uncompress_init(void);
-int cramfs_uncompress_exit(void);
-
-#endif
+#include "../../../bcm-2835/2835-kernel-2.6.32/include/linux/cramfs_fs.h"
diff -Naurwb cramfs-1.1/linux/magic.h cramfs-1.1.roku/linux/magic.h
--- cramfs-1.1/linux/magic.h	1969-12-31 16:00:00.000000000 -0800
+++ cramfs-1.1.roku/linux/magic.h	2011-10-21 12:16:52.739702111 -0700
@@ -0,0 +1 @@
+#include "../../../bcm-2835/2835-kernel-2.6.32/include/linux/magic.h"
diff -Naurwb cramfs-1.1/mkcramfs.c cramfs-1.1.roku/mkcramfs.c
--- cramfs-1.1/mkcramfs.c	2002-02-20 00:03:32.000000000 -0800
+++ cramfs-1.1.roku/mkcramfs.c	2011-10-21 12:35:20.978687132 -0700
@@ -36,6 +36,8 @@
 #include <linux/cramfs_fs.h>
 #include <zlib.h>
 
+#undef CRAMFS_CHECK_SIZE
+
 /* Exit codes used by mkfs-type programs */
 #define MKFS_OK          0	/* No errors */
 #define MKFS_ERROR       8	/* Operational error */
@@ -67,9 +69,11 @@
  * Note that if you want it to fit in a ROM then you're limited to what the
  * hardware and kernel can support.
  */
+#ifdef CRAMFS_CHECK_SIZE
 #define MAXFSLEN ((((1 << CRAMFS_OFFSET_WIDTH) - 1) << 2) /* offset */ \
 		  + (1 << CRAMFS_SIZE_WIDTH) - 1 /* filesize */ \
 		  + (1 << CRAMFS_SIZE_WIDTH) * 4 / PAGE_CACHE_SIZE /* block pointers */ )
+#endif
 
 static const char *progname = "mkcramfs";
 static unsigned int blksize = PAGE_CACHE_SIZE;
@@ -93,6 +97,8 @@
 static int opt_verbose = 0;
 static char *opt_image = NULL;
 static char *opt_name = NULL;
+static int opt_uid = -1;
+static int opt_gid = -1;
 
 static int warn_dev, warn_gid, warn_namelen, warn_skip, warn_size, warn_uid;
 
@@ -127,10 +133,12 @@
 		" -h         print this help\n"
 		" -E         make all warnings errors (non-zero exit status)\n"
 		" -e edition set edition number (part of fsid)\n"
+		" -g gid     set all files to specified gid\n"
 		" -i file    insert a file image into the filesystem (requires >= 2.4.0)\n"
 		" -n name    set name of cramfs filesystem\n"
 		" -p         pad by %d bytes for boot code\n"
 		" -s         sort directory entries (old option, ignored)\n"
+		" -u uid     set all files to specified uid\n"
 		" -v         be more verbose\n"
 		" -z         make explicit holes (requires >= 2.3.39)\n"
 		" dirname    root of the directory tree to be compressed\n"
@@ -305,9 +313,12 @@
 		entry->mode = st.st_mode;
 		entry->size = st.st_size;
 		entry->uid = st.st_uid;
+#if CRAMFS_UID_WIDTH < 32
 		if (entry->uid >= 1 << CRAMFS_UID_WIDTH)
 			warn_uid = 1;
+#endif
 		entry->gid = st.st_gid;
+#if CRAMFS_GID_WIDTH < 32
 		if (entry->gid >= 1 << CRAMFS_GID_WIDTH)
 			/* TODO: We ought to replace with a default
 			   gid instead of truncating; otherwise there
@@ -315,6 +326,7 @@
 			   be &= ~070.  Same goes for uid once Linux
 			   supports >16-bit uids. */
 			warn_gid = 1;
+#endif
 		size = sizeof(struct cramfs_inode) + ((namelen + 3) & ~3);
 		*fslen_ub += size;
 		if (S_ISDIR(st.st_mode)) {
@@ -329,10 +341,12 @@
 				if (!entry->path) {
 					die(MKFS_ERROR, 1, "strdup failed");
 				}
+#ifdef CRAMFS_CHECK_SIZE
 				if ((entry->size >= 1 << CRAMFS_SIZE_WIDTH)) {
 					warn_size = 1;
 					entry->size = (1 << CRAMFS_SIZE_WIDTH) - 1;
 				}
+#endif
 			}
 		} else if (S_ISLNK(st.st_mode)) {
 			entry->uncompressed = malloc(entry->size);
@@ -348,8 +362,10 @@
 			entry->size = 0;
 		} else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
 			entry->size = st.st_rdev;
+#ifdef CRAMFS_CHECK_SIZE
 			if (entry->size & -(1<<CRAMFS_SIZE_WIDTH))
 				warn_dev = 1;
+#endif
 		} else {
 			die(MKFS_ERROR, 0, "bogus file type: %s", entry->name);
 		}
@@ -416,9 +432,11 @@
 	if ((offset & 3) != 0) {
 		die(MKFS_ERROR, 0, "illegal offset of %lu bytes", offset);
 	}
+#ifdef CRAMFS_CHECK_SIZE
 	if (offset >= (1 << (2 + CRAMFS_OFFSET_WIDTH))) {
 		die(MKFS_ERROR, 0, "filesystem too big");
 	}
+#endif
 	inode->offset = (offset >> 2);
 }
 
@@ -482,8 +500,8 @@
 			entry->dir_offset = offset;
 
 			inode->mode = entry->mode;
-			inode->uid = entry->uid;
-			inode->gid = entry->gid;
+			inode->uid = (opt_uid >= 0) ? opt_uid : entry->uid;
+			inode->gid = (opt_gid >= 0) ? opt_gid : entry->gid;
 			inode->size = entry->size;
 			inode->offset = 0;
 			/* Non-empty directories, regfiles and symlinks will
@@ -699,7 +717,7 @@
 		progname = argv[0];
 
 	/* command line options */
-	while ((c = getopt(argc, argv, "hEe:i:n:psvz")) != EOF) {
+	while ((c = getopt(argc, argv, "hEe:g:i:n:psu:vz")) != EOF) {
 		switch (c) {
 		case 'h':
 			usage(MKFS_OK);
@@ -712,6 +730,12 @@
 			if (errno || optarg[0] == '\0' || *ep != '\0')
 				usage(MKFS_USAGE);
 			break;
+		case 'g':
+			errno = 0;
+			opt_gid = strtoul(optarg, &ep, 10);
+			if (errno || optarg[0] == '\0' || *ep != '\0')
+				usage(MKFS_USAGE);
+			break;
 		case 'i':
 			opt_image = optarg;
 			if (lstat(opt_image, &st) < 0) {
@@ -730,6 +754,12 @@
 		case 's':
 			/* old option, ignored */
 			break;
+		case 'u':
+			errno = 0;
+			opt_uid = strtoul(optarg, &ep, 10);
+			if (errno || optarg[0] == '\0' || *ep != '\0')
+				usage(MKFS_USAGE);
+			break;
 		case 'v':
 			opt_verbose++;
 			break;
@@ -747,7 +777,7 @@
 	if (stat(dirname, &st) < 0) {
 		die(MKFS_USAGE, 1, "stat failed: %s", dirname);
 	}
-	fd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+	fd = open(outfile, O_RDWR | O_CREAT | O_TRUNC, 0666);
 	if (fd < 0) {
 		die(MKFS_USAGE, 1, "open failed: %s", outfile);
 	}
@@ -757,8 +787,8 @@
 		die(MKFS_ERROR, 1, "calloc failed");
 	}
 	root_entry->mode = st.st_mode;
-	root_entry->uid = st.st_uid;
-	root_entry->gid = st.st_gid;
+	root_entry->uid = (opt_uid >= 0) ? opt_uid : st.st_uid;
+	root_entry->gid = (opt_gid >= 0) ? opt_gid : st.st_gid;
 
 	root_entry->size = parse_directory(root_entry, dirname, &root_entry->child, &fslen_ub);
 
@@ -766,6 +796,7 @@
 	   what we're going to write later on */
 	fslen_ub = ((fslen_ub - 1) | (blksize - 1)) + 1;
 
+#ifdef CRAMFS_CHECK_SIZE
 	if (fslen_ub > MAXFSLEN) {
 		fprintf(stderr,
 			"warning: estimate of required size (upper bound) is %LdMB, but maximum image size is %uMB, we might die prematurely\n",
@@ -773,24 +804,17 @@
 			MAXFSLEN >> 20);
 		fslen_ub = MAXFSLEN;
 	}
+#endif
 
 	/* find duplicate files. TODO: uses the most inefficient algorithm
 	   possible. */
 	eliminate_doubles(root_entry, root_entry);
 
-	/* TODO: Why do we use a private/anonymous mapping here
-	   followed by a write below, instead of just a shared mapping
-	   and a couple of ftruncate calls?  Is it just to save us
-	   having to deal with removing the file afterwards?  If we
-	   really need this huge anonymous mapping, we ought to mmap
-	   in smaller chunks, so that the user doesn't need nn MB of
-	   RAM free.  If the reason is to be able to write to
-	   un-mmappable block devices, then we could try shared mmap
-	   and revert to anonymous mmap if the shared mmap fails. */
-	rom_image = mmap(NULL, fslen_ub?fslen_ub:1, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	ftruncate(fd, fslen_ub);
+	rom_image = mmap(NULL, fslen_ub, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
 
 	if (rom_image == MAP_FAILED) {
-		die(MKFS_ERROR, 1, "mmap failed");
+		die(MKFS_ERROR, 1, "main mmap failed");
 	}
 
 	/* Skip the first opt_pad bytes for boot loader code */
@@ -831,13 +855,8 @@
 		die(MKFS_ERROR, 0, "not enough space allocated for ROM image (%Ld allocated, %d used)", fslen_ub, offset);
 	}
 
-	written = write(fd, rom_image, offset);
-	if (written < 0) {
-		die(MKFS_ERROR, 1, "write failed");
-	}
-	if (offset != written) {
-		die(MKFS_ERROR, 0, "ROM image write failed (wrote %d of %d bytes)", written, offset);
-	}
+	munmap(rom_image, fslen_ub);
+	ftruncate(fd, offset);
 
 	/* (These warnings used to come at the start, but they scroll off the
 	   screen too quickly.) */
