*** empty log message ***
[yaffs/.git] / direct / dtest.c
index 6f32cb53d81ac028a86c20f00f08ae4df32de1db..921b066d2c1c15f24451ba1c49a5b65c84996f8d 100644 (file)
@@ -64,6 +64,7 @@ void fill_disk(char *path,int nfiles)
        int h;
        int n;
        int result;
+       int f;
        
        char str[50];
        
@@ -77,7 +78,7 @@ void fill_disk(char *path,int nfiles)
                
                while ((result = yaffs_write(h,xx,600)) == 600)
                {
-                       //printf(".");
+                       f = yaffs_freespace("/boot");
                }
                result = yaffs_close(h);
                printf(" close %d\n",result);
@@ -197,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;
@@ -242,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;
@@ -477,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");
@@ -660,6 +661,46 @@ int cache_bypass_bug_test(void)
 }
 
 
+int free_space_check(void)
+{
+       int f;
+       
+               yaffs_StartUp();
+               yaffs_mount("/boot");
+           fill_disk("/boot/",2);
+           f = yaffs_freespace("/boot");
+           
+           printf("%d free when disk full\n",f);           
+           return 1;
+}
+
+
+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[])
 {
@@ -667,6 +708,10 @@ int main(int argc, char *argv[])
        
        //return cache_read_test();
        
-       return cache_bypass_bug_test();
+       //return cache_bypass_bug_test();
+       
+       // return free_space_check();
+       
+       return BeatsTest();
        
 }