Add Beat's test
authorcharles <charles>
Wed, 31 Aug 2005 09:21:12 +0000 (09:21 +0000)
committercharles <charles>
Wed, 31 Aug 2005 09:21:12 +0000 (09:21 +0000)
direct/dtest.c
direct/yaffsfs.c
direct/yaffsfs.h

index 9051c234fbb4c2820ef8380c6dfdacc875ef53d9..921b066d2c1c15f24451ba1c49a5b65c84996f8d 100644 (file)
@@ -198,8 +198,8 @@ void dumpDirFollow(const char *dname)
                        
                        yaffs_stat(str,&s);
                        
-                       printf("%s length %d mode %X ",de->d_name,s.st_size,s.st_mode);
-                       switch(s.st_mode & S_IFMT)
+                       printf("%s length %d mode %X ",de->d_name,s.yst_size,s.yst_mode);
+                       switch(s.yst_mode & S_IFMT)
                        {
                                case S_IFREG: printf("data file"); break;
                                case S_IFDIR: printf("directory"); break;
@@ -243,8 +243,8 @@ void dumpDir(const char *dname)
                        
                        yaffs_lstat(str,&s);
                        
-                       printf("%s length %d mode %X ",de->d_name,s.st_size,s.st_mode);
-                       switch(s.st_mode & S_IFMT)
+                       printf("%s length %d mode %X ",de->d_name,s.yst_size,s.yst_mode);
+                       switch(s.yst_mode & S_IFMT)
                        {
                                case S_IFREG: printf("data file"); break;
                                case S_IFDIR: printf("directory"); break;
@@ -478,7 +478,7 @@ int long_test(int argc, char *argv[])
        // Check chmod
        
        yaffs_stat("/boot/yyfile",&ystat);
-       temp_mode = ystat.st_mode;
+       temp_mode = ystat.yst_mode;
        
        yaffs_chmod("/boot/yyfile",0x55555);
        printf("\nDirectory look-up of /boot\n");
@@ -675,6 +675,33 @@ int free_space_check(void)
 }
 
 
+int BeatsTest(void)
+{
+       int h;
+       char b[2000];
+       int freeSpace;
+       int fsize;
+       yaffs_StartUp();
+       yaffs_mount("/ram");
+       
+       h = yaffs_open("/ram/f1", O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
+       
+       freeSpace = yaffs_freespace("/ram");
+       printf("start free space %d\n",freeSpace);
+       
+       while(yaffs_write(h,b,600) > 0) {
+               fsize = yaffs_lseek(h,0,SEEK_CUR);
+               freeSpace = yaffs_freespace("/ram");
+               printf(" %d  = %d + %d\n",fsize + freeSpace,fsize,freeSpace);
+       }
+       yaffs_close(h);
+       
+       freeSpace = yaffs_freespace("/ram");
+       
+       return 1;
+       
+}
+
 int main(int argc, char *argv[])
 {
        //return long_test(argc,argv);
@@ -683,6 +710,8 @@ int main(int argc, char *argv[])
        
        //return cache_bypass_bug_test();
        
-       return free_space_check();
+       // return free_space_check();
+       
+       return BeatsTest();
        
 }
index ec7ccf5c8b3ef2325bf30d24e4b4ebd72b520402..efd5f8cc70fd0799d1e016b17dcf37ec23cc4a54 100644 (file)
@@ -25,7 +25,7 @@
 #endif
 
 
-const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.7 2004-11-21 23:33:30 charles Exp $";
+const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.8 2005-08-31 09:21:12 charles Exp $";
 
 // configurationList is the list of devices that are supported
 static yaffsfs_DeviceConfiguration *yaffsfs_configurationList;
@@ -410,19 +410,19 @@ int yaffs_open(const char *path, int oflag, int mode)
                        
                        // Check file permissions
                        if( (oflag & (O_RDWR | O_WRONLY)) == 0 &&     // ie O_RDONLY
-                          !(obj->st_mode & S_IREAD))
+                          !(obj->yst_mode & S_IREAD))
                        {
                                openDenied = 1;
                        }
 
                        if( (oflag & O_RDWR) && 
-                          !(obj->st_mode & S_IREAD))
+                          !(obj->yst_mode & S_IREAD))
                        {
                                openDenied = 1;
                        }
 
                        if( (oflag & (O_RDWR | O_WRONLY)) && 
-                          !(obj->st_mode & S_IWRITE))
+                          !(obj->yst_mode & S_IWRITE))
                        {
                                openDenied = 1;
                        }
@@ -805,33 +805,33 @@ static int yaffsfs_DoStat(yaffs_Object *obj,struct yaffs_stat *buf)
 
        if(obj && buf)
        {
-       buf->st_dev = (int)obj->myDev->genericDevice;
-       buf->st_ino = obj->objectId;
-       buf->st_mode = obj->st_mode & ~S_IFMT; // clear out file type bits
+       buf->yst_dev = (int)obj->myDev->genericDevice;
+       buf->yst_ino = obj->objectId;
+       buf->yst_mode = obj->yst_mode & ~S_IFMT; // clear out file type bits
        
                if(obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY) 
                {
-                       buf->st_mode |= S_IFDIR;
+                       buf->yst_mode |= S_IFDIR;
                }
                else if(obj->variantType == YAFFS_OBJECT_TYPE_SYMLINK) 
                {
-                       buf->st_mode |= S_IFLNK;
+                       buf->yst_mode |= S_IFLNK;
                }
                else if(obj->variantType == YAFFS_OBJECT_TYPE_FILE)
                {
-                       buf->st_mode |= S_IFREG;
+                       buf->yst_mode |= S_IFREG;
                }
                
-       buf->st_nlink = yaffs_GetObjectLinkCount(obj);
-       buf->st_uid = 0;    
-       buf->st_gid = 0;;     
-       buf->st_rdev = obj->st_rdev;
-       buf->st_size = yaffs_GetObjectFileLength(obj);
-               buf->st_blksize = YAFFS_BYTES_PER_CHUNK;
-       buf->st_blocks = (buf->st_size + YAFFS_BYTES_PER_CHUNK -1)/YAFFS_BYTES_PER_CHUNK;
-       buf->st_atime = obj->st_atime; 
-       buf->st_ctime = obj->st_ctime; 
-       buf->st_mtime = obj->st_mtime; 
+       buf->yst_nlink = yaffs_GetObjectLinkCount(obj);
+       buf->yst_uid = 0;    
+       buf->yst_gid = 0;;     
+       buf->yst_rdev = obj->yst_rdev;
+       buf->yst_size = yaffs_GetObjectFileLength(obj);
+               buf->yst_blksize = YAFFS_BYTES_PER_CHUNK;
+       buf->yst_blocks = (buf->yst_size + YAFFS_BYTES_PER_CHUNK -1)/YAFFS_BYTES_PER_CHUNK;
+       buf->yst_atime = obj->yst_atime; 
+       buf->yst_ctime = obj->yst_ctime; 
+       buf->yst_mtime = obj->yst_mtime; 
                retVal = 0;
        }
        return retVal;
@@ -912,7 +912,7 @@ static int yaffsfs_DoChMod(yaffs_Object *obj,mode_t mode)
        
        if(obj)
        {
-               obj->st_mode = mode;
+               obj->yst_mode = mode;
                obj->dirty = 1;
                result = yaffs_FlushFile(obj,0);
        }
index 01870f3b8671cf8d0df1e4f3b67c6863562d5751..71ccc7be4c2a2ce3f4160b05d3eddce0368c3772 100644 (file)
@@ -156,19 +156,19 @@ typedef struct __opaque yaffs_DIR;
 
 
 struct yaffs_stat{
-    int                      st_dev;      /* device */
-    int           st_ino;      /* inode */
-    mode_t        st_mode;     /* protection */
-    int           st_nlink;    /* number of hard links */
-    int           st_uid;      /* user ID of owner */
-    int           st_gid;      /* group ID of owner */
-    unsigned      st_rdev;     /* device type (if inode device) */
-    off_t         st_size;     /* total size, in bytes */
-    unsigned long st_blksize;  /* blocksize for filesystem I/O */
-    unsigned long st_blocks;   /* number of blocks allocated */
-    unsigned long st_atime;    /* time of last access */
-    unsigned long st_mtime;    /* time of last modification */
-    unsigned long st_ctime;    /* time of last change */
+    int                  yst_dev;      /* device */
+    int           yst_ino;      /* inode */
+    mode_t        yst_mode;     /* protection */
+    int           yst_nlink;    /* number of hard links */
+    int           yst_uid;      /* user ID of owner */
+    int           yst_gid;      /* group ID of owner */
+    unsigned      yst_rdev;     /* device type (if inode device) */
+    off_t         yst_size;     /* total size, in bytes */
+    unsigned long yst_blksize;  /* blocksize for filesystem I/O */
+    unsigned long yst_blocks;   /* number of blocks allocated */
+    unsigned long yst_atime;    /* time of last access */
+    unsigned long yst_mtime;    /* time of last modification */
+    unsigned long yst_ctime;    /* time of last change */
 };
 
 int yaffs_open(const char *path, int oflag, int mode) ;