diff --git a/fs/yaffs2/direct/Makefile b/fs/yaffs2/direct/Makefile
new file mode 100644
index 0000000..6315117
--- /dev/null
+++ b/fs/yaffs2/direct/Makefile
@@ -0,0 +1,66 @@
+# Makefile for YAFFS direct test
+#
+#
+# YAFFS: Yet another Flash File System. A NAND-flash specific file system.
+#
+# Copyright (C) 2003 Aleph One Ltd.
+#
+#
+# Created by Charles Manning <charles@aleph1.co.uk>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# NB Warning this Makefile does not include header dependencies.
+#
+# $Id: Makefile,v 1.15 2007/07/18 19:40:38 charles Exp $
+
+#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
+
+CFLAGS =    -Wall -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 -g $(EXTRA_COMPILE_FLAGS) -DNO_Y_INLINE
+CFLAGS+=    -fstack-check -O0
+
+#CFLAGS+=   -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
+#CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
+
+
+DIRECTTESTOBJS = dtest.o yaffscfg2k.o yaffs_ecc.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
+		 yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
+		 yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
+		 yaffs_checkptrw.o  yaffs_qsort.o \
+#		 yaffs_checkptrwtest.o\
+		 
+
+BOOTTESTOBJS = bootldtst.o yboot.o yaffs_fileem.o nand_ecc.o
+
+#ALLOBJS =  dtest.o nand_ecc.o yaffscfg.o yaffs_fileem.o yaffsfs.o yaffs_ramdisk.o bootldtst.o yboot.o yaffs_ramem2k.o
+
+ALLOBJS = $(DIRECTTESTOBJS) $(BOOTTESTOBJS)
+
+SYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+          yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h  yaffs_nandemul2k.h \
+          yaffs_nand.c yaffs_nand.h \
+          yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
+          yaffs_qsort.c yaffs_qsort.h
+
+#all: directtest2k boottest
+
+all: directtest2k
+
+$(ALLOBJS): %.o: %.c
+	gcc -c $(CFLAGS) $< -o $@
+
+$(SYMLINKS):
+	ln -s ../$@ $@
+
+directtest2k: $(SYMLINKS) $(DIRECTTESTOBJS)
+	gcc -o $@ $(DIRECTTESTOBJS)
+
+
+boottest: $(SYMLINKS) $(BOOTTESTOBJS)
+	gcc -o $@ $(BOOTTESTOBJS)
+
+
+clean:
+	rm -f $(ALLOBJS) core
diff --git a/fs/yaffs2/direct/dtest.c b/fs/yaffs2/direct/dtest.c
new file mode 100644
index 0000000..be492b4
--- /dev/null
+++ b/fs/yaffs2/direct/dtest.c
@@ -0,0 +1,2280 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+* Test code for the "direct" interface. 
+*/
+
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "yaffsfs.h"
+
+void dumpDir(const char *dname);
+
+char xx[600];
+
+void copy_in_a_file(char *yaffsName,char *inName)
+{
+	int inh,outh;
+	unsigned char buffer[100];
+	int ni,no;
+	inh = open(inName,O_RDONLY);
+	outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
+	
+	while((ni = read(inh,buffer,100)) > 0)
+	{
+		no = yaffs_write(outh,buffer,ni);
+		if(ni != no)
+		{
+			printf("problem writing yaffs file\n");
+		}
+		
+	}
+	
+	yaffs_close(outh);
+	close(inh);
+}
+
+void make_a_file(char *yaffsName,char bval,int sizeOfFile)
+{
+	int outh;
+	int i;
+	unsigned char buffer[100];
+
+	outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
+	
+	memset(buffer,bval,100);
+	
+	do{
+		i = sizeOfFile;
+		if(i > 100) i = 100;
+		sizeOfFile -= i;
+		
+		yaffs_write(outh,buffer,i);
+		
+	} while (sizeOfFile > 0);
+	
+		
+	yaffs_close(outh);
+
+}
+
+void make_pattern_file(char *fn,int size)
+{
+	int outh;
+	int marker;
+	int i;
+	outh = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
+	yaffs_lseek(outh,size-1,SEEK_SET);
+	yaffs_write(outh,"A",1);
+	
+	for(i = 0; i < size; i+=256)
+	{
+		marker = ~i;
+		yaffs_lseek(outh,i,SEEK_SET);
+		yaffs_write(outh,&marker,sizeof(marker));
+	}
+	yaffs_close(outh);
+	
+}
+
+int check_pattern_file(char *fn)
+{
+	int h;
+	int marker;
+	int i;
+	int size;
+	int ok = 1;
+	
+	h = yaffs_open(fn, O_RDWR,0);
+	size = yaffs_lseek(h,0,SEEK_END);
+		
+	for(i = 0; i < size; i+=256)
+	{
+		yaffs_lseek(h,i,SEEK_SET);
+		yaffs_read(h,&marker,sizeof(marker));
+		ok = (marker == ~i);
+		if(!ok)
+		{
+		   printf("pattern check failed on file %s, size %d at position %d. Got %x instead of %x\n",
+					fn,size,i,marker,~i);
+		}
+	}
+	yaffs_close(h);
+	return ok;
+}
+
+
+
+
+
+int dump_file_data(char *fn)
+{
+	int h;
+	int marker;
+	int i = 0;
+	int size;
+	int ok = 1;
+	unsigned char b;
+	
+	h = yaffs_open(fn, O_RDWR,0);
+
+				
+	printf("%s\n",fn);
+	while(yaffs_read(h,&b,1)> 0)
+	{
+		printf("%02x",b);
+		i++;
+		if(i > 32) 
+		{
+		   printf("\n");
+		   i = 0;;
+		 }
+	}
+	printf("\n");
+	yaffs_close(h);
+	return ok;
+}
+
+
+
+void dump_file(const char *fn)
+{
+	int i;
+	int size;
+	int h;
+	
+	h = yaffs_open(fn,O_RDONLY,0);
+	if(h < 0)
+	{
+		printf("*****\nDump file %s does not exist\n",fn);
+	}
+	else
+	{
+		size = yaffs_lseek(h,0,SEEK_SET);
+		printf("*****\nDump file %s size %d\n",fn,size);
+		for(i = 0; i < size; i++)
+		{
+			
+		}
+	}
+}
+
+void create_file_of_size(const char *fn,int syze)
+{
+	int h;
+	int n;
+	
+	char xx[200];
+	
+	int iterations = (syze + strlen(fn) -1)/ strlen(fn);
+	
+	h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
+		
+	while (iterations > 0)
+	{
+		sprintf(xx,"%s %8d",fn,iterations);
+		yaffs_write(h,xx,strlen(xx));
+		iterations--;
+	}
+	yaffs_close (h);
+}
+
+void verify_file_of_size(const char *fn,int syze)
+{
+	int h;
+	int n;
+	
+	char xx[200];
+	char yy[200];
+	int l;
+	
+	int iterations = (syze + strlen(fn) -1)/ strlen(fn);
+	
+	h = yaffs_open(fn, O_RDONLY, S_IREAD | S_IWRITE);
+		
+	while (iterations > 0)
+	{
+		sprintf(xx,"%s %8d",fn,iterations);
+		l = strlen(xx);
+		
+		yaffs_read(h,yy,l);
+		yy[l] = 0;
+		
+		if(strcmp(xx,yy)){
+			printf("=====>>>>> verification of file %s failed near position %d\n",fn,yaffs_lseek(h,0,SEEK_CUR));
+		}
+		iterations--;
+	}
+	yaffs_close (h);
+}
+
+void create_resized_file_of_size(const char *fn,int syze1,int reSyze, int syze2)
+{
+	int h;
+	int n;
+	
+	
+	int iterations;
+	
+	h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
+		
+	iterations = (syze1 + strlen(fn) -1)/ strlen(fn);
+	while (iterations > 0)
+	{
+		yaffs_write(h,fn,strlen(fn));
+		iterations--;
+	}
+	
+	yaffs_truncate(h,reSyze);
+	
+	yaffs_lseek(h,0,SEEK_SET);
+	iterations = (syze2 + strlen(fn) -1)/ strlen(fn);
+	while (iterations > 0)
+	{
+		yaffs_write(h,fn,strlen(fn));
+		iterations--;
+	}
+	
+	yaffs_close (h);
+}
+
+
+void do_some_file_stuff(const char *path)
+{
+
+	char fn[100];
+
+	sprintf(fn,"%s/%s",path,"f1");
+	create_file_of_size(fn,10000);
+
+	sprintf(fn,"%s/%s",path,"fdel");
+	create_file_of_size(fn,10000);
+	yaffs_unlink(fn);
+
+	sprintf(fn,"%s/%s",path,"f2");
+	
+	create_resized_file_of_size(fn,10000,3000,4000);
+}
+
+void yaffs_backward_scan_test(const char *path)
+{
+	char fn[100];
+	
+	yaffs_StartUp();	
+	
+	yaffs_mount(path);
+	
+	do_some_file_stuff(path);
+	
+	sprintf(fn,"%s/ddd",path);
+	
+	yaffs_mkdir(fn,0);
+	
+	do_some_file_stuff(fn);
+	
+	yaffs_unmount(path);
+	
+	yaffs_mount(path);
+}
+
+char xxzz[2000];
+
+
+void yaffs_device_flush_test(const char *path)
+{
+	char fn[100];
+	int h;
+	int i;
+	
+	yaffs_StartUp();	
+	
+	yaffs_mount(path);
+	
+	do_some_file_stuff(path);
+	
+	// Open and add some data to a few files
+	for(i = 0; i < 10; i++) {
+	
+		sprintf(fn,"%s/ff%d",path,i);
+
+		h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IWRITE | S_IREAD);
+		yaffs_write(h,xxzz,2000);
+		yaffs_write(h,xxzz,2000);
+	}
+	yaffs_unmount(path);
+	
+	yaffs_mount(path);
+}
+
+
+
+void short_scan_test(const char *path, int fsize, int niterations)
+{
+	int i;
+	char fn[100];
+	
+	sprintf(fn,"%s/%s",path,"f1");
+	
+	yaffs_StartUp();
+	for(i = 0; i < niterations; i++)
+	{
+		printf("\n*****************\nIteration %d\n",i);
+		yaffs_mount(path);
+		printf("\nmount: Directory look-up of %s\n",path);
+		dumpDir(path);
+		make_a_file(fn,1,fsize);
+		yaffs_unmount(path);
+	}
+}
+
+
+
+void scan_pattern_test(const char *path, int fsize, int niterations)
+{
+	int i;
+	int j;
+	char fn[3][100];
+	int result;
+	
+	sprintf(fn[0],"%s/%s",path,"f0");
+	sprintf(fn[1],"%s/%s",path,"f1");
+	sprintf(fn[2],"%s/%s",path,"f2");
+	
+	yaffs_StartUp();
+	
+	for(i = 0; i < niterations; i++)
+	{
+		printf("\n*****************\nIteration %d\n",i);
+		yaffs_mount(path);
+		printf("\nmount: Directory look-up of %s\n",path);
+		dumpDir(path);
+		for(j = 0; j < 3; j++)
+		{
+			result = dump_file_data(fn[j]);
+			result = check_pattern_file(fn[j]);
+			make_pattern_file(fn[j],fsize); 
+			result = dump_file_data(fn[j]);
+			result = check_pattern_file(fn[j]);
+		}
+		yaffs_unmount(path);
+	}
+}
+
+void fill_disk(char *path,int nfiles)
+{
+	int h;
+	int n;
+	int result;
+	int f;
+	
+	char str[50];
+	
+	for(n = 0; n < nfiles; n++)
+	{
+		sprintf(str,"%s/%d",path,n);
+		
+		h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
+		
+		printf("writing file %s handle %d ",str, h);
+		
+		while ((result = yaffs_write(h,xx,600)) == 600)
+		{
+			f = yaffs_freespace(path);
+		}
+		result = yaffs_close(h);
+		printf(" close %d\n",result);
+	}
+}
+
+void fill_disk_and_delete(char *path, int nfiles, int ncycles)
+{
+	int i,j;
+	char str[50];
+	int result;
+	
+	for(i = 0; i < ncycles; i++)
+	{
+		printf("@@@@@@@@@@@@@@ cycle %d\n",i);
+		fill_disk(path,nfiles);
+		
+		for(j = 0; j < nfiles; j++)
+		{
+			sprintf(str,"%s/%d",path,j);
+			result = yaffs_unlink(str);
+			printf("unlinking file %s, result %d\n",str,result);
+		}
+	}
+}
+
+
+void fill_files(char *path,int flags, int maxIterations,int siz)
+{
+	int i;
+	int j;
+	char str[50];
+	int h;
+	
+	i = 0;
+	
+	do{
+		sprintf(str,"%s/%d",path,i);
+		h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
+		yaffs_close(h);
+
+		if(h >= 0)
+		{
+			for(j = 0; j < siz; j++)
+			{
+				yaffs_write(h,str,1);
+			}
+		}
+		
+		if( flags & 1)
+		{
+			yaffs_unlink(str);
+		}
+		i++;
+	} while(h >= 0 && i < maxIterations);
+	
+	if(flags & 2)
+	{
+		i = 0;
+		do{
+			sprintf(str,"%s/%d",path,i);
+			printf("unlink %s\n",str);
+			i++;
+		} while(yaffs_unlink(str) >= 0);
+	}
+}
+
+void leave_unlinked_file(char *path,int maxIterations,int siz)
+{
+	int i;
+	char str[50];
+	int h;
+	
+	i = 0;
+	
+	do{
+		sprintf(str,"%s/%d",path,i);
+		printf("create %s\n",str);
+		h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
+		if(h >= 0)
+		{
+			yaffs_unlink(str);
+		}
+		i++;
+	} while(h < 0 && i < maxIterations);
+	
+	if(h >= 0)
+	{
+		for(i = 0; i < siz; i++)
+		{
+			yaffs_write(h,str,1);
+		}
+	}
+	
+	printf("Leaving file %s open\n",str);
+
+}
+
+void dumpDirFollow(const char *dname)
+{
+	yaffs_DIR *d;
+	yaffs_dirent *de;
+	struct yaffs_stat s;
+	char str[100];
+			
+	d = yaffs_opendir(dname);
+	
+	if(!d)
+	{
+		printf("opendir failed\n");
+	}
+	else
+	{
+		while((de = yaffs_readdir(d)) != NULL)
+		{
+			sprintf(str,"%s/%s",dname,de->d_name);
+			
+			yaffs_stat(str,&s);
+			
+			printf("%s length %d mode %X ",de->d_name,(int)s.st_size,s.st_mode);
+			switch(s.st_mode & S_IFMT)
+			{
+				case S_IFREG: printf("data file"); break;
+				case S_IFDIR: printf("directory"); break;
+				case S_IFLNK: printf("symlink -->");
+							  if(yaffs_readlink(str,str,100) < 0)
+								printf("no alias");
+							  else
+								printf("\"%s\"",str);    
+							  break;
+				default: printf("unknown"); break;
+			}
+			
+			printf("\n");           
+		}
+		
+		yaffs_closedir(d);
+	}
+	printf("\n");
+	
+	printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
+
+}
+
+
+void dump_directory_tree_worker(const char *dname,int recursive)
+{
+	yaffs_DIR *d;
+	yaffs_dirent *de;
+	struct yaffs_stat s;
+	char str[1000];
+			
+	d = yaffs_opendir(dname);
+	
+	if(!d)
+	{
+		printf("opendir failed\n");
+	}
+	else
+	{
+		while((de = yaffs_readdir(d)) != NULL)
+		{
+			sprintf(str,"%s/%s",dname,de->d_name);
+			
+			yaffs_lstat(str,&s);
+			
+			printf("%s inode %d obj %x length %d mode %X ",str,s.st_ino,de->d_dont_use,(int)s.st_size,s.st_mode);
+			switch(s.st_mode & S_IFMT)
+			{
+				case S_IFREG: printf("data file"); break;
+				case S_IFDIR: printf("directory"); break;
+				case S_IFLNK: printf("symlink -->");
+							  if(yaffs_readlink(str,str,100) < 0)
+								printf("no alias");
+							  else
+								printf("\"%s\"",str);    
+							  break;
+				default: printf("unknown"); break;
+			}
+			
+			printf("\n");
+
+			if((s.st_mode & S_IFMT) == S_IFDIR && recursive)
+				dump_directory_tree_worker(str,1);
+							
+		}
+		
+		yaffs_closedir(d);
+	}
+
+}
+
+static void dump_directory_tree(const char *dname)
+{
+	dump_directory_tree_worker(dname,1);
+	printf("\n");
+	printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
+}
+
+void dumpDir(const char *dname)
+{	dump_directory_tree_worker(dname,0);
+	printf("\n");
+	printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
+}
+
+
+static void PermissionsCheck(const char *path, mode_t tmode, int tflags,int expectedResult)
+{
+	int fd;
+	
+	if(yaffs_chmod(path,tmode)< 0) printf("chmod failed\n");
+	
+	fd = yaffs_open(path,tflags,0);
+	
+	if((fd >= 0) != (expectedResult > 0))
+	{
+		printf("Permissions check %x %x %d failed\n",tmode,tflags,expectedResult);
+	}
+	else
+	{
+		printf("Permissions check %x %x %d OK\n",tmode,tflags,expectedResult);
+	}
+	
+	
+	yaffs_close(fd);
+	
+	
+}
+
+int long_test(int argc, char *argv[])
+{
+
+	int f;
+	int r;
+	char buffer[20];
+	
+	char str[100];
+	
+	int h;
+	mode_t temp_mode;
+	struct yaffs_stat ystat;
+	
+	yaffs_StartUp();
+	
+	yaffs_mount("/boot");
+	yaffs_mount("/data");
+	yaffs_mount("/flash");
+	yaffs_mount("/ram");
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	printf("\nDirectory look-up of /data\n");
+	dumpDir("/data");
+	printf("\nDirectory look-up of /flash\n");
+	dumpDir("/flash");
+
+	//leave_unlinked_file("/flash",20000,0);
+	//leave_unlinked_file("/data",20000,0);
+	
+	leave_unlinked_file("/ram",20,0);
+	
+
+	f = yaffs_open("/boot/b1", O_RDONLY,0);
+	
+	printf("open /boot/b1 readonly, f=%d\n",f);
+	
+	f = yaffs_open("/boot/b1", O_CREAT,S_IREAD | S_IWRITE);
+	
+	printf("open /boot/b1 O_CREAT, f=%d\n",f);
+	
+	
+	r = yaffs_write(f,"hello",1);
+	printf("write %d attempted to write to a read-only file\n",r);
+	
+	r = yaffs_close(f);
+	
+	printf("close %d\n",r);
+
+	f = yaffs_open("/boot/b1", O_RDWR,0);
+	
+	printf("open /boot/b1 O_RDWR,f=%d\n",f);
+	
+	
+	r = yaffs_write(f,"hello",2);
+	printf("write %d attempted to write to a writeable file\n",r);
+	r = yaffs_write(f,"world",3);
+	printf("write %d attempted to write to a writeable file\n",r);
+	
+	r= yaffs_lseek(f,0,SEEK_END);
+	printf("seek end %d\n",r);
+	memset(buffer,0,20);
+	r = yaffs_read(f,buffer,10);
+	printf("read %d \"%s\"\n",r,buffer);
+	r= yaffs_lseek(f,0,SEEK_SET);
+	printf("seek set %d\n",r);
+	memset(buffer,0,20);
+	r = yaffs_read(f,buffer,10);
+	printf("read %d \"%s\"\n",r,buffer);
+	memset(buffer,0,20);
+	r = yaffs_read(f,buffer,10);
+	printf("read %d \"%s\"\n",r,buffer);
+
+	// Check values reading at end.
+	// A read past end of file should return 0 for 0 bytes read.
+		
+	r= yaffs_lseek(f,0,SEEK_END);
+	r = yaffs_read(f,buffer,10);
+	printf("read at end returned  %d\n",r); 
+	r= yaffs_lseek(f,500,SEEK_END);
+	r = yaffs_read(f,buffer,10);
+	printf("read past end returned  %d\n",r);       
+	
+	r = yaffs_close(f);
+	
+	printf("close %d\n",r);
+	
+	copy_in_a_file("/boot/yyfile","xxx");
+	
+	// Create a file with a long name
+	
+	copy_in_a_file("/boot/file with a long name","xxx");
+	
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+
+	// Check stat
+	r = yaffs_stat("/boot/file with a long name",&ystat);
+	
+	// Check rename
+	
+	r = yaffs_rename("/boot/file with a long name","/boot/r1");
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	
+	// Check unlink
+	r = yaffs_unlink("/boot/r1");
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+
+	// Check mkdir
+	
+	r = yaffs_mkdir("/boot/directory1",0);
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	printf("\nDirectory look-up of /boot/directory1\n");
+	dumpDir("/boot/directory1");
+
+	// add a file to the directory                  
+	copy_in_a_file("/boot/directory1/file with a long name","xxx");
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	printf("\nDirectory look-up of /boot/directory1\n");
+	dumpDir("/boot/directory1");
+	
+	//  Attempt to delete directory (should fail)
+	
+	r = yaffs_rmdir("/boot/directory1");
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	printf("\nDirectory look-up of /boot/directory1\n");
+	dumpDir("/boot/directory1");
+	
+	// Delete file first, then rmdir should work
+	r = yaffs_unlink("/boot/directory1/file with a long name");
+	r = yaffs_rmdir("/boot/directory1");
+	
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	printf("\nDirectory look-up of /boot/directory1\n");
+	dumpDir("/boot/directory1");
+
+#if 0
+	fill_disk_and_delete("/boot",20,20);
+			
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+#endif
+
+	yaffs_symlink("yyfile","/boot/slink");
+	
+	yaffs_readlink("/boot/slink",str,100);
+	printf("symlink alias is %s\n",str);
+	
+	
+	
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	printf("\nDirectory look-up of /boot (using stat instead of lstat)\n");
+	dumpDirFollow("/boot");
+	printf("\nDirectory look-up of /boot/directory1\n");
+	dumpDir("/boot/directory1");
+
+	h = yaffs_open("/boot/slink",O_RDWR,0);
+	
+	printf("file length is %d\n",(int)yaffs_lseek(h,0,SEEK_END));
+	
+	yaffs_close(h);
+	
+	yaffs_unlink("/boot/slink");
+
+	
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	
+	// Check chmod
+	
+	yaffs_stat("/boot/yyfile",&ystat);
+	temp_mode = ystat.st_mode;
+	
+	yaffs_chmod("/boot/yyfile",0x55555);
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	
+	yaffs_chmod("/boot/yyfile",temp_mode);
+	printf("\nDirectory look-up of /boot\n");
+	dumpDir("/boot");
+	
+	// Permission checks...
+	PermissionsCheck("/boot/yyfile",0, O_WRONLY,0);
+	PermissionsCheck("/boot/yyfile",0, O_RDONLY,0);
+	PermissionsCheck("/boot/yyfile",0, O_RDWR,0);
+
+	PermissionsCheck("/boot/yyfile",S_IREAD, O_WRONLY,0);
+	PermissionsCheck("/boot/yyfile",S_IREAD, O_RDONLY,1);
+	PermissionsCheck("/boot/yyfile",S_IREAD, O_RDWR,0);
+
+	PermissionsCheck("/boot/yyfile",S_IWRITE, O_WRONLY,1);
+	PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDONLY,0);
+	PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDWR,0);
+	
+	PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_WRONLY,1);
+	PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDONLY,1);
+	PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDWR,1);
+
+	yaffs_chmod("/boot/yyfile",temp_mode);
+	
+	//create a zero-length file and unlink it (test for scan bug)
+	
+	h = yaffs_open("/boot/zlf",O_CREAT | O_TRUNC | O_RDWR,0);
+	yaffs_close(h);
+	
+	yaffs_unlink("/boot/zlf");
+	
+	
+	yaffs_DumpDevStruct("/boot");
+	
+	fill_disk_and_delete("/boot",20,20);
+	
+	yaffs_DumpDevStruct("/boot");
+	
+	fill_files("/boot",1,10000,0);
+	fill_files("/boot",1,10000,5000);
+	fill_files("/boot",2,10000,0);
+	fill_files("/boot",2,10000,5000);
+	
+	leave_unlinked_file("/data",20000,0);
+	leave_unlinked_file("/data",20000,5000);
+	leave_unlinked_file("/data",20000,5000);
+	leave_unlinked_file("/data",20000,5000);
+	leave_unlinked_file("/data",20000,5000);
+	leave_unlinked_file("/data",20000,5000);
+	
+	yaffs_DumpDevStruct("/boot");
+	yaffs_DumpDevStruct("/data");
+	
+		
+		
+	return 0;
+
+}
+
+int huge_directory_test_on_path(char *path)
+{
+
+	yaffs_DIR *d;
+	yaffs_dirent *de;
+	struct yaffs_stat s;
+
+	int f;
+	int i;
+	int r;
+	int total = 0;
+	int lastTotal = 0;
+	char buffer[20];
+	
+	char str[100];
+	char name[100];
+	char name2[100];
+	
+	int h;
+	mode_t temp_mode;
+	struct yaffs_stat ystat;
+	
+	yaffs_StartUp();
+	
+	yaffs_mount(path);
+	
+	// Create a large number of files
+	
+	for(i = 0; i < 2000; i++)
+	{
+	  sprintf(str,"%s/%d",path,i);
+	  
+	   f = yaffs_open(str,O_CREAT,S_IREAD | S_IWRITE);
+	   yaffs_close(f);
+	}
+	
+	
+	
+	d = yaffs_opendir(path);
+	i = 0;
+	if (d) {
+	while((de = yaffs_readdir(d)) != NULL) {
+	if (total >lastTotal+100*9*1024||(i & 1023)==0){
+	printf("files = %d, total = %d\n",i, total);
+	lastTotal = total;
+	}
+		i++;
+		sprintf(str,"%s/%s",path,de->d_name);
+		yaffs_lstat(str,&s);
+		switch(s.st_mode & S_IFMT){
+		case S_IFREG:
+	//printf("data file");
+	total += s.st_size;
+	break;
+	}
+	}
+	
+	yaffs_closedir(d);
+	}
+	
+	return 0;
+}
+
+int yaffs_scan_test(const char *path)
+{
+}
+
+
+void rename_over_test(const char *mountpt)
+{
+	int i;
+	char a[100];
+	char b[100];
+	
+	sprintf(a,"%s/a",mountpt);
+	sprintf(b,"%s/b",mountpt);
+	
+	yaffs_StartUp();
+	
+	yaffs_mount(mountpt);
+	i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0); 
+	yaffs_close(i);
+	i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR, 0);
+	yaffs_close(i);
+	yaffs_rename(a,b); // rename over
+	yaffs_rename(b,a); // rename back again (not renaimng over)
+	yaffs_rename(a,b); // rename back again (not renaimng over)
+	
+	
+	yaffs_unmount(mountpt);
+	
+}
+
+int resize_stress_test(const char *path)
+{
+   int a,b,i,j;
+   int x;
+   int r;
+   char aname[100];
+   char bname[100];
+   
+   char abuffer[1000];
+   char bbuffer[1000];
+   
+   yaffs_StartUp();
+   
+   yaffs_mount(path);
+   
+   sprintf(aname,"%s%s",path,"/a");
+   sprintf(bname,"%s%s",path,"/b");
+   
+   memset(abuffer,'a',1000);
+   memset(bbuffer,'b',1000);
+   
+   a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+   b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+   
+   printf(" %s %d %s %d\n",aname,a,bname,b);
+  
+   x = 0;
+   
+   for(j = 0; j < 100; j++)
+   {
+		yaffs_lseek(a,0,SEEK_END);
+
+		
+		for(i = 0; i <20000; i++)
+		{
+		   //r =        yaffs_lseek(b,i,SEEK_SET);
+			//r = yaffs_write(b,bbuffer,1000);
+			
+			if(x & 0x16)
+			{
+				// shrink
+				int syz = yaffs_lseek(a,0,SEEK_END);
+				
+				syz -= 500;
+				if(syz < 0) syz = 0;
+				yaffs_truncate(a,syz);
+				
+			}
+			else
+			{
+				//expand
+				r = yaffs_lseek(a,i * 500,SEEK_SET);
+				r = yaffs_write(a,abuffer,1000);
+			}
+			x++;
+			
+		}
+   }
+   
+   return 0;
+   
+}
+
+
+int resize_stress_test_no_grow_complex(const char *path,int iters)
+{
+   int a,b,i,j;
+   int x;
+   int r;
+   char aname[100];
+   char bname[100];
+   
+   char abuffer[1000];
+   char bbuffer[1000];
+   
+   yaffs_StartUp();
+   
+   yaffs_mount(path);
+   
+   sprintf(aname,"%s%s",path,"/a");
+   sprintf(bname,"%s%s",path,"/b");
+   
+   memset(abuffer,'a',1000);
+   memset(bbuffer,'b',1000);
+   
+   a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+   b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+   
+   printf(" %s %d %s %d\n",aname,a,bname,b);
+  
+   x = 0;
+   
+   for(j = 0; j < iters; j++)
+   {
+		yaffs_lseek(a,0,SEEK_END);
+
+		
+		for(i = 0; i <20000; i++)
+		{
+		   //r =        yaffs_lseek(b,i,SEEK_SET);
+			//r = yaffs_write(b,bbuffer,1000);
+			
+			if(!(x%20))
+			{
+				// shrink
+				int syz = yaffs_lseek(a,0,SEEK_END);
+				
+				while(syz > 4000)
+				{
+				
+					syz -= 2050;
+					if(syz < 0) syz = 0;
+					yaffs_truncate(a,syz);
+					syz = yaffs_lseek(a,0,SEEK_END);
+					printf("shrink to %d\n",syz);
+				}
+				
+				
+			}
+			else
+			{
+				//expand
+				r = yaffs_lseek(a,500,SEEK_END);
+				r = yaffs_write(a,abuffer,1000);
+			}
+			x++;
+			
+					
+		}
+		printf("file size is %d\n",yaffs_lseek(a,0,SEEK_END));
+
+   }
+   
+   return 0;
+   
+}
+
+int resize_stress_test_no_grow(const char *path,int iters)
+{
+   int a,b,i,j;
+   int x;
+   int r;
+   char aname[100];
+   char bname[100];
+   
+   char abuffer[1000];
+   char bbuffer[1000];
+   
+   yaffs_StartUp();
+   
+   yaffs_mount(path);
+   
+   sprintf(aname,"%s%s",path,"/a");
+   sprintf(bname,"%s%s",path,"/b");
+   
+   memset(abuffer,'a',1000);
+   memset(bbuffer,'b',1000);
+   
+   a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+   b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+   
+   printf(" %s %d %s %d\n",aname,a,bname,b);
+  
+   x = 0;
+   
+   for(j = 0; j < iters; j++)
+   {
+		yaffs_lseek(a,0,SEEK_END);
+
+		
+		for(i = 0; i <20000; i++)
+		{
+		   //r =        yaffs_lseek(b,i,SEEK_SET);
+			//r = yaffs_write(b,bbuffer,1000);
+			
+			if(!(x%20))
+			{
+				// shrink
+				int syz = yaffs_lseek(a,0,SEEK_END);
+				
+				while(syz > 4000)
+				{
+				
+					syz -= 2050;
+					if(syz < 0) syz = 0;
+					yaffs_truncate(a,syz);
+					syz = yaffs_lseek(a,0,SEEK_END);
+					printf("shrink to %d\n",syz);
+				}
+				
+				
+			}
+			else
+			{
+				//expand
+				r = yaffs_lseek(a,-500,SEEK_END);
+				r = yaffs_write(a,abuffer,1000);
+			}
+			x++;
+			
+					
+		}
+		printf("file size is %d\n",yaffs_lseek(a,0,SEEK_END));
+
+   }
+   
+   return 0;
+   
+}
+
+int directory_rename_test(void)
+{
+	int r;
+	yaffs_StartUp();
+	
+	yaffs_mount("/ram");
+	yaffs_mkdir("/ram/a",0);
+	yaffs_mkdir("/ram/a/b",0);
+	yaffs_mkdir("/ram/c",0);
+	
+	printf("\nDirectory look-up of /ram\n");
+	dumpDir("/ram");
+	dumpDir("/ram/a");
+	dumpDir("/ram/a/b");
+
+	printf("Do rename (should fail)\n");
+		
+	r = yaffs_rename("/ram/a","/ram/a/b/d");
+	printf("\nDirectory look-up of /ram\n");
+	dumpDir("/ram");
+	dumpDir("/ram/a");
+	dumpDir("/ram/a/b");
+
+	printf("Do rename (should not fail)\n");
+		
+	r = yaffs_rename("/ram/c","/ram/a/b/d");
+	printf("\nDirectory look-up of /ram\n");
+	dumpDir("/ram");
+	dumpDir("/ram/a");
+	dumpDir("/ram/a/b");
+	
+	
+	return 1;
+	
+}
+
+int cache_read_test(void)
+{
+	int a,b,c;
+	int i;
+	int sizeOfFiles = 500000;
+	char buffer[100];
+	
+	yaffs_StartUp();
+	
+	yaffs_mount("/boot");
+	
+	make_a_file("/boot/a",'a',sizeOfFiles);
+	make_a_file("/boot/b",'b',sizeOfFiles);
+
+	a = yaffs_open("/boot/a",O_RDONLY,0);
+	b = yaffs_open("/boot/b",O_RDONLY,0);
+	c = yaffs_open("/boot/c", O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
+
+	do{
+		i = sizeOfFiles;
+		if (i > 100) i = 100;
+		sizeOfFiles  -= i;
+		yaffs_read(a,buffer,i);
+		yaffs_read(b,buffer,i);
+		yaffs_write(c,buffer,i);
+	} while(sizeOfFiles > 0);
+	
+	
+	
+	return 1;
+	
+}
+
+int cache_bypass_bug_test(void)
+{
+	// This test reporoduces a bug whereby YAFFS caching *was* buypassed
+	// resulting in erroneous reads after writes.
+	// This bug has been fixed.
+	
+	int a;
+	int i;
+	char buffer1[1000];
+	char buffer2[1000];
+	
+	memset(buffer1,0,sizeof(buffer1));
+	memset(buffer2,0,sizeof(buffer2));
+		
+	yaffs_StartUp();
+	
+	yaffs_mount("/boot");
+	
+	// Create a file of 2000 bytes.
+	make_a_file("/boot/a",'X',2000);
+
+	a = yaffs_open("/boot/a",O_RDWR, S_IREAD | S_IWRITE);
+	
+	// Write a short sequence to the file.
+	// This will go into the cache.
+	yaffs_lseek(a,0,SEEK_SET);
+	yaffs_write(a,"abcdefghijklmnopqrstuvwxyz",20); 
+
+	// Read a short sequence from the file.
+	// This will come from the cache.
+	yaffs_lseek(a,0,SEEK_SET);
+	yaffs_read(a,buffer1,30); 
+
+	// Read a page size sequence from the file.
+	yaffs_lseek(a,0,SEEK_SET);
+	yaffs_read(a,buffer2,512); 
+	
+	printf("buffer 1 %s\n",buffer1);
+	printf("buffer 2 %s\n",buffer2);
+	
+	if(strncmp(buffer1,buffer2,20))
+	{
+		printf("Cache bypass bug detected!!!!!\n");
+	}
+	
+	
+	return 1;
+}
+
+
+int free_space_check(void)
+{
+	int f;
+	
+		yaffs_StartUp();
+		yaffs_mount("/boot");
+	    fill_disk("/boot/",2);
+	    f = yaffs_freespace("/boot");
+	    
+	    printf("%d free when disk full\n",f);           
+	    return 1;
+}
+
+int truncate_test(void)
+{
+	int a;
+	int r;
+	int i;
+	int l;
+
+	char y[10];
+
+	yaffs_StartUp();
+	yaffs_mount("/boot");
+
+	yaffs_unlink("/boot/trunctest");
+	
+	a = yaffs_open("/boot/trunctest", O_CREAT | O_TRUNC | O_RDWR,  S_IREAD | S_IWRITE);
+	
+	yaffs_write(a,"abcdefghijklmnopqrstuvwzyz",26);
+	
+	yaffs_truncate(a,3);
+	l= yaffs_lseek(a,0,SEEK_END);
+	
+	printf("truncated length is %d\n",l);
+
+	yaffs_lseek(a,5,SEEK_SET);
+	yaffs_write(a,"1",1);
+
+	yaffs_lseek(a,0,SEEK_SET);
+	
+	r = yaffs_read(a,y,10);
+
+	printf("read %d bytes:",r);
+
+	for(i = 0; i < r; i++) printf("[%02X]",y[i]);
+
+	printf("\n");
+
+	return 0;
+
+}
+
+
+
+
+
+void fill_disk_test(const char *mountpt)
+{
+	int i;
+	yaffs_StartUp();
+	
+	for(i = 0; i < 5; i++)
+	{
+		yaffs_mount(mountpt);
+		fill_disk_and_delete(mountpt,100,i+1);
+		yaffs_unmount(mountpt);
+	}
+	
+}
+
+
+
+void lookup_test(const char *mountpt)
+{
+	int i;
+	int h;
+	char a[100];
+	char b[100];
+	
+
+	yaffs_DIR *d;
+	yaffs_dirent *de;
+	struct yaffs_stat s;
+	char str[100];
+
+	yaffs_StartUp();
+	
+	yaffs_mount(mountpt);
+				
+	d = yaffs_opendir(mountpt);
+	
+	if(!d)
+	{
+		printf("opendir failed\n");
+	}
+	else
+	{
+		
+		for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
+		{
+			printf("unlinking %s\n",de->d_name);
+			yaffs_unlink(de->d_name);
+		}
+		
+		printf("%d files deleted\n",i);
+	}
+	
+	
+	for(i = 0; i < 2000; i++){
+	sprintf(a,"%s/%d",mountpt,i);
+		h =  yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0);
+		yaffs_close(h);
+	}
+
+	yaffs_rewinddir(d);
+	for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
+	{
+		printf("%d  %s\n",i,de->d_name);
+	}	
+	
+	printf("%d files listed\n\n\n",i);
+	
+	yaffs_rewinddir(d);
+	yaffs_readdir(d);
+	yaffs_readdir(d);
+	yaffs_readdir(d);
+	
+	for(i = 0; i < 2000; i++){
+		sprintf(a,"%s/%d",mountpt,i);
+		yaffs_unlink(a);
+	}
+	
+		
+	yaffs_unmount(mountpt);
+	
+}
+
+void link_test(const char *mountpt)
+{
+	int i;
+	int h;
+	char a[100];
+	char b[100];
+	char c[100];
+	
+	int  f0;
+	int f1;
+	int f2;
+	int f3;
+	sprintf(a,"%s/aaa",mountpt);
+	sprintf(b,"%s/bbb",mountpt);
+	sprintf(c,"%s/ccc",mountpt);
+	
+	yaffs_StartUp();
+	
+	yaffs_mount(mountpt);
+	
+	
+	h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+	for(i = 0; i < 100; i++)
+		yaffs_write(h,a,100);
+	
+	yaffs_close(h);
+	
+	yaffs_unlink(b);
+	yaffs_unlink(c);
+	yaffs_link(a,b);
+	yaffs_link(a,c);
+	yaffs_unlink(b);
+	yaffs_unlink(c);
+	yaffs_unlink(a);
+	
+	
+	yaffs_unmount(mountpt);
+	yaffs_mount(mountpt);
+	
+	printf("link test done\n");	
+	
+}
+
+void freespace_test(const char *mountpt)
+{
+	int i;
+	int h;
+	char a[100];
+	char b[100];
+	
+	int  f0;
+	int f1;
+	int f2;
+	int f3;
+	sprintf(a,"%s/aaa",mountpt);
+	
+	yaffs_StartUp();
+	
+	yaffs_mount(mountpt);
+	
+	f0 = yaffs_freespace(mountpt);
+	
+	h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+	
+	for(i = 0; i < 100; i++)
+		yaffs_write(h,a,100);
+	
+	yaffs_close(h);
+	
+	f1 = yaffs_freespace(mountpt);
+	
+	yaffs_unlink(a);
+	
+	f2 = yaffs_freespace(mountpt);
+	
+		
+	yaffs_unmount(mountpt);
+	yaffs_mount(mountpt);
+	
+	f3 = yaffs_freespace(mountpt);
+	
+	printf("%d\n%d\n%d\n%d\n",f0, f1,f2,f3);
+	
+	
+}
+
+void simple_rw_test(const char *mountpt)
+{
+	int i;
+	int h;
+	char a[100];
+	
+	int x;
+	int result;
+
+	sprintf(a,"%s/aaa",mountpt);
+	
+	yaffs_StartUp();
+	
+	yaffs_mount(mountpt);
+	
+	yaffs_unlink(a);
+	
+	h = yaffs_open(a,O_CREAT| O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+	
+	for(i = 100000;i < 200000; i++){
+		result = yaffs_write(h,&i,sizeof(i));
+		
+		if(result != 4)
+		{
+			printf("write error\n");
+			exit(1);
+		}
+	}
+	
+	//yaffs_close(h);
+	
+	// h = yaffs_open(a,O_RDWR, S_IREAD | S_IWRITE);
+	
+	
+	yaffs_lseek(h,0,SEEK_SET);
+	
+	for(i = 100000; i < 200000; i++){
+		result = yaffs_read(h,&x,sizeof(x));
+		
+		if(result != 4 || x != i){
+			printf("read error %d %x %x\n",i,result,x);
+		}
+	}
+	
+	printf("Simple rw test passed\n");
+	
+	
+	
+}
+
+
+void scan_deleted_files_test(const char *mountpt)
+{
+	char fn[100];
+	char sub[100];
+	
+	const char *p;
+	
+	int i;
+	int j;
+	int k;
+	int h;
+	
+	sprintf(sub,"%s/sdir",mountpt);
+	yaffs_StartUp();
+	
+	for(j = 0; j < 10; j++)
+	{
+		printf("\n\n>>>>>>> Run %d <<<<<<<<<<<<<\n\n",j);
+		yaffs_mount(mountpt);
+		yaffs_mkdir(sub,0);
+		
+		
+		p = (j & 0) ? mountpt: sub;
+	
+		for(i = 0; i < 100; i++)
+		{
+		  sprintf(fn,"%s/%d",p,i);  
+		  
+		  if(i & 1)
+		  {
+			  h = yaffs_open(fn,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+			  for(k = 0; k < 1000; k++)
+				  yaffs_write(h,fn,100);
+			  yaffs_close(h);
+		  }
+		  else
+		    	yaffs_mkdir(fn,0);
+		}
+		
+		for(i = 0; i < 10; i++)
+		{
+		  sprintf(fn,"%s/%d",p,i);  
+		  if(i & 1) 
+		  	yaffs_unlink(fn);
+		  else
+		  	yaffs_rmdir(fn);
+		  
+		}
+				
+		yaffs_unmount(mountpt);
+	}
+	
+	
+	
+
+}
+
+
+void write_10k(int h)
+{
+   int i;
+   const char *s="0123456789";
+   for(i = 0; i < 1000; i++)
+     yaffs_write(h,s,10);
+
+}
+void write_200k_file(const char *fn, const char *fdel, const char *fdel1)
+{
+   int h1;
+   int i;
+   int offs;
+   
+   h1 = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+   
+   for(i = 0; i < 100000; i+= 10000)
+   {
+   	write_10k(h1);
+   }
+   
+   offs = yaffs_lseek(h1,0,SEEK_CUR);
+   if( offs != 100000)
+   {
+   	printf("Could not write file\n");
+   }
+   
+   yaffs_unlink(fdel);
+   for(i = 0; i < 100000; i+= 10000)
+   {
+   	write_10k(h1);
+   }
+   
+   offs = yaffs_lseek(h1,0,SEEK_CUR);
+   if( offs != 200000)
+   {
+   	printf("Could not write file\n");
+   }
+   
+   yaffs_close(h1);
+   yaffs_unlink(fdel1);
+   
+}
+
+
+void verify_200k_file(const char *fn)
+{
+   int h1;
+   int i;
+   char x[11];
+   const char *s="0123456789";
+   int errCount = 0;
+   
+   h1 = yaffs_open(fn, O_RDONLY, 0);
+   
+   for(i = 0; i < 200000 && errCount < 10; i+= 10)
+   {
+   	yaffs_read(h1,x,10);
+	if(strncmp(x,s,10) != 0)
+	{
+		printf("File %s verification failed at %d\n",fn,i);
+		errCount++;
+	}
+   }
+   if(errCount >= 10)
+   	printf("Too many errors... aborted\n");
+      
+   yaffs_close(h1);	   
+	
+}
+
+
+void check_resize_gc_bug(const char *mountpt)
+{
+
+	char a[30];
+	char b[30];
+	char c[30];
+	
+	int i;
+	
+	sprintf(a,"%s/a",mountpt);
+	sprintf(b,"%s/b",mountpt);
+	sprintf(c,"%s/c",mountpt);
+	
+
+	
+	
+	yaffs_StartUp();
+	yaffs_mount(mountpt);
+	yaffs_unlink(a);
+	yaffs_unlink(b);
+	
+	for(i = 0; i < 50; i++)
+	{  
+	   printf("A\n");write_200k_file(a,"",c);
+	   printf("B\n");verify_200k_file(a);
+	   printf("C\n");write_200k_file(b,a,c);
+	   printf("D\n");verify_200k_file(b);
+	   yaffs_unmount(mountpt);
+	   yaffs_mount(mountpt);
+	   printf("E\n");verify_200k_file(a);
+	   printf("F\n");verify_200k_file(b);
+	}
+		
+}
+
+
+void multi_mount_test(const char *mountpt,int nmounts)
+{
+
+	char a[30];
+	char b[30];
+	char c[30];
+	
+	int i;
+	int j;
+	
+	sprintf(a,"%s/a",mountpt);
+
+	yaffs_StartUp();
+	
+	for(i = 0; i < nmounts; i++){
+		int h0;
+		int h1;
+		int len0;
+		int len1;
+		
+		static char xx[1000];
+		
+		printf("############### Iteration %d   Start\n",i);
+		if(1 || i == 0 || i == 5) 
+			yaffs_mount(mountpt);
+
+		dump_directory_tree(mountpt);
+		
+		
+		yaffs_mkdir(a,0);
+		
+		sprintf(xx,"%s/0",a);
+		h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+		
+		sprintf(xx,"%s/1",a);
+		h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+		
+		for(j = 0; j < 200; j++){
+		   yaffs_write(h0,xx,1000);
+		   yaffs_write(h1,xx,1000);
+		}
+		
+		len0 = yaffs_lseek(h0,0,SEEK_END);
+		len1 = yaffs_lseek(h1,0,SEEK_END);
+		
+		yaffs_lseek(h0,0,SEEK_SET);
+		yaffs_lseek(h1,0,SEEK_SET);
+
+		for(j = 0; j < 200; j++){
+		   yaffs_read(h0,xx,1000);
+		   yaffs_read(h1,xx,1000);
+		}
+		
+		
+		yaffs_truncate(h0,0);
+		yaffs_close(h0);
+		yaffs_close(h1);
+		
+		printf("########### %d\n",i);
+		dump_directory_tree(mountpt);
+
+		if(1 || i == 4 || i == nmounts -1)
+			yaffs_unmount(mountpt);
+	}
+}
+
+
+void small_mount_test(const char *mountpt,int nmounts)
+{
+
+	char a[30];
+	char b[30];
+	char c[30];
+	
+	int i;
+	int j;
+
+	int h0;
+	int h1;
+	int len0;
+	int len1;
+	int nread;
+	
+	sprintf(a,"%s/a",mountpt);
+
+	yaffs_StartUp();
+	
+	
+	
+	for(i = 0; i < nmounts; i++){
+		
+		static char xx[1000];
+		
+		printf("############### Iteration %d   Start\n",i);
+		if(1 || i == 0 || i == 5) 
+			yaffs_mount(mountpt);
+
+		dump_directory_tree(mountpt);
+		
+		yaffs_mkdir(a,0);
+		
+		sprintf(xx,"%s/0",a);
+		if(i ==0){
+		
+			h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+			for(j = 0; j < 130; j++)
+				yaffs_write(h0,xx,1000);
+			yaffs_close(h0);
+		}
+		
+		h0 = yaffs_open(xx,O_RDONLY,0);
+		
+		sprintf(xx,"%s/1",a);
+		h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+		
+		while((nread = yaffs_read(h0,xx,1000)) > 0)
+			yaffs_write(h1,xx,nread);
+		
+		
+		len0 = yaffs_lseek(h0,0,SEEK_END);
+		len1 = yaffs_lseek(h1,0,SEEK_END);
+		
+		yaffs_lseek(h0,0,SEEK_SET);
+		yaffs_lseek(h1,0,SEEK_SET);
+
+		for(j = 0; j < 200; j++){
+		   yaffs_read(h0,xx,1000);
+		   yaffs_read(h1,xx,1000);
+		}
+		
+		yaffs_close(h0);
+		yaffs_close(h1);
+		
+		printf("########### %d\n",i);
+		dump_directory_tree(mountpt);
+
+		if(1 || i == 4 || i == nmounts -1)
+			yaffs_unmount(mountpt);
+	}
+}
+
+
+int early_exit;
+
+void small_overwrite_test(const char *mountpt,int nmounts)
+{
+
+	char a[30];
+	char b[30];
+	char c[30];
+	
+	int i;
+	int j;
+
+	int h0;
+	int h1;
+	int len0;
+	int len1;
+	int nread;
+	
+	sprintf(a,"%s/a",mountpt);
+
+	yaffs_StartUp();
+	
+	
+	
+	for(i = 0; i < nmounts; i++){
+		
+		static char xx[8000];
+		
+		printf("############### Iteration %d   Start\n",i);
+		if(1)
+			yaffs_mount(mountpt);
+
+		dump_directory_tree(mountpt);
+		
+		yaffs_mkdir(a,0);
+		
+		sprintf(xx,"%s/0",a);
+		h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+		sprintf(xx,"%s/1",a);
+		h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+		
+		for(j = 0; j < 1000000; j+=1000){
+			yaffs_truncate(h0,j);
+			yaffs_lseek(h0,j,SEEK_SET);
+			yaffs_write(h0,xx,7000);
+			yaffs_write(h1,xx,7000);
+			
+			if(early_exit)
+				exit(0);
+		}
+		
+		yaffs_close(h0);
+		
+		printf("########### %d\n",i);
+		dump_directory_tree(mountpt);
+
+		if(1)
+			yaffs_unmount(mountpt);
+	}
+}
+
+
+void yaffs_touch(const char *fn)
+{
+	yaffs_chmod(fn, S_IREAD | S_IWRITE);
+}
+
+void checkpoint_fill_test(const char *mountpt,int nmounts)
+{
+
+	char a[50];
+	char b[50];
+	char c[50];
+	
+	int i;
+	int j;
+	int h;
+	
+	sprintf(a,"%s/a",mountpt);
+	
+
+	
+	
+	yaffs_StartUp();
+	
+	for(i = 0; i < nmounts; i++){
+		printf("############### Iteration %d   Start\n",i);
+		yaffs_mount(mountpt);
+		dump_directory_tree(mountpt);
+		yaffs_mkdir(a,0);
+		
+		sprintf(b,"%s/zz",a);
+		
+		h = yaffs_open(b,O_CREAT | O_RDWR,S_IREAD |S_IWRITE);
+		
+		
+		while(yaffs_write(h,c,50) == 50){}
+		
+		yaffs_close(h);
+		
+		for(j = 0; j < 2; j++){
+			printf("touch %d\n",j);
+			yaffs_touch(b);
+			yaffs_unmount(mountpt);
+			yaffs_mount(mountpt);
+		}
+
+		dump_directory_tree(mountpt);		
+		yaffs_unmount(mountpt);
+	}
+}
+
+
+int make_file2(const char *name1, const char *name2,int syz)
+{
+
+	char xx[2500];
+	int i;
+	int h1=-1,h2=-1;
+	int n = 1;
+
+
+	if(name1)
+		h1 = yaffs_open(name1,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+	if(name2)
+		h2 = yaffs_open(name2,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+	
+	while(syz > 0 && n > 0){
+		i = (syz > 2500) ? 2500 : syz;
+		n = yaffs_write(h1,xx,i);
+		n = yaffs_write(h2,xx,i);
+		syz -= 500;
+	}
+	yaffs_close(h1);
+	yaffs_close(h2);
+	
+}
+
+
+extern void SetCheckpointReservedBlocks(int n);
+
+void checkpoint_upgrade_test(const char *mountpt,int nmounts)
+{
+
+	char a[50];
+	char b[50];
+	char c[50];
+	char d[50];
+	
+	int i;
+	int j;
+	int h;
+	
+	sprintf(a,"%s/a",mountpt);
+	
+
+	
+	
+	printf("Create start condition\n");
+	yaffs_StartUp();
+	SetCheckpointReservedBlocks(0);
+	yaffs_mount(mountpt);
+	yaffs_mkdir(a,0);
+	sprintf(b,"%s/zz",a);
+	sprintf(c,"%s/xx",a);
+	make_file2(b,c,2000000);
+	sprintf(d,"%s/aa",a);
+	make_file2(d,NULL,500000000);
+	dump_directory_tree(mountpt);
+	
+	printf("Umount/mount attempt full\n");
+	yaffs_unmount(mountpt);
+	
+	SetCheckpointReservedBlocks(10);
+	yaffs_mount(mountpt);
+	
+	printf("unlink small file\n");
+	yaffs_unlink(c);
+	dump_directory_tree(mountpt);
+		
+	printf("Umount/mount attempt\n");
+	yaffs_unmount(mountpt);
+	yaffs_mount(mountpt);
+	
+	for(j = 0; j < 500; j++){
+		printf("***** touch %d\n",j);
+		dump_directory_tree(mountpt);
+		yaffs_touch(b);
+		yaffs_unmount(mountpt);
+		yaffs_mount(mountpt);
+	}
+
+	for(j = 0; j < 500; j++){
+		printf("***** touch %d\n",j);
+		dump_directory_tree(mountpt);
+		yaffs_touch(b);
+		yaffs_unmount(mountpt);
+		yaffs_mount(mountpt);
+	}
+}
+	
+void huge_array_test(const char *mountpt,int n)
+{
+
+	char a[50];
+
+	
+	int i;
+	int j;
+	int h;
+	
+	int fnum;
+	
+	sprintf(a,"mount point %s",mountpt);
+	
+
+	
+	yaffs_StartUp();
+
+	yaffs_mount(mountpt);
+	
+	while(n>0){
+		n--;
+		fnum = 0;
+		printf("\n\n START run\n\n");
+		while(yaffs_freespace(mountpt) > 25000000){
+			sprintf(a,"%s/file%d",mountpt,fnum);
+			fnum++;
+			printf("create file %s\n",a);
+			create_file_of_size(a,10000000);
+			printf("verifying file %s\n",a);
+			verify_file_of_size(a,10000000);
+		}
+		
+		printf("\n\n verification/deletion\n\n");
+		
+		for(i = 0; i < fnum; i++){
+			sprintf(a,"%s/file%d",mountpt,i);
+			printf("verifying file %s\n",a);
+			verify_file_of_size(a,10000000);
+			printf("deleting file %s\n",a);
+			yaffs_unlink(a);
+		}
+		printf("\n\n done \n\n");
+			
+		   
+	}
+}
+
+
+void random_write(int h)
+{
+	static char buffer[12000];
+	int n;
+	
+	n = random() & 0x1FFF;
+	yaffs_write(h,buffer,n);
+}
+
+void random_seek(int h)
+{
+	int n;
+	n = random() & 0xFFFFF;
+	yaffs_lseek(h,n,SEEK_SET);
+}
+
+void random_truncate(int h, char * name)
+{
+	int n;
+	int flen;
+	n = random() & 0xFFFFF;
+	flen = yaffs_lseek(h,0,SEEK_END);
+	if(n > flen)
+		n = flen / 2;
+	yaffs_truncate(name,n);
+	yaffs_lseek(h,n,SEEK_SET);
+}
+
+
+#define NSMALLFILES 10	
+void random_small_file_test(const char *mountpt,int iterations)
+{
+
+	char a[NSMALLFILES][50];
+
+	
+	int i;
+	int n;
+	int j;
+	int h[NSMALLFILES];
+	int r;
+	int fnum;
+	
+	
+	yaffs_StartUp();
+
+	yaffs_mount(mountpt);
+	
+	for(i = 0; i < NSMALLFILES; i++){
+		h[i]=-1;
+		strcpy(a[i],"");
+	}
+	
+	for(n = 0; n < iterations; n++){
+				
+		for(i = 0; i < NSMALLFILES; i++) {
+			r = random();
+			
+			if(strlen(a[i]) == 0){
+				sprintf(a[i],"%s/%dx%d",mountpt,n,i);
+				h[i] = yaffs_open(a,O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
+			}
+			
+			if(h[i] < -1)
+				printf("Could not open yaffs file %d %d error %d\n",n,i,h[i]);
+			else {
+				r = r & 7;
+				switch(r){
+					case 0:
+					case 1:
+					case 2:
+						random_write(h[i]);
+						break;
+					case 3:
+						random_truncate(h[i],a[i]);
+						break;
+					case 4:
+					case 5:	random_seek(h[i]);
+						break;
+					case 6:
+						yaffs_close(h[i]);
+						h[i] = -1;
+						break;
+					case 7:
+						yaffs_close(h[i]);
+						yaffs_unlink(a[i]);
+						strcpy(a[i],"");
+						h[i] = -1;
+				}
+			}
+		}
+		   
+	}
+	
+	for(i = 0; i < NSMALLFILES; i++)
+		yaffs_close(h[i]);
+		
+	yaffs_unmount(mountpt);
+}
+	
+
+
+int main(int argc, char *argv[])
+{
+	//return long_test(argc,argv);
+	
+	//return cache_read_test();
+	
+	resize_stress_test_no_grow("/flash/flash",20);
+	
+	//huge_directory_test_on_path("/ram2k");
+	
+	 //yaffs_backward_scan_test("/flash/flash");
+	// yaffs_device_flush_test("/flash/flash");
+
+	 
+	 //scan_pattern_test("/flash",10000,10);
+	//short_scan_test("/flash/flash",40000,200);
+	  //small_mount_test("/flash/flash",1000);
+	  //small_overwrite_test("/flash/flash",1000);
+	  //checkpoint_fill_test("/flash/flash",20);
+	// random_small_file_test("/flash/flash",10000);
+	 // huge_array_test("/flash/flash",10);
+
+
+
+	
+	//long_test_on_path("/ram2k");
+	// long_test_on_path("/flash");
+	//simple_rw_test("/flash/flash");
+	//fill_disk_test("/flash/flash");
+	// rename_over_test("/flash");
+	//lookup_test("/flash");
+	//freespace_test("/flash/flash");
+	
+	//link_test("/flash/flash");
+	
+	
+	
+	
+	// cache_bypass_bug_test();
+	
+	 //free_space_check();
+	 
+	 //check_resize_gc_bug("/flash");
+	 
+	 return 0;
+	
+}
diff --git a/fs/yaffs2/direct/fsx_test/Makefile b/fs/yaffs2/direct/fsx_test/Makefile
new file mode 100644
index 0000000..1927865
--- /dev/null
+++ b/fs/yaffs2/direct/fsx_test/Makefile
@@ -0,0 +1,75 @@
+# Makefile for YAFFS direct test
+#
+#
+# YAFFS: Yet another Flash File System. A NAND-flash specific file system.
+#
+# Copyright (C) 2003 Aleph One Ltd.
+#
+#
+# Created by Charles Manning <charles@aleph1.co.uk>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# NB Warning this Makefile does not include header dependencies.
+#
+# $Id: Makefile,v 1.1 2007/10/16 00:46:33 charles Exp $
+
+#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
+
+CFLAGS =    -Wall -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 -g $(EXTRA_COMPILE_FLAGS) -DNO_Y_INLINE
+CFLAGS+=    -fstack-check -O0
+
+#CFLAGS+=   -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
+#CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
+
+
+FSXTESTOBJS = yaffs_fsx.o yaffscfg2k.o yaffs_ecc.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
+		 yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
+		 yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
+		 yaffs_checkptrw.o  yaffs_qsort.o \
+#		 yaffs_checkptrwtest.o\
+		 
+
+BOOTTESTOBJS = bootldtst.o yboot.o yaffs_fileem.o nand_ecc.o
+
+#ALLOBJS =  dtest.o nand_ecc.o yaffscfg.o yaffs_fileem.o yaffsfs.o yaffs_ramdisk.o bootldtst.o yboot.o yaffs_ramem2k.o
+
+ALLOBJS = $(FSXTESTOBJS) $(BOOTTESTOBJS)
+
+YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+          yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h  yaffs_nandemul2k.h \
+          yaffs_nand.c yaffs_nand.h \
+          yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
+          yaffs_qsort.c yaffs_qsort.h
+
+YAFFSDIRECTSYMLINKS =  yaffscfg2k.c yaffs_fileem2k.c yaffsfs.c yaffs_flashif.h \
+		       yaffs_fileem2k.h yaffsfs.h yaffs_malloc.h yaffs_ramdisk.h ydirectenv.h \
+		       yaffscfg.h yaffs_fileem.c yaffs_flashif.c yaffs_ramdisk.c yaffs_ramem2k.c
+
+
+
+#all: fsxtest boottest
+
+all: fsxtest
+
+$(ALLOBJS): %.o: %.c
+	gcc -c $(CFLAGS) $< -o $@
+
+$(YAFFSSYMLINKS):
+	ln -s ../../$@ $@
+
+$(YAFFSDIRECTSYMLINKS):
+	ln -s ../$@ $@
+
+fsxtest: $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(FSXTESTOBJS)
+	gcc -o $@ $(FSXTESTOBJS)
+
+
+boottest: $(SYMLINKS) $(BOOTTESTOBJS)
+	gcc -o $@ $(BOOTTESTOBJS)
+
+
+clean:
+	rm -f $(ALLOBJS) core
diff --git a/fs/yaffs2/direct/fsx_test/README b/fs/yaffs2/direct/fsx_test/README
new file mode 100644
index 0000000..725ab07
--- /dev/null
+++ b/fs/yaffs2/direct/fsx_test/README
@@ -0,0 +1,7 @@
+NB THis directory uses a hacked version of fsx.c which is released under
+Apple Public Source License.
+
+From what I have been able to determine, it is legally OK to release a hacked
+version for the purposes of testing.
+
+If anyone knows otherwise, please contact me: manningc2@actrix.gen.nz
diff --git a/fs/yaffs2/direct/fsx_test/yaffs_fsx.c b/fs/yaffs2/direct/fsx_test/yaffs_fsx.c
new file mode 100644
index 0000000..1e110b9
--- /dev/null
+++ b/fs/yaffs2/direct/fsx_test/yaffs_fsx.c
@@ -0,0 +1,1007 @@
+/*
+ * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.2 (the
+ * "License").  You may not use this file except in compliance with the
+ * License.  Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ *
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ *
+ *	WARNING--WARNING--WARNING
+ *	This is not the original fsx.c. It has been modified to run with
+ *      yaffs direct. Seek out the original fsx.c if you want to do anything
+ *	else.
+ *
+ *	
+ *
+ *	File:	fsx.c
+ *	Author:	Avadis Tevanian, Jr.
+ *
+ *	File system exerciser. 
+ *
+ *	Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com
+ *
+ *	Various features from Joe Sokol, Pat Dirks, and Clark Warner.
+ *
+ *	Small changes to work under Linux -- davej@suse.de
+ *
+ *	Sundry porting patches from Guy Harris 12/2001
+ *
+ *	Checks for mmap last-page zero fill.
+ *
+ *	Modified heavily by Charles Manning to exercise via the
+ *	yaffs direct interface.
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef _UWIN
+# include <sys/param.h>
+# include <limits.h>
+# include <time.h>
+# include <strings.h>
+#endif
+#include <fcntl.h>
+#include <sys/mman.h>
+#ifndef MAP_FILE
+# define MAP_FILE 0
+#endif
+#include <limits.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include "yaffsfs.h"
+
+#define NUMPRINTCOLUMNS 32	/* # columns of data to print on each line */
+
+/*
+ *	A log entry is an operation and a bunch of arguments.
+ */
+
+struct log_entry {
+	int	operation;
+	int	args[3];
+};
+
+#define	LOGSIZE	1000
+
+struct log_entry	oplog[LOGSIZE];	/* the log */
+int			logptr = 0;	/* current position in log */
+int			logcount = 0;	/* total ops */
+
+/*
+ *	Define operations
+ */
+
+#define	OP_READ		1
+#define OP_WRITE	2
+#define OP_TRUNCATE	3
+#define OP_CLOSEOPEN	4
+#define OP_MAPREAD	5
+#define OP_MAPWRITE	6
+#define OP_SKIPPED	7
+
+int page_size;
+int page_mask;
+
+char	*original_buf;			/* a pointer to the original data */
+char	*good_buf;			/* a pointer to the correct data */
+char	*temp_buf;			/* a pointer to the current data */
+char	*fname;				/* name of our test file */
+int	fd;				/* fd for our test file */
+
+off_t		file_size = 0;
+off_t		biggest = 0;
+char		state[256];
+unsigned long	testcalls = 0;		/* calls to function "test" */
+
+unsigned long	simulatedopcount = 0;	/* -b flag */
+int	closeprob = 0;			/* -c flag */
+int	debug = 0;			/* -d flag */
+unsigned long	debugstart = 0;		/* -D flag */
+unsigned long	maxfilelen = 256 * 1024;	/* -l flag */
+int	sizechecks = 1;			/* -n flag disables them */
+int	maxoplen = 64 * 1024;		/* -o flag */
+int	quiet = 0;			/* -q flag */
+unsigned long progressinterval = 0;	/* -p flag */
+int	readbdy = 1;			/* -r flag */
+int	style = 0;			/* -s flag */
+int	truncbdy = 1;			/* -t flag */
+int	writebdy = 1;			/* -w flag */
+long	monitorstart = -1;		/* -m flag */
+long	monitorend = -1;		/* -m flag */
+int	lite = 0;			/* -L flag */
+long	numops = -1;			/* -N flag */
+int	randomoplen = 1;		/* -O flag disables it */
+int	seed = 1;			/* -S flag */
+
+int     mapped_writes = 0;	      /* yaffs direct does not support mmapped files */
+int 	mapped_reads = 0;
+
+int	fsxgoodfd = 0;
+FILE *	fsxlogf = NULL;
+int badoff = -1;
+int closeopen = 0;
+
+
+void
+vwarnc(code, fmt, ap)
+	int code;
+	const char *fmt;
+	va_list ap;
+{
+	fprintf(stderr, "fsx: ");
+	if (fmt != NULL) {
+		vfprintf(stderr, fmt, ap);
+		fprintf(stderr, ": ");
+	}
+	fprintf(stderr, "%s\n", strerror(code));
+}
+
+
+void
+warn(const char * fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	vwarnc(errno, fmt, ap);
+	va_end(ap);
+}
+
+
+void
+prt(char *fmt, ...)
+{
+	va_list args;
+
+	va_start(args, fmt);
+	vfprintf(stdout, fmt, args);
+	if (fsxlogf)
+		vfprintf(fsxlogf, fmt, args);
+	va_end(args);
+}
+
+void
+prterr(char *prefix)
+{
+	prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
+}
+
+
+void
+log4(int operation, int arg0, int arg1, int arg2)
+{
+	struct log_entry *le;
+
+	le = &oplog[logptr];
+	le->operation = operation;
+	if (closeopen)
+		le->operation = ~ le->operation;
+	le->args[0] = arg0;
+	le->args[1] = arg1;
+	le->args[2] = arg2;
+	logptr++;
+	logcount++;
+	if (logptr >= LOGSIZE)
+		logptr = 0;
+}
+
+
+void
+logdump(void)
+{
+	int	i, count, down;
+	struct log_entry	*lp;
+
+	prt("LOG DUMP (%d total operations):\n", logcount);
+	if (logcount < LOGSIZE) {
+		i = 0;
+		count = logcount;
+	} else {
+		i = logptr;
+		count = LOGSIZE;
+	}
+	for ( ; count > 0; count--) {
+		int opnum;
+
+		opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
+		prt("%d(%d mod 256): ", opnum, opnum%256);
+		lp = &oplog[i];
+		if ((closeopen = lp->operation < 0))
+			lp->operation = ~ lp->operation;
+			
+		switch (lp->operation) {
+		case OP_MAPREAD:
+			prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)",
+			    lp->args[0], lp->args[0] + lp->args[1] - 1,
+			    lp->args[1]);
+			if (badoff >= lp->args[0] && badoff <
+						     lp->args[0] + lp->args[1])
+				prt("\t***RRRR***");
+			break;
+		case OP_MAPWRITE:
+			prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)",
+			    lp->args[0], lp->args[0] + lp->args[1] - 1,
+			    lp->args[1]);
+			if (badoff >= lp->args[0] && badoff <
+						     lp->args[0] + lp->args[1])
+				prt("\t******WWWW");
+			break;
+		case OP_READ:
+			prt("READ\t0x%x thru 0x%x\t(0x%x bytes)",
+			    lp->args[0], lp->args[0] + lp->args[1] - 1,
+			    lp->args[1]);
+			if (badoff >= lp->args[0] &&
+			    badoff < lp->args[0] + lp->args[1])
+				prt("\t***RRRR***");
+			break;
+		case OP_WRITE:
+			prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)",
+			    lp->args[0], lp->args[0] + lp->args[1] - 1,
+			    lp->args[1]);
+			if (lp->args[0] > lp->args[2])
+				prt(" HOLE");
+			else if (lp->args[0] + lp->args[1] > lp->args[2])
+				prt(" EXTEND");
+			if ((badoff >= lp->args[0] || badoff >=lp->args[2]) &&
+			    badoff < lp->args[0] + lp->args[1])
+				prt("\t***WWWW");
+			break;
+		case OP_TRUNCATE:
+			down = lp->args[0] < lp->args[1];
+			prt("TRUNCATE %s\tfrom 0x%x to 0x%x",
+			    down ? "DOWN" : "UP", lp->args[1], lp->args[0]);
+			if (badoff >= lp->args[!down] &&
+			    badoff < lp->args[!!down])
+				prt("\t******WWWW");
+			break;
+		case OP_SKIPPED:
+			prt("SKIPPED (no operation)");
+			break;
+		default:
+			prt("BOGUS LOG ENTRY (operation code = %d)!",
+			    lp->operation);
+		}
+		if (closeopen)
+			prt("\n\t\tCLOSE/OPEN");
+		prt("\n");
+		i++;
+		if (i == LOGSIZE)
+			i = 0;
+	}
+}
+
+
+void
+save_buffer(char *buffer, off_t bufferlength, int fd)
+{
+	off_t ret;
+	ssize_t byteswritten;
+
+	if (fd <= 0 || bufferlength == 0)
+		return;
+
+	if (bufferlength > SSIZE_MAX) {
+		prt("fsx flaw: overflow in save_buffer\n");
+		exit(67);
+	}
+	if (lite) {
+		off_t size_by_seek = yaffs_lseek(fd, (off_t)0, SEEK_END);
+		if (size_by_seek == (off_t)-1)
+			prterr("save_buffer: lseek eof");
+		else if (bufferlength > size_by_seek) {
+			warn("save_buffer: .fsxgood file too short... will save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek,
+			     (unsigned long long)bufferlength);
+			bufferlength = size_by_seek;
+		}
+	}
+
+	ret = yaffs_lseek(fd, (off_t)0, SEEK_SET);
+	if (ret == (off_t)-1)
+		prterr("save_buffer: lseek 0");
+	
+	byteswritten = yaffs_write(fd, buffer, (size_t)bufferlength);
+	if (byteswritten != bufferlength) {
+		if (byteswritten == -1)
+			prterr("save_buffer write");
+		else
+			warn("save_buffer: short write, 0x%x bytes instead of 0x%llx\n",
+			     (unsigned)byteswritten,
+			     (unsigned long long)bufferlength);
+	}
+}
+
+
+void
+report_failure(int status)
+{
+	logdump();
+	
+	if (fsxgoodfd) {
+		if (good_buf) {
+			save_buffer(good_buf, file_size, fsxgoodfd);
+			prt("Correct content saved for comparison\n");
+			prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n",
+			    fname, fname);
+		}
+		close(fsxgoodfd);
+	}
+	prt("Exiting with %d\n",status);
+	exit(status);
+}
+
+
+#define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \
+					*(((unsigned char *)(cp)) + 1)))
+
+void
+check_buffers(unsigned offset, unsigned size)
+{
+	unsigned char c, t;
+	unsigned i = 0;
+	unsigned n = 0;
+	unsigned op = 0;
+	unsigned bad = 0;
+
+	if (memcmp(good_buf + offset, temp_buf, size) != 0) {
+		prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n",
+		    offset, size);
+		prt("OFFSET\tGOOD\tBAD\tRANGE\n");
+		while (size > 0) {
+			c = good_buf[offset];
+			t = temp_buf[i];
+			if (c != t) {
+				if (n == 0) {
+					bad = short_at(&temp_buf[i]);
+					prt("0x%5x\t0x%04x\t0x%04x", offset,
+					    short_at(&good_buf[offset]), bad);
+					op = temp_buf[offset & 1 ? i+1 : i];
+				}
+				n++;
+				badoff = offset;
+			}
+			offset++;
+			i++;
+			size--;
+		}
+		if (n) {
+			prt("\t0x%5x\n", n);
+			if (bad)
+				prt("operation# (mod 256) for the bad data may be %u\n", ((unsigned)op & 0xff));
+			else
+				prt("operation# (mod 256) for the bad data unknown, check HOLE and EXTEND ops\n");
+		} else
+			prt("????????????????\n");
+		report_failure(110);
+	}
+}
+
+
+void
+check_size(void)
+{
+	struct yaffs_stat	statbuf;
+	off_t	size_by_seek;
+
+	if (yaffs_fstat(fd, &statbuf)) {
+		prterr("check_size: fstat");
+		statbuf.st_size = -1;
+	}
+	size_by_seek = yaffs_lseek(fd, (off_t)0, SEEK_END);
+	if (file_size != statbuf.st_size || file_size != size_by_seek) {
+		prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n",
+		    (unsigned long long)file_size,
+		    (unsigned long long)statbuf.st_size,
+		    (unsigned long long)size_by_seek);
+		report_failure(120);
+	}
+}
+
+
+void
+check_trunc_hack(void)
+{
+	struct yaffs_stat statbuf;
+
+	yaffs_truncate(fd, (off_t)0);
+	yaffs_truncate(fd, (off_t)100000);
+	yaffs_fstat(fd, &statbuf);
+	if (statbuf.st_size != (off_t)100000) {
+		prt("no extend on truncate! not posix!\n");
+		exit(130);
+	}
+	yaffs_truncate(fd, (off_t)0);
+}
+
+
+void
+doread(unsigned offset, unsigned size)
+{
+	off_t ret;
+	unsigned iret;
+
+	offset -= offset % readbdy;
+	if (size == 0) {
+		if (!quiet && testcalls > simulatedopcount)
+			prt("skipping zero size read\n");
+		log4(OP_SKIPPED, OP_READ, offset, size);
+		return;
+	}
+	if (size + offset > file_size) {
+		if (!quiet && testcalls > simulatedopcount)
+			prt("skipping seek/read past end of file\n");
+		log4(OP_SKIPPED, OP_READ, offset, size);
+		return;
+	}
+
+	log4(OP_READ, offset, size, 0);
+
+	if (testcalls <= simulatedopcount)
+		return;
+
+	if (!quiet && ((progressinterval &&
+			testcalls % progressinterval == 0) ||
+		       (debug &&
+			(monitorstart == -1 ||
+			 (offset + size > monitorstart &&
+			  (monitorend == -1 || offset <= monitorend))))))
+		prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+		    offset, offset + size - 1, size);
+	ret = yaffs_lseek(fd, (off_t)offset, SEEK_SET);
+	if (ret == (off_t)-1) {
+		prterr("doread: lseek");
+		report_failure(140);
+	}
+	iret = yaffs_read(fd, temp_buf, size);
+	if (iret != size) {
+		if (iret == -1)
+			prterr("doread: read");
+		else
+			prt("short read: 0x%x bytes instead of 0x%x\n",
+			    iret, size);
+		report_failure(141);
+	}
+	check_buffers(offset, size);
+}
+
+
+
+
+
+void
+gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
+{
+	while (size--) {
+		good_buf[offset] = testcalls % 256; 
+		if (offset % 2)
+			good_buf[offset] += original_buf[offset];
+		offset++;
+	}
+}
+
+
+void
+dowrite(unsigned offset, unsigned size)
+{
+	off_t ret;
+	unsigned iret;
+
+	offset -= offset % writebdy;
+	if (size == 0) {
+		if (!quiet && testcalls > simulatedopcount)
+			prt("skipping zero size write\n");
+		log4(OP_SKIPPED, OP_WRITE, offset, size);
+		return;
+	}
+
+	log4(OP_WRITE, offset, size, file_size);
+
+	gendata(original_buf, good_buf, offset, size);
+	if (file_size < offset + size) {
+		if (file_size < offset)
+			memset(good_buf + file_size, '\0', offset - file_size);
+		file_size = offset + size;
+		if (lite) {
+			warn("Lite file size bug in fsx!");
+			report_failure(149);
+		}
+	}
+
+	if (testcalls <= simulatedopcount)
+		return;
+
+	if (!quiet && ((progressinterval &&
+			testcalls % progressinterval == 0) ||
+		       (debug &&
+			(monitorstart == -1 ||
+			 (offset + size > monitorstart &&
+			  (monitorend == -1 || offset <= monitorend))))))
+		prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
+		    offset, offset + size - 1, size);
+	ret = yaffs_lseek(fd, (off_t)offset, SEEK_SET);
+	if (ret == (off_t)-1) {
+		prterr("dowrite: lseek");
+		report_failure(150);
+	}
+	iret = yaffs_write(fd, good_buf + offset, size);
+	if (iret != size) {
+		if (iret == -1)
+			prterr("dowrite: write");
+		else
+			prt("short write: 0x%x bytes instead of 0x%x\n",
+			    iret, size);
+		report_failure(151);
+	}
+}
+
+
+
+void
+dotruncate(unsigned size)
+{
+	int oldsize = file_size;
+
+	size -= size % truncbdy;
+	if (size > biggest) {
+		biggest = size;
+		if (!quiet && testcalls > simulatedopcount)
+			prt("truncating to largest ever: 0x%x\n", size);
+	}
+
+	log4(OP_TRUNCATE, size, (unsigned)file_size, 0);
+
+	if (size > file_size)
+		memset(good_buf + file_size, '\0', size - file_size);
+	file_size = size;
+
+	if (testcalls <= simulatedopcount)
+		return;
+	
+	if ((progressinterval && testcalls % progressinterval == 0) ||
+	    (debug && (monitorstart == -1 || monitorend == -1 ||
+		       size <= monitorend)))
+		prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size);
+	if (yaffs_truncate(fd, (off_t)size) == -1) {
+		prt("ftruncate1: %x\n", size);
+		prterr("dotruncate: ftruncate");
+		report_failure(160);
+	}
+}
+
+
+void
+writefileimage()
+{
+	ssize_t iret;
+
+	if (yaffs_lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
+		prterr("writefileimage: lseek");
+		report_failure(171);
+	}
+	iret = yaffs_write(fd, good_buf, file_size);
+	if ((off_t)iret != file_size) {
+		if (iret == -1)
+			prterr("writefileimage: write");
+		else
+			prt("short write: 0x%x bytes instead of 0x%llx\n",
+			    iret, (unsigned long long)file_size);
+		report_failure(172);
+	}
+	if (lite ? 0 : yaffs_truncate(fd, file_size) == -1) {
+		prt("ftruncate2: %llx\n", (unsigned long long)file_size);
+		prterr("writefileimage: ftruncate");
+		report_failure(173);
+	}
+}
+
+
+void
+docloseopen(void)
+{ 
+	if (testcalls <= simulatedopcount)
+		return;
+
+	if (debug)
+		prt("%lu close/open\n", testcalls);
+	if (yaffs_close(fd)) {
+		prterr("docloseopen: close");
+		report_failure(180);
+	}
+	fd = yaffs_open(fname, O_RDWR, 0);
+	if (fd < 0) {
+		prterr("docloseopen: open");
+		report_failure(181);
+	}
+}
+
+
+void
+test(void)
+{
+	unsigned long	offset;
+	unsigned long	size = maxoplen;
+	unsigned long	rv = random();
+	unsigned long	op = rv % (3 + !lite + mapped_writes);
+
+	/* turn off the map read if necessary */
+
+	if (op == 2 && !mapped_reads)
+	    op = 0;
+
+	if (simulatedopcount > 0 && testcalls == simulatedopcount)
+		writefileimage();
+
+	testcalls++;
+
+	if (closeprob)
+		closeopen = (rv >> 3) < (1 << 28) / closeprob;
+
+	if (debugstart > 0 && testcalls >= debugstart)
+		debug = 1;
+
+	if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
+		prt("%lu...\n", testcalls);
+
+	/*
+	 * READ:	op = 0
+	 * WRITE:	op = 1
+	 * MAPREAD:     op = 2
+	 * TRUNCATE:	op = 3
+	 * MAPWRITE:    op = 3 or 4
+	 */
+	if (lite ? 0 : op == 3 && (style & 1) == 0) /* vanilla truncate? */
+		dotruncate(random() % maxfilelen);
+	else {
+		if (randomoplen)
+			size = random() % (maxoplen+1);
+		if (lite ? 0 : op == 3)
+			dotruncate(size);
+		else {
+			offset = random();
+			if (op == 1 || op == (lite ? 3 : 4)) {
+				offset %= maxfilelen;
+				if (offset + size > maxfilelen)
+					size = maxfilelen - offset;
+				dowrite(offset, size);
+			} else {
+				if (file_size)
+					offset %= file_size;
+				else
+					offset = 0;
+				if (offset + size > file_size)
+					size = file_size - offset;
+				doread(offset, size);
+			}
+		}
+	}
+	if (sizechecks && testcalls > simulatedopcount)
+		check_size();
+	if (closeopen)
+		docloseopen();
+}
+
+
+void
+cleanup(sig)
+	int	sig;
+{
+	if (sig)
+		prt("signal %d\n", sig);
+	prt("testcalls = %lu\n", testcalls);
+	exit(sig);
+}
+
+
+void
+usage(void)
+{
+	fprintf(stdout, "usage: %s",
+		"fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
+	-b opnum: beginning operation number (default 1)\n\
+	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
+	-d: debug output for all operations\n\
+	-l flen: the upper bound on file size (default 262144)\n\
+	-m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
+	-n: no verifications of file size\n\
+	-o oplen: the upper bound on operation size (default 65536)\n\
+	-p progressinterval: debug output at specified operation interval\n\
+	-q: quieter operation\n\
+	-r readbdy: 4096 would make reads page aligned (default 1)\n\
+	-s style: 1 gives smaller truncates (default 0)\n\
+	-t truncbdy: 4096 would make truncates page aligned (default 1)\n\
+	-w writebdy: 4096 would make writes page aligned (default 1)\n\
+	-D startingop: debug output starting at specified operation\n\
+	-L: fsxLite - no file creations & no file size changes\n\
+	-N numops: total # operations to do (default infinity)\n\
+	-O: use oplen (see -o flag) for every op (default random)\n\
+	-P dirpath: save .fsxlog and .fsxgood files in dirpath (default ./)\n\
+	-S seed: for random # generator (default 1) 0 gets timestamp\n\
+	fname: this filename is REQUIRED (no default)\n");
+	exit(90);
+}
+
+
+int
+getnum(char *s, char **e)
+{
+	int ret = -1;
+
+	*e = (char *) 0;
+	ret = strtol(s, e, 0);
+	if (*e)
+		switch (**e) {
+		case 'b':
+		case 'B':
+			ret *= 512;
+			*e = *e + 1;
+			break;
+		case 'k':
+		case 'K':
+			ret *= 1024;
+			*e = *e + 1;
+			break;
+		case 'm':
+		case 'M':
+			ret *= 1024*1024;
+			*e = *e + 1;
+			break;
+		case 'w':
+		case 'W':
+			ret *= 4;
+			*e = *e + 1;
+			break;
+		}
+	return (ret);
+}
+
+
+int
+main(int argc, char **argv)
+{
+	int	i, style, ch;
+	char	*endp;
+	char goodfile[1024];
+	char logfile[1024];
+
+	goodfile[0] = 0;
+	logfile[0] = 0;
+
+	page_size = getpagesize();
+	page_mask = page_size - 1;
+
+	setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
+
+	while ((ch = getopt(argc, argv, "b:c:dl:m:no:p:qr:s:t:w:D:LN:OP:RS:W"))
+	       != EOF)
+		switch (ch) {
+		case 'b':
+			simulatedopcount = getnum(optarg, &endp);
+			if (!quiet)
+				fprintf(stdout, "Will begin at operation %ld\n",
+					simulatedopcount);
+			if (simulatedopcount == 0)
+				usage();
+			simulatedopcount -= 1;
+			break;
+		case 'c':
+			closeprob = getnum(optarg, &endp);
+			if (!quiet)
+				fprintf(stdout,
+					"Chance of close/open is 1 in %d\n",
+					closeprob);
+			if (closeprob <= 0)
+				usage();
+			break;
+		case 'd':
+			debug = 1;
+			break;
+		case 'l':
+			maxfilelen = getnum(optarg, &endp);
+			if (maxfilelen <= 0)
+				usage();
+			break;
+		case 'm':
+			monitorstart = getnum(optarg, &endp);
+			if (monitorstart < 0)
+				usage();
+			if (!endp || *endp++ != ':')
+				usage();
+			monitorend = getnum(endp, &endp);
+			if (monitorend < 0)
+				usage();
+			if (monitorend == 0)
+				monitorend = -1; /* aka infinity */
+			debug = 1;
+		case 'n':
+			sizechecks = 0;
+			break;
+		case 'o':
+			maxoplen = getnum(optarg, &endp);
+			if (maxoplen <= 0)
+				usage();
+			break;
+		case 'p':
+			progressinterval = getnum(optarg, &endp);
+			if (progressinterval < 0)
+				usage();
+			break;
+		case 'q':
+			quiet = 1;
+			break;
+		case 'r':
+			readbdy = getnum(optarg, &endp);
+			if (readbdy <= 0)
+				usage();
+			break;
+		case 's':
+			style = getnum(optarg, &endp);
+			if (style < 0 || style > 1)
+				usage();
+			break;
+		case 't':
+			truncbdy = getnum(optarg, &endp);
+			if (truncbdy <= 0)
+				usage();
+			break;
+		case 'w':
+			writebdy = getnum(optarg, &endp);
+			if (writebdy <= 0)
+				usage();
+			break;
+		case 'D':
+			debugstart = getnum(optarg, &endp);
+			if (debugstart < 1)
+				usage();
+			break;
+		case 'L':
+			lite = 1;
+			break;
+		case 'N':
+			numops = getnum(optarg, &endp);
+			if (numops < 0)
+				usage();
+			break;
+		case 'O':
+			randomoplen = 0;
+			break;
+		case 'P':
+			strncpy(goodfile, optarg, sizeof(goodfile));
+			strcat(goodfile, "/");
+			strncpy(logfile, optarg, sizeof(logfile));
+			strcat(logfile, "/");
+			break;
+		case 'R':
+			mapped_reads = 0;
+			break;
+		case 'S':
+			seed = getnum(optarg, &endp);
+			if (seed == 0)
+				seed = time(0) % 10000;
+			if (!quiet)
+				fprintf(stdout, "Seed set to %d\n", seed);
+			if (seed < 0)
+				usage();
+			break;
+		case 'W':
+			mapped_writes = 0;
+			if (!quiet)
+				fprintf(stdout, "mapped writes DISABLED\n");
+			break;
+
+		default:
+			usage();
+			/* NOTREACHED */
+		}
+	argc -= optind;
+	argv += optind;
+
+	yaffs_StartUp();
+	yaffs_mount("/flash/flash");
+	
+	fname = "/flash/flash/fsxdata";
+
+	signal(SIGHUP,	cleanup);
+	signal(SIGINT,	cleanup);
+	signal(SIGPIPE,	cleanup);
+	signal(SIGALRM,	cleanup);
+	signal(SIGTERM,	cleanup);
+	signal(SIGXCPU,	cleanup);
+	signal(SIGXFSZ,	cleanup);
+	signal(SIGVTALRM,	cleanup);
+	signal(SIGUSR1,	cleanup);
+	signal(SIGUSR2,	cleanup);
+
+	initstate(seed, state, 256);
+	setstate(state);
+	fd = yaffs_open(fname, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), 0666);
+	if (fd < 0) {
+		prterr(fname);
+		exit(91);
+	}
+	strncat(goodfile, fname, 256);
+	strcat (goodfile, ".fsxgood");
+	fsxgoodfd = yaffs_open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
+	if (fsxgoodfd < 0) {
+		prterr(goodfile);
+		exit(92);
+	}
+	strncat(logfile, "fsx", 256);
+	strcat (logfile, ".fsxlog");
+	fsxlogf = fopen(logfile, "w");
+	if (fsxlogf == NULL) {
+		prterr(logfile);
+		exit(93);
+	}
+	if (lite) {
+		off_t ret;
+		file_size = maxfilelen = yaffs_lseek(fd, (off_t)0, SEEK_END);
+		if (file_size == (off_t)-1) {
+			prterr(fname);
+			warn("main: lseek eof");
+			exit(94);
+		}
+		ret = yaffs_lseek(fd, (off_t)0, SEEK_SET);
+		if (ret == (off_t)-1) {
+			prterr(fname);
+			warn("main: lseek 0");
+			exit(95);
+		}
+	}
+	original_buf = (char *) malloc(maxfilelen);
+	for (i = 0; i < maxfilelen; i++)
+		original_buf[i] = random() % 256;
+	good_buf = (char *) malloc(maxfilelen);
+	memset(good_buf, '\0', maxfilelen);
+	temp_buf = (char *) malloc(maxoplen);
+	memset(temp_buf, '\0', maxoplen);
+	if (lite) {	/* zero entire existing file */
+		ssize_t written;
+
+		written = yaffs_write(fd, good_buf, (size_t)maxfilelen);
+		if (written != maxfilelen) {
+			if (written == -1) {
+				prterr(fname);
+				warn("main: error on write");
+			} else
+				warn("main: short write, 0x%x bytes instead of 0x%x\n",
+				     (unsigned)written, maxfilelen);
+			exit(98);
+		}
+	} else 
+		check_trunc_hack();
+
+	while (numops == -1 || numops--)
+		test();
+
+	if (yaffs_close(fd)) {
+		prterr("close");
+		report_failure(99);
+	}
+	
+	yaffs_close(fsxgoodfd);
+	
+	yaffs_unmount("flash/flash");
+	prt("All operations completed A-OK!\n");
+
+	exit(0);
+	return 0;
+}
+
diff --git a/fs/yaffs2/direct/yaffs_fileem.c b/fs/yaffs2/direct/yaffs_fileem.c
new file mode 100644
index 0000000..e3cc30e
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_fileem.c
@@ -0,0 +1,218 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * This provides a YAFFS nand emulation on a file.
+ * This is only intended as test code to test persistence etc.
+ */
+
+const char *yaffs_flashif_c_version = "$Id: yaffs_fileem.c,v 1.3 2007/02/14 01:09:06 wookey Exp $";
+
+
+#include "yportenv.h"
+
+#include "yaffs_flashif.h"
+#include "yaffs_guts.h"
+
+#include "devextras.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h> 
+
+
+
+#define SIZE_IN_MB 16
+
+#define BLOCK_SIZE (32 * 528)
+#define BLOCKS_PER_MEG ((1024*1024)/(32 * 512))
+
+
+
+typedef struct 
+{
+	__u8 data[528]; // Data + spare
+} yflash_Page;
+
+typedef struct
+{
+	yflash_Page page[32]; // The pages in the block
+	
+} yflash_Block;
+
+
+
+typedef struct
+{
+	int handle;
+	int nBlocks;
+} yflash_Device;
+
+static yflash_Device filedisk;
+
+static int  CheckInit(yaffs_Device *dev)
+{
+	static int initialised = 0;
+	
+	int i;
+
+	
+	int fSize;
+	int written;
+	
+	yflash_Page p;
+	
+	if(initialised) 
+	{
+		return YAFFS_OK;
+	}
+
+	initialised = 1;
+	
+	
+	filedisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
+	
+	filedisk.handle = open("yaffsemfile", O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
+	
+	if(filedisk.handle < 0)
+	{
+		perror("Failed to open yaffs emulation file");
+		return YAFFS_FAIL;
+	}
+	
+	
+	fSize = lseek(filedisk.handle,0,SEEK_END);
+	
+	if(fSize < SIZE_IN_MB * 1024 * 1024)
+	{
+		printf("Creating yaffs emulation file\n");
+		
+		lseek(filedisk.handle,0,SEEK_SET);
+		
+		memset(&p,0xff,sizeof(yflash_Page));
+		
+		for(i = 0; i < SIZE_IN_MB * 1024 * 1024; i+= 512)
+		{
+			written = write(filedisk.handle,&p,sizeof(yflash_Page));
+			
+			if(written != sizeof(yflash_Page))
+			{
+				printf("Write failed\n");
+				return YAFFS_FAIL;
+			}
+		}		
+	}
+	
+	return 1;
+}
+
+int yflash_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_Spare *spare)
+{
+	int written;
+
+	CheckInit(dev);
+	
+	
+	
+	if(data)
+	{
+		lseek(filedisk.handle,chunkInNAND * 528,SEEK_SET);
+		written = write(filedisk.handle,data,512);
+		
+		if(written != 512) return YAFFS_FAIL;
+	}
+	
+	if(spare)
+	{
+		lseek(filedisk.handle,chunkInNAND * 528 + 512,SEEK_SET);
+		written = write(filedisk.handle,spare,16);
+		
+		if(written != 16) return YAFFS_FAIL;
+	}
+	
+
+	return YAFFS_OK;	
+
+}
+
+
+int yflash_ReadChunkFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_Spare *spare)
+{
+	int nread;
+
+	CheckInit(dev);
+	
+	
+	
+	if(data)
+	{
+		lseek(filedisk.handle,chunkInNAND * 528,SEEK_SET);
+		nread = read(filedisk.handle,data,512);
+		
+		if(nread != 512) return YAFFS_FAIL;
+	}
+	
+	if(spare)
+	{
+		lseek(filedisk.handle,chunkInNAND * 528 + 512,SEEK_SET);
+		nread= read(filedisk.handle,spare,16);
+		
+		if(nread != 16) return YAFFS_FAIL;
+	}
+	
+
+	return YAFFS_OK;	
+
+}
+
+
+int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
+{
+
+	int i;
+		
+	CheckInit(dev);
+	
+	if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
+	{
+		T(YAFFS_TRACE_ALWAYS,("Attempt to erase non-existant block %d\n",blockNumber));
+		return YAFFS_FAIL;
+	}
+	else
+	{
+	
+		yflash_Page pg;
+		
+		memset(&pg,0xff,sizeof(yflash_Page));
+		
+		lseek(filedisk.handle, blockNumber * 32 * 528, SEEK_SET);
+		
+		for(i = 0; i < 32; i++)
+		{
+			write(filedisk.handle,&pg,528);
+		}
+		return YAFFS_OK;
+	}
+	
+}
+
+int yflash_InitialiseNAND(yaffs_Device *dev)
+{
+	dev->useNANDECC = 1; // force on useNANDECC which gets faked. 
+						 // This saves us doing ECC checks.
+	
+	return YAFFS_OK;
+}
+
+
diff --git a/fs/yaffs2/direct/yaffs_fileem2k.c b/fs/yaffs2/direct/yaffs_fileem2k.c
new file mode 100644
index 0000000..7a3b299
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_fileem2k.c
@@ -0,0 +1,441 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * This provides a YAFFS nand emulation on a file for emulating 2kB pages.
+ * This is only intended as test code to test persistence etc.
+ */
+
+const char *yaffs_flashif_c_version = "$Id: yaffs_fileem2k.c,v 1.12 2007/02/14 01:09:06 wookey Exp $";
+
+
+#include "yportenv.h"
+
+#include "yaffs_flashif.h"
+#include "yaffs_guts.h"
+#include "devextras.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h> 
+
+#include "yaffs_fileem2k.h"
+#include "yaffs_packedtags2.h"
+
+//#define SIMULATE_FAILURES
+
+typedef struct 
+{
+	__u8 data[PAGE_SIZE]; // Data + spare
+} yflash_Page;
+
+typedef struct
+{
+	yflash_Page page[PAGES_PER_BLOCK]; // The pages in the block
+	
+} yflash_Block;
+
+
+
+#define MAX_HANDLES 20
+#define BLOCKS_PER_HANDLE 8000
+
+typedef struct
+{
+	int handle[MAX_HANDLES];
+	int nBlocks;
+} yflash_Device;
+
+static yflash_Device filedisk;
+
+int yaffs_testPartialWrite = 0;
+
+
+
+
+static __u8 localBuffer[PAGE_SIZE];
+
+static char *NToName(char *buf,int n)
+{
+	sprintf(buf,"emfile%d",n);
+	return buf;
+}
+
+static char dummyBuffer[BLOCK_SIZE];
+
+static int GetBlockFileHandle(int n)
+{
+	int h;
+	int requiredSize;
+	
+	char name[40];
+	NToName(name,n);
+	int fSize;
+	int i;
+	
+	h =  open(name, O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
+	if(h >= 0){
+		fSize = lseek(h,0,SEEK_END);
+		requiredSize = BLOCKS_PER_HANDLE * BLOCK_SIZE;
+		if(fSize < requiredSize){
+		   for(i = 0; i < BLOCKS_PER_HANDLE; i++)
+		   	if(write(h,dummyBuffer,BLOCK_SIZE) != BLOCK_SIZE)
+				return -1;
+			
+		}
+	}
+	
+	return h;
+
+}
+
+static int  CheckInit(void)
+{
+	static int initialised = 0;
+	int h;
+	int i;
+
+	
+	off_t fSize;
+	off_t requiredSize;
+	int written;
+	int blk;
+	
+	yflash_Page p;
+	
+	if(initialised) 
+	{
+		return YAFFS_OK;
+	}
+
+	initialised = 1;
+	
+	memset(dummyBuffer,0xff,sizeof(dummyBuffer));
+	
+	
+	filedisk.nBlocks = SIZE_IN_MB * BLOCKS_PER_MB;
+
+	for(i = 0; i <  MAX_HANDLES; i++)
+		filedisk.handle[i] = -1;
+	
+	for(i = 0,blk = 0; blk < filedisk.nBlocks; blk+=BLOCKS_PER_HANDLE,i++)
+		filedisk.handle[i] = GetBlockFileHandle(i);
+	
+	
+	return 1;
+}
+
+
+int yflash_GetNumberOfBlocks(void)
+{
+	CheckInit();
+	
+	return filedisk.nBlocks;
+}
+
+int yflash_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_ExtendedTags *tags)
+{
+	int written;
+	int pos;
+	int h;
+	int i;
+	int nRead;
+	int error;
+	
+	T(YAFFS_TRACE_MTD,(TSTR("write chunk %d data %x tags %x" TENDSTR),chunkInNAND,(unsigned)data, (unsigned)tags));
+
+	CheckInit();
+	
+	
+	
+	if(data)
+	{
+		pos = (chunkInNAND % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE;
+		h = filedisk.handle[(chunkInNAND / (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE))];
+		
+		lseek(h,pos,SEEK_SET);
+		nRead =  read(h, localBuffer,dev->nDataBytesPerChunk);
+		for(i = error = 0; i < dev->nDataBytesPerChunk && !error; i++){
+			if(localBuffer[i] != 0xFF){
+				printf("nand simulation: chunk %d data byte %d was %0x2\n",
+					chunkInNAND,i,localBuffer[i]);
+				error = 1;
+			}
+		}
+		
+		for(i = 0; i < dev->nDataBytesPerChunk; i++)
+		  localBuffer[i] &= data[i];
+		  
+		if(memcmp(localBuffer,data,dev->nDataBytesPerChunk))
+			printf("nand simulator: data does not match\n");
+			
+		lseek(h,pos,SEEK_SET);
+		written = write(h,localBuffer,dev->nDataBytesPerChunk);
+		
+		if(yaffs_testPartialWrite){
+			close(h);
+			exit(1);
+		}
+		
+#ifdef SIMULATE_FAILURES
+			if((chunkInNAND >> 6) == 100) 
+			  written = 0;
+
+			if((chunkInNAND >> 6) == 110) 
+			  written = 0;
+#endif
+
+
+		if(written != dev->nDataBytesPerChunk) return YAFFS_FAIL;
+	}
+	
+	if(tags)
+	{
+		pos = (chunkInNAND % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE + PAGE_DATA_SIZE ;
+		h = filedisk.handle[(chunkInNAND / (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE))];
+		
+		lseek(h,pos,SEEK_SET);
+
+		if( 0 && dev->isYaffs2)
+		{
+			
+			written = write(h,tags,sizeof(yaffs_ExtendedTags));
+			if(written != sizeof(yaffs_ExtendedTags)) return YAFFS_FAIL;
+		}
+		else
+		{
+			yaffs_PackedTags2 pt;
+			yaffs_PackTags2(&pt,tags);
+			__u8 * ptab = (__u8 *)&pt;
+
+			nRead = read(h,localBuffer,sizeof(pt));
+			for(i = error = 0; i < sizeof(pt) && !error; i++){
+				if(localBuffer[i] != 0xFF){
+					printf("nand simulation: chunk %d oob byte %d was %0x2\n",
+						chunkInNAND,i,localBuffer[i]);
+						error = 1;
+				}
+			}
+		
+			for(i = 0; i < sizeof(pt); i++)
+			  localBuffer[i] &= ptab[i];
+			 
+			if(memcmp(localBuffer,&pt,sizeof(pt)))
+				printf("nand sim: tags corruption\n");
+				
+			lseek(h,pos,SEEK_SET);
+			
+			written = write(h,localBuffer,sizeof(pt));
+			if(written != sizeof(pt)) return YAFFS_FAIL;
+		}
+	}
+	
+
+	return YAFFS_OK;	
+
+}
+
+int yaffs_CheckAllFF(const __u8 *ptr, int n)
+{
+	while(n)
+	{
+		n--;
+		if(*ptr!=0xFF) return 0;
+		ptr++;
+	}
+	return 1;
+}
+
+
+static int fail300 = 1;
+static int fail320 = 1;
+
+static int failRead10 = 2;
+
+int yflash_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags)
+{
+	int nread;
+	int pos;
+	int h;
+	
+	T(YAFFS_TRACE_MTD,(TSTR("read chunk %d data %x tags %x" TENDSTR),chunkInNAND,(unsigned)data, (unsigned)tags));
+	
+	CheckInit();
+	
+	
+	
+	if(data)
+	{
+
+		pos = (chunkInNAND % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE;
+		h = filedisk.handle[(chunkInNAND / (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE))];		
+		lseek(h,pos,SEEK_SET);
+		nread = read(h,data,dev->nDataBytesPerChunk);
+		
+		
+		if(nread != dev->nDataBytesPerChunk) return YAFFS_FAIL;
+	}
+	
+	if(tags)
+	{
+		pos = (chunkInNAND % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE + PAGE_DATA_SIZE;
+		h = filedisk.handle[(chunkInNAND / (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE))];		
+		lseek(h,pos,SEEK_SET);
+
+		if(0 && dev->isYaffs2)
+		{
+			nread= read(h,tags,sizeof(yaffs_ExtendedTags));
+			if(nread != sizeof(yaffs_ExtendedTags)) return YAFFS_FAIL;
+			if(yaffs_CheckAllFF((__u8 *)tags,sizeof(yaffs_ExtendedTags)))
+			{
+				yaffs_InitialiseTags(tags);
+			}
+			else
+			{
+				tags->chunkUsed = 1;
+			}
+		}
+		else
+		{
+			yaffs_PackedTags2 pt;
+			nread= read(h,&pt,sizeof(pt));
+			yaffs_UnpackTags2(tags,&pt);
+#ifdef SIMULATE_FAILURES
+			if((chunkInNAND >> 6) == 100) {
+			    if(fail300 && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR){
+			       tags->eccResult = YAFFS_ECC_RESULT_FIXED;
+			       fail300 = 0;
+			    }
+			    
+			}
+			if((chunkInNAND >> 6) == 110) {
+			    if(fail320 && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR){
+			       tags->eccResult = YAFFS_ECC_RESULT_FIXED;
+			       fail320 = 0;
+			    }
+			}
+#endif
+			if(failRead10>0 && chunkInNAND == 10){
+				failRead10--;
+				nread = 0;
+			}
+			
+			if(nread != sizeof(pt)) return YAFFS_FAIL;
+		}
+	}
+	
+
+	return YAFFS_OK;	
+
+}
+
+
+int yflash_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
+{
+	int written;
+	int h;
+	
+	yaffs_PackedTags2 pt;
+
+	CheckInit();
+	
+	memset(&pt,0,sizeof(pt));
+	h = filedisk.handle[(blockNo / ( BLOCKS_PER_HANDLE))];
+	lseek(h,((blockNo % BLOCKS_PER_HANDLE) * dev->nChunksPerBlock) * PAGE_SIZE + PAGE_DATA_SIZE,SEEK_SET);
+	written = write(h,&pt,sizeof(pt));
+		
+	if(written != sizeof(pt)) return YAFFS_FAIL;
+	
+	
+	return YAFFS_OK;
+	
+}
+
+int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
+{
+
+	int i;
+	int h;
+		
+	CheckInit();
+	
+	printf("erase block %d\n",blockNumber);
+	
+	if(blockNumber == 320)
+		fail320 = 1;
+	
+	if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
+	{
+		T(YAFFS_TRACE_ALWAYS,("Attempt to erase non-existant block %d\n",blockNumber));
+		return YAFFS_FAIL;
+	}
+	else
+	{
+	
+		__u8 pg[PAGE_SIZE];
+		int syz = PAGE_SIZE;
+		int pos;
+		
+		memset(pg,0xff,syz);
+		
+
+		h = filedisk.handle[(blockNumber / ( BLOCKS_PER_HANDLE))];
+		lseek(h,((blockNumber % BLOCKS_PER_HANDLE) * dev->nChunksPerBlock) * PAGE_SIZE,SEEK_SET);		
+		for(i = 0; i < dev->nChunksPerBlock; i++)
+		{
+			write(h,pg,PAGE_SIZE);
+		}
+		pos = lseek(h, 0,SEEK_CUR);
+		
+		return YAFFS_OK;
+	}
+	
+}
+
+int yflash_InitialiseNAND(yaffs_Device *dev)
+{
+	CheckInit();
+	
+	return YAFFS_OK;
+}
+
+
+
+
+int yflash_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber)
+{
+	yaffs_ExtendedTags tags;
+	int chunkNo;
+
+	*sequenceNumber = 0;
+	
+	chunkNo = blockNo * dev->nChunksPerBlock;
+	
+	yflash_ReadChunkWithTagsFromNAND(dev,chunkNo,NULL,&tags);
+	if(tags.blockBad)
+	{
+		*state = YAFFS_BLOCK_STATE_DEAD;
+	}
+	else if(!tags.chunkUsed)
+	{
+		*state = YAFFS_BLOCK_STATE_EMPTY;
+	}
+	else if(tags.chunkUsed)
+	{
+		*state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
+		*sequenceNumber = tags.sequenceNumber;
+	}
+	return YAFFS_OK;
+}
+
diff --git a/fs/yaffs2/direct/yaffs_fileem2k.h b/fs/yaffs2/direct/yaffs_fileem2k.h
new file mode 100644
index 0000000..e694c92
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_fileem2k.h
@@ -0,0 +1,50 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __FILEEM2K_H__
+#define __FILEEM2K_H__
+
+#if 1
+
+#define SIZE_IN_MB 128
+//#define SIZE_IN_MB 8000
+#define PAGE_DATA_SIZE (2048)
+#define PAGE_SPARE_SIZE  (64)
+#define PAGE_SIZE  (PAGE_DATA_SIZE + PAGE_SPARE_SIZE)
+#define PAGES_PER_BLOCK (64)
+#define BLOCK_DATA_SIZE (PAGE_DATA_SIZE * PAGES_PER_BLOCK)
+#define BLOCK_SIZE (PAGES_PER_BLOCK * (PAGE_SIZE))
+#define BLOCKS_PER_MB ((1024*1024)/BLOCK_DATA_SIZE)
+#define SIZE_IN_BLOCKS (BLOCKS_PER_MB * SIZE_IN_MB)
+
+#else
+
+#define SIZE_IN_MB 128
+#define PAGE_DATA_SIZE (512)
+#define SPARE_SIZE  (16)
+#define PAGE_SIZE  (PAGE_DATA_SIZE + SPARE_SIZE)
+#define PAGES_PER_BLOCK (32)
+#define BLOCK_DATA_SIZE (PAGE_SIZE * PAGES_PER_BLOCK)
+#define BLOCK_SIZE (PAGES_PER_BLOCK * (PAGE_SIZE))
+#define BLOCKS_PER_MB ((1024*1024)/BLOCK_DATA_SIZE)
+#define SIZE_IN_BLOCKS (BLOCKS_PER_MB * SIZE_IN_MB)
+
+#endif
+
+
+int yflash_GetNumberOfBlocks(void);
+
+#endif
+
diff --git a/fs/yaffs2/direct/yaffs_flashif.c b/fs/yaffs2/direct/yaffs_flashif.c
new file mode 100644
index 0000000..5178cb2
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_flashif.c
@@ -0,0 +1,229 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+
+const char *yaffs_flashif_c_version = "$Id: yaffs_flashif.c,v 1.3 2007/02/14 01:09:06 wookey Exp $";
+
+
+#include "yportenv.h"
+
+#include "yaffs_flashif.h"
+#include "yaffs_guts.h"
+#include "devextras.h"
+
+
+#define SIZE_IN_MB 16
+
+#define BLOCK_SIZE (32 * 528)
+#define BLOCKS_PER_MEG ((1024*1024)/(32 * 512))
+
+
+
+typedef struct 
+{
+	__u8 data[528]; // Data + spare
+} yflash_Page;
+
+typedef struct
+{
+	yflash_Page page[32]; // The pages in the block
+	
+} yflash_Block;
+
+
+
+typedef struct
+{
+	yflash_Block **block;
+	int nBlocks;
+} yflash_Device;
+
+static yflash_Device ramdisk;
+
+static int  CheckInit(yaffs_Device *dev)
+{
+	static int initialised = 0;
+	
+	int i;
+	int fail = 0;
+	int nAllocated = 0;
+	
+	if(initialised) 
+	{
+		return YAFFS_OK;
+	}
+
+	initialised = 1;
+	
+	
+	ramdisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
+	
+	ramdisk.block = YMALLOC(sizeof(yflash_Block *) * ramdisk.nBlocks);
+	
+	if(!ramdisk.block) return 0;
+	
+	for(i=0; i <ramdisk.nBlocks; i++)
+	{
+		ramdisk.block[i] = NULL;
+	}
+	
+	for(i=0; i <ramdisk.nBlocks && !fail; i++)
+	{
+		if((ramdisk.block[i] = YMALLOC(sizeof(yflash_Block))) == 0)
+		{
+			fail = 1;
+		}
+		else
+		{
+			yflash_EraseBlockInNAND(dev,i);
+			nAllocated++;
+		}
+	}
+	
+	if(fail)
+	{
+		for(i = 0; i < nAllocated; i++)
+		{
+			YFREE(ramdisk.block[i]);
+		}
+		YFREE(ramdisk.block);
+		
+		T(YAFFS_TRACE_ALWAYS,("Allocation failed, could only allocate %dMB of %dMB requested.\n",
+		   nAllocated/64,ramdisk.nBlocks * YAFFS_BYTES_PER_BLOCK));
+		return 0;
+	}
+	
+	
+	
+	return 1;
+}
+
+int yflash_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_ExtendedTags *tags)
+{
+	int blk;
+	int pg;
+	
+
+	CheckInit(dev);
+	
+	blk = chunkInNAND/32;
+	pg = chunkInNAND%32;
+	
+	
+	if(data)
+	{
+		memcpy(ramdisk.block[blk]->page[pg].data,data,512);
+	}
+	
+	
+	if(tags)
+	{
+		yaffs_PackedTags pt;
+		yaffs_PackTags(&pt,tags);
+		memcpy(&ramdisk.block[blk]->page[pg].data[512],&pt,sizeof(pt));
+	}
+
+	return YAFFS_OK;	
+
+}
+
+
+int yflash_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_Tags *tags)
+{
+	int blk;
+	int pg;
+
+	
+	CheckInit(dev);
+	
+	blk = chunkInNAND/32;
+	pg = chunkInNAND%32;
+	
+	
+	if(data)
+	{
+		memcpy(data,ramdisk.block[blk]->page[pg].data,512);
+	}
+	
+	
+	if(tags)
+	{
+		yaffs_PackedTags pt;
+		memcpy(&pt,&ramdisk.block[blk]->page[pg].data[512],sizeof(yaffs_PackedTags));
+		yaffs_UnpackTags(tags,&pt);
+	}
+
+	return YAFFS_OK;
+}
+
+
+int yflash_CheckChunkErased(yaffs_Device *dev,int chunkInNAND)
+{
+	int blk;
+	int pg;
+	int i;
+
+	
+	CheckInit(dev);
+	
+	blk = chunkInNAND/32;
+	pg = chunkInNAND%32;
+	
+	
+	for(i = 0; i < 528; i++)
+	{
+		if(ramdisk.block[blk]->page[pg].data[i] != 0xFF)
+		{
+			return YAFFS_FAIL;
+		}
+	}
+
+	return YAFFS_OK;
+
+}
+
+int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
+{
+	
+	CheckInit(dev);
+	
+	if(blockNumber < 0 || blockNumber >= ramdisk.nBlocks)
+	{
+		T(YAFFS_TRACE_ALWAYS,("Attempt to erase non-existant block %d\n",blockNumber));
+		return YAFFS_FAIL;
+	}
+	else
+	{
+		memset(ramdisk.block[blockNumber],0xFF,sizeof(yflash_Block));
+		return YAFFS_OK;
+	}
+	
+}
+
+int yflash_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
+{
+	return YAFFS_OK;
+	
+}
+int yflash_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber)
+{
+	*state = YAFFS_BLOCK_STATE_EMPTY;
+	*sequenceNumber = 0;
+}
+
+
+int yflash_InitialiseNAND(yaffs_Device *dev)
+{
+	return YAFFS_OK;
+}
+
diff --git a/fs/yaffs2/direct/yaffs_flashif.h b/fs/yaffs2/direct/yaffs_flashif.h
new file mode 100644
index 0000000..f7f4e42
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_flashif.h
@@ -0,0 +1,31 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __YAFFS_FLASH_H__
+#define __YAFFS_FLASH_H__
+
+
+#include "yaffs_guts.h"
+int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber);
+int yflash_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_Spare *spare);
+int yflash_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_ExtendedTags *tags);
+int yflash_ReadChunkFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_Spare *spare);
+int yflash_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags);
+int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber);
+int yflash_InitialiseNAND(yaffs_Device *dev);
+int yflash_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo);
+int yflash_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber);
+
+#endif
diff --git a/fs/yaffs2/direct/yaffs_malloc.h b/fs/yaffs2/direct/yaffs_malloc.h
new file mode 100644
index 0000000..245f9c9
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_malloc.h
@@ -0,0 +1,23 @@
+#ifndef __YAFFS_MALLOC_H__
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+ 
+#include <stdlib.h>
+ 
+void *yaffs_malloc(size_t size); 
+void yaffs_free(void *ptr);
+ 
+#endif
+
diff --git a/fs/yaffs2/direct/yaffs_ramdisk.c b/fs/yaffs2/direct/yaffs_ramdisk.c
new file mode 100644
index 0000000..6afee81
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_ramdisk.c
@@ -0,0 +1,234 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * yaffs_ramdisk.c: yaffs ram disk component
+ * This provides a ram disk under yaffs.
+ * NB this is not intended for NAND emulation.
+ * Use this with dev->useNANDECC enabled, then ECC overheads are not required.
+ */
+
+const char *yaffs_ramdisk_c_version = "$Id: yaffs_ramdisk.c,v 1.4 2007/02/14 01:09:06 wookey Exp $";
+
+
+#include "yportenv.h"
+
+#include "yaffs_ramdisk.h"
+#include "yaffs_guts.h"
+#include "devextras.h"
+#include "yaffs_packedtags1.h"
+
+
+
+#define SIZE_IN_MB 2
+
+#define BLOCK_SIZE (32 * 528)
+#define BLOCKS_PER_MEG ((1024*1024)/(32 * 512))
+
+
+
+
+
+typedef struct 
+{
+	__u8 data[528]; // Data + spare
+} yramdisk_Page;
+
+typedef struct
+{
+	yramdisk_Page page[32]; // The pages in the block
+	
+} yramdisk_Block;
+
+
+
+typedef struct
+{
+	yramdisk_Block **block;
+	int nBlocks;
+} yramdisk_Device;
+
+static yramdisk_Device ramdisk;
+
+static int  CheckInit(yaffs_Device *dev)
+{
+	static int initialised = 0;
+	
+	int i;
+	int fail = 0;
+	//int nBlocks; 
+	int nAllocated = 0;
+	
+	if(initialised) 
+	{
+		return YAFFS_OK;
+	}
+
+	initialised = 1;
+	
+	
+	ramdisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
+	
+	ramdisk.block = YMALLOC(sizeof(yramdisk_Block *) * ramdisk.nBlocks);
+	
+	if(!ramdisk.block) return 0;
+	
+	for(i=0; i <ramdisk.nBlocks; i++)
+	{
+		ramdisk.block[i] = NULL;
+	}
+	
+	for(i=0; i <ramdisk.nBlocks && !fail; i++)
+	{
+		if((ramdisk.block[i] = YMALLOC(sizeof(yramdisk_Block))) == 0)
+		{
+			fail = 1;
+		}
+		else
+		{
+			yramdisk_EraseBlockInNAND(dev,i);
+			nAllocated++;
+		}
+	}
+	
+	if(fail)
+	{
+		for(i = 0; i < nAllocated; i++)
+		{
+			YFREE(ramdisk.block[i]);
+		}
+		YFREE(ramdisk.block);
+		
+		T(YAFFS_TRACE_ALWAYS,("Allocation failed, could only allocate %dMB of %dMB requested.\n",
+		   nAllocated/64,ramdisk.nBlocks * 528));
+		return 0;
+	}
+	
+	
+	return 1;
+}
+
+int yramdisk_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_ExtendedTags *tags)
+{
+	int blk;
+	int pg;
+	
+
+	CheckInit(dev);
+	
+	blk = chunkInNAND/32;
+	pg = chunkInNAND%32;
+	
+	
+	if(data)
+	{
+		memcpy(ramdisk.block[blk]->page[pg].data,data,512);
+	}
+	
+	
+	if(tags)
+	{
+		yaffs_PackedTags1 pt;
+		
+		yaffs_PackTags1(&pt,tags);
+		memcpy(&ramdisk.block[blk]->page[pg].data[512],&pt,sizeof(pt));
+	}
+
+	return YAFFS_OK;	
+
+}
+
+
+int yramdisk_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags)
+{
+	int blk;
+	int pg;
+
+	
+	CheckInit(dev);
+	
+	blk = chunkInNAND/32;
+	pg = chunkInNAND%32;
+	
+	
+	if(data)
+	{
+		memcpy(data,ramdisk.block[blk]->page[pg].data,512);
+	}
+	
+	
+	if(tags)
+	{
+		yaffs_PackedTags1 pt;
+		
+		memcpy(&pt,&ramdisk.block[blk]->page[pg].data[512],sizeof(pt));
+		yaffs_UnpackTags1(tags,&pt);
+		
+	}
+
+	return YAFFS_OK;
+}
+
+
+int yramdisk_CheckChunkErased(yaffs_Device *dev,int chunkInNAND)
+{
+	int blk;
+	int pg;
+	int i;
+
+	
+	CheckInit(dev);
+	
+	blk = chunkInNAND/32;
+	pg = chunkInNAND%32;
+	
+	
+	for(i = 0; i < 528; i++)
+	{
+		if(ramdisk.block[blk]->page[pg].data[i] != 0xFF)
+		{
+			return YAFFS_FAIL;
+		}
+	}
+
+	return YAFFS_OK;
+
+}
+
+int yramdisk_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
+{
+	
+	CheckInit(dev);
+	
+	if(blockNumber < 0 || blockNumber >= ramdisk.nBlocks)
+	{
+		T(YAFFS_TRACE_ALWAYS,("Attempt to erase non-existant block %d\n",blockNumber));
+		return YAFFS_FAIL;
+	}
+	else
+	{
+		memset(ramdisk.block[blockNumber],0xFF,sizeof(yramdisk_Block));
+		return YAFFS_OK;
+	}
+	
+}
+
+int yramdisk_InitialiseNAND(yaffs_Device *dev)
+{
+	//dev->useNANDECC = 1; // force on useNANDECC which gets faked. 
+						 // This saves us doing ECC checks.
+	
+	return YAFFS_OK;
+}
+
+
diff --git a/fs/yaffs2/direct/yaffs_ramdisk.h b/fs/yaffs2/direct/yaffs_ramdisk.h
new file mode 100644
index 0000000..045ab42
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_ramdisk.h
@@ -0,0 +1,32 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+/*
+ * yaffs_ramdisk.h: yaffs ram disk component
+ */
+
+#ifndef __YAFFS_RAMDISK_H__
+#define __YAFFS_RAMDISK_H__
+
+
+#include "yaffs_guts.h"
+int yramdisk_EraseBlockInNAND(yaffs_Device *dev, int blockNumber);
+int yramdisk_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_ExtendedTags *tags);
+int yramdisk_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags);
+int yramdisk_EraseBlockInNAND(yaffs_Device *dev, int blockNumber);
+int yramdisk_InitialiseNAND(yaffs_Device *dev);
+int yramdisk_MarkNANDBlockBad(yaffs_Device *dev,int blockNumber);
+int yramdisk_QueryNANDBlock(yaffs_Device *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber);
+#endif
diff --git a/fs/yaffs2/direct/yaffs_ramem2k.c b/fs/yaffs2/direct/yaffs_ramem2k.c
new file mode 100644
index 0000000..1ab053c
--- /dev/null
+++ b/fs/yaffs2/direct/yaffs_ramem2k.c
@@ -0,0 +1,363 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * yaffs_ramem2k.c: RAM emulation in-kernel for 2K pages (YAFFS2)
+ */
+
+
+const char *yaffs_ramem2k_c_version = "$Id: yaffs_ramem2k.c,v 1.3 2007/02/14 01:09:06 wookey Exp $";
+
+#ifndef __KERNEL__
+#define CONFIG_YAFFS_RAM_ENABLED
+#else
+#include <linux/config.h>
+#endif
+
+#ifdef CONFIG_YAFFS_RAM_ENABLED
+
+#include "yportenv.h"
+
+#include "yaffs_nandemul2k.h"
+#include "yaffs_guts.h"
+#include "yaffsinterface.h"
+#include "devextras.h"
+#include "yaffs_packedtags2.h"
+
+
+
+#define EM_SIZE_IN_MEG (32)
+#define PAGE_DATA_SIZE  (2048)
+#define PAGE_SPARE_SIZE (64)
+#define PAGES_PER_BLOCK (64)
+
+
+
+#define EM_SIZE_IN_BYTES (EM_SIZE_IN_MEG * (1<<20))
+
+#define PAGE_TOTAL_SIZE (PAGE_DATA_SIZE+PAGE_SPARE_SIZE)
+
+#define BLOCK_TOTAL_SIZE (PAGES_PER_BLOCK * PAGE_TOTAL_SIZE)
+
+#define BLOCKS_PER_MEG ((1<<20)/(PAGES_PER_BLOCK * PAGE_DATA_SIZE))
+
+
+typedef struct 
+{
+	__u8 data[PAGE_TOTAL_SIZE]; // Data + spare
+	int empty;      // is this empty?
+} nandemul_Page;
+
+
+typedef struct
+{
+	nandemul_Page *page[PAGES_PER_BLOCK];
+	int damaged;	
+} nandemul_Block;
+
+
+
+typedef struct
+{
+	nandemul_Block**block;
+	int nBlocks;
+} nandemul_Device;
+
+static nandemul_Device ned;
+
+static int sizeInMB = EM_SIZE_IN_MEG;
+
+
+static void nandemul_yield(int n)
+{
+#ifdef __KERNEL__
+	if(n > 0) schedule_timeout(n);
+#endif
+
+}
+
+
+static void nandemul_ReallyEraseBlock(int blockNumber)
+{
+	int i;
+	
+	nandemul_Block *blk;
+	
+	if(blockNumber < 0 || blockNumber >= ned.nBlocks)
+	{
+		return;
+	}
+	
+	blk = ned.block[blockNumber];
+	
+	for(i = 0; i < PAGES_PER_BLOCK; i++)
+	{
+		memset(blk->page[i],0xff,sizeof(nandemul_Page));
+		blk->page[i]->empty = 1;
+	}
+	nandemul_yield(2);
+}
+
+
+static int nandemul2k_CalcNBlocks(void)
+{
+	return EM_SIZE_IN_MEG * BLOCKS_PER_MEG;
+}
+
+
+
+static int  CheckInit(void)
+{
+	static int initialised = 0;
+	
+	int i,j;
+	
+	int fail = 0;
+	int nBlocks; 
+
+	int nAllocated = 0;
+	
+	if(initialised) 
+	{
+		return YAFFS_OK;
+	}
+	
+	
+	ned.nBlocks = nBlocks = nandemul2k_CalcNBlocks();
+
+	
+	ned.block = YMALLOC(sizeof(nandemul_Block*) * nBlocks );
+	
+	if(!ned.block) return YAFFS_FAIL;
+	
+	
+	
+
+		
+	for(i=fail=0; i <nBlocks; i++)
+	{
+		
+		nandemul_Block *blk;
+		
+		if(!(blk = ned.block[i] = YMALLOC(sizeof(nandemul_Block))))
+		{
+		 fail = 1;
+		}  
+		else
+		{
+			for(j = 0; j < PAGES_PER_BLOCK; j++)
+			{
+				if((blk->page[j] = YMALLOC(sizeof(nandemul_Page))) == 0)
+				{
+					fail = 1;
+				}
+			}
+			nandemul_ReallyEraseBlock(i);
+			ned.block[i]->damaged = 0;
+			nAllocated++;
+		}
+	}
+	
+	if(fail)
+	{
+		//Todo thump pages
+		
+		for(i = 0; i < nAllocated; i++)
+		{
+			YFREE(ned.block[i]);
+		}
+		YFREE(ned.block);
+		
+		T(YAFFS_TRACE_ALWAYS,("Allocation failed, could only allocate %dMB of %dMB requested.\n",
+		   nAllocated/64,sizeInMB));
+		return 0;
+	}
+	
+	ned.nBlocks = nBlocks;
+	
+	initialised = 1;
+	
+	return 1;
+}
+
+int nandemul2k_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_ExtendedTags *tags)
+{
+	int blk;
+	int pg;
+	int i;
+	
+	__u8 *x;
+
+	
+	blk = chunkInNAND/PAGES_PER_BLOCK;
+	pg = chunkInNAND%PAGES_PER_BLOCK;
+	
+	
+	if(data)
+	{
+		x = ned.block[blk]->page[pg]->data;
+		
+		for(i = 0; i < PAGE_DATA_SIZE; i++)
+		{
+			x[i] &=data[i];
+		}
+
+		ned.block[blk]->page[pg]->empty = 0;
+	}
+	
+	
+	if(tags)
+	{
+		x = &ned.block[blk]->page[pg]->data[PAGE_DATA_SIZE];
+		
+		yaffs_PackTags2((yaffs_PackedTags2 *)x,tags);
+			
+	}
+	
+	if(tags || data)
+	{
+		nandemul_yield(1);
+	}
+
+	return YAFFS_OK;
+}
+
+
+int nandemul2k_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags)
+{
+	int blk;
+	int pg;
+	
+	__u8 *x;
+
+	
+	
+	blk = chunkInNAND/PAGES_PER_BLOCK;
+	pg = chunkInNAND%PAGES_PER_BLOCK;
+	
+	
+	if(data)
+	{
+		memcpy(data,ned.block[blk]->page[pg]->data,PAGE_DATA_SIZE);
+	}
+	
+	
+	if(tags)
+	{
+		x = &ned.block[blk]->page[pg]->data[PAGE_DATA_SIZE];
+		
+		yaffs_UnpackTags2(tags,(yaffs_PackedTags2 *)x);
+	}
+
+	return YAFFS_OK;
+}
+
+
+static int nandemul2k_CheckChunkErased(yaffs_Device *dev,int chunkInNAND)
+{
+	int blk;
+	int pg;
+	int i;
+
+	
+	
+	blk = chunkInNAND/PAGES_PER_BLOCK;
+	pg = chunkInNAND%PAGES_PER_BLOCK;
+	
+	
+	for(i = 0; i < PAGE_TOTAL_SIZE; i++)
+	{
+		if(ned.block[blk]->page[pg]->data[i] != 0xFF)
+		{
+			return YAFFS_FAIL;
+		}
+	}
+
+	return YAFFS_OK;
+
+}
+
+int nandemul2k_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
+{
+	
+	
+	if(blockNumber < 0 || blockNumber >= ned.nBlocks)
+	{
+		T(YAFFS_TRACE_ALWAYS,("Attempt to erase non-existant block %d\n",blockNumber));
+	}
+	else if(ned.block[blockNumber]->damaged)
+	{
+		T(YAFFS_TRACE_ALWAYS,("Attempt to erase damaged block %d\n",blockNumber));
+	}
+	else
+	{
+		nandemul_ReallyEraseBlock(blockNumber);
+	}
+	
+	return YAFFS_OK;
+}
+
+int nandemul2k_InitialiseNAND(yaffs_Device *dev)
+{
+	CheckInit();
+	return YAFFS_OK;
+}
+ 
+int nandemul2k_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
+{
+	
+	__u8 *x;
+	
+	x = &ned.block[blockNo]->page[0]->data[PAGE_DATA_SIZE];
+	
+	memset(x,0,sizeof(yaffs_PackedTags2));
+	
+	
+	return YAFFS_OK;
+	
+}
+
+int nandemul2k_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber)
+{
+	yaffs_ExtendedTags tags;
+	int chunkNo;
+
+	*sequenceNumber = 0;
+	
+	chunkNo = blockNo * dev->nChunksPerBlock;
+	
+	nandemul2k_ReadChunkWithTagsFromNAND(dev,chunkNo,NULL,&tags);
+	if(tags.blockBad)
+	{
+		*state = YAFFS_BLOCK_STATE_DEAD;
+	}
+	else if(!tags.chunkUsed)
+	{
+		*state = YAFFS_BLOCK_STATE_EMPTY;
+	}
+	else if(tags.chunkUsed)
+	{
+		*state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
+		*sequenceNumber = tags.sequenceNumber;
+	}
+	return YAFFS_OK;
+}
+
+int nandemul2k_GetBytesPerChunk(void) { return PAGE_DATA_SIZE;}
+
+int nandemul2k_GetChunksPerBlock(void) { return PAGES_PER_BLOCK; }
+int nandemul2k_GetNumberOfBlocks(void) {return nandemul2k_CalcNBlocks();}
+
+
+#endif //YAFFS_RAM_ENABLED
+
diff --git a/fs/yaffs2/direct/yaffscfg.c b/fs/yaffs2/direct/yaffscfg.c
new file mode 100644
index 0000000..b1d311e
--- /dev/null
+++ b/fs/yaffs2/direct/yaffscfg.c
@@ -0,0 +1,144 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * yaffscfg.c  The configuration for the "direct" use of yaffs.
+ *
+ * This file is intended to be modified to your requirements.
+ * There is no need to redistribute this file.
+ */
+
+#include "yaffscfg.h"
+#include "yaffsfs.h"
+#include <errno.h>
+
+unsigned yaffs_traceMask = 0xFFFFFFFF;
+
+
+void yaffsfs_SetError(int err)
+{
+	//Do whatever to set error
+	errno = err;
+}
+
+void yaffsfs_Lock(void)
+{
+}
+
+void yaffsfs_Unlock(void)
+{
+}
+
+__u32 yaffsfs_CurrentTime(void)
+{
+	return 0;
+}
+
+void *yaffs_malloc(size_t size)
+{
+	return malloc(size);
+}
+
+void yaffs_free(void *ptr)
+{
+	free(ptr);
+}
+
+void yaffsfs_LocalInitialisation(void)
+{
+	// Define locking semaphore.
+}
+
+// Configuration for:
+// /ram  2MB ramdisk
+// /boot 2MB boot disk (flash)
+// /flash 14MB flash disk (flash)
+// NB Though /boot and /flash occupy the same physical device they
+// are still disticnt "yaffs_Devices. You may think of these as "partitions"
+// using non-overlapping areas in the same device.
+// 
+
+#include "yaffs_ramdisk.h"
+#include "yaffs_flashif.h"
+
+static yaffs_Device ramDev;
+static yaffs_Device bootDev;
+static yaffs_Device flashDev;
+
+static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
+
+	{ "/ram", &ramDev},
+	{ "/boot", &bootDev},
+	{ "/flash", &flashDev},
+	{(void *)0,(void *)0}
+};
+
+
+int yaffs_StartUp(void)
+{
+	// Stuff to configure YAFFS
+	// Stuff to initialise anything special (eg lock semaphore).
+	yaffsfs_LocalInitialisation();
+	
+	// Set up devices
+
+	// /ram
+	ramDev.nBytesPerChunk = 512;
+	ramDev.nChunksPerBlock = 32;
+	ramDev.nReservedBlocks = 2; // Set this smaller for RAM
+	ramDev.startBlock = 1; // Can't use block 0
+	ramDev.endBlock = 127; // Last block in 2MB.	
+	ramDev.useNANDECC = 1;
+	ramDev.nShortOpCaches = 0;	// Disable caching on this device.
+	ramDev.genericDevice = (void *) 0;	// Used to identify the device in fstat.
+	ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
+	ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
+	ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
+	ramDev.initialiseNAND = yramdisk_InitialiseNAND;
+
+	// /boot
+	bootDev.nBytesPerChunk = 612;
+	bootDev.nChunksPerBlock = 32;
+	bootDev.nReservedBlocks = 5;
+	bootDev.startBlock = 1; // Can't use block 0
+	bootDev.endBlock = 127; // Last block in 2MB.	
+	bootDev.useNANDECC = 0; // use YAFFS's ECC
+	bootDev.nShortOpCaches = 10; // Use caches
+	bootDev.genericDevice = (void *) 1;	// Used to identify the device in fstat.
+	bootDev.writeChunkToNAND = yflash_WriteChunkToNAND;
+	bootDev.readChunkFromNAND = yflash_ReadChunkFromNAND;
+	bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
+	bootDev.initialiseNAND = yflash_InitialiseNAND;
+
+		// /flash
+	flashDev.nBytesPerChunk =  512;
+	flashDev.nChunksPerBlock = 32;
+	flashDev.nReservedBlocks = 5;
+	flashDev.startBlock = 128; // First block after 2MB
+	flashDev.endBlock = 1023; // Last block in 16MB
+	flashDev.useNANDECC = 0; // use YAFFS's ECC
+	flashDev.nShortOpCaches = 10; // Use caches
+	flashDev.genericDevice = (void *) 2;	// Used to identify the device in fstat.
+	flashDev.writeChunkToNAND = yflash_WriteChunkToNAND;
+	flashDev.readChunkFromNAND = yflash_ReadChunkFromNAND;
+	flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
+	flashDev.initialiseNAND = yflash_InitialiseNAND;
+
+	yaffs_initialise(yaffsfs_config);
+	
+	return 0;
+}
+
+
+
+
diff --git a/fs/yaffs2/direct/yaffscfg.h b/fs/yaffs2/direct/yaffscfg.h
new file mode 100644
index 0000000..2a60dc1
--- /dev/null
+++ b/fs/yaffs2/direct/yaffscfg.h
@@ -0,0 +1,45 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+/*
+ * Header file for using yaffs in an application via
+ * a direct interface.
+ */
+
+
+#ifndef __YAFFSCFG_H__
+#define __YAFFSCFG_H__
+
+
+#include "devextras.h"
+
+#define YAFFSFS_N_HANDLES 200
+
+
+typedef struct {
+	const char *prefix;
+	struct yaffs_DeviceStruct *dev;
+} yaffsfs_DeviceConfiguration;
+
+
+void yaffsfs_Lock(void);
+void yaffsfs_Unlock(void);
+
+__u32 yaffsfs_CurrentTime(void);
+
+void yaffsfs_SetError(int err);
+
+#endif
+
diff --git a/fs/yaffs2/direct/yaffscfg2k.c b/fs/yaffs2/direct/yaffscfg2k.c
new file mode 100644
index 0000000..6d5f542
--- /dev/null
+++ b/fs/yaffs2/direct/yaffscfg2k.c
@@ -0,0 +1,229 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * yaffscfg2k.c  The configuration for the "direct" use of yaffs.
+ *
+ * This file is intended to be modified to your requirements.
+ * There is no need to redistribute this file.
+ */
+
+#include "yaffscfg.h"
+#include "yaffsfs.h"
+#include "yaffs_fileem2k.h"
+#include "yaffs_nandemul2k.h"
+
+#include <errno.h>
+
+unsigned yaffs_traceMask = 
+
+	YAFFS_TRACE_SCAN |  
+	YAFFS_TRACE_GC | YAFFS_TRACE_GC_DETAIL | 
+	YAFFS_TRACE_ERASE | 
+	YAFFS_TRACE_TRACING | 
+	YAFFS_TRACE_ALLOCATE | 
+	YAFFS_TRACE_CHECKPOINT |
+	YAFFS_TRACE_BAD_BLOCKS |
+	YAFFS_TRACE_VERIFY |
+	YAFFS_TRACE_VERIFY_NAND |
+	YAFFS_TRACE_VERIFY_FULL |
+//	(~0) |
+	
+	0;
+        
+
+
+void yaffsfs_SetError(int err)
+{
+	//Do whatever to set error
+	errno = err;
+}
+
+void yaffsfs_Lock(void)
+{
+}
+
+void yaffsfs_Unlock(void)
+{
+}
+
+__u32 yaffsfs_CurrentTime(void)
+{
+	return 0;
+}
+
+
+static int yaffs_kill_alloc = 0;
+static size_t total_malloced = 0;
+static size_t malloc_limit = 0 & 6000000;
+
+void *yaffs_malloc(size_t size)
+{
+	size_t this;
+	if(yaffs_kill_alloc)
+		return NULL;
+	if(malloc_limit && malloc_limit <(total_malloced + size) )
+		return NULL;
+
+	this = malloc(size);
+	if(this)
+		total_malloced += size;
+	return this;
+}
+
+void yaffs_free(void *ptr)
+{
+	free(ptr);
+}
+
+void yaffsfs_LocalInitialisation(void)
+{
+	// Define locking semaphore.
+}
+
+// Configuration for:
+// /ram  2MB ramdisk
+// /boot 2MB boot disk (flash)
+// /flash 14MB flash disk (flash)
+// NB Though /boot and /flash occupy the same physical device they
+// are still disticnt "yaffs_Devices. You may think of these as "partitions"
+// using non-overlapping areas in the same device.
+// 
+
+#include "yaffs_ramdisk.h"
+#include "yaffs_flashif.h"
+#include "yaffs_nandemul2k.h"
+
+static yaffs_Device ramDev;
+static yaffs_Device bootDev;
+static yaffs_Device flashDev;
+static yaffs_Device ram2kDev;
+
+static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
+#if 0
+	{ "/ram", &ramDev},
+	{ "/boot", &bootDev},
+	{ "/flash/", &flashDev},
+	{ "/ram2k", &ram2kDev},
+	{(void *)0,(void *)0}
+#else
+	{ "/", &ramDev},
+	{ "/flash/boot", &bootDev},
+	{ "/flash/flash", &flashDev},
+	{ "/ram2k", &ram2kDev},
+	{(void *)0,(void *)0} /* Null entry to terminate list */
+#endif
+};
+
+
+int yaffs_StartUp(void)
+{
+	// Stuff to configure YAFFS
+	// Stuff to initialise anything special (eg lock semaphore).
+	yaffsfs_LocalInitialisation();
+	
+	// Set up devices
+	// /ram
+	memset(&ramDev,0,sizeof(ramDev));
+	ramDev.nDataBytesPerChunk = 512;
+	ramDev.nChunksPerBlock = 32;
+	ramDev.nReservedBlocks = 2; // Set this smaller for RAM
+	ramDev.startBlock = 0; // Can use block 0
+	ramDev.endBlock = 127; // Last block in 2MB.	
+	//ramDev.useNANDECC = 1;
+	ramDev.nShortOpCaches = 0;	// Disable caching on this device.
+	ramDev.genericDevice = (void *) 0;	// Used to identify the device in fstat.
+	ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
+	ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
+	ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
+	ramDev.initialiseNAND = yramdisk_InitialiseNAND;
+
+	// /boot
+	memset(&bootDev,0,sizeof(bootDev));
+	bootDev.nDataBytesPerChunk = 512;
+	bootDev.nChunksPerBlock = 32;
+	bootDev.nReservedBlocks = 5;
+	bootDev.startBlock = 0; // Can use block 0
+	bootDev.endBlock = 63; // Last block
+	//bootDev.useNANDECC = 0; // use YAFFS's ECC
+	bootDev.nShortOpCaches = 10; // Use caches
+	bootDev.genericDevice = (void *) 1;	// Used to identify the device in fstat.
+	bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
+	bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
+	bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
+	bootDev.initialiseNAND = yflash_InitialiseNAND;
+	bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
+	bootDev.queryNANDBlock = yflash_QueryNANDBlock;
+
+
+
+	// /flash
+	// Set this puppy up to use
+	// the file emulation space as
+	// 2kpage/64chunk per block/128MB device
+	memset(&flashDev,0,sizeof(flashDev));
+
+	flashDev.nDataBytesPerChunk = 2048;
+	flashDev.nChunksPerBlock = 64;
+	flashDev.nReservedBlocks = 5;
+	flashDev.nCheckpointReservedBlocks = 5;
+	//flashDev.checkpointStartBlock = 1;
+	//flashDev.checkpointEndBlock = 20;
+	flashDev.startBlock = 0;
+	flashDev.endBlock = 200; // Make it smaller
+	//flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
+	flashDev.isYaffs2 = 1;
+	flashDev.wideTnodesDisabled=0;
+	flashDev.nShortOpCaches = 10; // Use caches
+	flashDev.genericDevice = (void *) 2;	// Used to identify the device in fstat.
+	flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
+	flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
+	flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
+	flashDev.initialiseNAND = yflash_InitialiseNAND;
+	flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
+	flashDev.queryNANDBlock = yflash_QueryNANDBlock;
+
+	// /ram2k
+	// Set this puppy up to use
+	// the file emulation space as
+	// 2kpage/64chunk per block/128MB device
+	memset(&ram2kDev,0,sizeof(ram2kDev));
+
+	ram2kDev.nDataBytesPerChunk = nandemul2k_GetBytesPerChunk();
+	ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock();
+	ram2kDev.nReservedBlocks = 5;
+	ram2kDev.startBlock = 0; // First block after /boot
+	//ram2kDev.endBlock = 127; // Last block in 16MB
+	ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB
+	ram2kDev.isYaffs2 = 1;
+	ram2kDev.nShortOpCaches = 10; // Use caches
+	ram2kDev.genericDevice = (void *) 3;	// Used to identify the device in fstat.
+	ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND;
+	ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND;
+	ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND;
+	ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND;
+	ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad;
+	ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock;
+
+	yaffs_initialise(yaffsfs_config);
+	
+	return 0;
+}
+
+
+
+void SetCheckpointReservedBlocks(int n)
+{
+	flashDev.nCheckpointReservedBlocks = n;
+}
+
diff --git a/fs/yaffs2/direct/yaffsfs.c b/fs/yaffs2/direct/yaffsfs.c
new file mode 100644
index 0000000..a8519c2
--- /dev/null
+++ b/fs/yaffs2/direct/yaffsfs.c
@@ -0,0 +1,1505 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+ 
+#include "yaffsfs.h"
+#include "yaffs_guts.h"
+#include "yaffscfg.h"
+#include <string.h> // for memset
+#include "yportenv.h"
+
+#define YAFFSFS_MAX_SYMLINK_DEREFERENCES 5
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+
+const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.18 2007/07/18 19:40:38 charles Exp $";
+
+// configurationList is the list of devices that are supported
+static yaffsfs_DeviceConfiguration *yaffsfs_configurationList;
+
+
+/* Some forward references */
+static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const char *path, int symDepth);
+static void yaffsfs_RemoveObjectCallback(yaffs_Object *obj);
+
+
+// Handle management.
+// 
+
+
+unsigned int yaffs_wr_attempts;
+
+typedef struct
+{
+	__u8  inUse:1;		// this handle is in use
+	__u8  readOnly:1;	// this handle is read only
+	__u8  append:1;		// append only
+	__u8  exclusive:1;	// exclusive
+	__u32 position;		// current position in file
+	yaffs_Object *obj;	// the object
+}yaffsfs_Handle;
+
+
+static yaffsfs_Handle yaffsfs_handle[YAFFSFS_N_HANDLES];
+
+// yaffsfs_InitHandle
+/// Inilitalise handles on start-up.
+//
+static int yaffsfs_InitHandles(void)
+{
+	int i;
+	for(i = 0; i < YAFFSFS_N_HANDLES; i++)
+	{
+		yaffsfs_handle[i].inUse = 0;
+		yaffsfs_handle[i].obj = NULL;
+	}
+	return 0;
+}
+
+yaffsfs_Handle *yaffsfs_GetHandlePointer(int h)
+{
+	if(h < 0 || h >= YAFFSFS_N_HANDLES)
+	{
+		return NULL;
+	}
+	
+	return &yaffsfs_handle[h];
+}
+
+yaffs_Object *yaffsfs_GetHandleObject(int handle)
+{
+	yaffsfs_Handle *h = yaffsfs_GetHandlePointer(handle);
+
+	if(h && h->inUse)
+	{
+		return h->obj;
+	}
+	
+	return NULL;
+}
+
+
+//yaffsfs_GetHandle
+// Grab a handle (when opening a file)
+//
+
+static int yaffsfs_GetHandle(void)
+{
+	int i;
+	yaffsfs_Handle *h;
+	
+	for(i = 0; i < YAFFSFS_N_HANDLES; i++)
+	{
+		h = yaffsfs_GetHandlePointer(i);
+		if(!h)
+		{
+			// todo bug: should never happen
+		}
+		if(!h->inUse)
+		{
+			memset(h,0,sizeof(yaffsfs_Handle));
+			h->inUse=1;
+			return i;
+		}
+	}
+	return -1;
+}
+
+// yaffs_PutHandle
+// Let go of a handle (when closing a file)
+//
+static int yaffsfs_PutHandle(int handle)
+{
+	yaffsfs_Handle *h = yaffsfs_GetHandlePointer(handle);
+	
+	if(h)
+	{
+		h->inUse = 0;
+		h->obj = NULL;
+	}
+	return 0;
+}
+
+
+
+// Stuff to search for a directory from a path
+
+
+int yaffsfs_Match(char a, char b)
+{
+	// case sensitive
+	return (a == b);
+}
+
+// yaffsfs_FindDevice
+// yaffsfs_FindRoot
+// Scan the configuration list to find the root.
+// Curveballs: Should match paths that end in '/' too
+// Curveball2 Might have "/x/ and "/x/y". Need to return the longest match
+static yaffs_Device *yaffsfs_FindDevice(const char *path, char **restOfPath)
+{
+	yaffsfs_DeviceConfiguration *cfg = yaffsfs_configurationList;
+	const char *leftOver;
+	const char *p;
+	yaffs_Device *retval = NULL;
+	int thisMatchLength;
+	int longestMatch = -1;
+	
+	// Check all configs, choose the one that:
+	// 1) Actually matches a prefix (ie /a amd /abc will not match
+	// 2) Matches the longest.
+	while(cfg && cfg->prefix && cfg->dev)
+	{
+		leftOver = path;
+		p = cfg->prefix;
+		thisMatchLength = 0;
+		
+		while(*p &&  //unmatched part of prefix 
+		      strcmp(p,"/") && // the rest of the prefix is not / (to catch / at end)
+		      *leftOver && 
+		      yaffsfs_Match(*p,*leftOver))
+		{
+			p++;
+			leftOver++;
+			thisMatchLength++;
+		}
+		if((!*p || strcmp(p,"/") == 0) &&      // end of prefix
+		   (!*leftOver || *leftOver == '/') && // no more in this path name part
+		   (thisMatchLength > longestMatch))
+		{
+			// Matched prefix
+			*restOfPath = (char *)leftOver;
+			retval = cfg->dev;
+			longestMatch = thisMatchLength;
+		}
+		cfg++;
+	}
+	return retval;
+}
+
+static yaffs_Object *yaffsfs_FindRoot(const char *path, char **restOfPath)
+{
+
+	yaffs_Device *dev;
+	
+	dev= yaffsfs_FindDevice(path,restOfPath);
+	if(dev && dev->isMounted)
+	{
+		return dev->rootDir;
+	}
+	return NULL;
+}
+
+static yaffs_Object *yaffsfs_FollowLink(yaffs_Object *obj,int symDepth)
+{
+
+	while(obj && obj->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
+	{
+		char *alias = obj->variant.symLinkVariant.alias;
+						
+		if(*alias == '/')
+		{
+			// Starts with a /, need to scan from root up
+			obj = yaffsfs_FindObject(NULL,alias,symDepth++);
+		}
+		else
+		{
+			// Relative to here, so use the parent of the symlink as a start
+			obj = yaffsfs_FindObject(obj->parent,alias,symDepth++);
+		}
+	}
+	return obj;
+}
+
+
+// yaffsfs_FindDirectory
+// Parse a path to determine the directory and the name within the directory.
+//
+// eg. "/data/xx/ff" --> puts name="ff" and returns the directory "/data/xx"
+static yaffs_Object *yaffsfs_DoFindDirectory(yaffs_Object *startDir,const char *path,char **name,int symDepth)
+{
+	yaffs_Object *dir;
+	char *restOfPath;
+	char str[YAFFS_MAX_NAME_LENGTH+1];
+	int i;
+	
+	if(symDepth > YAFFSFS_MAX_SYMLINK_DEREFERENCES)
+	{
+		return NULL;
+	}
+	
+	if(startDir)
+	{
+		dir = startDir;
+		restOfPath = (char *)path;
+	}
+	else
+	{
+		dir = yaffsfs_FindRoot(path,&restOfPath);
+	}
+	
+	while(dir)
+	{	
+		// parse off /.
+		// curve ball: also throw away surplus '/' 
+		// eg. "/ram/x////ff" gets treated the same as "/ram/x/ff"
+		while(*restOfPath == '/')
+		{
+			restOfPath++; // get rid of '/'
+		}
+		
+		*name = restOfPath;
+		i = 0;
+		
+		while(*restOfPath && *restOfPath != '/')
+		{
+			if (i < YAFFS_MAX_NAME_LENGTH)
+			{
+				str[i] = *restOfPath;
+				str[i+1] = '\0';
+				i++;
+			}
+			restOfPath++;
+		}
+		
+		if(!*restOfPath)
+		{
+			// got to the end of the string
+			return dir;
+		}
+		else
+		{
+			if(strcmp(str,".") == 0)
+			{
+				// Do nothing
+			}
+			else if(strcmp(str,"..") == 0)
+			{
+				dir = dir->parent;
+			}
+			else
+			{
+				dir = yaffs_FindObjectByName(dir,str);
+				
+				while(dir && dir->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
+				{
+				
+					dir = yaffsfs_FollowLink(dir,symDepth);
+		
+				}
+				
+				if(dir && dir->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
+				{
+					dir = NULL;
+				}
+			}
+		}
+	}
+	// directory did not exist.
+	return NULL;
+}
+
+static yaffs_Object *yaffsfs_FindDirectory(yaffs_Object *relativeDirectory,const char *path,char **name,int symDepth)
+{
+	return yaffsfs_DoFindDirectory(relativeDirectory,path,name,symDepth);
+}
+
+// yaffsfs_FindObject turns a path for an existing object into the object
+// 
+static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const char *path,int symDepth)
+{
+	yaffs_Object *dir;
+	char *name;
+	
+	dir = yaffsfs_FindDirectory(relativeDirectory,path,&name,symDepth);
+	
+	if(dir && *name)
+	{
+		return yaffs_FindObjectByName(dir,name);
+	}
+	
+	return dir;
+}
+
+
+
+int yaffs_open(const char *path, int oflag, int mode)
+{
+	yaffs_Object *obj = NULL;
+	yaffs_Object *dir = NULL;
+	char *name;
+	int handle = -1;
+	yaffsfs_Handle *h = NULL;
+	int alreadyOpen = 0;
+	int alreadyExclusive = 0;
+	int openDenied = 0;
+	int symDepth = 0;
+	int errorReported = 0;
+	
+	int i;
+	
+	
+	// todo sanity check oflag (eg. can't have O_TRUNC without WRONLY or RDWR
+	
+	
+	yaffsfs_Lock();
+	
+	handle = yaffsfs_GetHandle();
+	
+	if(handle >= 0)
+	{
+
+		h = yaffsfs_GetHandlePointer(handle);
+	
+	
+		// try to find the exisiting object
+		obj = yaffsfs_FindObject(NULL,path,0);
+		
+		if(obj && obj->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
+		{
+		
+			obj = yaffsfs_FollowLink(obj,symDepth++);
+		}
+
+		if(obj)
+		{
+			// Check if the object is already in use
+			alreadyOpen = alreadyExclusive = 0;
+			
+			for(i = 0; i <= YAFFSFS_N_HANDLES; i++)
+			{
+				
+				if(i != handle &&
+				   yaffsfs_handle[i].inUse &&
+				    obj == yaffsfs_handle[i].obj)
+				 {
+				 	alreadyOpen = 1;
+					if(yaffsfs_handle[i].exclusive)
+					{
+						alreadyExclusive = 1;
+					}
+				 }
+			}
+
+			if(((oflag & O_EXCL) && alreadyOpen) || alreadyExclusive)
+			{
+				openDenied = 1;
+			}
+			
+			// Open should fail if O_CREAT and O_EXCL are specified
+			if((oflag & O_EXCL) && (oflag & O_CREAT))
+			{
+				openDenied = 1;
+				yaffsfs_SetError(-EEXIST);
+				errorReported = 1;
+			}
+			
+			// Check file permissions
+			if( (oflag & (O_RDWR | O_WRONLY)) == 0 &&     // ie O_RDONLY
+			   !(obj->yst_mode & S_IREAD))
+			{
+				openDenied = 1;
+			}
+
+			if( (oflag & O_RDWR) && 
+			   !(obj->yst_mode & S_IREAD))
+			{
+				openDenied = 1;
+			}
+
+			if( (oflag & (O_RDWR | O_WRONLY)) && 
+			   !(obj->yst_mode & S_IWRITE))
+			{
+				openDenied = 1;
+			}
+			
+		}
+		
+		else if((oflag & O_CREAT))
+		{
+			// Let's see if we can create this file
+			dir = yaffsfs_FindDirectory(NULL,path,&name,0);
+			if(dir)
+			{
+				obj = yaffs_MknodFile(dir,name,mode,0,0);	
+			}
+			else
+			{
+				yaffsfs_SetError(-ENOTDIR);
+			}
+		}
+		
+		if(obj && !openDenied)
+		{
+			h->obj = obj;
+			h->inUse = 1;
+	    	h->readOnly = (oflag & (O_WRONLY | O_RDWR)) ? 0 : 1;
+			h->append =  (oflag & O_APPEND) ? 1 : 0;
+			h->exclusive = (oflag & O_EXCL) ? 1 : 0;
+			h->position = 0;
+			
+			obj->inUse++;
+			if((oflag & O_TRUNC) && !h->readOnly)
+			{
+				//todo truncate
+				yaffs_ResizeFile(obj,0);
+			}
+			
+		}
+		else
+		{
+			yaffsfs_PutHandle(handle);
+			if(!errorReported)
+			{
+				yaffsfs_SetError(-EACCESS);
+				errorReported = 1;
+			}
+			handle = -1;
+		}
+		
+	}
+	
+	yaffsfs_Unlock();
+	
+	return handle;		
+}
+
+int yaffs_close(int fd)
+{
+	yaffsfs_Handle *h = NULL;
+	int retVal = 0;
+	
+	yaffsfs_Lock();
+
+	h = yaffsfs_GetHandlePointer(fd);
+	
+	if(h && h->inUse)
+	{
+		// clean up
+		yaffs_FlushFile(h->obj,1);
+		h->obj->inUse--;
+		if(h->obj->inUse <= 0 && h->obj->unlinked)
+		{
+			yaffs_DeleteFile(h->obj);
+		}
+		yaffsfs_PutHandle(fd);
+		retVal = 0;
+	}
+	else
+	{
+		// bad handle
+		yaffsfs_SetError(-EBADF);		
+		retVal = -1;
+	}
+	
+	yaffsfs_Unlock();
+	
+	return retVal;
+}
+
+int yaffs_read(int fd, void *buf, unsigned int nbyte)
+{
+	yaffsfs_Handle *h = NULL;
+	yaffs_Object *obj = NULL;
+	int pos = 0;
+	int nRead = -1;
+	int maxRead;
+	
+	yaffsfs_Lock();
+	h = yaffsfs_GetHandlePointer(fd);
+	obj = yaffsfs_GetHandleObject(fd);
+	
+	if(!h || !obj)
+	{
+		// bad handle
+		yaffsfs_SetError(-EBADF);		
+	}
+	else if( h && obj)
+	{
+		pos=  h->position;
+		if(yaffs_GetObjectFileLength(obj) > pos)
+		{
+			maxRead = yaffs_GetObjectFileLength(obj) - pos;
+		}
+		else
+		{
+			maxRead = 0;
+		}
+
+		if(nbyte > maxRead)
+		{
+			nbyte = maxRead;
+		}
+
+		
+		if(nbyte > 0)
+		{
+			nRead = yaffs_ReadDataFromFile(obj,buf,pos,nbyte);
+			if(nRead >= 0)
+			{
+				h->position = pos + nRead;
+			}
+			else
+			{
+				//todo error
+			}
+		}
+		else
+		{
+			nRead = 0;
+		}
+		
+	}
+	
+	yaffsfs_Unlock();
+	
+	
+	return (nRead >= 0) ? nRead : -1;
+		
+}
+
+int yaffs_write(int fd, const void *buf, unsigned int nbyte)
+{
+	yaffsfs_Handle *h = NULL;
+	yaffs_Object *obj = NULL;
+	int pos = 0;
+	int nWritten = -1;
+	int writeThrough = 0;
+	
+	yaffsfs_Lock();
+	h = yaffsfs_GetHandlePointer(fd);
+	obj = yaffsfs_GetHandleObject(fd);
+	
+	if(!h || !obj)
+	{
+		// bad handle
+		yaffsfs_SetError(-EBADF);		
+	}
+	else if( h && obj && h->readOnly)
+	{
+		// todo error
+	}
+	else if( h && obj)
+	{
+		if(h->append)
+		{
+			pos =  yaffs_GetObjectFileLength(obj);
+		}
+		else
+		{
+			pos = h->position;
+		}
+		
+		nWritten = yaffs_WriteDataToFile(obj,buf,pos,nbyte,writeThrough);
+		
+		if(nWritten >= 0)
+		{
+			h->position = pos + nWritten;
+		}
+		else
+		{
+			//todo error
+		}
+		
+	}
+	
+	yaffsfs_Unlock();
+	
+	
+	return (nWritten >= 0) ? nWritten : -1;
+
+}
+
+int yaffs_truncate(int fd, off_t newSize)
+{
+	yaffsfs_Handle *h = NULL;
+	yaffs_Object *obj = NULL;
+	int result = 0;
+	
+	yaffsfs_Lock();
+	h = yaffsfs_GetHandlePointer(fd);
+	obj = yaffsfs_GetHandleObject(fd);
+	
+	if(!h || !obj)
+	{
+		// bad handle
+		yaffsfs_SetError(-EBADF);		
+	}
+	else
+	{
+		// resize the file
+		result = yaffs_ResizeFile(obj,newSize);
+	}	
+	yaffsfs_Unlock();
+	
+	
+	return (result) ? 0 : -1;
+
+}
+
+off_t yaffs_lseek(int fd, off_t offset, int whence) 
+{
+	yaffsfs_Handle *h = NULL;
+	yaffs_Object *obj = NULL;
+	int pos = -1;
+	int fSize = -1;
+	
+	yaffsfs_Lock();
+	h = yaffsfs_GetHandlePointer(fd);
+	obj = yaffsfs_GetHandleObject(fd);
+	
+	if(!h || !obj)
+	{
+		// bad handle
+		yaffsfs_SetError(-EBADF);		
+	}
+	else if(whence == SEEK_SET)
+	{
+		if(offset >= 0)
+		{
+			pos = offset;
+		}
+	}
+	else if(whence == SEEK_CUR)
+	{
+		if( (h->position + offset) >= 0)
+		{
+			pos = (h->position + offset);
+		}
+	}
+	else if(whence == SEEK_END)
+	{
+		fSize = yaffs_GetObjectFileLength(obj);
+		if(fSize >= 0 && (fSize + offset) >= 0)
+		{
+			pos = fSize + offset;
+		}
+	}
+	
+	if(pos >= 0)
+	{
+		h->position = pos;
+	}
+	else
+	{
+		// todo error
+	}
+
+	
+	yaffsfs_Unlock();
+	
+	return pos;
+}
+
+
+int yaffsfs_DoUnlink(const char *path,int isDirectory) 
+{
+	yaffs_Object *dir = NULL;
+	yaffs_Object *obj = NULL;
+	char *name;
+	int result = YAFFS_FAIL;
+	
+	yaffsfs_Lock();
+
+	obj = yaffsfs_FindObject(NULL,path,0);
+	dir = yaffsfs_FindDirectory(NULL,path,&name,0);
+	if(!dir)
+	{
+		yaffsfs_SetError(-ENOTDIR);
+	}
+	else if(!obj)
+	{
+		yaffsfs_SetError(-ENOENT);
+	}
+	else if(!isDirectory && obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY)
+	{
+		yaffsfs_SetError(-EISDIR);
+	}
+	else if(isDirectory && obj->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
+	{
+		yaffsfs_SetError(-ENOTDIR);
+	}
+	else
+	{
+		result = yaffs_Unlink(dir,name);
+		
+		if(result == YAFFS_FAIL && isDirectory)
+		{
+			yaffsfs_SetError(-ENOTEMPTY);
+		}
+	}
+	
+	yaffsfs_Unlock();
+	
+	// todo error
+	
+	return (result == YAFFS_FAIL) ? -1 : 0;
+}
+int yaffs_rmdir(const char *path) 
+{
+	return yaffsfs_DoUnlink(path,1);
+}
+
+int yaffs_unlink(const char *path) 
+{
+	return yaffsfs_DoUnlink(path,0);
+}
+
+int yaffs_rename(const char *oldPath, const char *newPath)
+{
+	yaffs_Object *olddir = NULL;
+	yaffs_Object *newdir = NULL;
+	yaffs_Object *obj = NULL;
+	char *oldname;
+	char *newname;
+	int result= YAFFS_FAIL;
+	int renameAllowed = 1;
+	
+	yaffsfs_Lock();
+	
+	olddir = yaffsfs_FindDirectory(NULL,oldPath,&oldname,0);
+	newdir = yaffsfs_FindDirectory(NULL,newPath,&newname,0);
+	obj = yaffsfs_FindObject(NULL,oldPath,0);
+	
+	if(!olddir || !newdir || !obj)
+	{
+		// bad file
+		yaffsfs_SetError(-EBADF);	
+		renameAllowed = 0;	
+	}
+	else if(olddir->myDev != newdir->myDev)
+	{
+		// oops must be on same device
+		// todo error
+		yaffsfs_SetError(-EXDEV);
+		renameAllowed = 0;	
+	}
+	else if(obj && obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY)
+	{
+		// It is a directory, check that it is not being renamed to 
+		// being its own decendent.
+		// Do this by tracing from the new directory back to the root, checking for obj
+		
+		yaffs_Object *xx = newdir;
+		
+		while( renameAllowed && xx)
+		{
+			if(xx == obj)
+			{
+				renameAllowed = 0;
+			}
+			xx = xx->parent;
+		}
+		if(!renameAllowed) yaffsfs_SetError(-EACCESS);
+	}
+	
+	if(renameAllowed)
+	{
+		result = yaffs_RenameObject(olddir,oldname,newdir,newname);
+	}
+	
+	yaffsfs_Unlock();
+	
+	return (result == YAFFS_FAIL) ? -1 : 0;	
+}
+
+
+static int yaffsfs_DoStat(yaffs_Object *obj,struct yaffs_stat *buf)
+{
+	int retVal = -1;
+
+	if(obj)
+	{
+		obj = yaffs_GetEquivalentObject(obj);
+	}
+
+	if(obj && buf)
+	{
+    	buf->st_dev = (int)obj->myDev->genericDevice;
+    	buf->st_ino = obj->objectId;
+    	buf->st_mode = obj->yst_mode & ~S_IFMT; // clear out file type bits
+	
+		if(obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY) 
+		{
+			buf->st_mode |= S_IFDIR;
+		}
+		else if(obj->variantType == YAFFS_OBJECT_TYPE_SYMLINK) 
+		{
+			buf->st_mode |= S_IFLNK;
+		}
+		else if(obj->variantType == YAFFS_OBJECT_TYPE_FILE)
+		{
+			buf->st_mode |= S_IFREG;
+		}
+		
+    	buf->st_nlink = yaffs_GetObjectLinkCount(obj);
+    	buf->st_uid = 0;    
+    	buf->st_gid = 0;;     
+    	buf->st_rdev = obj->yst_rdev;
+    	buf->st_size = yaffs_GetObjectFileLength(obj);
+		buf->st_blksize = obj->myDev->nDataBytesPerChunk;
+    	buf->st_blocks = (buf->st_size + buf->st_blksize -1)/buf->st_blksize;
+    	buf->yst_atime = obj->yst_atime; 
+    	buf->yst_ctime = obj->yst_ctime; 
+    	buf->yst_mtime = obj->yst_mtime; 
+		retVal = 0;
+	}
+	return retVal;
+}
+
+static int yaffsfs_DoStatOrLStat(const char *path, struct yaffs_stat *buf,int doLStat)
+{
+	yaffs_Object *obj;
+	
+	int retVal = -1;
+	
+	yaffsfs_Lock();
+	obj = yaffsfs_FindObject(NULL,path,0);
+	
+	if(!doLStat && obj)
+	{
+		obj = yaffsfs_FollowLink(obj,0);
+	}
+	
+	if(obj)
+	{
+		retVal = yaffsfs_DoStat(obj,buf);
+	}
+	else
+	{
+		// todo error not found
+		yaffsfs_SetError(-ENOENT);
+	}
+	
+	yaffsfs_Unlock();
+	
+	return retVal;
+	
+}
+
+int yaffs_stat(const char *path, struct yaffs_stat *buf)
+{
+	return yaffsfs_DoStatOrLStat(path,buf,0);
+}
+
+int yaffs_lstat(const char *path, struct yaffs_stat *buf)
+{
+	return yaffsfs_DoStatOrLStat(path,buf,1);
+}
+
+int yaffs_fstat(int fd, struct yaffs_stat *buf)
+{
+	yaffs_Object *obj;
+	
+	int retVal = -1;
+	
+	yaffsfs_Lock();
+	obj = yaffsfs_GetHandleObject(fd);
+	
+	if(obj)
+	{
+		retVal = yaffsfs_DoStat(obj,buf);
+	}
+	else
+	{
+		// bad handle
+		yaffsfs_SetError(-EBADF);		
+	}
+	
+	yaffsfs_Unlock();
+	
+	return retVal;
+}
+
+static int yaffsfs_DoChMod(yaffs_Object *obj,mode_t mode)
+{
+	int result;
+
+	if(obj)
+	{
+		obj = yaffs_GetEquivalentObject(obj);
+	}
+	
+	if(obj)
+	{
+		obj->yst_mode = mode;
+		obj->dirty = 1;
+		result = yaffs_FlushFile(obj,0);
+	}
+	
+	return result == YAFFS_OK ? 0 : -1;
+}
+
+
+int yaffs_chmod(const char *path, mode_t mode)
+{
+	yaffs_Object *obj;
+	
+	int retVal = -1;
+	
+	yaffsfs_Lock();
+	obj = yaffsfs_FindObject(NULL,path,0);
+	
+	if(obj)
+	{
+		retVal = yaffsfs_DoChMod(obj,mode);
+	}
+	else
+	{
+		// todo error not found
+		yaffsfs_SetError(-ENOENT);
+	}
+	
+	yaffsfs_Unlock();
+	
+	return retVal;
+	
+}
+
+
+int yaffs_fchmod(int fd, mode_t mode)
+{
+	yaffs_Object *obj;
+	
+	int retVal = -1;
+	
+	yaffsfs_Lock();
+	obj = yaffsfs_GetHandleObject(fd);
+	
+	if(obj)
+	{
+		retVal = yaffsfs_DoChMod(obj,mode);
+	}
+	else
+	{
+		// bad handle
+		yaffsfs_SetError(-EBADF);		
+	}
+	
+	yaffsfs_Unlock();
+	
+	return retVal;
+}
+
+
+int yaffs_mkdir(const char *path, mode_t mode)
+{
+	yaffs_Object *parent = NULL;
+	yaffs_Object *dir = NULL;
+	char *name;
+	int retVal= -1;
+	
+	yaffsfs_Lock();
+	parent = yaffsfs_FindDirectory(NULL,path,&name,0);
+	if(parent)
+		dir = yaffs_MknodDirectory(parent,name,mode,0,0);
+	if(dir)
+	{
+		retVal = 0;
+	}
+	else
+	{
+		yaffsfs_SetError(-ENOSPC); // just assume no space for now
+		retVal = -1;
+	}
+	
+	yaffsfs_Unlock();
+	
+	return retVal;
+}
+
+int yaffs_mount(const char *path)
+{
+	int retVal=-1;
+	int result=YAFFS_FAIL;
+	yaffs_Device *dev=NULL;
+	char *dummy;
+	
+	T(YAFFS_TRACE_ALWAYS,("yaffs: Mounting %s\n",path));
+	
+	yaffsfs_Lock();
+	dev = yaffsfs_FindDevice(path,&dummy);
+	if(dev)
+	{
+		if(!dev->isMounted)
+		{
+			result = yaffs_GutsInitialise(dev);
+			if(result == YAFFS_FAIL)
+			{
+				// todo error - mount failed
+				yaffsfs_SetError(-ENOMEM);
+			}
+			retVal = result ? 0 : -1;
+			
+		}
+		else
+		{
+			//todo error - already mounted.
+			yaffsfs_SetError(-EBUSY);
+		}
+	}
+	else
+	{
+		// todo error - no device
+		yaffsfs_SetError(-ENODEV);
+	}
+	yaffsfs_Unlock();
+	return retVal;
+	
+}
+
+int yaffs_unmount(const char *path)
+{
+	int retVal=-1;
+	yaffs_Device *dev=NULL;
+	char *dummy;
+	
+	yaffsfs_Lock();
+	dev = yaffsfs_FindDevice(path,&dummy);
+	if(dev)
+	{
+		if(dev->isMounted)
+		{
+			int i;
+			int inUse;
+			
+			yaffs_FlushEntireDeviceCache(dev);
+			yaffs_CheckpointSave(dev);
+			
+			for(i = inUse = 0; i < YAFFSFS_N_HANDLES && !inUse; i++)
+			{
+				if(yaffsfs_handle[i].inUse && yaffsfs_handle[i].obj->myDev == dev)
+				{
+					inUse = 1; // the device is in use, can't unmount
+				}
+			}
+			
+			if(!inUse)
+			{
+				yaffs_Deinitialise(dev);
+					
+				retVal = 0;
+			}
+			else
+			{
+				// todo error can't unmount as files are open
+				yaffsfs_SetError(-EBUSY);
+			}
+			
+		}
+		else
+		{
+			//todo error - not mounted.
+			yaffsfs_SetError(-EINVAL);
+			
+		}
+	}
+	else
+	{
+		// todo error - no device
+		yaffsfs_SetError(-ENODEV);
+	}	
+	yaffsfs_Unlock();
+	return retVal;
+	
+}
+
+loff_t yaffs_freespace(const char *path)
+{
+	loff_t retVal=-1;
+	yaffs_Device *dev=NULL;
+	char *dummy;
+	
+	yaffsfs_Lock();
+	dev = yaffsfs_FindDevice(path,&dummy);
+	if(dev  && dev->isMounted)
+	{
+		retVal = yaffs_GetNumberOfFreeChunks(dev);
+		retVal *= dev->nDataBytesPerChunk;
+		
+	}
+	else
+	{
+		yaffsfs_SetError(-EINVAL);
+	}
+	
+	yaffsfs_Unlock();
+	return retVal;	
+}
+
+
+
+void yaffs_initialise(yaffsfs_DeviceConfiguration *cfgList)
+{
+	
+	yaffsfs_DeviceConfiguration *cfg;
+	
+	yaffsfs_configurationList = cfgList;
+	
+	yaffsfs_InitHandles();
+	
+	cfg = yaffsfs_configurationList;
+	
+	while(cfg && cfg->prefix && cfg->dev)
+	{
+		cfg->dev->isMounted = 0;
+		cfg->dev->removeObjectCallback = yaffsfs_RemoveObjectCallback;
+		cfg++;
+	}
+	
+	
+}
+
+
+//
+// Directory search stuff.
+
+//
+// Directory search context
+//
+// NB this is an opaque structure.
+
+
+typedef struct
+{
+	__u32 magic;
+	yaffs_dirent de;		/* directory entry being used by this dsc */
+	char name[NAME_MAX+1];		/* name of directory being searched */
+	yaffs_Object *dirObj;		/* ptr to directory being searched */
+	yaffs_Object *nextReturn;	/* obj to be returned by next readddir */
+	int offset;
+	struct list_head others;	
+} yaffsfs_DirectorySearchContext;
+
+
+
+static struct list_head search_contexts;
+
+
+static void yaffsfs_SetDirRewound(yaffsfs_DirectorySearchContext *dsc)
+{
+	if(dsc &&
+	   dsc->dirObj &&
+	   dsc->dirObj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY){
+	   
+	   dsc->offset = 0;
+	   
+	   if( list_empty(&dsc->dirObj->variant.directoryVariant.children)){
+	   	dsc->nextReturn = NULL;
+	   } else {
+	      	dsc->nextReturn = list_entry(dsc->dirObj->variant.directoryVariant.children.next,
+						yaffs_Object,siblings);
+	   }
+	} else {
+		/* Hey someone isn't playing nice! */
+	}
+}
+
+static void yaffsfs_DirAdvance(yaffsfs_DirectorySearchContext *dsc)
+{
+	if(dsc &&
+	   dsc->dirObj &&
+	   dsc->dirObj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY){
+	   
+	   if( dsc->nextReturn == NULL ||
+	       list_empty(&dsc->dirObj->variant.directoryVariant.children)){
+	   	dsc->nextReturn = NULL;
+	   } else {
+		   struct list_head *next = dsc->nextReturn->siblings.next;
+   
+		   if( next == &dsc->dirObj->variant.directoryVariant.children)
+	   		dsc->nextReturn = NULL; /* end of list */
+	   	   else 
+		   	dsc->nextReturn = list_entry(next,yaffs_Object,siblings);
+	   }
+	} else {
+		/* Hey someone isn't playing nice! */
+	}
+}
+
+static void yaffsfs_RemoveObjectCallback(yaffs_Object *obj)
+{
+
+	struct list_head *i;
+	yaffsfs_DirectorySearchContext *dsc;
+	
+	/* if search contexts not initilised then skip */
+	if(!search_contexts.next)
+		return;
+		
+	/* Iteratethrough the directory search contexts.
+	 * If any are the one being removed, then advance the dsc to
+	 * the next one to prevent a hanging ptr.
+	 */
+	 list_for_each(i, &search_contexts) {
+		if (i) {
+			dsc = list_entry(i, yaffsfs_DirectorySearchContext,others);
+			if(dsc->nextReturn == obj)
+				yaffsfs_DirAdvance(dsc);
+		}
+	}
+				
+}
+
+yaffs_DIR *yaffs_opendir(const char *dirname)
+{
+	yaffs_DIR *dir = NULL;
+ 	yaffs_Object *obj = NULL;
+	yaffsfs_DirectorySearchContext *dsc = NULL;
+	
+	yaffsfs_Lock();
+	
+	obj = yaffsfs_FindObject(NULL,dirname,0);
+	
+	if(obj && obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY)
+	{
+		
+		dsc = YMALLOC(sizeof(yaffsfs_DirectorySearchContext));
+		dir = (yaffs_DIR *)dsc;
+		if(dsc)
+		{
+			memset(dsc,0,sizeof(yaffsfs_DirectorySearchContext));
+			dsc->magic = YAFFS_MAGIC;
+			dsc->dirObj = obj;
+			strncpy(dsc->name,dirname,NAME_MAX);
+			INIT_LIST_HEAD(&dsc->others);
+			
+			if(!search_contexts.next)
+				INIT_LIST_HEAD(&search_contexts);
+				
+			list_add(&dsc->others,&search_contexts);	
+			yaffsfs_SetDirRewound(dsc);		}
+	
+	}
+	
+	yaffsfs_Unlock();
+	
+	return dir;
+}
+
+struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp)
+{
+	yaffsfs_DirectorySearchContext *dsc = (yaffsfs_DirectorySearchContext *)dirp;
+	struct yaffs_dirent *retVal = NULL;
+		
+	yaffsfs_Lock();
+	
+	if(dsc && dsc->magic == YAFFS_MAGIC){
+		yaffsfs_SetError(0);
+		if(dsc->nextReturn){
+			dsc->de.d_ino = yaffs_GetEquivalentObject(dsc->nextReturn)->objectId;
+			dsc->de.d_dont_use = (unsigned)dsc->nextReturn;
+			dsc->de.d_off = dsc->offset++;
+			yaffs_GetObjectName(dsc->nextReturn,dsc->de.d_name,NAME_MAX);
+			if(strlen(dsc->de.d_name) == 0)
+			{
+				// this should not happen!
+				strcpy(dsc->de.d_name,"zz");
+			}
+			dsc->de.d_reclen = sizeof(struct yaffs_dirent);
+			retVal = &dsc->de;
+			yaffsfs_DirAdvance(dsc);
+		} else
+			retVal = NULL;
+	}
+	else
+	{
+		yaffsfs_SetError(-EBADF);
+	}
+	
+	yaffsfs_Unlock();
+	
+	return retVal;
+	
+}
+
+
+void yaffs_rewinddir(yaffs_DIR *dirp)
+{
+	yaffsfs_DirectorySearchContext *dsc = (yaffsfs_DirectorySearchContext *)dirp;
+	
+	yaffsfs_Lock();
+	
+	yaffsfs_SetDirRewound(dsc);
+
+	yaffsfs_Unlock();
+}
+
+
+int yaffs_closedir(yaffs_DIR *dirp)
+{
+	yaffsfs_DirectorySearchContext *dsc = (yaffsfs_DirectorySearchContext *)dirp;
+		
+	yaffsfs_Lock();
+	dsc->magic = 0;
+	list_del(&dsc->others); /* unhook from list */
+	YFREE(dsc);
+	yaffsfs_Unlock();
+	return 0;
+}
+
+// end of directory stuff
+
+
+int yaffs_symlink(const char *oldpath, const char *newpath)
+{
+	yaffs_Object *parent = NULL;
+	yaffs_Object *obj;
+	char *name;
+	int retVal= -1;
+	int mode = 0; // ignore for now
+	
+	yaffsfs_Lock();
+	parent = yaffsfs_FindDirectory(NULL,newpath,&name,0);
+	obj = yaffs_MknodSymLink(parent,name,mode,0,0,oldpath);
+	if(obj)
+	{
+		retVal = 0;
+	}
+	else
+	{
+		yaffsfs_SetError(-ENOSPC); // just assume no space for now
+		retVal = -1;
+	}
+	
+	yaffsfs_Unlock();
+	
+	return retVal;
+	
+}
+
+int yaffs_readlink(const char *path, char *buf, int bufsiz)
+{
+	yaffs_Object *obj = NULL;
+	int retVal;
+
+		
+	yaffsfs_Lock();
+	
+	obj = yaffsfs_FindObject(NULL,path,0);
+	
+	if(!obj)
+	{
+		yaffsfs_SetError(-ENOENT);
+		retVal = -1;
+	}
+	else if(obj->variantType != YAFFS_OBJECT_TYPE_SYMLINK)
+	{
+		yaffsfs_SetError(-EINVAL);
+		retVal = -1;
+	}
+	else
+	{
+		char *alias = obj->variant.symLinkVariant.alias;
+		memset(buf,0,bufsiz);
+		strncpy(buf,alias,bufsiz - 1);
+		retVal = 0;
+	}
+	yaffsfs_Unlock();
+	return retVal;
+}
+
+int yaffs_link(const char *oldpath, const char *newpath)
+{
+	// Creates a link called newpath to existing oldpath
+	yaffs_Object *obj = NULL;
+	yaffs_Object *target = NULL;
+	int retVal = 0;
+
+		
+	yaffsfs_Lock();
+	
+	obj = yaffsfs_FindObject(NULL,oldpath,0);
+	target = yaffsfs_FindObject(NULL,newpath,0);
+	
+	if(!obj)
+	{
+		yaffsfs_SetError(-ENOENT);
+		retVal = -1;
+	}
+	else if(target)
+	{
+		yaffsfs_SetError(-EEXIST);
+		retVal = -1;
+	}
+	else	
+	{
+		yaffs_Object *newdir = NULL;
+		yaffs_Object *link = NULL;
+		
+		char *newname;
+		
+		newdir = yaffsfs_FindDirectory(NULL,newpath,&newname,0);
+		
+		if(!newdir)
+		{
+			yaffsfs_SetError(-ENOTDIR);
+			retVal = -1;
+		}
+		else if(newdir->myDev != obj->myDev)
+		{
+			yaffsfs_SetError(-EXDEV);
+			retVal = -1;
+		}
+		if(newdir && strlen(newname) > 0)
+		{
+			link = yaffs_Link(newdir,newname,obj);
+			if(link)
+				retVal = 0;
+			else
+			{
+				yaffsfs_SetError(-ENOSPC);
+				retVal = -1;
+			}
+
+		}
+	}
+	yaffsfs_Unlock();
+	
+	return retVal;
+}
+
+int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev);
+
+int yaffs_DumpDevStruct(const char *path)
+{
+	char *rest;
+	
+	yaffs_Object *obj = yaffsfs_FindRoot(path,&rest);
+	
+	if(obj)
+	{
+		yaffs_Device *dev = obj->myDev;
+		
+		printf("\n"
+			   "nPageWrites.......... %d\n"
+			   "nPageReads........... %d\n"
+			   "nBlockErasures....... %d\n"
+			   "nGCCopies............ %d\n"
+			   "garbageCollections... %d\n"
+			   "passiveGarbageColl'ns %d\n"
+			   "\n",
+				dev->nPageWrites,
+				dev->nPageReads,
+				dev->nBlockErasures,
+				dev->nGCCopies,
+				dev->garbageCollections,
+				dev->passiveGarbageCollections
+		);
+		
+	}
+	return 0;
+}
+
diff --git a/fs/yaffs2/direct/yaffsfs.h b/fs/yaffs2/direct/yaffsfs.h
new file mode 100644
index 0000000..9afe60a
--- /dev/null
+++ b/fs/yaffs2/direct/yaffsfs.h
@@ -0,0 +1,233 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+/*
+ * Header file for using yaffs in an application via
+ * a direct interface.
+ */
+
+
+#ifndef __YAFFSFS_H__
+#define __YAFFSFS_H__
+
+#include "yaffscfg.h"
+#include "yportenv.h"
+
+
+//typedef long off_t;
+//typedef long dev_t;
+//typedef unsigned long mode_t;
+
+
+#ifndef NAME_MAX
+#define NAME_MAX	256
+#endif
+
+#ifndef O_RDONLY
+#define O_RDONLY	00
+#endif
+
+#ifndef O_WRONLY
+#define O_WRONLY	01
+#endif
+
+#ifndef O_RDWR
+#define O_RDWR		02
+#endif
+
+#ifndef O_CREAT		
+#define O_CREAT 	0100
+#endif
+
+#ifndef O_EXCL
+#define O_EXCL		0200
+#endif
+
+#ifndef O_TRUNC
+#define O_TRUNC		01000
+#endif
+
+#ifndef O_APPEND
+#define O_APPEND	02000
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET	0
+#endif
+
+#ifndef SEEK_CUR
+#define SEEK_CUR	1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END	2
+#endif
+
+#ifndef EBUSY
+#define EBUSY	16
+#endif
+
+#ifndef ENODEV
+#define ENODEV	19
+#endif
+
+#ifndef EINVAL
+#define EINVAL	22
+#endif
+
+#ifndef EBADF
+#define EBADF	9
+#endif
+
+#ifndef EACCESS
+#define EACCESS	13
+#endif
+
+#ifndef EXDEV	
+#define EXDEV	18
+#endif
+
+#ifndef ENOENT
+#define ENOENT	2
+#endif
+
+#ifndef ENOSPC
+#define ENOSPC	28
+#endif
+
+#ifndef ENOTEMPTY
+#define ENOTEMPTY 39
+#endif
+
+#ifndef ENOMEM
+#define ENOMEM 12
+#endif
+
+#ifndef EEXIST
+#define EEXIST 17
+#endif
+
+#ifndef ENOTDIR
+#define ENOTDIR 20
+#endif
+
+#ifndef EISDIR
+#define EISDIR 21
+#endif
+
+
+// Mode flags
+
+#ifndef S_IFMT
+#define S_IFMT		0170000
+#endif
+
+#ifndef S_IFLNK
+#define S_IFLNK		0120000
+#endif
+
+#ifndef S_IFDIR
+#define S_IFDIR		0040000
+#endif
+
+#ifndef S_IFREG
+#define S_IFREG		0100000
+#endif
+
+#ifndef S_IREAD 
+#define S_IREAD		0000400
+#endif
+
+#ifndef S_IWRITE
+#define	S_IWRITE	0000200
+#endif
+
+
+
+
+struct yaffs_dirent{
+    long d_ino;                 /* inode number */
+    off_t d_off;                /* offset to this dirent */
+    unsigned short d_reclen;    /* length of this d_name */
+    char d_name [NAME_MAX+1];   /* file name (null-terminated) */
+    unsigned d_dont_use;	/* debug pointer, not for public consumption */
+};
+
+typedef struct yaffs_dirent yaffs_dirent;
+
+
+typedef struct __opaque yaffs_DIR;
+
+
+
+struct yaffs_stat{
+    int		      st_dev;      /* device */
+    int           st_ino;      /* inode */
+    mode_t        st_mode;     /* protection */
+    int           st_nlink;    /* number of hard links */
+    int           st_uid;      /* user ID of owner */
+    int           st_gid;      /* group ID of owner */
+    unsigned      st_rdev;     /* device type (if inode device) */
+    off_t         st_size;     /* total size, in bytes */
+    unsigned long st_blksize;  /* blocksize for filesystem I/O */
+    unsigned long st_blocks;   /* number of blocks allocated */
+    unsigned long yst_atime;    /* time of last access */
+    unsigned long yst_mtime;    /* time of last modification */
+    unsigned long yst_ctime;    /* time of last change */
+};
+
+int yaffs_open(const char *path, int oflag, int mode) ;
+int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
+int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
+int yaffs_close(int fd) ;
+off_t yaffs_lseek(int fd, off_t offset, int whence) ;
+int yaffs_truncate(int fd, off_t newSize);
+
+int yaffs_unlink(const char *path) ;
+int yaffs_rename(const char *oldPath, const char *newPath) ;
+
+int yaffs_stat(const char *path, struct yaffs_stat *buf) ;
+int yaffs_lstat(const char *path, struct yaffs_stat *buf) ;
+int yaffs_fstat(int fd, struct yaffs_stat *buf) ;
+
+int yaffs_chmod(const char *path, mode_t mode); 
+int yaffs_fchmod(int fd, mode_t mode); 
+
+int yaffs_mkdir(const char *path, mode_t mode) ;
+int yaffs_rmdir(const char *path) ;
+
+yaffs_DIR *yaffs_opendir(const char *dirname) ;
+struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ;
+void yaffs_rewinddir(yaffs_DIR *dirp) ;
+int yaffs_closedir(yaffs_DIR *dirp) ;
+
+int yaffs_mount(const char *path) ;
+int yaffs_unmount(const char *path) ;
+
+int yaffs_symlink(const char *oldpath, const char *newpath); 
+int yaffs_readlink(const char *path, char *buf, int bufsiz); 
+
+int yaffs_link(const char *oldpath, const char *newpath); 
+int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev);
+
+loff_t yaffs_freespace(const char *path);
+
+void yaffs_initialise(yaffsfs_DeviceConfiguration *configList);
+
+int yaffs_StartUp(void);
+
+#endif
+
+
diff --git a/fs/yaffs2/direct/ydirectenv.h b/fs/yaffs2/direct/ydirectenv.h
new file mode 100644
index 0000000..0c28205
--- /dev/null
+++ b/fs/yaffs2/direct/ydirectenv.h
@@ -0,0 +1,88 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+/*
+ * ydirectenv.h: Environment wrappers for YAFFS direct.
+ */
+
+#ifndef __YDIRECTENV_H__
+#define __YDIRECTENV_H__
+
+// Direct interface
+
+#include "devextras.h"
+
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+#include "yaffs_malloc.h"
+
+#include "assert.h"
+#define YBUG() assert(1)
+
+#define YCHAR char
+#define YUCHAR unsigned char
+#define _Y(x) x
+#define yaffs_strcpy(a,b)    strcpy(a,b)
+#define yaffs_strncpy(a,b,c) strncpy(a,b,c)
+#define yaffs_strncmp(a,b,c) strncmp(a,b,c)
+#define yaffs_strlen(s)	     strlen(s)
+#define yaffs_sprintf	     sprintf
+#define yaffs_toupper(a)     toupper(a)
+
+#ifdef NO_Y_INLINE
+#define Y_INLINE
+#else
+#define Y_INLINE inline
+#endif
+
+#define YMALLOC(x) yaffs_malloc(x)
+#define YFREE(x)   free(x)
+#define YMALLOC_ALT(x) yaffs_malloc(x)
+#define YFREE_ALT(x)   free(x)
+
+#define YMALLOC_DMA(x) yaffs_malloc(x)
+
+#define YYIELD()  do {} while(0)
+
+
+
+//#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
+//#define YALERT(s) YINFO(s)
+
+
+#define TENDSTR "\n"
+#define TSTR(x) x
+#define TOUT(p) printf p
+
+
+#define YAFFS_LOSTNFOUND_NAME		"lost+found"
+#define YAFFS_LOSTNFOUND_PREFIX		"obj"
+//#define YPRINTF(x) printf x
+
+#include "yaffscfg.h"
+
+#define Y_CURRENT_TIME yaffsfs_CurrentTime()
+#define Y_TIME_CONVERT(x) x
+
+#define YAFFS_ROOT_MODE				0666
+#define YAFFS_LOSTNFOUND_MODE		0666
+
+#define yaffs_SumCompare(x,y) ((x) == (y))
+#define yaffs_strcmp(a,b) strcmp(a,b)
+
+#endif
+
+
