Some tinkering on test harness and st_xxx to yst_xxx changes
authorcharles <charles>
Mon, 18 Jul 2005 23:12:00 +0000 (23:12 +0000)
committercharles <charles>
Mon, 18 Jul 2005 23:12:00 +0000 (23:12 +0000)
direct/Makefile
direct/dtest.c
direct/yaffs_fileem2k.c
direct/yaffs_fileem2k.h
direct/yaffscfg2k.c
direct/yaffsfs.c
direct/yaffsfs.h

index cb76c590a6c50bb8e4a2be64e413b6ca233c138e..3d7c263a8673633a7ac1a775200ef54377196440 100644 (file)
 #
 # NB Warning this Makefile does not include header dependencies.
 #
-# $Id: Makefile,v 1.6 2005-07-03 05:48:11 charles Exp $
+# $Id: Makefile,v 1.7 2005-07-18 23:12:00 charles Exp $
 
-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 \
index 4d9cb894566d6a5c0cd8d986255fd45d2396517d..8100406266e582141b5834377d78c28d94d933bc 100644 (file)
@@ -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");
        
        
        
index 786094b349a307c5ab28ba41feb05f068086e1b4..4c5e200ed9f0c5384efbdb136175b59f4abdd7d2 100644 (file)
@@ -15,7 +15,7 @@
 // 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.3 2005-07-03 05:48:11 charles Exp $";
+const char *yaffs_flashif_c_version = "$Id: yaffs_fileem2k.c,v 1.4 2005-07-18 23:12:00 charles Exp $";
 
 
 #include "yportenv.h"
@@ -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_DeviceStruct *dev, int blockNo)
        
        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(yaffs_Device *dev,int chunkInNAND, __u8 *da
        int nread;
        int pos;
 
-       CheckInit(dev);
+       CheckInit();
        
        
        
@@ -240,7 +252,7 @@ int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
 
        int i;
                
-       CheckInit(dev);
+       CheckInit();
        
        if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
        {
@@ -271,7 +283,7 @@ int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
 
 int yflash_InitialiseNAND(yaffs_Device *dev)
 {
-       CheckInit(dev);
+       CheckInit();
        
        return YAFFS_OK;
 }
index febbf84dbec02dc267aaa485541845b5dff0e036..222df53ef07a503b8ee2ef1b0cf5d657feee0c1e 100644 (file)
@@ -41,5 +41,8 @@
 
 #endif
 
+
+int yflash_GetNumberOfBlocks(void);
+
 #endif
 
index 7a67df0072ddbc1155f12948e12dffc7563c8073..9c45524774993f7097c7821faa58057cebc5455b 100644 (file)
@@ -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.
index 9109da7f1df5d635de725d95b590a4806159e65e..821848ec805a9344911cfd0e25ace4a72227e877 100644 (file)
@@ -25,7 +25,7 @@
 #endif
 
 
-const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.4 2005-07-03 05:48:11 charles Exp $";
+const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.5 2005-07-18 23:12:00 charles Exp $";
 
 // configurationList is the list of devices that are supported
 static yaffsfs_DeviceConfiguration *yaffsfs_configurationList;
@@ -410,19 +410,19 @@ int yaffs_open(const char *path, int oflag, int mode)
                        
                        // 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 *obj,struct yaffs_stat *buf)
        {
        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 *obj,struct yaffs_stat *buf)
        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 *obj,mode_t mode)
        
        if(obj)
        {
-               obj->st_mode = mode;
+               obj->yst_mode = mode;
                obj->dirty = 1;
                result = yaffs_FlushFile(obj,0);
        }
index 2a6ae2720cdf036b4f0199da75c5c5688ad4bbfb..b670f11690282531e9c213566707342576ffe345 100644 (file)
@@ -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) ;