X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs%2F.git;a=blobdiff_plain;f=yaffs_fileem.c;h=3ee50eb739ab6a39f32bff4259b985a0ec331c14;hp=700695b52dadc8227c22f637ad0b513f3c26b132;hb=8f88750ecfa15e4ddb80fcc6080a0c104fd27bd9;hpb=a1d28cf77fe06fe98cea4c4e80cc1cab94ea6736 diff --git a/yaffs_fileem.c b/yaffs_fileem.c index 700695b..3ee50eb 100644 --- a/yaffs_fileem.c +++ b/yaffs_fileem.c @@ -26,7 +26,7 @@ #include #include -#define FILE_SIZE_IN_MEG 4 +#define FILE_SIZE_IN_MEG 2 // #define YAFFS_ERROR_TESTING @@ -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 } }