X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fyaffsfs.c;h=bd94a89bb984163ff2d20e7162bde7243d0bcc4b;hp=0638c80b4af0423af184291efa4e43ff68c51e34;hb=170ea32c52fd2d9b7cbda9b169ad44038b1d15cf;hpb=a43ef00519138a156135816bd164afb9e7feaa99 diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 0638c80..bd94a89 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -1,8 +1,8 @@ /* - * 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 * @@ -25,7 +25,7 @@ #endif -const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.9 2006-03-01 08:18:09 charles Exp $"; +const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.16 2007-02-12 16:49:50 wookey Exp $"; // configurationList is the list of devices that are supported static yaffsfs_DeviceConfiguration *yaffsfs_configurationList; @@ -620,7 +620,7 @@ int yaffs_write(int fd, const void *buf, unsigned int nbyte) } -int yaffs_truncate(int fd, unsigned int newSize) +int yaffs_truncate(int fd, off_t newSize) { yaffsfs_Handle *h = NULL; yaffs_Object *obj = NULL; @@ -729,10 +729,6 @@ int yaffsfs_DoUnlink(const char *path,int isDirectory) { yaffsfs_SetError(-ENOTDIR); } - else if(isDirectory && obj->variantType != YAFFS_OBJECT_TYPE_DIRECTORY) - { - yaffsfs_SetError(-ENOTDIR); - } else { result = yaffs_Unlink(dir,name); @@ -851,7 +847,7 @@ static int yaffsfs_DoStat(yaffs_Object *obj,struct yaffs_stat *buf) 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; @@ -1076,6 +1072,10 @@ int yaffs_unmount(const char *path) { int i; int inUse; + + yaffs_FlushEntireDeviceCache(dev); + yaffs_CheckpointSave(dev); + for(i = inUse = 0; i < YAFFSFS_N_HANDLES && !inUse; i++) { if(yaffsfs_handle[i].inUse && yaffsfs_handle[i].obj->myDev == dev) @@ -1114,9 +1114,9 @@ int yaffs_unmount(const char *path) } -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; @@ -1125,7 +1125,7 @@ off_t yaffs_freespace(const char *path) if(dev && dev->isMounted) { retVal = yaffs_GetNumberOfFreeChunks(dev); - retVal *= dev->nBytesPerChunk; + retVal *= dev->nDataBytesPerChunk; } else @@ -1298,8 +1298,14 @@ struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) 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); @@ -1408,7 +1414,7 @@ int yaffs_link(const char *oldpath, const char *newpath) // Creates a link called newpath to existing oldpath yaffs_Object *obj = NULL; yaffs_Object *target = NULL; - int retVal; + int retVal = 0; yaffsfs_Lock();