X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fyaffsfs.c;h=67671ea6b69e90ce155b7cb68437f9c99ed34792;hp=4f06f9c6ef10e41e390bf0e58bf5b8fe5f007eec;hb=e1b8e63260986ab7afec3c379e7a320677c95846;hpb=f67d10d7a5a6d1cc7d1cb6eaada2522873ce5e99 diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 4f06f9c..67671ea 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -25,7 +25,7 @@ #endif -const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.7 2005-10-07 03:48:50 charles Exp $"; +const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.12 2006-05-08 10:13:35 charles Exp $"; // configurationList is the list of devices that are supported static yaffsfs_DeviceConfiguration *yaffsfs_configurationList; @@ -999,13 +999,14 @@ int yaffs_fchmod(int fd, mode_t mode) int yaffs_mkdir(const char *path, mode_t mode) { yaffs_Object *parent = NULL; - yaffs_Object *dir; + yaffs_Object *dir = NULL; char *name; int retVal= -1; yaffsfs_Lock(); parent = yaffsfs_FindDirectory(NULL,path,&name,0); - dir = yaffs_MknodDirectory(parent,name,mode,0,0); + if(parent) + dir = yaffs_MknodDirectory(parent,name,mode,0,0); if(dir) { retVal = 0; @@ -1075,6 +1076,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) @@ -1402,7 +1407,66 @@ int yaffs_readlink(const char *path, char *buf, int bufsiz) return retVal; } -int yaffs_link(const char *oldpath, const char *newpath); +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 = 0; + + + yaffsfs_Lock(); + + obj = yaffsfs_FindObject(NULL,oldpath,0); + target = yaffsfs_FindObject(NULL,newpath,0); + + if(!obj) + { + yaffsfs_SetError(-ENOENT); + retVal = -1; + } + else if(target) + { + yaffsfs_SetError(-EEXIST); + retVal = -1; + } + else + { + yaffs_Object *newdir = NULL; + yaffs_Object *link = NULL; + + char *newname; + + newdir = yaffsfs_FindDirectory(NULL,newpath,&newname,0); + + if(!newdir) + { + yaffsfs_SetError(-ENOTDIR); + retVal = -1; + } + else if(newdir->myDev != obj->myDev) + { + yaffsfs_SetError(-EXDEV); + retVal = -1; + } + if(newdir && strlen(newname) > 0) + { + link = yaffs_Link(newdir,newname,obj); + if(link) + retVal = 0; + else + { + yaffsfs_SetError(-ENOSPC); + retVal = -1; + } + + } + } + yaffsfs_Unlock(); + + return retVal; +} + int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev); int yaffs_DumpDevStruct(const char *path)