changeset 23:12ec56e7ccfa

Some tinkering on test harness and st_xxx to yst_xxx changes
author charles
date Tue, 19 Jul 2005 00:12:00 +0100
parents d1b2721cc645
children 4ebabd859f38
files direct/Makefile direct/dtest.c direct/yaffs_fileem2k.c direct/yaffs_fileem2k.h direct/yaffscfg2k.c direct/yaffsfs.c direct/yaffsfs.h
diffstat 7 files changed, 59 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/direct/Makefile
+++ b/direct/Makefile
@@ -12,16 +12,20 @@
 #
 # $Id$
 
-CFLAGS =    -Wall -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 -g
+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)
 #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_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o
+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
 
 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 =  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_ramem2k.c yaffs_nandemul2k.h \
--- a/direct/dtest.c
+++ b/direct/dtest.c
@@ -321,7 +321,7 @@ void fill_disk(char *path,int nfiles)
 		
 		while ((result = yaffs_write(h,xx,600)) == 600)
 		{
-			f = yaffs_freespace("/boot");
+			f = yaffs_freespace(path);
 		}
 		result = yaffs_close(h);
 		printf(" close %d\n",result);
@@ -1241,6 +1241,20 @@ int truncate_test(void)
 
 
 
+
+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 scan_deleted_files_test(const char *mountpt)
 {
 	char fn[100];
@@ -1316,7 +1330,7 @@ int main(int argc, char *argv[])
 	
 	//long_test_on_path("/ram2k");
 	//long_test_on_path("/flash");
-	scan_deleted_files_test("/flash");
+	fill_disk_test("/flash");
 	
 	
 	
--- a/direct/yaffs_fileem2k.c
+++ b/direct/yaffs_fileem2k.c
@@ -55,7 +55,7 @@ typedef struct
 
 static yflash_Device filedisk;
 
-static int  CheckInit(yaffs_Device *dev)
+static int  CheckInit(void)
 {
 	static int initialised = 0;
 	
@@ -107,16 +107,28 @@ static int  CheckInit(yaffs_Device *dev)
 			}
 		}		
 	}
+	else
+	{
+		filedisk.nBlocks = fSize/(BLOCK_SIZE);
+	}
 	
 	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;
 
-	CheckInit(dev);
+	CheckInit();
 	
 	
 	
@@ -160,7 +172,7 @@ int yflash_MarkNANDBlockBad(struct yaffs
 	
 	yaffs_PackedTags2 pt;
 
-	CheckInit(dev);
+	CheckInit();
 	
 	memset(&pt,0,sizeof(pt));
 	lseek(filedisk.handle,(blockNo * dev->nChunksPerBlock) * PAGE_SIZE + PAGE_DATA_SIZE,SEEK_SET);
@@ -190,7 +202,7 @@ int yflash_ReadChunkWithTagsFromNAND(yaf
 	int nread;
 	int pos;
 
-	CheckInit(dev);
+	CheckInit();
 	
 	
 	
@@ -240,7 +252,7 @@ int yflash_EraseBlockInNAND(yaffs_Device
 
 	int i;
 		
-	CheckInit(dev);
+	CheckInit();
 	
 	if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
 	{
@@ -271,7 +283,7 @@ int yflash_EraseBlockInNAND(yaffs_Device
 
 int yflash_InitialiseNAND(yaffs_Device *dev)
 {
-	CheckInit(dev);
+	CheckInit();
 	
 	return YAFFS_OK;
 }
--- a/direct/yaffs_fileem2k.h
+++ b/direct/yaffs_fileem2k.h
@@ -41,5 +41,8 @@
 
 #endif
 
+
+int yflash_GetNumberOfBlocks(void);
+
 #endif
 
--- a/direct/yaffscfg2k.c
+++ b/direct/yaffscfg2k.c
@@ -118,9 +118,9 @@ int yaffs_StartUp(void)
 	flashDev.nBytesPerChunk = 2048;
 	flashDev.nChunksPerBlock = 64;
 	flashDev.nReservedBlocks = 5;
-	flashDev.startBlock = 64; // First block after /boot
+	flashDev.startBlock = 0; 
 	//flashDev.endBlock = 127; // Last block in 16MB
-	flashDev.endBlock = (32 * 1024 * 1024)/(flashDev.nBytesPerChunk * flashDev.nChunksPerBlock) - 1; // Last block in 512MB
+	flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
 	flashDev.isYaffs2 = 1;
 	flashDev.nShortOpCaches = 10; // Use caches
 	flashDev.genericDevice = (void *) 2;	// Used to identify the device in fstat.
--- a/direct/yaffsfs.c
+++ b/direct/yaffsfs.c
@@ -410,19 +410,19 @@ int yaffs_open(const char *path, int ofl
 			
 			// Check file permissions
 			if( (oflag & (O_RDWR | O_WRONLY)) == 0 &&     // ie O_RDONLY
-			   !(obj->st_mode & S_IREAD))
+			   !(obj->yst_mode & S_IREAD))
 			{
 				openDenied = 1;
 			}
 
 			if( (oflag & O_RDWR) && 
-			   !(obj->st_mode & S_IREAD))
+			   !(obj->yst_mode & S_IREAD))
 			{
 				openDenied = 1;
 			}
 
 			if( (oflag & (O_RDWR | O_WRONLY)) && 
-			   !(obj->st_mode & S_IWRITE))
+			   !(obj->yst_mode & S_IWRITE))
 			{
 				openDenied = 1;
 			}
@@ -835,7 +835,7 @@ static int yaffsfs_DoStat(yaffs_Object *
 	{
     	buf->st_dev = (int)obj->myDev->genericDevice;
     	buf->st_ino = obj->objectId;
-    	buf->st_mode = obj->st_mode & ~S_IFMT; // clear out file type bits
+    	buf->st_mode = obj->yst_mode & ~S_IFMT; // clear out file type bits
 	
 		if(obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY) 
 		{
@@ -853,13 +853,13 @@ static int yaffsfs_DoStat(yaffs_Object *
     	buf->st_nlink = yaffs_GetObjectLinkCount(obj);
     	buf->st_uid = 0;    
     	buf->st_gid = 0;;     
-    	buf->st_rdev = obj->st_rdev;
+    	buf->st_rdev = obj->yst_rdev;
     	buf->st_size = yaffs_GetObjectFileLength(obj);
 		buf->st_blksize = obj->myDev->nBytesPerChunk;
     	buf->st_blocks = (buf->st_size + buf->st_blksize -1)/buf->st_blksize;
-    	buf->st_atime = obj->st_atime; 
-    	buf->st_ctime = obj->st_ctime; 
-    	buf->st_mtime = obj->st_mtime; 
+    	buf->yst_atime = obj->yst_atime; 
+    	buf->yst_ctime = obj->yst_ctime; 
+    	buf->yst_mtime = obj->yst_mtime; 
 		retVal = 0;
 	}
 	return retVal;
@@ -940,7 +940,7 @@ static int yaffsfs_DoChMod(yaffs_Object 
 	
 	if(obj)
 	{
-		obj->st_mode = mode;
+		obj->yst_mode = mode;
 		obj->dirty = 1;
 		result = yaffs_FlushFile(obj,0);
 	}
--- a/direct/yaffsfs.h
+++ b/direct/yaffsfs.h
@@ -155,6 +155,7 @@ typedef struct yaffs_dirent yaffs_dirent
 typedef struct __opaque yaffs_DIR;
 
 
+
 struct yaffs_stat{
     int		      st_dev;      /* device */
     int           st_ino;      /* inode */
@@ -166,9 +167,9 @@ struct yaffs_stat{
     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 st_atime;    /* time of last access */
-    unsigned long st_mtime;    /* time of last modification */
-    unsigned long st_ctime;    /* time of last change */
+    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) ;