*** empty log message ***
[yaffs/.git] / yaffs_fileem.c
index 700695b52dadc8227c22f637ad0b513f3c26b132..f4a324e113e33b2e590d7f73fd01009c04524648 100644 (file)
@@ -137,17 +137,18 @@ static void  CheckInit(yaffs_Device *dev)
        static int initialised = 0;
 
        int length;
+       int nWritten;
 
        
        if(!initialised)
        {
                memset(ffChunk,0xFF,528);
                
-#ifdef YAFFS_DUMP
-               h = open("yaffs-em-file" , O_RDONLY);
-#else
+//#ifdef YAFFS_DUMP
+//             h = open("yaffs-em-file" , O_RDONLY);
+//#else
                h = open("yaffs-em-file" , O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
-#endif
+//#endif
                if(h < 0)
                {
                        perror("Fatal error opening yaffs emulation file");
@@ -156,27 +157,26 @@ static void  CheckInit(yaffs_Device *dev)
                initialised = 1;
                
                length = lseek(h,0,SEEK_END);
-               if(length !=  FILE_SIZE_IN_BYTES)
+               nWritten = 528;
+               while(length <  FILE_SIZE_IN_BYTES && nWritten == 528)
                {
-                       // Create file contents
-                       int i;
-                       
-                       printf("Creating emulation file...\n");
-                       for(i = 0; i < FILE_SIZE_IN_BLOCKS; i++)
-                       {
-                               yaffs_FEEraseBlockInNAND(dev,i);
-                               
-                               if(IsAMarkedBadBlock(i))
-                               {
-                                       yaffs_Spare spare;
-                                       memset(&spare,0xff,sizeof(spare));
-                                       spare.blockStatus = 1;
-                                       
-                                       yaffs_FEWriteChunkToNAND(dev, i * 32,NULL,&spare);
-                               }
-                       }
+                       write(h,ffChunk,528);
+                       length = lseek(h,0,SEEK_END);           
+               }
+               if(nWritten != 528)
+               {
+                       perror("Fatal error expanding yaffs emulation file");
+                       exit(1);
+
                }
-               eraseDisplayEnabled = 1;
+               
+               close(h);
+               
+#ifdef YAFFS_DUMP
+               h = open("yaffs-em-file" , O_RDONLY);
+#else
+               h = open("yaffs-em-file" , O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
+#endif
        }
 }