*/
-const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.5 2005-04-29 07:01:18 charles Exp $";
+const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.6 2005-07-03 10:32:40 charles Exp $";
extern const char *yaffs_guts_c_version;
yaffs_GrossLock(obj->myDev);
- nWritten = yaffs_WriteDataToFile(obj,buffer,page->index << PAGE_CACHE_SHIFT,nBytes);
+ nWritten = yaffs_WriteDataToFile(obj,buffer,page->index << PAGE_CACHE_SHIFT,nBytes,0);
yaffs_GrossUnlock(obj->myDev);
T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write about to write writing %d bytes to object %d at %d\n",n,obj->objectId,ipos));
}
- nWritten = yaffs_WriteDataToFile(obj,buf,ipos,n);
+ nWritten = yaffs_WriteDataToFile(obj,buf,ipos,n,0);
T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write writing %d bytes, %d written at %d\n",n,nWritten,ipos));
if(nWritten > 0)
*/
//yaffs_guts.c
-const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.6 2005-04-24 09:57:06 charles Exp $";
+const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.7 2005-07-03 10:32:40 charles Exp $";
#include "yportenv.h"
static int yaffs_PutChunkIntoFile(yaffs_Object *in,int chunkInInode, int chunkInNAND, int inScan)
{
- // NB inScan is zero unless scanning. For forward scanning, inScan is > 0 for backward scanning inScan is < 0
+ // NB inScan is zero unless scanning. For forward scanning, inScan is > 0; for backward scanning inScan is < 0
yaffs_Tnode *tn;
yaffs_Device *dev = in->myDev;
int existingChunk;
// chunk should ever be affected.
//
// Correction for YAFFS2: This could happen quite a lot and we need to think about efficiency! TODO
+ // Update: For backward scanning we don't need to re-read tags so this is quite cheap.
+
if(existingChunk != 0)
//
//
- if(inScan >= 0)
+ if(inScan > 0)
{
- // No need to do this for backward scanning
+ // Only do this for forward scanning
yaffs_ReadChunkWithTagsFromNAND(dev,chunkInNAND, NULL,&newTags);
newSerial = newTags.serialNumber;
existingSerial = existingTags.serialNumber;
- if( (inScan >= 0) &&
+ if( (inScan > 0) &&
( in->myDev->isYaffs2 ||
existingChunk <= 0 ||
((existingSerial+1) & 3) == newSerial))
{
- // Forward scanning or not during scanning
-
+ // Forward scanning.
// Use new
// Delete the old one and drop through to update the tnode
yaffs_DeleteChunk(dev,existingChunk,1,__LINE__);
-int yaffs_WriteDataToFile(yaffs_Object *in,const __u8 * buffer, __u32 offset, int nBytes)
+int yaffs_WriteDataToFile(yaffs_Object *in,const __u8 * buffer, __u32 offset, int nBytes, int writeThrough)
{
int chunk;
// OK now check for the curveball where the start and end are in
// the same chunk.
- if( (start + n) < dev->nBytesPerChunk)
+ if((start + n) < dev->nBytesPerChunk)
{
nToCopy = n;
{
// An incomplete start or end chunk (or maybe both start and end chunk)
if(dev->nShortOpCaches > 0)
- {
+ {
yaffs_ChunkCache *cache;
// If we can't find the data in the cache, then load it up.
cache = yaffs_FindChunkCache(in,chunk);
#endif
cache->locked = 0;
cache->nBytes = nToWriteBack;
+
+ if(writeThrough)
+ {
+ chunkWritten = yaffs_WriteChunkDataToObject(cache->object,
+ cache->chunkId,
+ cache->data,
+ cache->nBytes,1);
+ cache->dirty = 0;
+ }
+
}
else
{
*
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*
- * $Id: yaffs_guts.h,v 1.4 2005-04-24 09:57:06 charles Exp $
+ * $Id: yaffs_guts.h,v 1.5 2005-07-03 10:32:40 charles Exp $
*/
#ifndef __YAFFS_GUTS_H__
struct list_head siblings; // siblings in a directory
// also used for linking up the free list
- // Where's my data in NAND?
+ // Where's my object header in NAND?
int chunkId; // where it lives
- int nDataChunks;
+ int nDataChunks; // Number of data chunks attached to the file.
__u32 objectId; // the object id value
// File operations
int yaffs_ReadDataFromFile(yaffs_Object *obj, __u8 *buffer, __u32 offset, int nBytes);
-int yaffs_WriteDataToFile(yaffs_Object *obj, const __u8 *buffer, __u32 offset, int nBytes);
+int yaffs_WriteDataToFile(yaffs_Object *obj, const __u8 *buffer, __u32 offset, int nBytes, int writeThrough);
int yaffs_ResizeFile(yaffs_Object *obj, int newSize);
yaffs_Object *yaffs_MknodFile(yaffs_Object *parent,const YCHAR *name, __u32 mode, __u32 uid, __u32 gid);