-/* YAFFS: Yet another FFS. A NAND-flash specific file system.
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
*
- * Copyright (C) 2002 Aleph One Ltd.
+ * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering
*
* Created by Charles Manning <charles@aleph1.co.uk>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
- *
*/
const char *yaffs_checkptrw_c_version =
- "$Id: yaffs_checkptrw.c,v 1.11 2006-11-11 23:27:04 charles Exp $";
+ "$Id: yaffs_checkptrw.c,v 1.14 2007-05-15 20:07:40 charles Exp $";
#include "yaffs_checkptrw.h"
}
-
static int yaffs_CheckpointErase(yaffs_Device *dev)
{
dev->checkpointOpenForWrite = forWriting;
dev->checkpointByteCount = 0;
+ dev->checkpointSum = 0;
+ dev->checkpointXor = 0;
dev->checkpointCurrentBlock = -1;
dev->checkpointCurrentChunk = -1;
dev->checkpointNextBlock = dev->internalStartBlock;
return 1;
}
+int yaffs_GetCheckpointSum(yaffs_Device *dev, __u32 *sum)
+{
+ __u32 compositeSum;
+ compositeSum = (dev->checkpointSum << 8) | (dev->checkpointXor & 0xFF);
+ *sum = compositeSum;
+ return 1;
+}
+
static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
{
if(!dev->checkpointBuffer)
return 0;
+
+ if(!dev->checkpointOpenForWrite)
+ return -1;
while(i < nBytes && ok) {
- dev->checkpointBuffer[dev->checkpointByteOffset] = *dataBytes ;
+ dev->checkpointBuffer[dev->checkpointByteOffset] = *dataBytes ;
+ dev->checkpointSum += *dataBytes;
+ dev->checkpointXor ^= *dataBytes;
+
dev->checkpointByteOffset++;
i++;
dataBytes++;
if(!dev->checkpointBuffer)
return 0;
+ if(dev->checkpointOpenForWrite)
+ return -1;
+
while(i < nBytes && ok) {
if(ok){
*dataBytes = dev->checkpointBuffer[dev->checkpointByteOffset];
+ dev->checkpointSum += *dataBytes;
+ dev->checkpointXor ^= *dataBytes;
dev->checkpointByteOffset++;
i++;
dataBytes++;