+
+ memcpy(localBuffer,data, dev->nDataBytesPerChunk);
+
+ n_partials = rand()%20;
+
+ for(i = 0; i < n_partials; i++){
+ bpos = rand() % dev->nDataBytesPerChunk;
+
+ localBuffer[bpos] |= (1 << (rand() & 7));
+ }
+
+ if(REPORT_ERROR && 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);
+ }
+
+
+ if(written != dev->nDataBytesPerChunk) return YAFFS_FAIL;
+ }
+ // yflash2_MaybePowerFail(chunkInNAND,1);
+
+ 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))];
+