diff --exclude CVS -uNr mtd-utils/nanddump.c mtd-utils.modified/nanddump.c
--- mtd-utils/nanddump.c	2008-06-18 16:16:40.000000000 -0500
+++ mtd-utils.modified/nanddump.c	2009-04-14 17:30:46.000000000 -0500
@@ -121,7 +121,7 @@
 				omitbad = 1;
 				break;
 			case 's':
-				start_addr = strtol(optarg, NULL, 0);
+				start_addr = strtoul(optarg, NULL, 0);
 				break;
 			case 'f':
 				if (!(dumpfile = strdup(optarg))) {
@@ -133,7 +133,7 @@
 				ignoreerrors = 1;
 				break;
 			case 'l':
-				length = strtol(optarg, NULL, 0);
+				length = strtoul(optarg, NULL, 0);
 				break;
 			case 'o':
 				omitoob = 1;
@@ -159,8 +159,8 @@
 /*
  * Buffers for reading data from flash
  */
-unsigned char readbuf[2048];
-unsigned char oobbuf[64];
+unsigned char *readbuf;
+unsigned char *oobbuf;
 
 /*
  * Main program
@@ -170,7 +170,7 @@
 	unsigned long ofs, end_addr = 0;
 	unsigned long long blockstart = 1;
 	int ret, i, fd, ofd, bs, badblock = 0;
-	struct mtd_oob_buf oob = {0, 16, oobbuf};
+	struct mtd_oob_buf oob = {0, 16, 0};
 	mtd_info_t meminfo;
 	char pretty_buf[80];
 	int oobinfochanged = 0 ;
@@ -193,17 +193,19 @@
 		exit (1);
 	}
 
-	/* Make sure device page sizes are valid */
-	if (!(meminfo.oobsize == 64 && meminfo.writesize == 2048) &&
-			!(meminfo.oobsize == 32 && meminfo.writesize == 1024) &&
-			!(meminfo.oobsize == 16 && meminfo.writesize == 512) &&
-			!(meminfo.oobsize == 8 && meminfo.writesize == 256)) {
-		fprintf(stderr, "Unknown flash (not normal NAND)\n");
-		close(fd);
-		exit(1);
+	/* Allocate the page buffers. */
+	if (!(readbuf = malloc(meminfo.writesize))) {
+		perror ("Allocating writebuf");
+		exit (1);
+	}
+	if (!(oobbuf = malloc(meminfo.oobsize))) {
+		perror ("Allocating oobbuf");
+		exit (1);
 	}
-	/* Read the real oob length */
+
+	/* Fill in oob. */
 	oob.length = meminfo.oobsize;
+	oob.ptr    = oobbuf;
 
 	if (noecc)  {
 		ret = ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW);
@@ -236,9 +238,9 @@
 		if (!ioctl(fd, ECCGETSTATS, &stat1)) {
 			eccstats = 1;
 			fprintf(stderr, "ECC failed: %d\n", stat1.failed);
-			fprintf(stderr, "ECC corrected: %d\n", stat1.corrected);    
-			fprintf(stderr, "Number of bad blocks: %d\n", stat1.badblocks);    
-			fprintf(stderr, "Number of bbt blocks: %d\n", stat1.bbtblocks);    
+			fprintf(stderr, "ECC corrected: %d\n", stat1.corrected);
+			fprintf(stderr, "Number of bad blocks: %d\n", stat1.badblocks);
+			fprintf(stderr, "Number of bbt blocks: %d\n", stat1.bbtblocks);
 		} else
 			perror("No ECC status information available");
 	}
@@ -286,8 +288,12 @@
 			memset (readbuf, 0xff, bs);
 		} else {
 			/* Read page data and exit on failure */
-			if (pread(fd, readbuf, bs, ofs) != bs) {
-				perror("pread");
+			if (lseek64(fd, (off64_t) ofs, SEEK_SET) != ((off64_t) ofs)) {
+				perror("lseek64");
+				goto closeall;
+			}
+			if (read(fd, readbuf, bs) != bs) {
+				perror("read");
 				goto closeall;
 			}
 		}
diff --exclude CVS -uNr mtd-utils/nandtest.c mtd-utils.modified/nandtest.c
--- mtd-utils/nandtest.c	2008-06-18 16:16:40.000000000 -0500
+++ mtd-utils.modified/nandtest.c	2009-04-14 17:06:13.000000000 -0500
@@ -58,7 +58,12 @@
 	printf("\r%08x: writing...", (unsigned)ofs);
 	fflush(stdout);
 
-	len = pwrite(fd, data, meminfo.erasesize, ofs);
+	if (lseek64(fd, (off64_t) ofs, SEEK_SET) != ((off64_t) ofs)) {
+		printf("\n");
+		perror("lseek64");
+		return 1;
+	}
+	len = write(fd, data, meminfo.erasesize);
 	if (len < 0) {
 		printf("\n");
 		perror("write");
@@ -76,8 +81,13 @@
 
 	printf("\r%08x: reading...", (unsigned)ofs);
 	fflush(stdout);
-	
-	len = pread(fd, rbuf, meminfo.erasesize, ofs);
+
+	if (lseek64(fd, (off64_t) ofs, SEEK_SET) != ((off64_t) ofs)) {
+		printf("\n");
+		perror("lseek64");
+		exit(1);
+	}
+	len = read(fd, rbuf, meminfo.erasesize);
 	if (len < meminfo.erasesize) {
 		printf("\n");
 		if (len)
@@ -86,7 +96,7 @@
 			perror("read");
 		exit(1);
 	}
-		
+
 	if (ioctl(fd, ECCGETSTATS, &newstats)) {
 		printf("\n");
 		perror("ECCGETSTATS");
@@ -175,13 +185,13 @@
 			break;
 
 		case 'o':
-			offset = atol(optarg);
+			offset = strtoul(optarg, NULL, 0);
 			break;
 
 		case 'l':
 			length = strtol(optarg, NULL, 0);
 			break;
-			
+
 		}
 	}
 	if (argc - optind != 1)
@@ -192,7 +202,7 @@
 		perror("open");
 		exit(1);
 	}
-	
+
 	if (ioctl(fd, MEMGETINFO, &meminfo)) {
 		perror("MEMGETINFO");
 		close(fd);
@@ -203,20 +213,20 @@
 		length = meminfo.size;
 
 	if (offset % meminfo.erasesize) {
-		fprintf(stderr, "Offset %x not multiple of erase size %x\n", 
+		fprintf(stderr, "Offset %x not multiple of erase size %x\n",
 			offset, meminfo.erasesize);
 		exit(1);
 	}
 	if (length % meminfo.erasesize) {
-		fprintf(stderr, "Length %x not multiple of erase size %x\n", 
+		fprintf(stderr, "Length %x not multiple of erase size %x\n",
 			length, meminfo.erasesize);
 		exit(1);
 	}
 	if (length + offset > meminfo.size) {
-		fprintf(stderr, "Length %x + offset %x exceeds device size %x\n", 
+		fprintf(stderr, "Length %x + offset %x exceeds device size %x\n",
 			length, offset, meminfo.size);
 		exit(1);
-	}		
+	}
 
 	wbuf = malloc(meminfo.erasesize * 3);
 	if (!wbuf) {
@@ -259,6 +269,11 @@
 				printf("\r%08x: reading... ", (unsigned)test_ofs);
 				fflush(stdout);
 
+				if (lseek64(fd, (off64_t) test_ofs, SEEK_SET) != ((off64_t) test_ofs)) {
+					printf("\n");
+					perror("lseek64");
+					exit(1);
+				}
 				len = pread(fd, rbuf, meminfo.erasesize, test_ofs);
 				if (len < meminfo.erasesize) {
 					printf("\n");
diff --exclude CVS -uNr mtd-utils/nandwrite.c mtd-utils.modified/nandwrite.c
--- mtd-utils/nandwrite.c	2009-04-14 18:11:04.000000000 -0500
+++ mtd-utils.modified/nandwrite.c	2009-04-14 17:10:47.000000000 -0500
@@ -39,16 +39,12 @@
 #define PROGRAM "nandwrite"
 #define VERSION "$Revision: 1.32 $"
 
-/*add support for interleave support*/ 
-#define MAX_PAGE_SIZE	(4096 * 8)
-#define MAX_OOB_SIZE	(218 * 8)
-
 /*
  * Buffer array used for writing data
  */
-unsigned char writebuf[MAX_PAGE_SIZE];
-unsigned char oobbuf[MAX_OOB_SIZE];
-unsigned char oobreadbuf[MAX_OOB_SIZE];
+unsigned char *writebuf;
+unsigned char *oobbuf;
+unsigned char *oobreadbuf;
 
 // oob layouts to pass into the kernel as default
 struct nand_oobinfo none_oobinfo = {
@@ -222,8 +218,6 @@
 
 	process_options(argc, argv);
 
-	memset(oobbuf, 0xff, sizeof(oobbuf));
-
 	if (pad && writeoob) {
 		fprintf(stderr, "Can't pad when oob data is present.\n");
 		exit(1);
@@ -246,6 +240,25 @@
 	 * (virtual) block size */
 	meminfo.erasesize *= blockalign;
 
+	/* Allocate the page buffers. */
+
+	if (!(writebuf = malloc(meminfo.writesize))) {
+		perror ("Allocating writebuf");
+		exit (1);
+	}
+
+	if (!(oobbuf = malloc(meminfo.oobsize))) {
+		perror ("Allocating oobbuf");
+		exit (1);
+	}
+
+	if (!(oobreadbuf = malloc(meminfo.oobsize))) {
+		perror ("Allocating oobreadbuf");
+		exit (1);
+	}
+
+	memset(oobbuf, 0xff, sizeof(oobbuf));
+
 	if (autoplace) {
 		/* Read the current oob info */
 		if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
@@ -447,12 +460,16 @@
 		}
 
 		/* Write out the Page data */
-		if (pwrite(fd, writebuf, meminfo.writesize, mtdoffset) != meminfo.writesize) {
+		if (lseek64(fd, (off64_t) mtdoffset, SEEK_SET) != ((off64_t) mtdoffset)) {
+			perror("lseek64");
+			goto closeall;
+		}
+		if (write(fd, writebuf, meminfo.writesize) != meminfo.writesize) {
 			int rewind_blocks;
 			off_t rewind_bytes;
 			erase_info_t erase;
 
-			perror ("pwrite");
+			perror ("write");
 			/* Must rewind to blockstart if we can */
 			rewind_blocks = (mtdoffset - blockstart) / meminfo.writesize; /* Not including the one we just attempted */
 			rewind_bytes = (rewind_blocks * meminfo.writesize) + readlen;

