2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
3 * yaffsfs.c The interface functions for using YAFFS via a "direct" interface.
5 * Copyright (C) 2002 Aleph One Ltd.
7 * Created by Charles Manning <charles@aleph1.co.uk>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
16 #include "yaffs_guts.h"
18 #include <string.h> // for memset
21 #define YAFFSFS_MAX_SYMLINK_DEREFERENCES 5
24 #define NULL ((void *)0)
28 const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.6 2005-09-20 05:05:40 charles Exp $";
30 // configurationList is the list of devices that are supported
31 static yaffsfs_DeviceConfiguration *yaffsfs_configurationList;
34 /* Some forward references */
35 static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const char *path, int symDepth);
36 static void yaffsfs_RemoveObjectCallback(yaffs_Object *obj);
44 __u8 inUse:1; // this handle is in use
45 __u8 readOnly:1; // this handle is read only
46 __u8 append:1; // append only
47 __u8 exclusive:1; // exclusive
48 __u32 position; // current position in file
49 yaffs_Object *obj; // the object
53 static yaffsfs_Handle yaffsfs_handle[YAFFSFS_N_HANDLES];
56 /// Inilitalise handles on start-up.
58 static int yaffsfs_InitHandles(void)
61 for(i = 0; i < YAFFSFS_N_HANDLES; i++)
63 yaffsfs_handle[i].inUse = 0;
64 yaffsfs_handle[i].obj = NULL;
69 yaffsfs_Handle *yaffsfs_GetHandlePointer(int h)
71 if(h < 0 || h >= YAFFSFS_N_HANDLES)
76 return &yaffsfs_handle[h];
79 yaffs_Object *yaffsfs_GetHandleObject(int handle)
81 yaffsfs_Handle *h = yaffsfs_GetHandlePointer(handle);
93 // Grab a handle (when opening a file)
96 static int yaffsfs_GetHandle(void)
101 for(i = 0; i < YAFFSFS_N_HANDLES; i++)
103 h = yaffsfs_GetHandlePointer(i);
106 // todo bug: should never happen
110 memset(h,0,sizeof(yaffsfs_Handle));
119 // Let go of a handle (when closing a file)
121 static int yaffsfs_PutHandle(int handle)
123 yaffsfs_Handle *h = yaffsfs_GetHandlePointer(handle);
135 // Stuff to search for a directory from a path
138 int yaffsfs_Match(char a, char b)
144 // yaffsfs_FindDevice
146 // Scan the configuration list to find the root.
147 static yaffs_Device *yaffsfs_FindDevice(const char *path, char **restOfPath)
149 yaffsfs_DeviceConfiguration *cfg = yaffsfs_configurationList;
150 const char *leftOver;
153 while(cfg && cfg->prefix && cfg->dev)
157 while(*p && *leftOver && yaffsfs_Match(*p,*leftOver))
162 if(!*p && (!*leftOver || *leftOver == '/'))
165 *restOfPath = (char *)leftOver;
173 static yaffs_Object *yaffsfs_FindRoot(const char *path, char **restOfPath)
178 dev= yaffsfs_FindDevice(path,restOfPath);
179 if(dev && dev->isMounted)
186 static yaffs_Object *yaffsfs_FollowLink(yaffs_Object *obj,int symDepth)
189 while(obj && obj->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
191 char *alias = obj->variant.symLinkVariant.alias;
195 // Starts with a /, need to scan from root up
196 obj = yaffsfs_FindObject(NULL,alias,symDepth++);
200 // Relative to here, so use the parent of the symlink as a start
201 obj = yaffsfs_FindObject(obj->parent,alias,symDepth++);
208 // yaffsfs_FindDirectory
209 // Parse a path to determine the directory and the name within the directory.
211 // eg. "/data/xx/ff" --> puts name="ff" and returns the directory "/data/xx"
212 static yaffs_Object *yaffsfs_DoFindDirectory(yaffs_Object *startDir,const char *path,char **name,int symDepth)
216 char str[YAFFS_MAX_NAME_LENGTH+1];
219 if(symDepth > YAFFSFS_MAX_SYMLINK_DEREFERENCES)
227 restOfPath = (char *)path;
231 dir = yaffsfs_FindRoot(path,&restOfPath);
237 // curve ball: also throw away surplus '/'
238 // eg. "/ram/x////ff" gets treated the same as "/ram/x/ff"
239 while(*restOfPath == '/')
241 restOfPath++; // get rid of '/'
247 while(*restOfPath && *restOfPath != '/')
249 if (i < YAFFS_MAX_NAME_LENGTH)
251 str[i] = *restOfPath;
260 // got to the end of the string
265 if(strcmp(str,".") == 0)
269 else if(strcmp(str,"..") == 0)
275 dir = yaffs_FindObjectByName(dir,str);
277 while(dir && dir->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
280 dir = yaffsfs_FollowLink(dir,symDepth);
284 if(dir && dir->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
291 // directory did not exist.
295 static yaffs_Object *yaffsfs_FindDirectory(yaffs_Object *relativeDirectory,const char *path,char **name,int symDepth)
297 return yaffsfs_DoFindDirectory(relativeDirectory,path,name,symDepth);
300 // yaffsfs_FindObject turns a path for an existing object into the object
302 static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const char *path,int symDepth)
307 dir = yaffsfs_FindDirectory(relativeDirectory,path,&name,symDepth);
311 return yaffs_FindObjectByName(dir,name);
319 int yaffs_open(const char *path, int oflag, int mode)
321 yaffs_Object *obj = NULL;
322 yaffs_Object *dir = NULL;
325 yaffsfs_Handle *h = NULL;
327 int alreadyExclusive = 0;
330 int errorReported = 0;
335 // todo sanity check oflag (eg. can't have O_TRUNC without WRONLY or RDWR
340 handle = yaffsfs_GetHandle();
345 h = yaffsfs_GetHandlePointer(handle);
348 // try to find the exisiting object
349 obj = yaffsfs_FindObject(NULL,path,0);
351 if(obj && obj->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
354 obj = yaffsfs_FollowLink(obj,symDepth++);
359 // Check if the object is already in use
360 alreadyOpen = alreadyExclusive = 0;
362 for(i = 0; i <= YAFFSFS_N_HANDLES; i++)
366 yaffsfs_handle[i].inUse &&
367 obj == yaffsfs_handle[i].obj)
370 if(yaffsfs_handle[i].exclusive)
372 alreadyExclusive = 1;
377 if(((oflag & O_EXCL) && alreadyOpen) || alreadyExclusive)
382 // Open should fail if O_CREAT and O_EXCL are specified
383 if((oflag & O_EXCL) && (oflag & O_CREAT))
386 yaffsfs_SetError(-EEXIST);
390 // Check file permissions
391 if( (oflag & (O_RDWR | O_WRONLY)) == 0 && // ie O_RDONLY
392 !(obj->yst_mode & S_IREAD))
397 if( (oflag & O_RDWR) &&
398 !(obj->yst_mode & S_IREAD))
403 if( (oflag & (O_RDWR | O_WRONLY)) &&
404 !(obj->yst_mode & S_IWRITE))
411 else if((oflag & O_CREAT))
413 // Let's see if we can create this file
414 dir = yaffsfs_FindDirectory(NULL,path,&name,0);
417 obj = yaffs_MknodFile(dir,name,mode,0,0);
421 yaffsfs_SetError(-ENOTDIR);
425 if(obj && !openDenied)
429 h->readOnly = (oflag & (O_WRONLY | O_RDWR)) ? 0 : 1;
430 h->append = (oflag & O_APPEND) ? 1 : 0;
431 h->exclusive = (oflag & O_EXCL) ? 1 : 0;
435 if((oflag & O_TRUNC) && !h->readOnly)
438 yaffs_ResizeFile(obj,0);
444 yaffsfs_PutHandle(handle);
447 yaffsfs_SetError(-EACCESS);
460 int yaffs_close(int fd)
462 yaffsfs_Handle *h = NULL;
467 h = yaffsfs_GetHandlePointer(fd);
472 yaffs_FlushFile(h->obj,1);
474 if(h->obj->inUse <= 0 && h->obj->unlinked)
476 yaffs_DeleteFile(h->obj);
478 yaffsfs_PutHandle(fd);
484 yaffsfs_SetError(-EBADF);
493 int yaffs_read(int fd, void *buf, unsigned int nbyte)
495 yaffsfs_Handle *h = NULL;
496 yaffs_Object *obj = NULL;
502 h = yaffsfs_GetHandlePointer(fd);
503 obj = yaffsfs_GetHandleObject(fd);
508 yaffsfs_SetError(-EBADF);
513 if(yaffs_GetObjectFileLength(obj) > pos)
515 maxRead = yaffs_GetObjectFileLength(obj) - pos;
530 nRead = yaffs_ReadDataFromFile(obj,buf,pos,nbyte);
533 h->position = pos + nRead;
550 return (nRead >= 0) ? nRead : -1;
554 int yaffs_write(int fd, const void *buf, unsigned int nbyte)
556 yaffsfs_Handle *h = NULL;
557 yaffs_Object *obj = NULL;
560 int writeThrough = 0;
563 h = yaffsfs_GetHandlePointer(fd);
564 obj = yaffsfs_GetHandleObject(fd);
569 yaffsfs_SetError(-EBADF);
571 else if( h && obj && h->readOnly)
579 pos = yaffs_GetObjectFileLength(obj);
586 nWritten = yaffs_WriteDataToFile(obj,buf,pos,nbyte,writeThrough);
590 h->position = pos + nWritten;
602 return (nWritten >= 0) ? nWritten : -1;
606 int yaffs_truncate(int fd, unsigned int newSize)
608 yaffsfs_Handle *h = NULL;
609 yaffs_Object *obj = NULL;
613 h = yaffsfs_GetHandlePointer(fd);
614 obj = yaffsfs_GetHandleObject(fd);
619 yaffsfs_SetError(-EBADF);
624 result = yaffs_ResizeFile(obj,newSize);
629 return (result) ? 0 : -1;
633 off_t yaffs_lseek(int fd, off_t offset, int whence)
635 yaffsfs_Handle *h = NULL;
636 yaffs_Object *obj = NULL;
641 h = yaffsfs_GetHandlePointer(fd);
642 obj = yaffsfs_GetHandleObject(fd);
647 yaffsfs_SetError(-EBADF);
649 else if(whence == SEEK_SET)
656 else if(whence == SEEK_CUR)
658 if( (h->position + offset) >= 0)
660 pos = (h->position + offset);
663 else if(whence == SEEK_END)
665 fSize = yaffs_GetObjectFileLength(obj);
666 if(fSize >= 0 && (fSize + offset) >= 0)
668 pos = fSize + offset;
688 int yaffsfs_DoUnlink(const char *path,int isDirectory)
690 yaffs_Object *dir = NULL;
691 yaffs_Object *obj = NULL;
693 int result = YAFFS_FAIL;
697 obj = yaffsfs_FindObject(NULL,path,0);
698 dir = yaffsfs_FindDirectory(NULL,path,&name,0);
701 yaffsfs_SetError(-ENOTDIR);
705 yaffsfs_SetError(-ENOENT);
707 else if(!isDirectory && obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY)
709 yaffsfs_SetError(-EISDIR);
711 else if(isDirectory && obj->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
713 yaffsfs_SetError(-ENOTDIR);
715 else if(isDirectory && obj->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
717 yaffsfs_SetError(-ENOTDIR);
721 result = yaffs_Unlink(dir,name);
723 if(result == YAFFS_FAIL && isDirectory)
725 yaffsfs_SetError(-ENOTEMPTY);
733 return (result == YAFFS_FAIL) ? -1 : 0;
735 int yaffs_rmdir(const char *path)
737 return yaffsfs_DoUnlink(path,1);
740 int yaffs_unlink(const char *path)
742 return yaffsfs_DoUnlink(path,0);
745 int yaffs_rename(const char *oldPath, const char *newPath)
747 yaffs_Object *olddir = NULL;
748 yaffs_Object *newdir = NULL;
749 yaffs_Object *obj = NULL;
752 int result= YAFFS_FAIL;
753 int renameAllowed = 1;
757 olddir = yaffsfs_FindDirectory(NULL,oldPath,&oldname,0);
758 newdir = yaffsfs_FindDirectory(NULL,newPath,&newname,0);
759 obj = yaffsfs_FindObject(NULL,oldPath,0);
761 if(!olddir || !newdir || !obj)
764 yaffsfs_SetError(-EBADF);
767 else if(olddir->myDev != newdir->myDev)
769 // oops must be on same device
771 yaffsfs_SetError(-EXDEV);
774 else if(obj && obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY)
776 // It is a directory, check that it is not being renamed to
777 // being its own decendent.
778 // Do this by tracing from the new directory back to the root, checking for obj
780 yaffs_Object *xx = newdir;
782 while( renameAllowed && xx)
790 if(!renameAllowed) yaffsfs_SetError(-EACCESS);
795 result = yaffs_RenameObject(olddir,oldname,newdir,newname);
800 return (result == YAFFS_FAIL) ? -1 : 0;
804 static int yaffsfs_DoStat(yaffs_Object *obj,struct yaffs_stat *buf)
810 obj = yaffs_GetEquivalentObject(obj);
815 buf->st_dev = (int)obj->myDev->genericDevice;
816 buf->st_ino = obj->objectId;
817 buf->st_mode = obj->yst_mode & ~S_IFMT; // clear out file type bits
819 if(obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY)
821 buf->st_mode |= S_IFDIR;
823 else if(obj->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
825 buf->st_mode |= S_IFLNK;
827 else if(obj->variantType == YAFFS_OBJECT_TYPE_FILE)
829 buf->st_mode |= S_IFREG;
832 buf->st_nlink = yaffs_GetObjectLinkCount(obj);
835 buf->st_rdev = obj->yst_rdev;
836 buf->st_size = yaffs_GetObjectFileLength(obj);
837 buf->st_blksize = obj->myDev->nBytesPerChunk;
838 buf->st_blocks = (buf->st_size + buf->st_blksize -1)/buf->st_blksize;
839 buf->yst_atime = obj->yst_atime;
840 buf->yst_ctime = obj->yst_ctime;
841 buf->yst_mtime = obj->yst_mtime;
847 static int yaffsfs_DoStatOrLStat(const char *path, struct yaffs_stat *buf,int doLStat)
854 obj = yaffsfs_FindObject(NULL,path,0);
858 obj = yaffsfs_FollowLink(obj,0);
863 retVal = yaffsfs_DoStat(obj,buf);
867 // todo error not found
868 yaffsfs_SetError(-ENOENT);
877 int yaffs_stat(const char *path, struct yaffs_stat *buf)
879 return yaffsfs_DoStatOrLStat(path,buf,0);
882 int yaffs_lstat(const char *path, struct yaffs_stat *buf)
884 return yaffsfs_DoStatOrLStat(path,buf,1);
887 int yaffs_fstat(int fd, struct yaffs_stat *buf)
894 obj = yaffsfs_GetHandleObject(fd);
898 retVal = yaffsfs_DoStat(obj,buf);
903 yaffsfs_SetError(-EBADF);
911 static int yaffsfs_DoChMod(yaffs_Object *obj,mode_t mode)
917 obj = yaffs_GetEquivalentObject(obj);
922 obj->yst_mode = mode;
924 result = yaffs_FlushFile(obj,0);
927 return result == YAFFS_OK ? 0 : -1;
931 int yaffs_chmod(const char *path, mode_t mode)
938 obj = yaffsfs_FindObject(NULL,path,0);
942 retVal = yaffsfs_DoChMod(obj,mode);
946 // todo error not found
947 yaffsfs_SetError(-ENOENT);
957 int yaffs_fchmod(int fd, mode_t mode)
964 obj = yaffsfs_GetHandleObject(fd);
968 retVal = yaffsfs_DoChMod(obj,mode);
973 yaffsfs_SetError(-EBADF);
982 int yaffs_mkdir(const char *path, mode_t mode)
984 yaffs_Object *parent = NULL;
990 parent = yaffsfs_FindDirectory(NULL,path,&name,0);
991 dir = yaffs_MknodDirectory(parent,name,mode,0,0);
998 yaffsfs_SetError(-ENOSPC); // just assume no space for now
1007 int yaffs_mount(const char *path)
1010 int result=YAFFS_FAIL;
1011 yaffs_Device *dev=NULL;
1014 T(YAFFS_TRACE_ALWAYS,("yaffs: Mounting %s\n",path));
1017 dev = yaffsfs_FindDevice(path,&dummy);
1022 result = yaffs_GutsInitialise(dev);
1023 if(result == YAFFS_FAIL)
1025 // todo error - mount failed
1026 yaffsfs_SetError(-ENOMEM);
1028 retVal = result ? 0 : -1;
1033 //todo error - already mounted.
1034 yaffsfs_SetError(-EBUSY);
1039 // todo error - no device
1040 yaffsfs_SetError(-ENODEV);
1047 int yaffs_unmount(const char *path)
1050 yaffs_Device *dev=NULL;
1054 dev = yaffsfs_FindDevice(path,&dummy);
1061 for(i = inUse = 0; i < YAFFSFS_N_HANDLES && !inUse; i++)
1063 if(yaffsfs_handle[i].inUse && yaffsfs_handle[i].obj->myDev == dev)
1065 inUse = 1; // the device is in use, can't unmount
1071 yaffs_Deinitialise(dev);
1077 // todo error can't unmount as files are open
1078 yaffsfs_SetError(-EBUSY);
1084 //todo error - not mounted.
1085 yaffsfs_SetError(-EINVAL);
1091 // todo error - no device
1092 yaffsfs_SetError(-ENODEV);
1099 off_t yaffs_freespace(const char *path)
1102 yaffs_Device *dev=NULL;
1106 dev = yaffsfs_FindDevice(path,&dummy);
1107 if(dev && dev->isMounted)
1109 retVal = yaffs_GetNumberOfFreeChunks(dev);
1110 retVal *= dev->nBytesPerChunk;
1115 yaffsfs_SetError(-EINVAL);
1124 void yaffs_initialise(yaffsfs_DeviceConfiguration *cfgList)
1127 yaffsfs_DeviceConfiguration *cfg;
1129 yaffsfs_configurationList = cfgList;
1131 yaffsfs_InitHandles();
1133 cfg = yaffsfs_configurationList;
1135 while(cfg && cfg->prefix && cfg->dev)
1137 cfg->dev->isMounted = 0;
1138 cfg->dev->removeObjectCallback = yaffsfs_RemoveObjectCallback;
1147 // Directory search stuff.
1150 // Directory search context
1152 // NB this is an opaque structure.
1158 yaffs_dirent de; /* directory entry being used by this dsc */
1159 char name[NAME_MAX+1]; /* name of directory being searched */
1160 yaffs_Object *dirObj; /* ptr to directory being searched */
1161 yaffs_Object *nextReturn; /* obj to be returned by next readddir */
1163 struct list_head others;
1164 } yaffsfs_DirectorySearchContext;
1168 static struct list_head search_contexts;
1171 static void yaffsfs_SetDirRewound(yaffsfs_DirectorySearchContext *dsc)
1175 dsc->dirObj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY){
1179 if( list_empty(&dsc->dirObj->variant.directoryVariant.children)){
1180 dsc->nextReturn = NULL;
1182 dsc->nextReturn = list_entry(dsc->dirObj->variant.directoryVariant.children.next,
1183 yaffs_Object,siblings);
1186 /* Hey someone isn't playing nice! */
1190 static void yaffsfs_DirAdvance(yaffsfs_DirectorySearchContext *dsc)
1194 dsc->dirObj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY){
1196 if( dsc->nextReturn == NULL ||
1197 list_empty(&dsc->dirObj->variant.directoryVariant.children)){
1198 dsc->nextReturn = NULL;
1200 struct list_head *next = dsc->nextReturn->siblings.next;
1202 if( next == &dsc->dirObj->variant.directoryVariant.children)
1203 dsc->nextReturn = NULL; /* end of list */
1205 dsc->nextReturn = list_entry(next,yaffs_Object,siblings);
1208 /* Hey someone isn't playing nice! */
1212 static void yaffsfs_RemoveObjectCallback(yaffs_Object *obj)
1215 struct list_head *i;
1216 yaffsfs_DirectorySearchContext *dsc;
1218 /* if search contexts not initilised then skip */
1219 if(!search_contexts.next)
1222 /* Iteratethrough the directory search contexts.
1223 * If any are the one being removed, then advance the dsc to
1224 * the next one to prevent a hanging ptr.
1226 list_for_each(i, &search_contexts) {
1228 dsc = list_entry(i, yaffsfs_DirectorySearchContext,others);
1229 if(dsc->nextReturn == obj)
1230 yaffsfs_DirAdvance(dsc);
1236 yaffs_DIR *yaffs_opendir(const char *dirname)
1238 yaffs_DIR *dir = NULL;
1239 yaffs_Object *obj = NULL;
1240 yaffsfs_DirectorySearchContext *dsc = NULL;
1244 obj = yaffsfs_FindObject(NULL,dirname,0);
1246 if(obj && obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY)
1249 dsc = YMALLOC(sizeof(yaffsfs_DirectorySearchContext));
1250 dir = (yaffs_DIR *)dsc;
1253 dsc->magic = YAFFS_MAGIC;
1254 memset(dsc->name,0,NAME_MAX+1);
1255 strncpy(dsc->name,dirname,NAME_MAX);
1256 INIT_LIST_HEAD(&dsc->others);
1258 if(!search_contexts.next)
1259 INIT_LIST_HEAD(&search_contexts);
1261 list_add(&dsc->others,&search_contexts);
1271 struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp)
1273 yaffsfs_DirectorySearchContext *dsc = (yaffsfs_DirectorySearchContext *)dirp;
1274 struct yaffs_dirent *retVal = NULL;
1278 if(dsc && dsc->magic == YAFFS_MAGIC){
1279 yaffsfs_SetError(0);
1280 if(dsc->nextReturn){
1281 dsc->de.d_ino = yaffs_GetEquivalentObject(dsc->nextReturn)->objectId;
1282 dsc->de.d_off = dsc->offset++;
1283 yaffs_GetObjectName(dsc->nextReturn,dsc->de.d_name,NAME_MAX+1);
1284 dsc->de.d_reclen = sizeof(struct yaffs_dirent);
1286 yaffsfs_DirAdvance(dsc);
1292 yaffsfs_SetError(-EBADF);
1302 void yaffs_rewinddir(yaffs_DIR *dirp)
1304 yaffsfs_DirectorySearchContext *dsc = (yaffsfs_DirectorySearchContext *)dirp;
1308 yaffsfs_SetDirRewound(dsc);
1314 int yaffs_closedir(yaffs_DIR *dirp)
1316 yaffsfs_DirectorySearchContext *dsc = (yaffsfs_DirectorySearchContext *)dirp;
1320 list_del(&dsc->others); /* unhook from list */
1326 // end of directory stuff
1329 int yaffs_symlink(const char *oldpath, const char *newpath)
1331 yaffs_Object *parent = NULL;
1335 int mode = 0; // ignore for now
1338 parent = yaffsfs_FindDirectory(NULL,newpath,&name,0);
1339 obj = yaffs_MknodSymLink(parent,name,mode,0,0,oldpath);
1346 yaffsfs_SetError(-ENOSPC); // just assume no space for now
1356 int yaffs_readlink(const char *path, char *buf, int bufsiz)
1358 yaffs_Object *obj = NULL;
1364 obj = yaffsfs_FindObject(NULL,path,0);
1368 yaffsfs_SetError(-ENOENT);
1371 else if(obj->variantType != YAFFS_OBJECT_TYPE_SYMLINK)
1373 yaffsfs_SetError(-EINVAL);
1378 char *alias = obj->variant.symLinkVariant.alias;
1379 memset(buf,0,bufsiz);
1380 strncpy(buf,alias,bufsiz - 1);
1387 int yaffs_link(const char *oldpath, const char *newpath);
1388 int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev);
1390 int yaffs_DumpDevStruct(const char *path)
1394 yaffs_Object *obj = yaffsfs_FindRoot(path,&rest);
1398 yaffs_Device *dev = obj->myDev;
1401 "nPageWrites.......... %d\n"
1402 "nPageReads........... %d\n"
1403 "nBlockErasures....... %d\n"
1404 "nGCCopies............ %d\n"
1405 "garbageCollections... %d\n"
1406 "passiveGarbageColl'ns %d\n"
1410 dev->nBlockErasures,
1412 dev->garbageCollections,
1413 dev->passiveGarbageCollections