/*
- * YAFFS: Yet another FFS. A NAND-flash specific file system.
- * yaffsfs.c The interface functions for using YAFFS via a "direct" interface.
+ * 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.
- *
*/
#include "yaffsfs.h"
#endif
-const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.12 2006-05-08 10:13:35 charles Exp $";
+const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.18 2007-07-18 19:40:38 charles Exp $";
// configurationList is the list of devices that are supported
static yaffsfs_DeviceConfiguration *yaffsfs_configurationList;
// Handle management.
//
+
+unsigned int yaffs_wr_attempts;
+
typedef struct
{
__u8 inUse:1; // this handle is in use
}
-int yaffs_truncate(int fd, unsigned int newSize)
+int yaffs_truncate(int fd, off_t newSize)
{
yaffsfs_Handle *h = NULL;
yaffs_Object *obj = NULL;
{
yaffsfs_SetError(-ENOTDIR);
}
- else if(isDirectory && obj->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
- {
- yaffsfs_SetError(-ENOTDIR);
- }
else
{
result = yaffs_Unlink(dir,name);
buf->st_gid = 0;;
buf->st_rdev = obj->yst_rdev;
buf->st_size = yaffs_GetObjectFileLength(obj);
- buf->st_blksize = obj->myDev->nBytesPerChunk;
+ buf->st_blksize = obj->myDev->nDataBytesPerChunk;
buf->st_blocks = (buf->st_size + buf->st_blksize -1)/buf->st_blksize;
buf->yst_atime = obj->yst_atime;
buf->yst_ctime = obj->yst_ctime;
}
-off_t yaffs_freespace(const char *path)
+loff_t yaffs_freespace(const char *path)
{
- off_t retVal=-1;
+ loff_t retVal=-1;
yaffs_Device *dev=NULL;
char *dummy;
if(dev && dev->isMounted)
{
retVal = yaffs_GetNumberOfFreeChunks(dev);
- retVal *= dev->nBytesPerChunk;
+ retVal *= dev->nDataBytesPerChunk;
}
else
yaffsfs_SetError(0);
if(dsc->nextReturn){
dsc->de.d_ino = yaffs_GetEquivalentObject(dsc->nextReturn)->objectId;
+ dsc->de.d_dont_use = (unsigned)dsc->nextReturn;
dsc->de.d_off = dsc->offset++;
- yaffs_GetObjectName(dsc->nextReturn,dsc->de.d_name,NAME_MAX+1);
+ yaffs_GetObjectName(dsc->nextReturn,dsc->de.d_name,NAME_MAX);
+ if(strlen(dsc->de.d_name) == 0)
+ {
+ // this should not happen!
+ strcpy(dsc->de.d_name,"zz");
+ }
dsc->de.d_reclen = sizeof(struct yaffs_dirent);
retVal = &dsc->de;
yaffsfs_DirAdvance(dsc);