2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2018 Aleph One Ltd.
6 * Created by Charles Manning <charles@aleph1.co.uk>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
24 #include "yaffs_guts.h" /* Only for dumping device innards */
25 #include "yaffs_endian.h" /*For testing the swap_u64 macro */
27 extern int yaffs_trace_mask;
29 void dumpDir(const char *dname);
31 void copy_in_a_file(const char *yaffsName,const char *inName)
34 unsigned char buffer[100];
36 inh = open(inName,O_RDONLY);
37 outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
39 while((ni = read(inh,buffer,100)) > 0)
41 no = yaffs_write(outh,buffer,ni);
44 printf("problem writing yaffs file\n");
53 void make_a_file(const char *yaffsName,char bval,int sizeOfFile)
57 unsigned char buffer[100];
59 outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
61 memset(buffer,bval,100);
68 yaffs_write(outh,buffer,i);
70 } while (sizeOfFile > 0);
77 void make_pattern_file(char *fn,int size)
82 outh = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
83 yaffs_lseek(outh,size-1,SEEK_SET);
84 yaffs_write(outh,"A",1);
86 for(i = 0; i < size; i+=256)
89 yaffs_lseek(outh,i,SEEK_SET);
90 yaffs_write(outh,&marker,sizeof(marker));
96 int check_pattern_file(char *fn)
104 h = yaffs_open(fn, O_RDWR,0);
105 size = yaffs_lseek(h,0,SEEK_END);
107 for(i = 0; i < size; i+=256)
109 yaffs_lseek(h,i,SEEK_SET);
110 yaffs_read(h,&marker,sizeof(marker));
114 printf("pattern check failed on file %s, size %d at position %d. Got %x instead of %x\n",
115 fn,size,i,marker,~i);
123 int dump_file_data(char *fn)
130 h = yaffs_open(fn, O_RDWR,0);
134 while(yaffs_read(h,&b,1)> 0)
151 void dump_file(const char *fn)
157 h = yaffs_open(fn,O_RDONLY,0);
160 printf("*****\nDump file %s does not exist\n",fn);
164 size = yaffs_lseek(h,0,SEEK_SET);
165 printf("*****\nDump file %s size %d\n",fn,size);
166 for(i = 0; i < size; i++)
173 void create_file_of_size(const char *fn,int syze)
181 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
185 sprintf(xx,"%s %8d",fn,iteration);
187 result = yaffs_write(h,xx,n);
189 printf("Wrote %d, should have been %d. syze is %d\n",result,n,syze);
198 void verify_file_of_size(const char *fn,int syze)
207 int iterations = (syze + strlen(fn) -1)/ strlen(fn);
209 h = yaffs_open(fn, O_RDONLY, S_IREAD | S_IWRITE);
211 while (iterations > 0)
213 sprintf(xx,"%s %8d",fn,iterations);
216 result = yaffs_read(h,yy,l);
218 printf("result in line %d is %d", __LINE__, result);
222 printf("=====>>>>> verification of file %s failed near position %lld\n",fn,(long long)yaffs_lseek(h,0,SEEK_CUR));
229 void create_resized_file_of_size(const char *fn,int syze1,int reSyze, int syze2)
235 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
237 iterations = (syze1 + strlen(fn) -1)/ strlen(fn);
238 while (iterations > 0)
240 yaffs_write(h,fn,strlen(fn));
244 yaffs_ftruncate(h,reSyze);
246 yaffs_lseek(h,0,SEEK_SET);
247 iterations = (syze2 + strlen(fn) -1)/ strlen(fn);
248 while (iterations > 0)
250 yaffs_write(h,fn,strlen(fn));
258 void do_some_file_stuff(const char *path)
263 sprintf(fn,"%s/%s",path,"f1");
264 create_file_of_size(fn,10000);
266 sprintf(fn,"%s/%s",path,"fdel");
267 create_file_of_size(fn,10000);
270 sprintf(fn,"%s/%s",path,"f2");
272 create_resized_file_of_size(fn,10000,3000,4000);
275 void yaffs_backward_scan_test(const char *path)
283 do_some_file_stuff(path);
285 sprintf(fn,"%s/ddd",path);
289 do_some_file_stuff(fn);
296 void null_name_test(const char *path)
304 sprintf(fn,"%s",path);
306 h = yaffs_open(fn,O_CREAT| O_TRUNC| O_RDWR, 0666);
315 void yaffs_device_flush_test(const char *path)
325 do_some_file_stuff(path);
327 // Open and add some data to a few files
328 for(i = 0; i < 10; i++) {
330 sprintf(fn,"%s/ff%d",path,i);
332 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IWRITE | S_IREAD);
333 yaffs_write(h,xxzz,2000);
334 yaffs_write(h,xxzz,2000);
343 void short_scan_test(const char *path, int fsize, int niterations)
348 sprintf(fn,"%s/%s",path,"f1");
351 for(i = 0; i < niterations; i++)
353 printf("\n*****************\nIteration %d\n",i);
355 printf("\nmount: Directory look-up of %s\n",path);
357 make_a_file(fn,1,fsize);
364 void scan_pattern_test(const char *path, int fsize, int niterations)
371 sprintf(fn[0],"%s/%s",path,"f0");
372 sprintf(fn[1],"%s/%s",path,"f1");
373 sprintf(fn[2],"%s/%s",path,"f2");
377 for(i = 0; i < niterations; i++)
379 printf("\n*****************\nIteration %d\n",i);
381 printf("\nmount: Directory look-up of %s\n",path);
383 for(j = 0; j < 3; j++)
385 result = dump_file_data(fn[j]);
386 result = check_pattern_file(fn[j]);
387 make_pattern_file(fn[j],fsize);
388 result = dump_file_data(fn[j]);
389 result = check_pattern_file(fn[j]);
391 printf("result in line %d is %d", __LINE__, result);
397 void fill_disk(const char *path,int nfiles)
407 for(n = 0; n < nfiles; n++)
409 sprintf(str,"%s/%d",path,n);
411 h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
413 printf("writing file %s handle %d ",str, h);
415 while ((result = yaffs_write(h,xx,600)) == 600)
417 f = yaffs_freespace(path);
419 printf("last freespace was %d\n", f);
420 result = yaffs_close(h);
421 printf(" close %d\n", result);
425 void fill_disk_and_delete(const char *path, int nfiles, int ncycles)
431 for(i = 0; i < ncycles; i++)
433 printf("@@@@@@@@@@@@@@ cycle %d\n",i);
434 fill_disk(path,nfiles);
436 for(j = 0; j < nfiles; j++)
438 sprintf(str,"%s/%d",path,j);
439 result = yaffs_unlink(str);
440 printf("unlinking file %s, result %d\n", str, result);
446 void fill_files(const char *path,int flags, int maxIterations,int siz)
456 sprintf(str,"%s/%d",path,i);
457 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
461 for(j = 0; j < siz; j++)
463 yaffs_write(h,str,1);
472 } while(h >= 0 && i < maxIterations);
478 sprintf(str,"%s/%d",path,i);
479 printf("unlink %s\n",str);
481 } while(yaffs_unlink(str) >= 0);
485 void leave_unlinked_file(const char *path,int maxIterations,int siz)
494 sprintf(str,"%s/%d",path,i);
495 printf("create %s\n",str);
496 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
502 } while(h < 0 && i < maxIterations);
506 for(i = 0; i < siz; i++)
508 yaffs_write(h,str,1);
512 printf("Leaving file %s open\n",str);
516 void dumpDirFollow(const char *dname)
519 struct yaffs_dirent *de;
523 d = yaffs_opendir(dname);
527 printf("opendir failed\n");
531 while((de = yaffs_readdir(d)) != NULL)
533 sprintf(str,"%s/%s",dname,de->d_name);
537 printf("%s ino %d length %d mode %X ",
538 de->d_name, (int)s.st_ino, (int)s.st_size, s.st_mode);
539 switch(s.st_mode & S_IFMT)
541 case S_IFREG: printf("data file"); break;
542 case S_IFDIR: printf("directory"); break;
543 case S_IFLNK: printf("symlink -->");
544 if(yaffs_readlink(str,str,100) < 0)
547 printf("\"%s\"",str);
549 default: printf("unknown"); break;
559 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
564 void dump_directory_tree_worker(const char *dname,int recursive)
567 struct yaffs_dirent *de;
571 d = yaffs_opendir(dname);
575 printf("opendir failed\n");
579 while((de = yaffs_readdir(d)) != NULL)
581 sprintf(str,"%s/%s",dname,de->d_name);
585 printf("%s inode %d length %d mode %X ",
586 str, s.st_ino, (int)s.st_size, s.st_mode);
587 switch(s.st_mode & S_IFMT)
589 case S_IFREG: printf("data file"); break;
590 case S_IFDIR: printf("directory"); break;
591 case S_IFLNK: printf("symlink -->");
592 if(yaffs_readlink(str,str,100) < 0)
595 printf("\"%s\"",str);
597 default: printf("unknown"); break;
602 if((s.st_mode & S_IFMT) == S_IFDIR && recursive)
603 dump_directory_tree_worker(str,1);
612 static void dump_directory_tree(const char *dname)
614 dump_directory_tree_worker(dname,1);
616 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
619 void dump_directory_tree_worker_fd(const char *dname,int recursive)
622 struct yaffs_dirent *de;
626 h = yaffs_open(dname, O_RDONLY, 0);
630 printf("open of dir failed\n");
634 printf("using fd %d\n", h);
636 while((de = yaffs_readdir_fd(h)) != NULL)
638 sprintf(str,"%s/%s",dname,de->d_name);
642 printf("%s inode %d length %d mode %X ",
643 str,s.st_ino, (int)s.st_size, s.st_mode);
644 switch(s.st_mode & S_IFMT)
646 case S_IFREG: printf("data file"); break;
647 case S_IFDIR: printf("directory"); break;
648 case S_IFLNK: printf("symlink -->");
649 if(yaffs_readlink(str,str,100) < 0)
652 printf("\"%s\"",str);
654 default: printf("unknown"); break;
659 if((s.st_mode & S_IFMT) == S_IFDIR && recursive)
660 dump_directory_tree_worker_fd(str,1);
669 static void dump_directory_tree_fd(const char *dname)
671 dump_directory_tree_worker_fd(dname,1);
673 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
676 void dumpDir(const char *dname)
677 { dump_directory_tree_worker(dname,0);
679 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
683 static void PermissionsCheck(const char *path, mode_t tmode, int tflags,int expectedResult)
687 if(yaffs_chmod(path,tmode)< 0) printf("chmod failed\n");
689 fd = yaffs_open(path,tflags,0);
691 if((fd >= 0) != (expectedResult > 0))
693 printf("Permissions check %x %x %d failed\n",tmode,tflags,expectedResult);
697 printf("Permissions check %x %x %d OK\n",tmode,tflags,expectedResult);
706 int long_test(int argc, char *argv[])
717 struct yaffs_stat ystat;
724 yaffs_mount("/boot");
725 yaffs_mount("/data");
726 yaffs_mount("/flash");
729 printf("\nDirectory look-up of /boot\n");
731 printf("\nDirectory look-up of /data\n");
733 printf("\nDirectory look-up of /flash\n");
736 //leave_unlinked_file("/flash",20000,0);
737 //leave_unlinked_file("/data",20000,0);
739 leave_unlinked_file("/ram",20,0);
742 f = yaffs_open("/boot/b1", O_RDONLY,0);
744 printf("open /boot/b1 readonly, f=%d\n",f);
746 f = yaffs_open("/boot/b1", O_CREAT,S_IREAD | S_IWRITE);
748 printf("open /boot/b1 O_CREAT, f=%d\n",f);
751 r = yaffs_write(f,"hello",1);
752 printf("write %d attempted to write to a read-only file\n",r);
756 printf("close %d\n",r);
758 f = yaffs_open("/boot/b1", O_RDWR,0);
760 printf("open /boot/b1 O_RDWR,f=%d\n",f);
763 r = yaffs_write(f,"hello",2);
764 printf("write %d attempted to write to a writeable file\n",r);
765 r = yaffs_write(f,"world",3);
766 printf("write %d attempted to write to a writeable file\n",r);
768 r= yaffs_lseek(f,0,SEEK_END);
769 printf("seek end %d\n",r);
771 r = yaffs_read(f,buffer,10);
772 printf("read %d \"%s\"\n",r,buffer);
773 r= yaffs_lseek(f,0,SEEK_SET);
774 printf("seek set %d\n",r);
776 r = yaffs_read(f,buffer,10);
777 printf("read %d \"%s\"\n",r,buffer);
779 r = yaffs_read(f,buffer,10);
780 printf("read %d \"%s\"\n",r,buffer);
782 // Check values reading at end.
783 // A read past end of file should return 0 for 0 bytes read.
785 r= yaffs_lseek(f,0,SEEK_END);
786 r = yaffs_read(f,buffer,10);
787 printf("read at end returned %d\n",r);
788 r= yaffs_lseek(f,500,SEEK_END);
789 r = yaffs_read(f,buffer,10);
790 printf("read past end returned %d\n",r);
794 printf("close %d\n",r);
796 copy_in_a_file("/boot/yyfile","xxx");
798 // Create a file with a long name
800 copy_in_a_file("/boot/file with a long name","xxx");
803 printf("\nDirectory look-up of /boot\n");
807 r = yaffs_lstat("/boot/file with a long name",&ystat);
811 r = yaffs_rename("/boot/file with a long name","/boot/r1");
813 printf("\nDirectory look-up of /boot\n");
817 r = yaffs_unlink("/boot/r1");
819 printf("\nDirectory look-up of /boot\n");
824 r = yaffs_mkdir("/boot/directory1",0);
826 printf("\nDirectory look-up of /boot\n");
828 printf("\nDirectory look-up of /boot/directory1\n");
829 dumpDir("/boot/directory1");
831 // add a file to the directory
832 copy_in_a_file("/boot/directory1/file with a long name","xxx");
834 printf("\nDirectory look-up of /boot\n");
836 printf("\nDirectory look-up of /boot/directory1\n");
837 dumpDir("/boot/directory1");
839 // Attempt to delete directory (should fail)
841 r = yaffs_rmdir("/boot/directory1");
843 printf("\nDirectory look-up of /boot\n");
845 printf("\nDirectory look-up of /boot/directory1\n");
846 dumpDir("/boot/directory1");
848 // Delete file first, then rmdir should work
849 r = yaffs_unlink("/boot/directory1/file with a long name");
850 r = yaffs_rmdir("/boot/directory1");
853 printf("\nDirectory look-up of /boot\n");
855 printf("\nDirectory look-up of /boot/directory1\n");
856 dumpDir("/boot/directory1");
859 fill_disk_and_delete("/boot",20,20);
861 printf("\nDirectory look-up of /boot\n");
865 yaffs_symlink("yyfile","/boot/slink");
867 yaffs_readlink("/boot/slink",str,100);
868 printf("symlink alias is %s\n",str);
873 printf("\nDirectory look-up of /boot\n");
875 printf("\nDirectory look-up of /boot (using stat instead of lstat)\n");
876 dumpDirFollow("/boot");
877 printf("\nDirectory look-up of /boot/directory1\n");
878 dumpDir("/boot/directory1");
880 h = yaffs_open("/boot/slink",O_RDWR,0);
882 printf("file length is %d\n",(int)yaffs_lseek(h,0,SEEK_END));
886 yaffs_unlink("/boot/slink");
889 printf("\nDirectory look-up of /boot\n");
894 yaffs_lstat("/boot/yyfile",&ystat);
895 temp_mode = ystat.st_mode;
897 yaffs_chmod("/boot/yyfile",0x55555);
898 printf("\nDirectory look-up of /boot\n");
901 yaffs_chmod("/boot/yyfile",temp_mode);
902 printf("\nDirectory look-up of /boot\n");
905 // Permission checks...
906 PermissionsCheck("/boot/yyfile",0, O_WRONLY,0);
907 PermissionsCheck("/boot/yyfile",0, O_RDONLY,0);
908 PermissionsCheck("/boot/yyfile",0, O_RDWR,0);
910 PermissionsCheck("/boot/yyfile",S_IREAD, O_WRONLY,0);
911 PermissionsCheck("/boot/yyfile",S_IREAD, O_RDONLY,1);
912 PermissionsCheck("/boot/yyfile",S_IREAD, O_RDWR,0);
914 PermissionsCheck("/boot/yyfile",S_IWRITE, O_WRONLY,1);
915 PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDONLY,0);
916 PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDWR,0);
918 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_WRONLY,1);
919 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDONLY,1);
920 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDWR,1);
922 yaffs_chmod("/boot/yyfile",temp_mode);
924 //create a zero-length file and unlink it (test for scan bug)
926 h = yaffs_open("/boot/zlf",O_CREAT | O_TRUNC | O_RDWR,0);
929 yaffs_unlink("/boot/zlf");
932 yaffs_dump_dev("/boot");
934 fill_disk_and_delete("/boot",20,20);
936 yaffs_dump_dev("/boot");
938 fill_files("/boot",1,10000,0);
939 fill_files("/boot",1,10000,5000);
940 fill_files("/boot",2,10000,0);
941 fill_files("/boot",2,10000,5000);
943 leave_unlinked_file("/data",20000,0);
944 leave_unlinked_file("/data",20000,5000);
945 leave_unlinked_file("/data",20000,5000);
946 leave_unlinked_file("/data",20000,5000);
947 leave_unlinked_file("/data",20000,5000);
948 leave_unlinked_file("/data",20000,5000);
950 yaffs_dump_dev("/boot");
951 yaffs_dump_dev("/data");
959 int huge_directory_test_on_path(char *path)
963 struct yaffs_dirent *de;
979 // Create a large number of files
981 for(i = 0; i < 2000; i++)
983 sprintf(str,"%s/%d",path,i);
985 f = yaffs_open(str,O_CREAT,S_IREAD | S_IWRITE);
991 d = yaffs_opendir(path);
994 while((de = yaffs_readdir(d)) != NULL) {
995 if (total >lastTotal+100*9*1024||(i & 1023)==0){
996 printf("files = %d, total = %d\n",i, total);
1000 sprintf(str,"%s/%s",path,de->d_name);
1001 yaffs_lstat(str,&s);
1002 switch(s.st_mode & S_IFMT){
1004 //printf("data file");
1016 int yaffs_scan_test(const char *path)
1024 void rename_over_test(const char *mountpt)
1031 sprintf(a,"%s/a",mountpt);
1032 sprintf(b,"%s/b",mountpt);
1033 sprintf(c,"%s/c",mountpt);
1037 yaffs_mount(mountpt);
1039 printf("Existing files\n");
1040 dumpDirFollow(mountpt);
1044 i = yaffs_open(c,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1045 printf("File c handle is %d\n",i);
1047 i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1049 i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1051 yaffs_rename(a,b); // rename over
1052 yaffs_rename(b,a); // rename back again (not renaimng over)
1053 yaffs_rename(a,b); // rename back again (not renaimng over)
1056 yaffs_unmount(mountpt);
1061 int resize_stress_test(const char *path)
1076 sprintf(aname,"%s%s",path,"/a");
1077 sprintf(bname,"%s%s",path,"/b");
1079 memset(abuffer,'a',1000);
1080 memset(bbuffer,'b',1000);
1082 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1083 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1085 printf(" %s %d %s %d\n",aname,a,bname,b);
1089 for(j = 0; j < 100; j++)
1091 yaffs_lseek(a,0,SEEK_END);
1094 for(i = 0; i <20000; i++)
1096 //r = yaffs_lseek(b,i,SEEK_SET);
1097 //r = yaffs_write(b,bbuffer,1000);
1102 int syz = yaffs_lseek(a,0,SEEK_END);
1105 if(syz < 0) syz = 0;
1106 yaffs_ftruncate(a,syz);
1112 r = yaffs_lseek(a,i * 500,SEEK_SET);
1114 printf("At line %d, r is %d\n", __LINE__, r);
1115 r = yaffs_write(a,abuffer,1000);
1117 printf("At line %d, r is %d\n", __LINE__, r);
1129 int overwrite_test(const char *path)
1141 sprintf(aname,"%s%s",path,"/a");
1142 sprintf(bname,"%s%s",path,"/b");
1144 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1145 for(j= 0; j < 500; j++){
1146 yaffs_write(b,bname,100);
1147 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1148 for(i = 0; i < rand() % 20000; i++)
1149 yaffs_write(a,&a,sizeof(a));
1158 int root_perm_remount(const char *path)
1160 struct yaffs_stat s;
1166 yaffs_lstat(path,&s);
1167 printf("root perms after mount %x\n",s.st_mode);
1169 yaffs_chmod(path, 0777);
1171 yaffs_lstat(path,&s);
1172 printf("root perms after setting to 0777 is %x\n",s.st_mode);
1174 yaffs_unmount(path);
1181 int resize_stress_test_no_grow_complex(const char *path,int iters)
1197 sprintf(aname,"%s%s",path,"/a");
1198 sprintf(bname,"%s%s",path,"/b");
1200 memset(abuffer,'a',1000);
1201 memset(bbuffer,'b',1000);
1203 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1204 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1206 printf(" %s %d %s %d\n",aname,a,bname,b);
1210 for(j = 0; j < iters; j++)
1212 yaffs_lseek(a,0,SEEK_END);
1215 for(i = 0; i <20000; i++)
1217 //r = yaffs_lseek(b,i,SEEK_SET);
1218 //r = yaffs_write(b,bbuffer,1000);
1223 int syz = yaffs_lseek(a,0,SEEK_END);
1229 if(syz < 0) syz = 0;
1230 yaffs_ftruncate(a,syz);
1231 syz = yaffs_lseek(a,0,SEEK_END);
1232 printf("shrink to %d\n",syz);
1240 r = yaffs_lseek(a,500,SEEK_END);
1241 r = yaffs_write(a,abuffer,1000);
1243 printf("At line %d, r is %d\n", __LINE__, r);
1250 printf("file size is %lld\n",(long long)yaffs_lseek(a,0,SEEK_END));
1258 int resize_stress_test_no_grow(const char *path,int iters)
1273 sprintf(aname,"%s%s",path,"/a");
1274 sprintf(bname,"%s%s",path,"/b");
1276 memset(abuffer,'a',1000);
1277 memset(bbuffer,'b',1000);
1279 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1280 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1282 printf(" %s %d %s %d\n",aname,a,bname,b);
1286 for(j = 0; j < iters; j++)
1288 yaffs_lseek(a,0,SEEK_END);
1291 for(i = 0; i <20000; i++)
1293 //r = yaffs_lseek(b,i,SEEK_SET);
1294 //r = yaffs_write(b,bbuffer,1000);
1299 int syz = yaffs_lseek(a,0,SEEK_END);
1305 if(syz < 0) syz = 0;
1306 yaffs_ftruncate(a,syz);
1307 syz = yaffs_lseek(a,0,SEEK_END);
1308 printf("shrink to %d\n",syz);
1316 r = yaffs_lseek(a,-500,SEEK_END);
1317 r = yaffs_write(a,abuffer,1000);
1319 printf("At line %d, r is %d\n", __LINE__, r);
1325 printf("file size is %lld\n",(long long)yaffs_lseek(a,0,SEEK_END));
1333 int directory_rename_test(void)
1338 yaffs_mount("/ram");
1339 yaffs_mkdir("/ram/a",0);
1340 yaffs_mkdir("/ram/a/b",0);
1341 yaffs_mkdir("/ram/c",0);
1343 printf("\nDirectory look-up of /ram\n");
1346 dumpDir("/ram/a/b");
1348 printf("Do rename (should fail)\n");
1350 r = yaffs_rename("/ram/a","/ram/a/b/d");
1352 printf("At line %d, r is %d\n", __LINE__, r);
1354 printf("\nDirectory look-up of /ram\n");
1357 dumpDir("/ram/a/b");
1359 printf("Do rename (should not fail)\n");
1361 r = yaffs_rename("/ram/c","/ram/a/b/d");
1362 printf("\nDirectory look-up of /ram\n");
1365 dumpDir("/ram/a/b");
1372 int cache_read_test(void)
1376 int sizeOfFiles = 500000;
1381 yaffs_mount("/boot");
1383 make_a_file("/boot/a",'a',sizeOfFiles);
1384 make_a_file("/boot/b",'b',sizeOfFiles);
1386 a = yaffs_open("/boot/a",O_RDONLY,0);
1387 b = yaffs_open("/boot/b",O_RDONLY,0);
1388 c = yaffs_open("/boot/c", O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
1392 if (i > 100) i = 100;
1394 yaffs_read(a,buffer,i);
1395 yaffs_read(b,buffer,i);
1396 yaffs_write(c,buffer,i);
1397 } while(sizeOfFiles > 0);
1405 int cache_bypass_bug_test(void)
1407 // This test reporoduces a bug whereby YAFFS caching *was* buypassed
1408 // resulting in erroneous reads after writes.
1409 // This bug has been fixed.
1415 memset(buffer1,0,sizeof(buffer1));
1416 memset(buffer2,0,sizeof(buffer2));
1420 yaffs_mount("/boot");
1422 // Create a file of 2000 bytes.
1423 make_a_file("/boot/a",'X',2000);
1425 a = yaffs_open("/boot/a",O_RDWR, S_IREAD | S_IWRITE);
1427 // Write a short sequence to the file.
1428 // This will go into the cache.
1429 yaffs_lseek(a,0,SEEK_SET);
1430 yaffs_write(a,"abcdefghijklmnopqrstuvwxyz",20);
1432 // Read a short sequence from the file.
1433 // This will come from the cache.
1434 yaffs_lseek(a,0,SEEK_SET);
1435 yaffs_read(a,buffer1,30);
1437 // Read a page size sequence from the file.
1438 yaffs_lseek(a,0,SEEK_SET);
1439 yaffs_read(a,buffer2,512);
1441 printf("buffer 1 %s\n",buffer1);
1442 printf("buffer 2 %s\n",buffer2);
1444 if(strncmp(buffer1,buffer2,20))
1446 printf("Cache bypass bug detected!!!!!\n");
1454 int free_space_check(void)
1459 yaffs_mount("/boot");
1460 fill_disk("/boot/",2);
1461 f = yaffs_freespace("/boot");
1463 printf("%d free when disk full\n",f);
1467 int truncate_test(void)
1477 yaffs_mount("/boot");
1479 yaffs_unlink("/boot/trunctest");
1481 a = yaffs_open("/boot/trunctest", O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1483 yaffs_write(a,"abcdefghijklmnopqrstuvwzyz",26);
1485 yaffs_ftruncate(a,3);
1486 l= yaffs_lseek(a,0,SEEK_END);
1488 printf("truncated length is %d\n",l);
1490 yaffs_lseek(a,5,SEEK_SET);
1491 yaffs_write(a,"1",1);
1493 yaffs_lseek(a,0,SEEK_SET);
1495 r = yaffs_read(a,y,10);
1497 printf("read %d bytes:", r);
1499 for(i = 0; i < r; i++) printf("[%02X]",y[i]);
1511 void fill_disk_test(const char *mountpt)
1516 for(i = 0; i < 5; i++)
1518 yaffs_mount(mountpt);
1519 fill_disk_and_delete(mountpt,100,i+1);
1520 yaffs_unmount(mountpt);
1526 void fill_n_file_test(const char *mountpt, int n, int syz)
1533 yaffs_format(mountpt, 0, 0, 0);
1534 yaffs_mount(mountpt);
1537 for(i = 0; i < n; i++)
1542 sprintf(fname, "%s/%d", mountpt, i);
1544 h = yaffs_open(fname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1549 yaffs_write(h, fname, sizeof(fname));
1560 void fill_files_test(const char *mountpt)
1565 for(i = 0; i < 5; i++)
1567 yaffs_mount(mountpt);
1568 fill_files(mountpt,2,3,100);
1569 yaffs_unmount(mountpt);
1574 void fill_empty_files_test(const char *mountpt)
1583 for(i = 0; i < 5; i++)
1585 yaffs_mount(mountpt);
1586 for(d = 0; result >= 0 && d < 1000; d++){
1587 sprintf(name,"%s/%d",mountpt,d);
1588 result= yaffs_mkdir(name,0);
1589 printf("creating directory %s result %d\n",name,result);
1591 for(f = 0; result >= 0 && f < 100; f++){
1592 sprintf(name,"%s/%d/%d",mountpt,d,f);
1593 result= yaffs_open(name,O_CREAT, 0);
1594 yaffs_close(result);
1595 printf("creating file %s result %d\n",name,result);
1598 yaffs_unmount(mountpt);
1603 void long_name_test(const char *mountpt)
1607 char fullName[1000];
1613 // Make a 256 byte name
1614 memset(name,0,sizeof(name));
1615 for(i = 0; i < 256; i++)
1616 name[i] = '0' + i % 10;
1618 sprintf(fullName,"%s/%s",mountpt,name);
1620 for(i = 0; i < 1; i++)
1622 yaffs_mount(mountpt);
1624 printf("Files at start\n");
1627 printf("Creating file %s\n",fullName);
1629 f = yaffs_open(fullName,O_CREAT | O_RDWR,0);
1632 printf("Result %d\n",f);
1637 printf("Deleting %s\n",fullName);
1638 result = yaffs_unlink(fullName);
1639 printf("Result %d\n",result);
1645 yaffs_unmount(mountpt);
1651 void lookup_test(const char *mountpt)
1659 struct yaffs_dirent *de;
1663 yaffs_mount(mountpt);
1665 d = yaffs_opendir(mountpt);
1669 printf("opendir failed\n");
1674 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1676 printf("unlinking %s\n",de->d_name);
1677 yaffs_unlink(de->d_name);
1680 printf("%d files deleted\n",i);
1684 for(i = 0; i < 2000; i++){
1685 sprintf(a,"%s/%d",mountpt,i);
1686 h = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0);
1691 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1693 printf("%d %s\n",i,de->d_name);
1696 printf("%d files listed\n\n\n",i);
1703 for(i = 0; i < 2000; i++){
1704 sprintf(a,"%s/%d",mountpt,i);
1709 yaffs_unmount(mountpt);
1713 void link_test0(const char *mountpt)
1721 yaffs_mount(mountpt);
1724 sprintf(namea,"%s/a",mountpt);
1725 sprintf(nameb,"%s/b",mountpt);
1727 printf("mounted\n");
1730 yaffs_unlink(namea);
1731 printf("a unlinked\n");
1734 yaffs_unlink(nameb);
1735 printf("b unlinked\n");
1738 result = yaffs_open(namea,O_CREAT| O_RDWR,0666);
1739 yaffs_close(result);
1740 printf("a created\n");
1743 yaffs_link(namea,nameb);
1746 yaffs_unlink(namea);
1747 printf("a ulinked\n");
1749 yaffs_unlink(nameb);
1750 printf("b unlinked\n");
1753 yaffs_unmount(mountpt);
1757 void link_test1(const char *mountpt)
1765 sprintf(a,"%s/aaa",mountpt);
1766 sprintf(b,"%s/bbb",mountpt);
1767 sprintf(c,"%s/ccc",mountpt);
1771 yaffs_mount(mountpt);
1774 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1775 for(i = 0; i < 100; i++)
1776 yaffs_write(h,a,100);
1789 yaffs_unmount(mountpt);
1790 yaffs_mount(mountpt);
1792 printf("link test done\n");
1795 void handle_test(const char *mountpt)
1802 sprintf(a,"%s/aaa",mountpt);
1806 yaffs_mount(mountpt);
1808 for(cycle = 0; cycle < 5; cycle++){
1809 printf("Start cycle %d\n",cycle);
1812 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1813 printf("%d handle %d\n",i,h);
1823 yaffs_unmount(mountpt);
1826 void freespace_test(const char *mountpt)
1836 sprintf(a,"%s/aaa",mountpt);
1840 yaffs_mount(mountpt);
1842 f0 = yaffs_freespace(mountpt);
1844 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1846 for(i = 0; i < 100; i++)
1847 yaffs_write(h,a,100);
1851 f1 = yaffs_freespace(mountpt);
1855 f2 = yaffs_freespace(mountpt);
1858 yaffs_unmount(mountpt);
1859 yaffs_mount(mountpt);
1861 f3 = yaffs_freespace(mountpt);
1863 printf("%d\n%d\n%d\n%d\n",f0, f1,f2,f3);
1868 void simple_rw_test(const char *mountpt)
1877 sprintf(a,"%s/aaa",mountpt);
1881 yaffs_mount(mountpt);
1885 h = yaffs_open(a,O_CREAT| O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1887 for(i = 100000;i < 200000; i++){
1888 result = yaffs_write(h,&i,sizeof(i));
1892 printf("write error\n");
1899 // h = yaffs_open(a,O_RDWR, S_IREAD | S_IWRITE);
1902 yaffs_lseek(h,0,SEEK_SET);
1904 for(i = 100000; i < 200000; i++){
1905 result = yaffs_read(h,&x,sizeof(x));
1907 if(result != 4 || x != i){
1908 printf("read error %d %x %x\n",i,result,x);
1912 printf("Simple rw test passed\n");
1919 void scan_deleted_files_test(const char *mountpt)
1931 sprintf(sub,"%s/sdir",mountpt);
1934 for(j = 0; j < 10; j++)
1936 printf("\n\n>>>>>>> Run %d <<<<<<<<<<<<<\n\n",j);
1937 yaffs_mount(mountpt);
1941 p = (j & 0) ? mountpt: sub;
1943 for(i = 0; i < 100; i++)
1945 sprintf(fn,"%s/%d",p,i);
1949 h = yaffs_open(fn,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1950 for(k = 0; k < 1000; k++)
1951 yaffs_write(h,fn,100);
1958 for(i = 0; i < 10; i++)
1960 sprintf(fn,"%s/%d",p,i);
1968 yaffs_unmount(mountpt);
1977 void write_10k(int h)
1980 const char *s="0123456789";
1981 for(i = 0; i < 1000; i++)
1982 yaffs_write(h,s,10);
1985 void write_200k_file(const char *fn, const char *fdel, const char *fdel1)
1991 h1 = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1993 for(i = 0; i < 100000; i+= 10000)
1998 offs = yaffs_lseek(h1,0,SEEK_CUR);
2001 printf("Could not write file\n");
2005 for(i = 0; i < 100000; i+= 10000)
2010 offs = yaffs_lseek(h1,0,SEEK_CUR);
2013 printf("Could not write file\n");
2017 yaffs_unlink(fdel1);
2022 void verify_200k_file(const char *fn)
2027 const char *s="0123456789";
2030 h1 = yaffs_open(fn, O_RDONLY, 0);
2032 for(i = 0; i < 200000 && errCount < 10; i+= 10)
2034 yaffs_read(h1,x,10);
2035 if(strncmp(x,s,10) != 0)
2037 printf("File %s verification failed at %d\n",fn,i);
2042 printf("Too many errors... aborted\n");
2049 void check_resize_gc_bug(const char *mountpt)
2058 sprintf(a,"%s/a",mountpt);
2059 sprintf(b,"%s/b",mountpt);
2060 sprintf(c,"%s/c",mountpt);
2066 yaffs_mount(mountpt);
2070 for(i = 0; i < 50; i++)
2072 printf("A\n");write_200k_file(a,"",c);
2073 printf("B\n");verify_200k_file(a);
2074 printf("C\n");write_200k_file(b,a,c);
2075 printf("D\n");verify_200k_file(b);
2076 yaffs_unmount(mountpt);
2077 yaffs_mount(mountpt);
2078 printf("E\n");verify_200k_file(a);
2079 printf("F\n");verify_200k_file(b);
2085 void multi_mount_test(const char *mountpt,int nmounts)
2093 sprintf(a,"%s/a",mountpt);
2097 for(i = 0; i < nmounts; i++){
2102 printf("############### Iteration %d Start\n",i);
2103 if(1 || i == 0 || i == 5)
2104 yaffs_mount(mountpt);
2106 dump_directory_tree(mountpt);
2111 sprintf(xx,"%s/0",a);
2112 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2114 sprintf(xx,"%s/1",a);
2115 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2118 for(j = 0; j < 200; j++){
2119 yaffs_write(h0,xx,1000);
2120 yaffs_write(h1,xx,1000);
2123 while(yaffs_write(h0,xx,1000) > 0){
2125 yaffs_write(h1,xx,1000);
2128 yaffs_lseek(h0,0,SEEK_END);
2129 yaffs_lseek(h1,0,SEEK_END);
2131 yaffs_lseek(h0,0,SEEK_SET);
2132 yaffs_lseek(h1,0,SEEK_SET);
2134 for(j = 0; j < 200; j++){
2135 yaffs_read(h0,xx,1000);
2136 yaffs_read(h1,xx,1000);
2140 // yaffs_truncate(h0,0);
2144 printf("########### %d\n",i);
2145 dump_directory_tree(mountpt);
2147 if(1 || i == 4 || i == nmounts -1)
2148 yaffs_unmount(mountpt);
2153 void small_mount_test(const char *mountpt,int nmounts)
2165 sprintf(a,"%s/a",mountpt);
2171 for(i = 0; i < nmounts; i++){
2175 printf("############### Iteration %d Start\n",i);
2176 if(1 || i == 0 || i == 5)
2177 yaffs_mount(mountpt);
2179 dump_directory_tree(mountpt);
2183 sprintf(xx,"%s/0",a);
2186 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2187 for(j = 0; j < 130; j++)
2188 yaffs_write(h0,xx,1000);
2192 h0 = yaffs_open(xx,O_RDONLY,0);
2194 sprintf(xx,"%s/1",a);
2195 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2197 while((nread = yaffs_read(h0,xx,1000)) > 0)
2198 yaffs_write(h1,xx,nread);
2201 yaffs_lseek(h0,0,SEEK_END);
2202 yaffs_lseek(h1,0,SEEK_END);
2204 yaffs_lseek(h0,0,SEEK_SET);
2205 yaffs_lseek(h1,0,SEEK_SET);
2207 for(j = 0; j < 200; j++){
2208 yaffs_read(h0,xx,1000);
2209 yaffs_read(h1,xx,1000);
2215 printf("########### %d\n",i);
2216 dump_directory_tree(mountpt);
2218 if(1 || i == 4 || i == nmounts -1)
2219 yaffs_unmount(mountpt);
2226 void small_overwrite_test(const char *mountpt,int nmounts)
2237 sprintf(a,"%s/a",mountpt);
2243 for(i = 0; i < nmounts; i++){
2245 static char xx[8000];
2247 printf("############### Iteration %d Start\n",i);
2249 yaffs_mount(mountpt);
2251 dump_directory_tree(mountpt);
2255 sprintf(xx,"%s/0",a);
2256 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2257 sprintf(xx,"%s/1",a);
2258 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2260 for(j = 0; j < 1000000; j+=1000){
2261 yaffs_ftruncate(h0,j);
2262 yaffs_lseek(h0,j,SEEK_SET);
2263 yaffs_write(h0,xx,7000);
2264 yaffs_write(h1,xx,7000);
2272 printf("########### %d\n",i);
2273 dump_directory_tree(mountpt);
2276 yaffs_unmount(mountpt);
2281 void seek_overwrite_test(const char *mountpt,int nmounts)
2283 static char xx[5000];
2292 sprintf(a,"%s/f",mountpt);
2296 yaffs_mount(mountpt);
2299 for(i = 0; i < nmounts; i++){
2301 h0 = yaffs_open(a, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2303 for(j = 0; j < 100000; j++){
2304 yaffs_lseek(h0,0,SEEK_SET);
2305 yaffs_write(h0,xx,5000);
2306 yaffs_lseek(h0,0x100000,SEEK_SET);
2307 yaffs_write(h0,xx,5000);
2319 void yaffs_touch(const char *fn)
2321 yaffs_chmod(fn, S_IREAD | S_IWRITE);
2324 void checkpoint_fill_test(const char *mountpt,int nmounts)
2335 sprintf(a,"%s/a",mountpt);
2342 for(i = 0; i < nmounts; i++){
2343 printf("############### Iteration %d Start\n",i);
2344 yaffs_mount(mountpt);
2345 dump_directory_tree(mountpt);
2348 sprintf(b,"%s/zz",a);
2350 h = yaffs_open(b,O_CREAT | O_RDWR,S_IREAD |S_IWRITE);
2353 while(yaffs_write(h,c,50) == 50){}
2357 for(j = 0; j < 2; j++){
2358 printf("touch %d\n",j);
2360 yaffs_unmount(mountpt);
2361 yaffs_mount(mountpt);
2364 dump_directory_tree(mountpt);
2365 yaffs_unmount(mountpt);
2370 int make_file2(const char *name1, const char *name2,int syz)
2380 h1 = yaffs_open(name1,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2382 h2 = yaffs_open(name2,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2384 while(syz > 0 && n > 0){
2385 i = (syz > 2500) ? 2500 : syz;
2386 n = yaffs_write(h1,xx,i);
2387 n = yaffs_write(h2,xx,i);
2396 extern void SetCheckpointReservedBlocks(int n);
2398 void checkpoint_upgrade_test(const char *mountpt, int nmounts)
2410 sprintf(a,"%s/a",mountpt);
2412 printf("Create start condition\n");
2414 yaffs_mount(mountpt);
2416 sprintf(b,"%s/zz",a);
2417 sprintf(c,"%s/xx",a);
2418 make_file2(b,c,2000000);
2419 sprintf(d,"%s/aa",a);
2420 make_file2(d,NULL,500000000);
2421 dump_directory_tree(mountpt);
2423 printf("Umount/mount attempt full\n");
2424 yaffs_unmount(mountpt);
2426 yaffs_mount(mountpt);
2428 printf("unlink small file\n");
2430 dump_directory_tree(mountpt);
2432 printf("Umount/mount attempt\n");
2433 yaffs_unmount(mountpt);
2434 yaffs_mount(mountpt);
2436 for(j = 0; j < 500; j++){
2437 printf("***** touch %d\n",j);
2438 dump_directory_tree(mountpt);
2440 yaffs_unmount(mountpt);
2441 yaffs_mount(mountpt);
2444 for(j = 0; j < 500; j++){
2445 printf("***** touch %d\n",j);
2446 dump_directory_tree(mountpt);
2448 yaffs_unmount(mountpt);
2449 yaffs_mount(mountpt);
2453 void huge_array_test(const char *mountpt,int n)
2464 sprintf(a,"mount point %s",mountpt);
2470 yaffs_mount(mountpt);
2475 printf("\n\n START run\n\n");
2476 while((space = yaffs_freespace(mountpt)) > 25000000){
2477 sprintf(a,"%s/file%d",mountpt,fnum);
2479 printf("create file %s, free space %d\n",a,space);
2480 create_file_of_size(a,10000000);
2481 printf("verifying file %s\n",a);
2482 verify_file_of_size(a,10000000);
2485 printf("\n\n verification/deletion\n\n");
2487 for(i = 0; i < fnum; i++){
2488 sprintf(a,"%s/file%d",mountpt,i);
2489 printf("verifying file %s\n",a);
2490 verify_file_of_size(a,10000000);
2491 printf("deleting file %s\n",a);
2494 printf("\n\n done \n\n");
2501 void random_write(int h)
2503 static char buffer[12000];
2506 n = random() & 0x1FFF;
2507 yaffs_write(h,buffer,n);
2510 void random_seek(int h)
2513 n = random() & 0xFFFFF;
2514 yaffs_lseek(h,n,SEEK_SET);
2517 void random_truncate(int h, char *name)
2524 n = random() & 0xFFFFF;
2525 flen = yaffs_lseek(h,0,SEEK_END);
2528 yaffs_ftruncate(h,n);
2529 yaffs_lseek(h,n,SEEK_SET);
2533 #define NSMALLFILES 10
2534 void random_small_file_test(const char *mountpt,int iterations)
2537 char a[NSMALLFILES][50];
2548 yaffs_mount(mountpt);
2550 for(i = 0; i < NSMALLFILES; i++){
2555 for(n = 0; n < iterations; n++){
2557 for(i = 0; i < NSMALLFILES; i++) {
2560 if(strlen(a[i]) == 0){
2561 sprintf(a[i],"%s/%dx%d",mountpt,n,i);
2562 h[i] = yaffs_open(a[i],O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2566 printf("Could not open yaffs file %d %d error %d\n",n,i,h[i]);
2576 random_truncate(h[i],a[i]);
2579 case 5: random_seek(h[i]);
2596 for(i = 0; i < NSMALLFILES; i++)
2599 yaffs_unmount(mountpt);
2602 void rmdir_test(const char *mountpt)
2607 yaffs_mount(mountpt);
2609 strcpy(name,mountpt);
2611 strcat(name,"hello");
2612 yaffs_mkdir(name,0666);
2614 yaffs_unmount(mountpt);
2619 static void print_xattrib_val(const char *path, const char *name)
2624 n = yaffs_getxattr(path,name,buffer,sizeof(buffer));
2626 u8 *b = (u8 *)buffer;
2628 printf("%d bytes:",n);
2632 printf("[%02X]",*b);
2638 printf(" Novalue result %d\n",n);
2641 static void list_xattr(const char *path)
2648 list_len = yaffs_listxattr(path,list,sizeof(list));
2649 printf("xattribs for %s, result is %d\n",path,list_len);
2650 while(n < list_len){
2651 len = strlen(list + n);
2652 printf("\"%s\" value ",list+n);
2653 print_xattrib_val(path,list + n);
2659 void basic_utime_test(const char *mountpt)
2664 struct yaffs_utimbuf utb;
2665 struct yaffs_stat st;
2670 yaffs_mount(mountpt);
2672 strcpy(name,mountpt);
2674 strcat(name,"xfile");
2678 printf("created\n");
2679 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2682 printf(" times before %llu %llu %llu\n",
2683 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2685 //here are the last access and modification times.
2689 //futime sets the last modification and access time of the file
2690 result = yaffs_futime(h,&utb);
2691 printf("setting times using the futime function to a 1000 m 2000 result %d\n",result);
2693 //read the times from the file header
2695 printf(" times %llu %llu %llu\n",
2696 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2701 result = yaffs_utime(name, &utb);
2702 printf("utime to a 5000 m 8000 result %d\n",result);
2704 printf(" times %llu %llu %llu\n",
2705 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2707 result = yaffs_utime(name, NULL);
2708 printf("utime to NULL result %d\n",result);
2710 printf(" times %llu %llu %llu\n",
2711 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2716 void print_binary(u64 val){
2718 for (int i= 63; i>=0; i --) {
2722 if ((((u64)1) << i) & val) {
2727 count = (count +1) % 8;
2731 void testing_swap_u64() {
2732 int numberOfFailedTests = 0;
2733 for (int i =0; i < 8; i ++) {
2734 u64 startingNumber = (0xffLLu << (i*8));
2735 u64 expected = (0xffLLu << (64 - (i*8) -8));
2736 u64 converted = swap_u64(startingNumber);
2737 if (converted != expected) {
2738 numberOfFailedTests ++;
2739 printf("numbers do not match.\n");
2740 printf("0xff\t\t\t");
2742 printf("\nStarting Number \t");
2743 print_binary(startingNumber);
2744 printf("\nExpecting \t\t");
2745 print_binary(expected);
2746 printf("\nConverted \t\t");
2747 print_binary(converted);
2752 if (numberOfFailedTests){
2753 printf("testing_swap failed %d tests\n", numberOfFailedTests);
2755 printf("testing_swap_u64 passed all tests\n");
2760 void size_utime_test(const char *mountpt)
2765 struct yaffs_utimbuf utb;
2766 struct yaffs_stat st;
2771 yaffs_mount(mountpt);
2773 strcpy(name,mountpt);
2775 strcat(name,"xfile");
2779 printf("created\n");
2780 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2783 printf(" times before %llu %llu %llu\n",
2784 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2786 //first lets get the yaffs_object.
2788 //then check that yaffs_stat also works.
2789 //yaffs_stat already uses 64 bits for both wince and unix times.
2790 //To see if we are using 32 or 64 bit time, save a large number into the time and
2791 //see if it overflows.
2792 long bitsInTime = 8*sizeof(st.yst_ctime);
2793 printf("the times are %ld bits long\n", bitsInTime);
2796 if (bitsInTime == 64) {
2797 //no need to test the overflow. Just check that it can be retrieved intact.
2799 //use u64 variables in case utb truncates the values to 32 bit time by accident.
2800 u64 start = 0xfffff;
2806 result = yaffs_futime(h,&utb);
2808 if (st.yst_atime == start && st.yst_mtime == end) {
2809 printf("successfully stored and retrevied a 64 bit number for atime and modtime\n");
2811 printf("failed to store and retrieve a 64 bit number for atime and modtime\n");
2815 //it is a 32 bit number. Check to see that it overflowed.
2820 //here are the last access and modification times.
2824 //futime sets the last modification and access time of the file
2825 result = yaffs_futime(h,&utb);
2826 printf("setting times using the futime function to a 1000 m 2000 result %d\n",result);
2828 //read the times from the file header
2830 printf(" times %llu %llu %llu\n",
2831 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2836 result = yaffs_utime(name, &utb);
2837 printf("utime to a 5000 m 8000 result %d\n",result);
2839 printf(" times %llu %llu %llu\n",
2840 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2842 result = yaffs_utime(name, NULL);
2843 printf("utime to NULL result %d\n",result);
2845 printf(" times %llu %llu %llu\n",
2846 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2852 void basic_xattr_test(const char *mountpt)
2861 yaffs_mount(mountpt);
2863 strcpy(name,mountpt);
2865 strcat(name,"xfile");
2868 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2874 printf("Add an attribute\n");
2876 result = yaffs_setxattr(name,"foo",&val1,sizeof(val1),0);
2877 printf("wrote attribute foo: result %d\n",result);
2879 printf("Add an attribute\n");
2881 result = yaffs_setxattr(name,"bar",&val1,sizeof(val1),0);
2882 printf("wrote attribute bar: result %d\n",result);
2885 printf("Get non-existanrt attribute\n");
2886 print_xattrib_val(name,"not here");
2888 printf("Delete non existing attribute\n");
2889 yaffs_removexattr(name,"not here");
2892 printf("Remove foo\n");
2893 yaffs_removexattr(name,"foo");
2896 printf("Remove bar\n");
2897 yaffs_removexattr(name,"bar");
2902 void big_xattr_test(const char *mountpt)
2911 yaffs_mount(mountpt);
2913 strcpy(name,mountpt);
2915 strcat(name,"xfile");
2918 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2924 printf("Add a large attribute\n");
2925 memset(val,0x1,sizeof(val));
2926 result = yaffs_setxattr(name,"aaa",val,200,0);
2927 printf("wrote attribute aaa: result %d\n",result);
2930 printf("Add a large attribute\n");
2931 memset(val,0x2,sizeof(val));
2932 result = yaffs_setxattr(name,"bbb",val,1000,0);
2933 printf("wrote attribute bbb: result %d\n",result);
2936 printf("Replace attribute\n");
2937 memset(val,0x3,sizeof(val));
2938 result = yaffs_setxattr(name,"aaa",val,1000,0);
2939 printf("wrote attribute aaa: result %d\n",result);
2945 void dump_dev_stats(struct yaffs_dev *dev, const char * str)
2948 printf( "space free %d erased %d "
2949 "nand reads %d writes %d erases %d "
2950 "gc all %d passive %d oldestdirty %d blocks %d copies %d \n",
2951 dev->n_free_chunks, dev->n_erased_blocks * dev->param.chunks_per_block,
2952 dev->n_page_reads, dev->n_page_writes, dev->n_erasures,
2953 dev->all_gcs, dev->passive_gc_count, dev->oldest_dirty_gc_count, dev->n_gc_blocks, dev->n_gc_copies);
2956 void test_flash_traffic(const char *mountpt)
2961 struct yaffs_dev *dev;
2963 yaffs_trace_mask = 0;
2967 yaffs_mount(mountpt);
2969 dev = yaffs_getdev(mountpt);
2971 strcpy(name0,mountpt);
2974 strcpy(name1,mountpt);
2977 dump_dev_stats(dev,"start");
2978 create_file_of_size(name0,32 * 1024 * 1024);
2979 dump_dev_stats(dev,"32MB written");
2980 for(i = 0; i < 20; i++)
2981 create_file_of_size(name1,1024 * 1024);
2982 dump_dev_stats(dev,"20x 1MB files written");
2986 void link_follow_test(const char *mountpt)
2994 yaffs_trace_mask = 0;
2998 yaffs_mount(mountpt);
3000 sprintf(fn,"%s/file",mountpt);
3001 sprintf(sn,"%s/sym",mountpt);
3002 sprintf(hn,"%s/hl-sym",mountpt);
3004 h = yaffs_open(fn,O_CREAT| O_RDWR, S_IREAD | S_IWRITE);
3005 result = yaffs_close(h);
3007 result = yaffs_symlink(fn,sn);
3008 result = yaffs_link(sn,hn);
3011 printf("At line %d result is %d\n", __LINE__, result);
3013 h =yaffs_open(hn,O_RDWR,0);
3017 void max_files_test(const char *mountpt)
3025 yaffs_trace_mask = 0;
3029 yaffs_mount(mountpt);
3031 for(i = 0; i < 5000; i++) {
3032 sprintf(fn,"%s/file%d", mountpt, i);
3034 h = yaffs_open(fn,O_CREAT| O_RDWR, S_IREAD | S_IWRITE);
3036 printf("File %s not created\n", fn);
3037 yaffs_write(h,fn,100);
3038 result = yaffs_close(h);
3040 for(i = 0; i < 5; i++){
3041 sprintf(fn,"%s/file%d",mountpt, i);
3045 for(i = 1000; i < 1010; i++){
3046 sprintf(fn,"%s/file%d",mountpt, i);
3047 h = yaffs_open(fn,O_CREAT| O_RDWR, S_IREAD | S_IWRITE);
3048 yaffs_write(h,fn,100);
3050 printf("File %s not created\n", fn);
3051 result = yaffs_close(h);
3055 printf("At line %d result is %d\n", __LINE__, result);
3057 yaffs_unmount(mountpt);
3060 void case_insensitive_test(const char *mountpt)
3066 struct yaffs_stat s;
3070 yaffs_trace_mask = 0;
3074 yaffs_mount(mountpt);
3075 dump_directory_tree(mountpt);
3077 sprintf(fn,"%s/Abc.Txt",mountpt);
3079 h = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
3081 ret = yaffs_write(h,fn, strlen(fn) + 1);
3083 ret = yaffs_close(h);
3085 dump_directory_tree(mountpt);
3095 h = yaffs_open(fn2, O_RDONLY, 0);
3096 ret = yaffs_read(h, buffer, 100);
3098 if (ret != (int)(strlen(fn) + 1) || memcmp(buffer, fn, ret)){
3099 printf("wrong file read\n");
3101 printf("File %s is the same as file %s\n", fn, fn2);
3104 ret = yaffs_stat(fn2, &s);
3106 printf("renaming\n");
3108 ret = yaffs_rename(fn, fn2);
3109 dump_directory_tree(mountpt);
3113 void start_twice(const char *mountpt)
3115 printf("About to do first yaffs_start\n");
3117 printf("started\n");
3118 printf("First mount returns %d\n", yaffs_mount(mountpt));
3119 printf("About to do second yaffs_start\n");
3121 printf("started\n");
3122 printf("Second mount returns %d\n", yaffs_mount(mountpt));
3125 #define N_WRITES 2000
3128 #define BUFFER_N 1100
3129 unsigned xxbuffer[BUFFER_N];
3131 void set_buffer(int n)
3134 for(i = 0; i < BUFFER_N; i++)
3135 xxbuffer[i] = i + n;
3138 void write_big_sparse_file(int h)
3143 int n = sizeof(xxbuffer);
3146 for(i = 0; i < N_WRITES; i++) {
3147 printf("writing at %d\n", (int)offset);
3149 pos = yaffs_lseek(h, offset, SEEK_SET);
3151 printf("mismatched seek pos %d offset %d\n",
3152 (int)pos, (int)offset);
3156 wrote = yaffs_write(h, xxbuffer, n);
3159 printf("mismatched write wrote %d n %d\n", wrote, n);
3163 offset += (STRIDE * sizeof(xxbuffer));
3166 yaffs_ftruncate(h, offset);
3170 void verify_big_sparse_file(int h)
3172 unsigned check_buffer[BUFFER_N];
3176 int n = sizeof(check_buffer);
3178 int checks_failed = 0;
3179 int checks_passed = 0;
3181 for(i = 0; i < N_WRITES * STRIDE; i++) {
3183 memset(xxbuffer,0, n);
3185 set_buffer(i/STRIDE);
3187 pos = yaffs_lseek(h, offset, SEEK_SET);
3189 printf("mismatched seek pos %d offset %d\n",
3190 (int)pos, (int)offset);
3194 result = yaffs_read(h, check_buffer, n);
3197 printf("mismatched read result %d n %d\n", result, n);
3201 if(memcmp(xxbuffer, check_buffer, n)) {
3204 printf("buffer at %d mismatches\n", (int)pos);
3205 printf("xxbuffer ");
3206 for(j = 0; j < 20; j++)
3207 printf(" %d",xxbuffer[j]);
3209 printf("check_buffer ");
3210 for(j = 0; j < 20; j++)
3211 printf(" %d",check_buffer[j]);
3219 offset += sizeof(xxbuffer);
3222 printf("%d checks passed, %d checks failed\n", checks_passed, checks_failed);
3227 void large_file_test(const char *mountpt)
3229 char xx_buffer[1000];
3235 yaffs_trace_mask = 0;
3239 yaffs_mount(mountpt);
3240 printf("mounted\n");
3243 sprintf(fullname, "%s/%s", mountpt, "big-test-file");
3245 handle = yaffs_open(fullname, O_RDONLY, 0);
3247 handle = yaffs_open(fullname, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
3250 perror("opening file");
3254 write_big_sparse_file(handle);
3255 verify_big_sparse_file(handle);
3257 yaffs_close(handle);
3259 printf("Job done\n");
3260 yaffs_unmount(mountpt);
3262 yaffs_mount(mountpt);
3263 printf("mounted again\n");
3265 handle = yaffs_open(fullname, O_RDONLY, 0);
3266 verify_big_sparse_file(handle);
3267 yaffs_unmount(mountpt);
3270 yaffs_mount3(mountpt, 0, 1);
3271 printf("mounted with no checkpt\n");
3273 handle = yaffs_open(fullname, O_RDONLY, 0);
3274 verify_big_sparse_file(handle);
3275 yaffs_unmount(mountpt);
3277 /* Check resize by adding to the end, resizing back and verifying. */
3278 yaffs_mount3(mountpt, 0, 1);
3279 printf("checking resize\n");
3281 handle = yaffs_open(fullname, O_RDWR, 0);
3283 file_end = yaffs_lseek(handle, 0, SEEK_END);
3284 printf("file_end %d\n", (int)file_end);
3285 for(i = 0; i < 10000; i++)
3286 yaffs_write(handle, xx_buffer, sizeof(xx_buffer));
3287 yaffs_ftruncate(handle, file_end);
3289 verify_big_sparse_file(handle);
3290 yaffs_unmount(mountpt);
3295 int mk_dir(const char *mp, const char *name)
3297 char full_name[100];
3299 sprintf(full_name, "%s/%s", mp, name);
3301 return yaffs_mkdir(full_name, S_IREAD| S_IWRITE);
3304 int mk_file(const char *mp, const char *name)
3306 char full_name[100];
3309 sprintf(full_name, "%s/%s", mp, name);
3311 h = yaffs_open(full_name, O_RDWR | O_CREAT | O_TRUNC, S_IREAD| S_IWRITE);
3313 yaffs_write(h, name, strlen(name));
3319 void xx_test(const char *mountpt)
3323 yaffs_format(mountpt,0,0,0);
3325 yaffs_mount(mountpt);
3326 printf("mounted\n");
3329 printf("create files\n");
3331 mk_dir(mountpt, "foo");
3332 mk_file(mountpt, "foo/f1");
3333 mk_file(mountpt, "foo/f2");
3334 mk_file(mountpt, "foo/f3");
3335 mk_file(mountpt, "foo/f4");
3336 dump_directory_tree(mountpt);
3338 printf("unmount and remount\n");
3340 /* Unmount/remount */
3341 yaffs_unmount(mountpt);
3342 yaffs_mount(mountpt);
3343 dump_directory_tree(mountpt);
3346 void yy_test(const char *mountpt)
3350 yaffs_mount(mountpt);
3351 dump_directory_tree(mountpt);
3355 void readdir_test(const char *mountpt)
3358 yaffs_DIR *dirs[100];
3360 yaffs_trace_mask = 0;
3364 yaffs_mount(mountpt);
3366 for(i = 0; i < 100; i++) {
3367 dirs[i] = yaffs_opendir(mountpt);
3368 printf("%2d %p,", i, dirs[i]);
3373 for(i = 0; i < 100; i++) {
3375 yaffs_closedir(dirs[i]);
3379 for(i = 0; i < 100; i++) {
3380 dirs[i] = yaffs_opendir(mountpt);
3381 printf("%2d %p,", i, dirs[i]);
3384 yaffs_unmount(mountpt);
3388 void format_test(const char *mountpt)
3394 ret = yaffs_format(mountpt, 0, 0, 0);
3395 printf("yaffs_format(...,0, 0, 0) of unmounted returned %d."
3396 " Should return 0\n\n\n", ret);
3398 yaffs_mount(mountpt);
3400 ret = yaffs_format(mountpt, 0, 0, 0);
3401 printf("yaffs_format(...,0, 0, 0) of mounted returned %d."
3402 " Should return -1 (busy)\n\n\n", ret);
3404 ret = yaffs_format(mountpt, 1, 0, 0);
3405 printf("yaffs_format(...,1, 0, 0) of mounted returned %d."
3406 " Should return 0.\n\n\n", ret);
3408 ret = yaffs_mount(mountpt);
3409 printf("mount should return 0 returned %d\n\n\n", ret);
3411 ret = yaffs_format(mountpt, 1, 0, 1);
3412 printf("yaffs_format(...,1, 0, 1) of mounted returned %d."
3413 " Should return 0.\n\n\n", ret);
3415 ret = yaffs_mount(mountpt);
3416 printf("mount should return -1 returned %d\n", ret);
3419 void dir_rename_test(const char *mountpt)
3427 yaffs_mount(mountpt);
3429 sprintf(fname,"%s/file",mountpt);
3430 sprintf(dname,"%s/directory",mountpt);
3432 h = yaffs_open(fname,O_CREAT | O_RDWR | O_TRUNC, 0666);
3435 yaffs_mkdir(dname, 0666);
3437 dump_directory_tree(mountpt);
3439 printf("Try to rename %s to %s\n", fname, dname);
3440 ret = yaffs_rename(fname, dname);
3441 printf("result %d, %d\n", ret, yaffs_get_error());
3443 printf("Try to rename %s to %s\n", dname, fname);
3444 ret = yaffs_rename(dname, fname);
3445 printf("result %d, %d\n", ret, yaffs_get_error());
3451 void dir_fd_test(const char *mountpt)
3458 yaffs_mount(mountpt);
3460 sprintf(name,"%s/directory",mountpt);
3461 yaffs_mkdir(name, 0666);
3462 for(i=0; i < 20; i++) {
3463 sprintf(name,"%s/directory/file%d",mountpt, i);
3465 h = yaffs_open(name, O_CREAT | O_TRUNC | O_RDWR, 0666);
3466 yaffs_write(h, name, strlen(name));
3469 sprintf(name,"%s/dddd",mountpt);
3470 yaffs_mkdir(name, 0666);
3471 for(i=0; i < 20; i++) {
3472 sprintf(name,"%s/dddd/filezzz%d",mountpt, i);
3474 h = yaffs_open(name, O_CREAT | O_TRUNC | O_RDWR, 0666);
3475 yaffs_write(h, name, strlen(name));
3480 dump_directory_tree(mountpt);
3481 dump_directory_tree_fd(mountpt);
3482 dump_directory_tree_fd(mountpt);
3486 void create_delete_many_files_test(const char *mountpt)
3498 yaffs_mount(mountpt);
3500 for(i = 1; i < 2000; i++) {
3501 sprintf(fn,"%s/f%d",mountpt, i);
3502 fsize = (i%10) * 10000 + 20000;
3503 h = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, 0666);
3505 wrote = yaffs_write(h, buffer, sizeof(buffer));
3506 if (wrote != sizeof(buffer)) {
3507 printf("Writing file %s, only wrote %d bytes\n", fn, wrote);
3518 void find_device_check(void)
3521 yaffs_mount("/nand");
3523 yaffs_mkdir("/nandxxx", 0666);
3524 yaffs_mkdir("/nand/xxx", 0666);
3528 void try_opendir(const char *str)
3532 d = yaffs_opendir(str);
3534 printf("%s --> %p\n", str, d);
3540 void opendir_test(void)
3543 yaffs_mount("/nand/");
3544 yaffs_symlink("x", "/nand/sym");
3545 yaffs_mkdir("/nand/x",0666);
3546 yaffs_mkdir("/nand/y",0666);
3547 yaffs_mkdir("/nand/x/r",0666);
3548 yaffs_mkdir("/nand/x/s",0666);
3549 yaffs_mkdir("/nand/x/t",0666);
3551 try_opendir("nand/x/.");
3552 try_opendir("nand/x/r/..");
3553 try_opendir("nand/x/./");
3554 try_opendir("nand/x/r/../");
3555 try_opendir("/nand/x");
3556 try_opendir("/nand/x/");
3557 try_opendir("nand/x");
3558 try_opendir("nand/sym");
3559 try_opendir("nand/sym/");
3563 void try_rmdir(const char *str)
3567 ret= yaffs_rmdir(str);
3569 printf("rmdir(\"%s\") --> %d, errno %d\n", str, ret, yaffs_get_error());
3573 void rmdir_test2(void)
3577 yaffs_mount("/nand/");
3578 yaffs_mkdir("/nand/z",0666);
3579 try_rmdir("/nand/z");
3580 yaffs_mkdir("/nand/z",0666);
3581 try_rmdir("/nand/z/");
3585 void dump_yaffs_malloc_usage(void)
3588 unsigned high_water;
3590 yaffsfs_get_malloc_values(¤t, &high_water);
3593 "***************************************\n"
3594 "Dump of yaffs malloc usage during run\n"
3595 "Currently allocated : %u bytes\n"
3596 "High water allocated : %u bytes\n"
3597 "Note, this is not accurate on all platforms\n",
3598 current, high_water);
3604 int simulate_power_failure;
3606 int main(int argc, char *argv[])
3609 //unlink("emfile-nand");
3612 atexit(dump_yaffs_malloc_usage);
3617 random_seed = time(NULL);
3618 //return long_test(argc,argv);
3620 //return cache_read_test();
3622 // resize_stress_test_no_grow("/flash/flash",20);
3623 //root_perm_remount("/flash/flash");
3625 //huge_directory_test_on_path("/ram2k");
3627 //yaffs_backward_scan_test("/flash/flash");
3628 // yaffs_device_flush_test("/flash/flash");
3630 //rename_over_test("//////////////////flash///////////////////yaffs1///////////");
3632 //fill_empty_files_test("/nand/");
3633 //resize_stress_test("/nand");
3634 //overwrite_test("/nand");
3636 //long_name_test("/nand");
3637 //link_test0("/nand");
3638 //link_test1("yaffs2");
3639 //scan_pattern_test("/flash",10000,10);
3640 //short_scan_test("/yflash2",40000,200);
3641 //short_scan_test("/nand128MB",40000,200);
3642 //small_mount_test("/flash/flash",1000);
3643 //small_overwrite_test("/flash/flash",1000);
3644 //seek_overwrite_test("/flash/flash",1000);
3645 //checkpoint_fill_test("/flash/flash",20);
3646 //checkpoint_upgrade_test("/flash/flash",20);
3647 //small_overwrite_test("/flash/flash",1000);
3648 //checkpoint_fill_test("/flash/flash",20);
3649 //random_small_file_test("/flash/flash",10000);
3650 // huge_array_test("/flash/flash",10);
3653 // handle_test("yaffs2/");
3655 //long_test_on_path("/ram2k");
3656 // long_test_on_path("/flash");
3657 //simple_rw_test("/flash/flash");
3658 //fill_n_file_test("/nand128MB", 50, 128000000/50);
3659 // rename_over_test("/flash");
3660 //lookup_test("/flash");
3661 //freespace_test("/flash/flash");
3663 //link_test("/flash/flash");
3665 // cache_bypass_bug_test();
3667 //free_space_check();
3669 //check_resize_gc_bug("/flash");
3671 //basic_xattr_test("/nand");
3672 //big_xattr_test("/nand");
3674 //null_name_test("yaffs2");
3676 //test_flash_traffic("yaffs2");
3677 // link_follow_test("/nand");
3678 //basic_utime_test("/nand");
3681 //format_test("/nand");
3683 //max_files_test("/nand");
3685 //start_twice("/nand");
3687 //large_file_test("/nand");
3688 //readdir_test("/nand");
3690 basic_utime_test("/nand");
3692 size_utime_test("/nand");
3693 //case_insensitive_test("/nand");
3696 //dir_rename_test("/nand");
3698 //dir_fd_test("/nand");
3700 //format_test("/nand");
3705 //create_delete_many_files_test("/nand");