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.
23 #include "yaffs_guts.h" /* Only for dumping device innards */
25 extern int yaffs_trace_mask;
27 void dumpDir(const char *dname);
29 void copy_in_a_file(const char *yaffsName,const char *inName)
32 unsigned char buffer[100];
34 inh = open(inName,O_RDONLY);
35 outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
37 while((ni = read(inh,buffer,100)) > 0)
39 no = yaffs_write(outh,buffer,ni);
42 printf("problem writing yaffs file\n");
51 void make_a_file(const char *yaffsName,char bval,int sizeOfFile)
55 unsigned char buffer[100];
57 outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
59 memset(buffer,bval,100);
66 yaffs_write(outh,buffer,i);
68 } while (sizeOfFile > 0);
75 void make_pattern_file(char *fn,int size)
80 outh = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
81 yaffs_lseek(outh,size-1,SEEK_SET);
82 yaffs_write(outh,"A",1);
84 for(i = 0; i < size; i+=256)
87 yaffs_lseek(outh,i,SEEK_SET);
88 yaffs_write(outh,&marker,sizeof(marker));
94 int check_pattern_file(char *fn)
102 h = yaffs_open(fn, O_RDWR,0);
103 size = yaffs_lseek(h,0,SEEK_END);
105 for(i = 0; i < size; i+=256)
107 yaffs_lseek(h,i,SEEK_SET);
108 yaffs_read(h,&marker,sizeof(marker));
112 printf("pattern check failed on file %s, size %d at position %d. Got %x instead of %x\n",
113 fn,size,i,marker,~i);
121 int dump_file_data(char *fn)
128 h = yaffs_open(fn, O_RDWR,0);
132 while(yaffs_read(h,&b,1)> 0)
149 void dump_file(const char *fn)
155 h = yaffs_open(fn,O_RDONLY,0);
158 printf("*****\nDump file %s does not exist\n",fn);
162 size = yaffs_lseek(h,0,SEEK_SET);
163 printf("*****\nDump file %s size %d\n",fn,size);
164 for(i = 0; i < size; i++)
171 void create_file_of_size(const char *fn,int syze)
179 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
183 sprintf(xx,"%s %8d",fn,iteration);
185 result = yaffs_write(h,xx,n);
187 printf("Wrote %d, should have been %d. syze is %d\n",result,n,syze);
196 void verify_file_of_size(const char *fn,int syze)
205 int iterations = (syze + strlen(fn) -1)/ strlen(fn);
207 h = yaffs_open(fn, O_RDONLY, S_IREAD | S_IWRITE);
209 while (iterations > 0)
211 sprintf(xx,"%s %8d",fn,iterations);
214 result = yaffs_read(h,yy,l);
216 printf("result in line %d is %d", __LINE__, result);
220 printf("=====>>>>> verification of file %s failed near position %lld\n",fn,(long long)yaffs_lseek(h,0,SEEK_CUR));
227 void create_resized_file_of_size(const char *fn,int syze1,int reSyze, int syze2)
233 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
235 iterations = (syze1 + strlen(fn) -1)/ strlen(fn);
236 while (iterations > 0)
238 yaffs_write(h,fn,strlen(fn));
242 yaffs_ftruncate(h,reSyze);
244 yaffs_lseek(h,0,SEEK_SET);
245 iterations = (syze2 + strlen(fn) -1)/ strlen(fn);
246 while (iterations > 0)
248 yaffs_write(h,fn,strlen(fn));
256 void do_some_file_stuff(const char *path)
261 sprintf(fn,"%s/%s",path,"f1");
262 create_file_of_size(fn,10000);
264 sprintf(fn,"%s/%s",path,"fdel");
265 create_file_of_size(fn,10000);
268 sprintf(fn,"%s/%s",path,"f2");
270 create_resized_file_of_size(fn,10000,3000,4000);
273 void yaffs_backward_scan_test(const char *path)
281 do_some_file_stuff(path);
283 sprintf(fn,"%s/ddd",path);
287 do_some_file_stuff(fn);
294 void null_name_test(const char *path)
302 sprintf(fn,"%s",path);
304 h = yaffs_open(fn,O_CREAT| O_TRUNC| O_RDWR, 0666);
313 void yaffs_device_flush_test(const char *path)
323 do_some_file_stuff(path);
325 // Open and add some data to a few files
326 for(i = 0; i < 10; i++) {
328 sprintf(fn,"%s/ff%d",path,i);
330 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IWRITE | S_IREAD);
331 yaffs_write(h,xxzz,2000);
332 yaffs_write(h,xxzz,2000);
341 void short_scan_test(const char *path, int fsize, int niterations)
346 sprintf(fn,"%s/%s",path,"f1");
349 for(i = 0; i < niterations; i++)
351 printf("\n*****************\nIteration %d\n",i);
353 printf("\nmount: Directory look-up of %s\n",path);
355 make_a_file(fn,1,fsize);
362 void scan_pattern_test(const char *path, int fsize, int niterations)
369 sprintf(fn[0],"%s/%s",path,"f0");
370 sprintf(fn[1],"%s/%s",path,"f1");
371 sprintf(fn[2],"%s/%s",path,"f2");
375 for(i = 0; i < niterations; i++)
377 printf("\n*****************\nIteration %d\n",i);
379 printf("\nmount: Directory look-up of %s\n",path);
381 for(j = 0; j < 3; j++)
383 result = dump_file_data(fn[j]);
384 result = check_pattern_file(fn[j]);
385 make_pattern_file(fn[j],fsize);
386 result = dump_file_data(fn[j]);
387 result = check_pattern_file(fn[j]);
389 printf("result in line %d is %d", __LINE__, result);
395 void fill_disk(const char *path,int nfiles)
405 for(n = 0; n < nfiles; n++)
407 sprintf(str,"%s/%d",path,n);
409 h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
411 printf("writing file %s handle %d ",str, h);
413 while ((result = yaffs_write(h,xx,600)) == 600)
415 f = yaffs_freespace(path);
417 printf("last freespace was %d\n", f);
418 result = yaffs_close(h);
419 printf(" close %d\n", result);
423 void fill_disk_and_delete(const char *path, int nfiles, int ncycles)
429 for(i = 0; i < ncycles; i++)
431 printf("@@@@@@@@@@@@@@ cycle %d\n",i);
432 fill_disk(path,nfiles);
434 for(j = 0; j < nfiles; j++)
436 sprintf(str,"%s/%d",path,j);
437 result = yaffs_unlink(str);
438 printf("unlinking file %s, result %d\n", str, result);
444 void fill_files(const char *path,int flags, int maxIterations,int siz)
454 sprintf(str,"%s/%d",path,i);
455 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
459 for(j = 0; j < siz; j++)
461 yaffs_write(h,str,1);
470 } while(h >= 0 && i < maxIterations);
476 sprintf(str,"%s/%d",path,i);
477 printf("unlink %s\n",str);
479 } while(yaffs_unlink(str) >= 0);
483 void leave_unlinked_file(const char *path,int maxIterations,int siz)
492 sprintf(str,"%s/%d",path,i);
493 printf("create %s\n",str);
494 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
500 } while(h < 0 && i < maxIterations);
504 for(i = 0; i < siz; i++)
506 yaffs_write(h,str,1);
510 printf("Leaving file %s open\n",str);
514 void dumpDirFollow(const char *dname)
517 struct yaffs_dirent *de;
521 d = yaffs_opendir(dname);
525 printf("opendir failed\n");
529 while((de = yaffs_readdir(d)) != NULL)
531 sprintf(str,"%s/%s",dname,de->d_name);
535 printf("%s ino %d length %d mode %X ",
536 de->d_name, (int)s.st_ino, (int)s.st_size, s.st_mode);
537 switch(s.st_mode & S_IFMT)
539 case S_IFREG: printf("data file"); break;
540 case S_IFDIR: printf("directory"); break;
541 case S_IFLNK: printf("symlink -->");
542 if(yaffs_readlink(str,str,100) < 0)
545 printf("\"%s\"",str);
547 default: printf("unknown"); break;
557 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
562 void dump_directory_tree_worker(const char *dname,int recursive)
565 struct yaffs_dirent *de;
569 d = yaffs_opendir(dname);
573 printf("opendir failed\n");
577 while((de = yaffs_readdir(d)) != NULL)
579 sprintf(str,"%s/%s",dname,de->d_name);
583 printf("%s inode %d length %d mode %X ",
584 str, s.st_ino, (int)s.st_size, s.st_mode);
585 switch(s.st_mode & S_IFMT)
587 case S_IFREG: printf("data file"); break;
588 case S_IFDIR: printf("directory"); break;
589 case S_IFLNK: printf("symlink -->");
590 if(yaffs_readlink(str,str,100) < 0)
593 printf("\"%s\"",str);
595 default: printf("unknown"); break;
600 if((s.st_mode & S_IFMT) == S_IFDIR && recursive)
601 dump_directory_tree_worker(str,1);
610 static void dump_directory_tree(const char *dname)
612 dump_directory_tree_worker(dname,1);
614 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
617 void dump_directory_tree_worker_fd(const char *dname,int recursive)
620 struct yaffs_dirent *de;
624 h = yaffs_open(dname, O_RDONLY, 0);
628 printf("open of dir failed\n");
632 printf("using fd %d\n", h);
634 while((de = yaffs_readdir_fd(h)) != NULL)
636 sprintf(str,"%s/%s",dname,de->d_name);
640 printf("%s inode %d length %d mode %X ",
641 str,s.st_ino, (int)s.st_size, s.st_mode);
642 switch(s.st_mode & S_IFMT)
644 case S_IFREG: printf("data file"); break;
645 case S_IFDIR: printf("directory"); break;
646 case S_IFLNK: printf("symlink -->");
647 if(yaffs_readlink(str,str,100) < 0)
650 printf("\"%s\"",str);
652 default: printf("unknown"); break;
657 if((s.st_mode & S_IFMT) == S_IFDIR && recursive)
658 dump_directory_tree_worker_fd(str,1);
667 static void dump_directory_tree_fd(const char *dname)
669 dump_directory_tree_worker_fd(dname,1);
671 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
674 void dumpDir(const char *dname)
675 { dump_directory_tree_worker(dname,0);
677 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
681 static void PermissionsCheck(const char *path, mode_t tmode, int tflags,int expectedResult)
685 if(yaffs_chmod(path,tmode)< 0) printf("chmod failed\n");
687 fd = yaffs_open(path,tflags,0);
689 if((fd >= 0) != (expectedResult > 0))
691 printf("Permissions check %x %x %d failed\n",tmode,tflags,expectedResult);
695 printf("Permissions check %x %x %d OK\n",tmode,tflags,expectedResult);
704 int long_test(int argc, char *argv[])
715 struct yaffs_stat ystat;
722 yaffs_mount("/boot");
723 yaffs_mount("/data");
724 yaffs_mount("/flash");
727 printf("\nDirectory look-up of /boot\n");
729 printf("\nDirectory look-up of /data\n");
731 printf("\nDirectory look-up of /flash\n");
734 //leave_unlinked_file("/flash",20000,0);
735 //leave_unlinked_file("/data",20000,0);
737 leave_unlinked_file("/ram",20,0);
740 f = yaffs_open("/boot/b1", O_RDONLY,0);
742 printf("open /boot/b1 readonly, f=%d\n",f);
744 f = yaffs_open("/boot/b1", O_CREAT,S_IREAD | S_IWRITE);
746 printf("open /boot/b1 O_CREAT, f=%d\n",f);
749 r = yaffs_write(f,"hello",1);
750 printf("write %d attempted to write to a read-only file\n",r);
754 printf("close %d\n",r);
756 f = yaffs_open("/boot/b1", O_RDWR,0);
758 printf("open /boot/b1 O_RDWR,f=%d\n",f);
761 r = yaffs_write(f,"hello",2);
762 printf("write %d attempted to write to a writeable file\n",r);
763 r = yaffs_write(f,"world",3);
764 printf("write %d attempted to write to a writeable file\n",r);
766 r= yaffs_lseek(f,0,SEEK_END);
767 printf("seek end %d\n",r);
769 r = yaffs_read(f,buffer,10);
770 printf("read %d \"%s\"\n",r,buffer);
771 r= yaffs_lseek(f,0,SEEK_SET);
772 printf("seek set %d\n",r);
774 r = yaffs_read(f,buffer,10);
775 printf("read %d \"%s\"\n",r,buffer);
777 r = yaffs_read(f,buffer,10);
778 printf("read %d \"%s\"\n",r,buffer);
780 // Check values reading at end.
781 // A read past end of file should return 0 for 0 bytes read.
783 r= yaffs_lseek(f,0,SEEK_END);
784 r = yaffs_read(f,buffer,10);
785 printf("read at end returned %d\n",r);
786 r= yaffs_lseek(f,500,SEEK_END);
787 r = yaffs_read(f,buffer,10);
788 printf("read past end returned %d\n",r);
792 printf("close %d\n",r);
794 copy_in_a_file("/boot/yyfile","xxx");
796 // Create a file with a long name
798 copy_in_a_file("/boot/file with a long name","xxx");
801 printf("\nDirectory look-up of /boot\n");
805 r = yaffs_lstat("/boot/file with a long name",&ystat);
809 r = yaffs_rename("/boot/file with a long name","/boot/r1");
811 printf("\nDirectory look-up of /boot\n");
815 r = yaffs_unlink("/boot/r1");
817 printf("\nDirectory look-up of /boot\n");
822 r = yaffs_mkdir("/boot/directory1",0);
824 printf("\nDirectory look-up of /boot\n");
826 printf("\nDirectory look-up of /boot/directory1\n");
827 dumpDir("/boot/directory1");
829 // add a file to the directory
830 copy_in_a_file("/boot/directory1/file with a long name","xxx");
832 printf("\nDirectory look-up of /boot\n");
834 printf("\nDirectory look-up of /boot/directory1\n");
835 dumpDir("/boot/directory1");
837 // Attempt to delete directory (should fail)
839 r = yaffs_rmdir("/boot/directory1");
841 printf("\nDirectory look-up of /boot\n");
843 printf("\nDirectory look-up of /boot/directory1\n");
844 dumpDir("/boot/directory1");
846 // Delete file first, then rmdir should work
847 r = yaffs_unlink("/boot/directory1/file with a long name");
848 r = yaffs_rmdir("/boot/directory1");
851 printf("\nDirectory look-up of /boot\n");
853 printf("\nDirectory look-up of /boot/directory1\n");
854 dumpDir("/boot/directory1");
857 fill_disk_and_delete("/boot",20,20);
859 printf("\nDirectory look-up of /boot\n");
863 yaffs_symlink("yyfile","/boot/slink");
865 yaffs_readlink("/boot/slink",str,100);
866 printf("symlink alias is %s\n",str);
871 printf("\nDirectory look-up of /boot\n");
873 printf("\nDirectory look-up of /boot (using stat instead of lstat)\n");
874 dumpDirFollow("/boot");
875 printf("\nDirectory look-up of /boot/directory1\n");
876 dumpDir("/boot/directory1");
878 h = yaffs_open("/boot/slink",O_RDWR,0);
880 printf("file length is %d\n",(int)yaffs_lseek(h,0,SEEK_END));
884 yaffs_unlink("/boot/slink");
887 printf("\nDirectory look-up of /boot\n");
892 yaffs_lstat("/boot/yyfile",&ystat);
893 temp_mode = ystat.st_mode;
895 yaffs_chmod("/boot/yyfile",0x55555);
896 printf("\nDirectory look-up of /boot\n");
899 yaffs_chmod("/boot/yyfile",temp_mode);
900 printf("\nDirectory look-up of /boot\n");
903 // Permission checks...
904 PermissionsCheck("/boot/yyfile",0, O_WRONLY,0);
905 PermissionsCheck("/boot/yyfile",0, O_RDONLY,0);
906 PermissionsCheck("/boot/yyfile",0, O_RDWR,0);
908 PermissionsCheck("/boot/yyfile",S_IREAD, O_WRONLY,0);
909 PermissionsCheck("/boot/yyfile",S_IREAD, O_RDONLY,1);
910 PermissionsCheck("/boot/yyfile",S_IREAD, O_RDWR,0);
912 PermissionsCheck("/boot/yyfile",S_IWRITE, O_WRONLY,1);
913 PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDONLY,0);
914 PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDWR,0);
916 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_WRONLY,1);
917 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDONLY,1);
918 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDWR,1);
920 yaffs_chmod("/boot/yyfile",temp_mode);
922 //create a zero-length file and unlink it (test for scan bug)
924 h = yaffs_open("/boot/zlf",O_CREAT | O_TRUNC | O_RDWR,0);
927 yaffs_unlink("/boot/zlf");
930 yaffs_dump_dev("/boot");
932 fill_disk_and_delete("/boot",20,20);
934 yaffs_dump_dev("/boot");
936 fill_files("/boot",1,10000,0);
937 fill_files("/boot",1,10000,5000);
938 fill_files("/boot",2,10000,0);
939 fill_files("/boot",2,10000,5000);
941 leave_unlinked_file("/data",20000,0);
942 leave_unlinked_file("/data",20000,5000);
943 leave_unlinked_file("/data",20000,5000);
944 leave_unlinked_file("/data",20000,5000);
945 leave_unlinked_file("/data",20000,5000);
946 leave_unlinked_file("/data",20000,5000);
948 yaffs_dump_dev("/boot");
949 yaffs_dump_dev("/data");
957 int huge_directory_test_on_path(char *path)
961 struct yaffs_dirent *de;
977 // Create a large number of files
979 for(i = 0; i < 2000; i++)
981 sprintf(str,"%s/%d",path,i);
983 f = yaffs_open(str,O_CREAT,S_IREAD | S_IWRITE);
989 d = yaffs_opendir(path);
992 while((de = yaffs_readdir(d)) != NULL) {
993 if (total >lastTotal+100*9*1024||(i & 1023)==0){
994 printf("files = %d, total = %d\n",i, total);
998 sprintf(str,"%s/%s",path,de->d_name);
1000 switch(s.st_mode & S_IFMT){
1002 //printf("data file");
1014 int yaffs_scan_test(const char *path)
1022 void rename_over_test(const char *mountpt)
1029 sprintf(a,"%s/a",mountpt);
1030 sprintf(b,"%s/b",mountpt);
1031 sprintf(c,"%s/c",mountpt);
1035 yaffs_mount(mountpt);
1037 printf("Existing files\n");
1038 dumpDirFollow(mountpt);
1042 i = yaffs_open(c,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1043 printf("File c handle is %d\n",i);
1045 i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1047 i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1049 yaffs_rename(a,b); // rename over
1050 yaffs_rename(b,a); // rename back again (not renaimng over)
1051 yaffs_rename(a,b); // rename back again (not renaimng over)
1054 yaffs_unmount(mountpt);
1059 int resize_stress_test(const char *path)
1074 sprintf(aname,"%s%s",path,"/a");
1075 sprintf(bname,"%s%s",path,"/b");
1077 memset(abuffer,'a',1000);
1078 memset(bbuffer,'b',1000);
1080 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1081 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1083 printf(" %s %d %s %d\n",aname,a,bname,b);
1087 for(j = 0; j < 100; j++)
1089 yaffs_lseek(a,0,SEEK_END);
1092 for(i = 0; i <20000; i++)
1094 //r = yaffs_lseek(b,i,SEEK_SET);
1095 //r = yaffs_write(b,bbuffer,1000);
1100 int syz = yaffs_lseek(a,0,SEEK_END);
1103 if(syz < 0) syz = 0;
1104 yaffs_ftruncate(a,syz);
1110 r = yaffs_lseek(a,i * 500,SEEK_SET);
1112 printf("At line %d, r is %d\n", __LINE__, r);
1113 r = yaffs_write(a,abuffer,1000);
1115 printf("At line %d, r is %d\n", __LINE__, r);
1127 int overwrite_test(const char *path)
1139 sprintf(aname,"%s%s",path,"/a");
1140 sprintf(bname,"%s%s",path,"/b");
1142 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1143 for(j= 0; j < 500; j++){
1144 yaffs_write(b,bname,100);
1145 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1146 for(i = 0; i < rand() % 20000; i++)
1147 yaffs_write(a,&a,sizeof(a));
1156 int root_perm_remount(const char *path)
1158 struct yaffs_stat s;
1164 yaffs_lstat(path,&s);
1165 printf("root perms after mount %x\n",s.st_mode);
1167 yaffs_chmod(path, 0777);
1169 yaffs_lstat(path,&s);
1170 printf("root perms after setting to 0777 is %x\n",s.st_mode);
1172 yaffs_unmount(path);
1179 int resize_stress_test_no_grow_complex(const char *path,int iters)
1195 sprintf(aname,"%s%s",path,"/a");
1196 sprintf(bname,"%s%s",path,"/b");
1198 memset(abuffer,'a',1000);
1199 memset(bbuffer,'b',1000);
1201 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1202 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1204 printf(" %s %d %s %d\n",aname,a,bname,b);
1208 for(j = 0; j < iters; j++)
1210 yaffs_lseek(a,0,SEEK_END);
1213 for(i = 0; i <20000; i++)
1215 //r = yaffs_lseek(b,i,SEEK_SET);
1216 //r = yaffs_write(b,bbuffer,1000);
1221 int syz = yaffs_lseek(a,0,SEEK_END);
1227 if(syz < 0) syz = 0;
1228 yaffs_ftruncate(a,syz);
1229 syz = yaffs_lseek(a,0,SEEK_END);
1230 printf("shrink to %d\n",syz);
1238 r = yaffs_lseek(a,500,SEEK_END);
1239 r = yaffs_write(a,abuffer,1000);
1241 printf("At line %d, r is %d\n", __LINE__, r);
1248 printf("file size is %lld\n",(long long)yaffs_lseek(a,0,SEEK_END));
1256 int resize_stress_test_no_grow(const char *path,int iters)
1271 sprintf(aname,"%s%s",path,"/a");
1272 sprintf(bname,"%s%s",path,"/b");
1274 memset(abuffer,'a',1000);
1275 memset(bbuffer,'b',1000);
1277 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1278 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1280 printf(" %s %d %s %d\n",aname,a,bname,b);
1284 for(j = 0; j < iters; j++)
1286 yaffs_lseek(a,0,SEEK_END);
1289 for(i = 0; i <20000; i++)
1291 //r = yaffs_lseek(b,i,SEEK_SET);
1292 //r = yaffs_write(b,bbuffer,1000);
1297 int syz = yaffs_lseek(a,0,SEEK_END);
1303 if(syz < 0) syz = 0;
1304 yaffs_ftruncate(a,syz);
1305 syz = yaffs_lseek(a,0,SEEK_END);
1306 printf("shrink to %d\n",syz);
1314 r = yaffs_lseek(a,-500,SEEK_END);
1315 r = yaffs_write(a,abuffer,1000);
1317 printf("At line %d, r is %d\n", __LINE__, r);
1323 printf("file size is %lld\n",(long long)yaffs_lseek(a,0,SEEK_END));
1331 int directory_rename_test(void)
1336 yaffs_mount("/ram");
1337 yaffs_mkdir("/ram/a",0);
1338 yaffs_mkdir("/ram/a/b",0);
1339 yaffs_mkdir("/ram/c",0);
1341 printf("\nDirectory look-up of /ram\n");
1344 dumpDir("/ram/a/b");
1346 printf("Do rename (should fail)\n");
1348 r = yaffs_rename("/ram/a","/ram/a/b/d");
1350 printf("At line %d, r is %d\n", __LINE__, r);
1352 printf("\nDirectory look-up of /ram\n");
1355 dumpDir("/ram/a/b");
1357 printf("Do rename (should not fail)\n");
1359 r = yaffs_rename("/ram/c","/ram/a/b/d");
1360 printf("\nDirectory look-up of /ram\n");
1363 dumpDir("/ram/a/b");
1370 int cache_read_test(void)
1374 int sizeOfFiles = 500000;
1379 yaffs_mount("/boot");
1381 make_a_file("/boot/a",'a',sizeOfFiles);
1382 make_a_file("/boot/b",'b',sizeOfFiles);
1384 a = yaffs_open("/boot/a",O_RDONLY,0);
1385 b = yaffs_open("/boot/b",O_RDONLY,0);
1386 c = yaffs_open("/boot/c", O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
1390 if (i > 100) i = 100;
1392 yaffs_read(a,buffer,i);
1393 yaffs_read(b,buffer,i);
1394 yaffs_write(c,buffer,i);
1395 } while(sizeOfFiles > 0);
1403 int cache_bypass_bug_test(void)
1405 // This test reporoduces a bug whereby YAFFS caching *was* buypassed
1406 // resulting in erroneous reads after writes.
1407 // This bug has been fixed.
1413 memset(buffer1,0,sizeof(buffer1));
1414 memset(buffer2,0,sizeof(buffer2));
1418 yaffs_mount("/boot");
1420 // Create a file of 2000 bytes.
1421 make_a_file("/boot/a",'X',2000);
1423 a = yaffs_open("/boot/a",O_RDWR, S_IREAD | S_IWRITE);
1425 // Write a short sequence to the file.
1426 // This will go into the cache.
1427 yaffs_lseek(a,0,SEEK_SET);
1428 yaffs_write(a,"abcdefghijklmnopqrstuvwxyz",20);
1430 // Read a short sequence from the file.
1431 // This will come from the cache.
1432 yaffs_lseek(a,0,SEEK_SET);
1433 yaffs_read(a,buffer1,30);
1435 // Read a page size sequence from the file.
1436 yaffs_lseek(a,0,SEEK_SET);
1437 yaffs_read(a,buffer2,512);
1439 printf("buffer 1 %s\n",buffer1);
1440 printf("buffer 2 %s\n",buffer2);
1442 if(strncmp(buffer1,buffer2,20))
1444 printf("Cache bypass bug detected!!!!!\n");
1452 int free_space_check(void)
1457 yaffs_mount("/boot");
1458 fill_disk("/boot/",2);
1459 f = yaffs_freespace("/boot");
1461 printf("%d free when disk full\n",f);
1465 int truncate_test(void)
1475 yaffs_mount("/boot");
1477 yaffs_unlink("/boot/trunctest");
1479 a = yaffs_open("/boot/trunctest", O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1481 yaffs_write(a,"abcdefghijklmnopqrstuvwzyz",26);
1483 yaffs_ftruncate(a,3);
1484 l= yaffs_lseek(a,0,SEEK_END);
1486 printf("truncated length is %d\n",l);
1488 yaffs_lseek(a,5,SEEK_SET);
1489 yaffs_write(a,"1",1);
1491 yaffs_lseek(a,0,SEEK_SET);
1493 r = yaffs_read(a,y,10);
1495 printf("read %d bytes:", r);
1497 for(i = 0; i < r; i++) printf("[%02X]",y[i]);
1509 void fill_disk_test(const char *mountpt)
1514 for(i = 0; i < 5; i++)
1516 yaffs_mount(mountpt);
1517 fill_disk_and_delete(mountpt,100,i+1);
1518 yaffs_unmount(mountpt);
1524 void fill_n_file_test(const char *mountpt, int n, int syz)
1531 yaffs_format(mountpt, 0, 0, 0);
1532 yaffs_mount(mountpt);
1535 for(i = 0; i < n; i++)
1540 sprintf(fname, "%s/%d", mountpt, i);
1542 h = yaffs_open(fname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1547 yaffs_write(h, fname, sizeof(fname));
1558 void fill_files_test(const char *mountpt)
1563 for(i = 0; i < 5; i++)
1565 yaffs_mount(mountpt);
1566 fill_files(mountpt,2,3,100);
1567 yaffs_unmount(mountpt);
1572 void fill_empty_files_test(const char *mountpt)
1581 for(i = 0; i < 5; i++)
1583 yaffs_mount(mountpt);
1584 for(d = 0; result >= 0 && d < 1000; d++){
1585 sprintf(name,"%s/%d",mountpt,d);
1586 result= yaffs_mkdir(name,0);
1587 printf("creating directory %s result %d\n",name,result);
1589 for(f = 0; result >= 0 && f < 100; f++){
1590 sprintf(name,"%s/%d/%d",mountpt,d,f);
1591 result= yaffs_open(name,O_CREAT, 0);
1592 yaffs_close(result);
1593 printf("creating file %s result %d\n",name,result);
1596 yaffs_unmount(mountpt);
1601 void long_name_test(const char *mountpt)
1605 char fullName[1000];
1611 // Make a 256 byte name
1612 memset(name,0,sizeof(name));
1613 for(i = 0; i < 256; i++)
1614 name[i] = '0' + i % 10;
1616 sprintf(fullName,"%s/%s",mountpt,name);
1618 for(i = 0; i < 1; i++)
1620 yaffs_mount(mountpt);
1622 printf("Files at start\n");
1625 printf("Creating file %s\n",fullName);
1627 f = yaffs_open(fullName,O_CREAT | O_RDWR,0);
1630 printf("Result %d\n",f);
1635 printf("Deleting %s\n",fullName);
1636 result = yaffs_unlink(fullName);
1637 printf("Result %d\n",result);
1643 yaffs_unmount(mountpt);
1649 void lookup_test(const char *mountpt)
1657 struct yaffs_dirent *de;
1661 yaffs_mount(mountpt);
1663 d = yaffs_opendir(mountpt);
1667 printf("opendir failed\n");
1672 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1674 printf("unlinking %s\n",de->d_name);
1675 yaffs_unlink(de->d_name);
1678 printf("%d files deleted\n",i);
1682 for(i = 0; i < 2000; i++){
1683 sprintf(a,"%s/%d",mountpt,i);
1684 h = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0);
1689 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1691 printf("%d %s\n",i,de->d_name);
1694 printf("%d files listed\n\n\n",i);
1701 for(i = 0; i < 2000; i++){
1702 sprintf(a,"%s/%d",mountpt,i);
1707 yaffs_unmount(mountpt);
1711 void link_test0(const char *mountpt)
1719 yaffs_mount(mountpt);
1722 sprintf(namea,"%s/a",mountpt);
1723 sprintf(nameb,"%s/b",mountpt);
1725 printf("mounted\n");
1728 yaffs_unlink(namea);
1729 printf("a unlinked\n");
1732 yaffs_unlink(nameb);
1733 printf("b unlinked\n");
1736 result = yaffs_open(namea,O_CREAT| O_RDWR,0666);
1737 yaffs_close(result);
1738 printf("a created\n");
1741 yaffs_link(namea,nameb);
1744 yaffs_unlink(namea);
1745 printf("a ulinked\n");
1747 yaffs_unlink(nameb);
1748 printf("b unlinked\n");
1751 yaffs_unmount(mountpt);
1755 void link_test1(const char *mountpt)
1763 sprintf(a,"%s/aaa",mountpt);
1764 sprintf(b,"%s/bbb",mountpt);
1765 sprintf(c,"%s/ccc",mountpt);
1769 yaffs_mount(mountpt);
1772 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1773 for(i = 0; i < 100; i++)
1774 yaffs_write(h,a,100);
1787 yaffs_unmount(mountpt);
1788 yaffs_mount(mountpt);
1790 printf("link test done\n");
1793 void handle_test(const char *mountpt)
1800 sprintf(a,"%s/aaa",mountpt);
1804 yaffs_mount(mountpt);
1806 for(cycle = 0; cycle < 5; cycle++){
1807 printf("Start cycle %d\n",cycle);
1810 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1811 printf("%d handle %d\n",i,h);
1821 yaffs_unmount(mountpt);
1824 void freespace_test(const char *mountpt)
1834 sprintf(a,"%s/aaa",mountpt);
1838 yaffs_mount(mountpt);
1840 f0 = yaffs_freespace(mountpt);
1842 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1844 for(i = 0; i < 100; i++)
1845 yaffs_write(h,a,100);
1849 f1 = yaffs_freespace(mountpt);
1853 f2 = yaffs_freespace(mountpt);
1856 yaffs_unmount(mountpt);
1857 yaffs_mount(mountpt);
1859 f3 = yaffs_freespace(mountpt);
1861 printf("%d\n%d\n%d\n%d\n",f0, f1,f2,f3);
1866 void simple_rw_test(const char *mountpt)
1875 sprintf(a,"%s/aaa",mountpt);
1879 yaffs_mount(mountpt);
1883 h = yaffs_open(a,O_CREAT| O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1885 for(i = 100000;i < 200000; i++){
1886 result = yaffs_write(h,&i,sizeof(i));
1890 printf("write error\n");
1897 // h = yaffs_open(a,O_RDWR, S_IREAD | S_IWRITE);
1900 yaffs_lseek(h,0,SEEK_SET);
1902 for(i = 100000; i < 200000; i++){
1903 result = yaffs_read(h,&x,sizeof(x));
1905 if(result != 4 || x != i){
1906 printf("read error %d %x %x\n",i,result,x);
1910 printf("Simple rw test passed\n");
1917 void scan_deleted_files_test(const char *mountpt)
1929 sprintf(sub,"%s/sdir",mountpt);
1932 for(j = 0; j < 10; j++)
1934 printf("\n\n>>>>>>> Run %d <<<<<<<<<<<<<\n\n",j);
1935 yaffs_mount(mountpt);
1939 p = (j & 0) ? mountpt: sub;
1941 for(i = 0; i < 100; i++)
1943 sprintf(fn,"%s/%d",p,i);
1947 h = yaffs_open(fn,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1948 for(k = 0; k < 1000; k++)
1949 yaffs_write(h,fn,100);
1956 for(i = 0; i < 10; i++)
1958 sprintf(fn,"%s/%d",p,i);
1966 yaffs_unmount(mountpt);
1975 void write_10k(int h)
1978 const char *s="0123456789";
1979 for(i = 0; i < 1000; i++)
1980 yaffs_write(h,s,10);
1983 void write_200k_file(const char *fn, const char *fdel, const char *fdel1)
1989 h1 = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1991 for(i = 0; i < 100000; i+= 10000)
1996 offs = yaffs_lseek(h1,0,SEEK_CUR);
1999 printf("Could not write file\n");
2003 for(i = 0; i < 100000; i+= 10000)
2008 offs = yaffs_lseek(h1,0,SEEK_CUR);
2011 printf("Could not write file\n");
2015 yaffs_unlink(fdel1);
2020 void verify_200k_file(const char *fn)
2025 const char *s="0123456789";
2028 h1 = yaffs_open(fn, O_RDONLY, 0);
2030 for(i = 0; i < 200000 && errCount < 10; i+= 10)
2032 yaffs_read(h1,x,10);
2033 if(strncmp(x,s,10) != 0)
2035 printf("File %s verification failed at %d\n",fn,i);
2040 printf("Too many errors... aborted\n");
2047 void check_resize_gc_bug(const char *mountpt)
2056 sprintf(a,"%s/a",mountpt);
2057 sprintf(b,"%s/b",mountpt);
2058 sprintf(c,"%s/c",mountpt);
2064 yaffs_mount(mountpt);
2068 for(i = 0; i < 50; i++)
2070 printf("A\n");write_200k_file(a,"",c);
2071 printf("B\n");verify_200k_file(a);
2072 printf("C\n");write_200k_file(b,a,c);
2073 printf("D\n");verify_200k_file(b);
2074 yaffs_unmount(mountpt);
2075 yaffs_mount(mountpt);
2076 printf("E\n");verify_200k_file(a);
2077 printf("F\n");verify_200k_file(b);
2083 void multi_mount_test(const char *mountpt,int nmounts)
2091 sprintf(a,"%s/a",mountpt);
2095 for(i = 0; i < nmounts; i++){
2100 printf("############### Iteration %d Start\n",i);
2101 if(1 || i == 0 || i == 5)
2102 yaffs_mount(mountpt);
2104 dump_directory_tree(mountpt);
2109 sprintf(xx,"%s/0",a);
2110 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2112 sprintf(xx,"%s/1",a);
2113 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2116 for(j = 0; j < 200; j++){
2117 yaffs_write(h0,xx,1000);
2118 yaffs_write(h1,xx,1000);
2121 while(yaffs_write(h0,xx,1000) > 0){
2123 yaffs_write(h1,xx,1000);
2126 yaffs_lseek(h0,0,SEEK_END);
2127 yaffs_lseek(h1,0,SEEK_END);
2129 yaffs_lseek(h0,0,SEEK_SET);
2130 yaffs_lseek(h1,0,SEEK_SET);
2132 for(j = 0; j < 200; j++){
2133 yaffs_read(h0,xx,1000);
2134 yaffs_read(h1,xx,1000);
2138 // yaffs_truncate(h0,0);
2142 printf("########### %d\n",i);
2143 dump_directory_tree(mountpt);
2145 if(1 || i == 4 || i == nmounts -1)
2146 yaffs_unmount(mountpt);
2151 void small_mount_test(const char *mountpt,int nmounts)
2163 sprintf(a,"%s/a",mountpt);
2169 for(i = 0; i < nmounts; i++){
2173 printf("############### Iteration %d Start\n",i);
2174 if(1 || i == 0 || i == 5)
2175 yaffs_mount(mountpt);
2177 dump_directory_tree(mountpt);
2181 sprintf(xx,"%s/0",a);
2184 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2185 for(j = 0; j < 130; j++)
2186 yaffs_write(h0,xx,1000);
2190 h0 = yaffs_open(xx,O_RDONLY,0);
2192 sprintf(xx,"%s/1",a);
2193 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2195 while((nread = yaffs_read(h0,xx,1000)) > 0)
2196 yaffs_write(h1,xx,nread);
2199 yaffs_lseek(h0,0,SEEK_END);
2200 yaffs_lseek(h1,0,SEEK_END);
2202 yaffs_lseek(h0,0,SEEK_SET);
2203 yaffs_lseek(h1,0,SEEK_SET);
2205 for(j = 0; j < 200; j++){
2206 yaffs_read(h0,xx,1000);
2207 yaffs_read(h1,xx,1000);
2213 printf("########### %d\n",i);
2214 dump_directory_tree(mountpt);
2216 if(1 || i == 4 || i == nmounts -1)
2217 yaffs_unmount(mountpt);
2224 void small_overwrite_test(const char *mountpt,int nmounts)
2235 sprintf(a,"%s/a",mountpt);
2241 for(i = 0; i < nmounts; i++){
2243 static char xx[8000];
2245 printf("############### Iteration %d Start\n",i);
2247 yaffs_mount(mountpt);
2249 dump_directory_tree(mountpt);
2253 sprintf(xx,"%s/0",a);
2254 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2255 sprintf(xx,"%s/1",a);
2256 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2258 for(j = 0; j < 1000000; j+=1000){
2259 yaffs_ftruncate(h0,j);
2260 yaffs_lseek(h0,j,SEEK_SET);
2261 yaffs_write(h0,xx,7000);
2262 yaffs_write(h1,xx,7000);
2270 printf("########### %d\n",i);
2271 dump_directory_tree(mountpt);
2274 yaffs_unmount(mountpt);
2279 void seek_overwrite_test(const char *mountpt,int nmounts)
2281 static char xx[5000];
2290 sprintf(a,"%s/f",mountpt);
2294 yaffs_mount(mountpt);
2297 for(i = 0; i < nmounts; i++){
2299 h0 = yaffs_open(a, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2301 for(j = 0; j < 100000; j++){
2302 yaffs_lseek(h0,0,SEEK_SET);
2303 yaffs_write(h0,xx,5000);
2304 yaffs_lseek(h0,0x100000,SEEK_SET);
2305 yaffs_write(h0,xx,5000);
2317 void yaffs_touch(const char *fn)
2319 yaffs_chmod(fn, S_IREAD | S_IWRITE);
2322 void checkpoint_fill_test(const char *mountpt,int nmounts)
2333 sprintf(a,"%s/a",mountpt);
2340 for(i = 0; i < nmounts; i++){
2341 printf("############### Iteration %d Start\n",i);
2342 yaffs_mount(mountpt);
2343 dump_directory_tree(mountpt);
2346 sprintf(b,"%s/zz",a);
2348 h = yaffs_open(b,O_CREAT | O_RDWR,S_IREAD |S_IWRITE);
2351 while(yaffs_write(h,c,50) == 50){}
2355 for(j = 0; j < 2; j++){
2356 printf("touch %d\n",j);
2358 yaffs_unmount(mountpt);
2359 yaffs_mount(mountpt);
2362 dump_directory_tree(mountpt);
2363 yaffs_unmount(mountpt);
2368 int make_file2(const char *name1, const char *name2,int syz)
2378 h1 = yaffs_open(name1,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2380 h2 = yaffs_open(name2,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2382 while(syz > 0 && n > 0){
2383 i = (syz > 2500) ? 2500 : syz;
2384 n = yaffs_write(h1,xx,i);
2385 n = yaffs_write(h2,xx,i);
2394 extern void SetCheckpointReservedBlocks(int n);
2396 void checkpoint_upgrade_test(const char *mountpt, int nmounts)
2408 sprintf(a,"%s/a",mountpt);
2410 printf("Create start condition\n");
2412 yaffs_mount(mountpt);
2414 sprintf(b,"%s/zz",a);
2415 sprintf(c,"%s/xx",a);
2416 make_file2(b,c,2000000);
2417 sprintf(d,"%s/aa",a);
2418 make_file2(d,NULL,500000000);
2419 dump_directory_tree(mountpt);
2421 printf("Umount/mount attempt full\n");
2422 yaffs_unmount(mountpt);
2424 yaffs_mount(mountpt);
2426 printf("unlink small file\n");
2428 dump_directory_tree(mountpt);
2430 printf("Umount/mount attempt\n");
2431 yaffs_unmount(mountpt);
2432 yaffs_mount(mountpt);
2434 for(j = 0; j < 500; j++){
2435 printf("***** touch %d\n",j);
2436 dump_directory_tree(mountpt);
2438 yaffs_unmount(mountpt);
2439 yaffs_mount(mountpt);
2442 for(j = 0; j < 500; j++){
2443 printf("***** touch %d\n",j);
2444 dump_directory_tree(mountpt);
2446 yaffs_unmount(mountpt);
2447 yaffs_mount(mountpt);
2451 void huge_array_test(const char *mountpt,int n)
2462 sprintf(a,"mount point %s",mountpt);
2468 yaffs_mount(mountpt);
2473 printf("\n\n START run\n\n");
2474 while((space = yaffs_freespace(mountpt)) > 25000000){
2475 sprintf(a,"%s/file%d",mountpt,fnum);
2477 printf("create file %s, free space %d\n",a,space);
2478 create_file_of_size(a,10000000);
2479 printf("verifying file %s\n",a);
2480 verify_file_of_size(a,10000000);
2483 printf("\n\n verification/deletion\n\n");
2485 for(i = 0; i < fnum; i++){
2486 sprintf(a,"%s/file%d",mountpt,i);
2487 printf("verifying file %s\n",a);
2488 verify_file_of_size(a,10000000);
2489 printf("deleting file %s\n",a);
2492 printf("\n\n done \n\n");
2499 void random_write(int h)
2501 static char buffer[12000];
2504 n = random() & 0x1FFF;
2505 yaffs_write(h,buffer,n);
2508 void random_seek(int h)
2511 n = random() & 0xFFFFF;
2512 yaffs_lseek(h,n,SEEK_SET);
2515 void random_truncate(int h, char *name)
2522 n = random() & 0xFFFFF;
2523 flen = yaffs_lseek(h,0,SEEK_END);
2526 yaffs_ftruncate(h,n);
2527 yaffs_lseek(h,n,SEEK_SET);
2531 #define NSMALLFILES 10
2532 void random_small_file_test(const char *mountpt,int iterations)
2535 char a[NSMALLFILES][50];
2546 yaffs_mount(mountpt);
2548 for(i = 0; i < NSMALLFILES; i++){
2553 for(n = 0; n < iterations; n++){
2555 for(i = 0; i < NSMALLFILES; i++) {
2558 if(strlen(a[i]) == 0){
2559 sprintf(a[i],"%s/%dx%d",mountpt,n,i);
2560 h[i] = yaffs_open(a[i],O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2564 printf("Could not open yaffs file %d %d error %d\n",n,i,h[i]);
2574 random_truncate(h[i],a[i]);
2577 case 5: random_seek(h[i]);
2594 for(i = 0; i < NSMALLFILES; i++)
2597 yaffs_unmount(mountpt);
2600 void rmdir_test(const char *mountpt)
2605 yaffs_mount(mountpt);
2607 strcpy(name,mountpt);
2609 strcat(name,"hello");
2610 yaffs_mkdir(name,0666);
2612 yaffs_unmount(mountpt);
2617 static void print_xattrib_val(const char *path, const char *name)
2622 n = yaffs_getxattr(path,name,buffer,sizeof(buffer));
2624 u8 *b = (u8 *)buffer;
2626 printf("%d bytes:",n);
2630 printf("[%02X]",*b);
2636 printf(" Novalue result %d\n",n);
2639 static void list_xattr(const char *path)
2646 list_len = yaffs_listxattr(path,list,sizeof(list));
2647 printf("xattribs for %s, result is %d\n",path,list_len);
2648 while(n < list_len){
2649 len = strlen(list + n);
2650 printf("\"%s\" value ",list+n);
2651 print_xattrib_val(path,list + n);
2657 void basic_utime_test(const char *mountpt)
2662 struct yaffs_utimbuf utb;
2663 struct yaffs_stat st;
2668 yaffs_mount(mountpt);
2670 strcpy(name,mountpt);
2672 strcat(name,"xfile");
2676 printf("created\n");
2677 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2680 printf(" times before %llu %llu %llu\n",
2681 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2683 //here are the last access and modification times.
2687 //futime sets the last modification and access time of the file
2688 result = yaffs_futime(h,&utb);
2689 printf("setting times using the futime function to a 1000 m 2000 result %d\n",result);
2691 //read the times from the file header
2693 printf(" times %llu %llu %llu\n",
2694 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2699 result = yaffs_utime(name, &utb);
2700 printf("utime to a 5000 m 8000 result %d\n",result);
2702 printf(" times %llu %llu %llu\n",
2703 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2705 result = yaffs_utime(name, NULL);
2706 printf("utime to NULL result %d\n",result);
2708 printf(" times %llu %llu %llu\n",
2709 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2714 void size_utime_test(const char *mountpt)
2719 struct yaffs_utimbuf utb;
2720 struct yaffs_stat st;
2725 yaffs_mount(mountpt);
2727 strcpy(name,mountpt);
2729 strcat(name,"xfile");
2733 printf("created\n");
2734 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2737 printf(" times before %llu %llu %llu\n",
2738 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2740 //first lets get the yaffs_object.
2742 //then check that yaffs_stat also works.
2743 //yaffs_stat already uses 64 bits for both wince and unix times.
2744 //To see if we are using 32 or 64 bit time, save a large number into the time and
2745 //see if it overflows.
2746 long bitsInTime = 8*sizeof(st.yst_ctime);
2747 printf("the times are %ld bits long\n", bitsInTime);
2750 if (bitsInTime == 64) {
2751 //no need to test the overflow. Just check that it can be retrieved intact.
2753 //use u64 variables in case utb truncates the values to 32 bit time by accident.
2754 u64 start = 0xfffff;
2760 result = yaffs_futime(h,&utb);
2762 if (st.yst_atime == start && st.yst_mtime == end) {
2763 printf("successfully stored and retrevied a 64 bit number for atime and modtime\n");
2765 printf("failed to store and retrieve a 64 bit number for atime and modtime\n");
2769 //it is a 32 bit number. Check to see that it overflowed.
2774 //here are the last access and modification times.
2778 //futime sets the last modification and access time of the file
2779 result = yaffs_futime(h,&utb);
2780 printf("setting times using the futime function to a 1000 m 2000 result %d\n",result);
2782 //read the times from the file header
2784 printf(" times %llu %llu %llu\n",
2785 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2790 result = yaffs_utime(name, &utb);
2791 printf("utime to a 5000 m 8000 result %d\n",result);
2793 printf(" times %llu %llu %llu\n",
2794 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2796 result = yaffs_utime(name, NULL);
2797 printf("utime to NULL result %d\n",result);
2799 printf(" times %llu %llu %llu\n",
2800 ( u64) st.yst_atime, ( u64) st.yst_ctime, ( u64) st.yst_mtime);
2806 void basic_xattr_test(const char *mountpt)
2815 yaffs_mount(mountpt);
2817 strcpy(name,mountpt);
2819 strcat(name,"xfile");
2822 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2828 printf("Add an attribute\n");
2830 result = yaffs_setxattr(name,"foo",&val1,sizeof(val1),0);
2831 printf("wrote attribute foo: result %d\n",result);
2833 printf("Add an attribute\n");
2835 result = yaffs_setxattr(name,"bar",&val1,sizeof(val1),0);
2836 printf("wrote attribute bar: result %d\n",result);
2839 printf("Get non-existanrt attribute\n");
2840 print_xattrib_val(name,"not here");
2842 printf("Delete non existing attribute\n");
2843 yaffs_removexattr(name,"not here");
2846 printf("Remove foo\n");
2847 yaffs_removexattr(name,"foo");
2850 printf("Remove bar\n");
2851 yaffs_removexattr(name,"bar");
2856 void big_xattr_test(const char *mountpt)
2865 yaffs_mount(mountpt);
2867 strcpy(name,mountpt);
2869 strcat(name,"xfile");
2872 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2878 printf("Add a large attribute\n");
2879 memset(val,0x1,sizeof(val));
2880 result = yaffs_setxattr(name,"aaa",val,200,0);
2881 printf("wrote attribute aaa: result %d\n",result);
2884 printf("Add a large attribute\n");
2885 memset(val,0x2,sizeof(val));
2886 result = yaffs_setxattr(name,"bbb",val,1000,0);
2887 printf("wrote attribute bbb: result %d\n",result);
2890 printf("Replace attribute\n");
2891 memset(val,0x3,sizeof(val));
2892 result = yaffs_setxattr(name,"aaa",val,1000,0);
2893 printf("wrote attribute aaa: result %d\n",result);
2899 void dump_dev_stats(struct yaffs_dev *dev, const char * str)
2902 printf( "space free %d erased %d "
2903 "nand reads %d writes %d erases %d "
2904 "gc all %d passive %d oldestdirty %d blocks %d copies %d \n",
2905 dev->n_free_chunks, dev->n_erased_blocks * dev->param.chunks_per_block,
2906 dev->n_page_reads, dev->n_page_writes, dev->n_erasures,
2907 dev->all_gcs, dev->passive_gc_count, dev->oldest_dirty_gc_count, dev->n_gc_blocks, dev->n_gc_copies);
2910 void test_flash_traffic(const char *mountpt)
2915 struct yaffs_dev *dev;
2917 yaffs_trace_mask = 0;
2921 yaffs_mount(mountpt);
2923 dev = yaffs_getdev(mountpt);
2925 strcpy(name0,mountpt);
2928 strcpy(name1,mountpt);
2931 dump_dev_stats(dev,"start");
2932 create_file_of_size(name0,32 * 1024 * 1024);
2933 dump_dev_stats(dev,"32MB written");
2934 for(i = 0; i < 20; i++)
2935 create_file_of_size(name1,1024 * 1024);
2936 dump_dev_stats(dev,"20x 1MB files written");
2940 void link_follow_test(const char *mountpt)
2948 yaffs_trace_mask = 0;
2952 yaffs_mount(mountpt);
2954 sprintf(fn,"%s/file",mountpt);
2955 sprintf(sn,"%s/sym",mountpt);
2956 sprintf(hn,"%s/hl-sym",mountpt);
2958 h = yaffs_open(fn,O_CREAT| O_RDWR, S_IREAD | S_IWRITE);
2959 result = yaffs_close(h);
2961 result = yaffs_symlink(fn,sn);
2962 result = yaffs_link(sn,hn);
2965 printf("At line %d result is %d\n", __LINE__, result);
2967 h =yaffs_open(hn,O_RDWR,0);
2971 void max_files_test(const char *mountpt)
2979 yaffs_trace_mask = 0;
2983 yaffs_mount(mountpt);
2985 for(i = 0; i < 5000; i++) {
2986 sprintf(fn,"%s/file%d", mountpt, i);
2988 h = yaffs_open(fn,O_CREAT| O_RDWR, S_IREAD | S_IWRITE);
2990 printf("File %s not created\n", fn);
2991 yaffs_write(h,fn,100);
2992 result = yaffs_close(h);
2994 for(i = 0; i < 5; i++){
2995 sprintf(fn,"%s/file%d",mountpt, i);
2999 for(i = 1000; i < 1010; i++){
3000 sprintf(fn,"%s/file%d",mountpt, i);
3001 h = yaffs_open(fn,O_CREAT| O_RDWR, S_IREAD | S_IWRITE);
3002 yaffs_write(h,fn,100);
3004 printf("File %s not created\n", fn);
3005 result = yaffs_close(h);
3009 printf("At line %d result is %d\n", __LINE__, result);
3011 yaffs_unmount(mountpt);
3014 void case_insensitive_test(const char *mountpt)
3020 struct yaffs_stat s;
3024 yaffs_trace_mask = 0;
3028 yaffs_mount(mountpt);
3029 dump_directory_tree(mountpt);
3031 sprintf(fn,"%s/Abc.Txt",mountpt);
3033 h = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
3035 ret = yaffs_write(h,fn, strlen(fn) + 1);
3037 ret = yaffs_close(h);
3039 dump_directory_tree(mountpt);
3049 h = yaffs_open(fn2, O_RDONLY, 0);
3050 ret = yaffs_read(h, buffer, 100);
3052 if (ret != (int)(strlen(fn) + 1) || memcmp(buffer, fn, ret)){
3053 printf("wrong file read\n");
3055 printf("File %s is the same as file %s\n", fn, fn2);
3058 ret = yaffs_stat(fn2, &s);
3060 printf("renaming\n");
3062 ret = yaffs_rename(fn, fn2);
3063 dump_directory_tree(mountpt);
3067 void start_twice(const char *mountpt)
3069 printf("About to do first yaffs_start\n");
3071 printf("started\n");
3072 printf("First mount returns %d\n", yaffs_mount(mountpt));
3073 printf("About to do second yaffs_start\n");
3075 printf("started\n");
3076 printf("Second mount returns %d\n", yaffs_mount(mountpt));
3079 #define N_WRITES 2000
3082 #define BUFFER_N 1100
3083 unsigned xxbuffer[BUFFER_N];
3085 void set_buffer(int n)
3088 for(i = 0; i < BUFFER_N; i++)
3089 xxbuffer[i] = i + n;
3092 void write_big_sparse_file(int h)
3097 int n = sizeof(xxbuffer);
3100 for(i = 0; i < N_WRITES; i++) {
3101 printf("writing at %d\n", (int)offset);
3103 pos = yaffs_lseek(h, offset, SEEK_SET);
3105 printf("mismatched seek pos %d offset %d\n",
3106 (int)pos, (int)offset);
3110 wrote = yaffs_write(h, xxbuffer, n);
3113 printf("mismatched write wrote %d n %d\n", wrote, n);
3117 offset += (STRIDE * sizeof(xxbuffer));
3120 yaffs_ftruncate(h, offset);
3124 void verify_big_sparse_file(int h)
3126 unsigned check_buffer[BUFFER_N];
3130 int n = sizeof(check_buffer);
3132 int checks_failed = 0;
3133 int checks_passed = 0;
3135 for(i = 0; i < N_WRITES * STRIDE; i++) {
3137 memset(xxbuffer,0, n);
3139 set_buffer(i/STRIDE);
3141 pos = yaffs_lseek(h, offset, SEEK_SET);
3143 printf("mismatched seek pos %d offset %d\n",
3144 (int)pos, (int)offset);
3148 result = yaffs_read(h, check_buffer, n);
3151 printf("mismatched read result %d n %d\n", result, n);
3155 if(memcmp(xxbuffer, check_buffer, n)) {
3158 printf("buffer at %d mismatches\n", (int)pos);
3159 printf("xxbuffer ");
3160 for(j = 0; j < 20; j++)
3161 printf(" %d",xxbuffer[j]);
3163 printf("check_buffer ");
3164 for(j = 0; j < 20; j++)
3165 printf(" %d",check_buffer[j]);
3173 offset += sizeof(xxbuffer);
3176 printf("%d checks passed, %d checks failed\n", checks_passed, checks_failed);
3181 void large_file_test(const char *mountpt)
3183 char xx_buffer[1000];
3189 yaffs_trace_mask = 0;
3193 yaffs_mount(mountpt);
3194 printf("mounted\n");
3197 sprintf(fullname, "%s/%s", mountpt, "big-test-file");
3199 handle = yaffs_open(fullname, O_RDONLY, 0);
3201 handle = yaffs_open(fullname, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
3204 perror("opening file");
3208 write_big_sparse_file(handle);
3209 verify_big_sparse_file(handle);
3211 yaffs_close(handle);
3213 printf("Job done\n");
3214 yaffs_unmount(mountpt);
3216 yaffs_mount(mountpt);
3217 printf("mounted again\n");
3219 handle = yaffs_open(fullname, O_RDONLY, 0);
3220 verify_big_sparse_file(handle);
3221 yaffs_unmount(mountpt);
3224 yaffs_mount3(mountpt, 0, 1);
3225 printf("mounted with no checkpt\n");
3227 handle = yaffs_open(fullname, O_RDONLY, 0);
3228 verify_big_sparse_file(handle);
3229 yaffs_unmount(mountpt);
3231 /* Check resize by adding to the end, resizing back and verifying. */
3232 yaffs_mount3(mountpt, 0, 1);
3233 printf("checking resize\n");
3235 handle = yaffs_open(fullname, O_RDWR, 0);
3237 file_end = yaffs_lseek(handle, 0, SEEK_END);
3238 printf("file_end %d\n", (int)file_end);
3239 for(i = 0; i < 10000; i++)
3240 yaffs_write(handle, xx_buffer, sizeof(xx_buffer));
3241 yaffs_ftruncate(handle, file_end);
3243 verify_big_sparse_file(handle);
3244 yaffs_unmount(mountpt);
3249 int mk_dir(const char *mp, const char *name)
3251 char full_name[100];
3253 sprintf(full_name, "%s/%s", mp, name);
3255 return yaffs_mkdir(full_name, S_IREAD| S_IWRITE);
3258 int mk_file(const char *mp, const char *name)
3260 char full_name[100];
3263 sprintf(full_name, "%s/%s", mp, name);
3265 h = yaffs_open(full_name, O_RDWR | O_CREAT | O_TRUNC, S_IREAD| S_IWRITE);
3267 yaffs_write(h, name, strlen(name));
3273 void xx_test(const char *mountpt)
3277 yaffs_format(mountpt,0,0,0);
3279 yaffs_mount(mountpt);
3280 printf("mounted\n");
3283 printf("create files\n");
3285 mk_dir(mountpt, "foo");
3286 mk_file(mountpt, "foo/f1");
3287 mk_file(mountpt, "foo/f2");
3288 mk_file(mountpt, "foo/f3");
3289 mk_file(mountpt, "foo/f4");
3290 dump_directory_tree(mountpt);
3292 printf("unmount and remount\n");
3294 /* Unmount/remount */
3295 yaffs_unmount(mountpt);
3296 yaffs_mount(mountpt);
3297 dump_directory_tree(mountpt);
3300 void yy_test(const char *mountpt)
3304 yaffs_mount(mountpt);
3305 dump_directory_tree(mountpt);
3309 void readdir_test(const char *mountpt)
3312 yaffs_DIR *dirs[100];
3314 yaffs_trace_mask = 0;
3318 yaffs_mount(mountpt);
3320 for(i = 0; i < 100; i++) {
3321 dirs[i] = yaffs_opendir(mountpt);
3322 printf("%2d %p,", i, dirs[i]);
3327 for(i = 0; i < 100; i++) {
3329 yaffs_closedir(dirs[i]);
3333 for(i = 0; i < 100; i++) {
3334 dirs[i] = yaffs_opendir(mountpt);
3335 printf("%2d %p,", i, dirs[i]);
3338 yaffs_unmount(mountpt);
3342 void format_test(const char *mountpt)
3348 ret = yaffs_format(mountpt, 0, 0, 0);
3349 printf("yaffs_format(...,0, 0, 0) of unmounted returned %d."
3350 " Should return 0\n\n\n", ret);
3352 yaffs_mount(mountpt);
3354 ret = yaffs_format(mountpt, 0, 0, 0);
3355 printf("yaffs_format(...,0, 0, 0) of mounted returned %d."
3356 " Should return -1 (busy)\n\n\n", ret);
3358 ret = yaffs_format(mountpt, 1, 0, 0);
3359 printf("yaffs_format(...,1, 0, 0) of mounted returned %d."
3360 " Should return 0.\n\n\n", ret);
3362 ret = yaffs_mount(mountpt);
3363 printf("mount should return 0 returned %d\n\n\n", ret);
3365 ret = yaffs_format(mountpt, 1, 0, 1);
3366 printf("yaffs_format(...,1, 0, 1) of mounted returned %d."
3367 " Should return 0.\n\n\n", ret);
3369 ret = yaffs_mount(mountpt);
3370 printf("mount should return -1 returned %d\n", ret);
3373 void dir_rename_test(const char *mountpt)
3381 yaffs_mount(mountpt);
3383 sprintf(fname,"%s/file",mountpt);
3384 sprintf(dname,"%s/directory",mountpt);
3386 h = yaffs_open(fname,O_CREAT | O_RDWR | O_TRUNC, 0666);
3389 yaffs_mkdir(dname, 0666);
3391 dump_directory_tree(mountpt);
3393 printf("Try to rename %s to %s\n", fname, dname);
3394 ret = yaffs_rename(fname, dname);
3395 printf("result %d, %d\n", ret, yaffs_get_error());
3397 printf("Try to rename %s to %s\n", dname, fname);
3398 ret = yaffs_rename(dname, fname);
3399 printf("result %d, %d\n", ret, yaffs_get_error());
3405 void dir_fd_test(const char *mountpt)
3412 yaffs_mount(mountpt);
3414 sprintf(name,"%s/directory",mountpt);
3415 yaffs_mkdir(name, 0666);
3416 for(i=0; i < 20; i++) {
3417 sprintf(name,"%s/directory/file%d",mountpt, i);
3419 h = yaffs_open(name, O_CREAT | O_TRUNC | O_RDWR, 0666);
3420 yaffs_write(h, name, strlen(name));
3423 sprintf(name,"%s/dddd",mountpt);
3424 yaffs_mkdir(name, 0666);
3425 for(i=0; i < 20; i++) {
3426 sprintf(name,"%s/dddd/filezzz%d",mountpt, i);
3428 h = yaffs_open(name, O_CREAT | O_TRUNC | O_RDWR, 0666);
3429 yaffs_write(h, name, strlen(name));
3434 dump_directory_tree(mountpt);
3435 dump_directory_tree_fd(mountpt);
3436 dump_directory_tree_fd(mountpt);
3440 void create_delete_many_files_test(const char *mountpt)
3452 yaffs_mount(mountpt);
3454 for(i = 1; i < 2000; i++) {
3455 sprintf(fn,"%s/f%d",mountpt, i);
3456 fsize = (i%10) * 10000 + 20000;
3457 h = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, 0666);
3459 wrote = yaffs_write(h, buffer, sizeof(buffer));
3460 if (wrote != sizeof(buffer)) {
3461 printf("Writing file %s, only wrote %d bytes\n", fn, wrote);
3472 void find_device_check(void)
3475 yaffs_mount("/nand");
3477 yaffs_mkdir("/nandxxx", 0666);
3478 yaffs_mkdir("/nand/xxx", 0666);
3482 void try_opendir(const char *str)
3486 d = yaffs_opendir(str);
3488 printf("%s --> %p\n", str, d);
3494 void opendir_test(void)
3497 yaffs_mount("/nand/");
3498 yaffs_symlink("x", "/nand/sym");
3499 yaffs_mkdir("/nand/x",0666);
3500 yaffs_mkdir("/nand/y",0666);
3501 yaffs_mkdir("/nand/x/r",0666);
3502 yaffs_mkdir("/nand/x/s",0666);
3503 yaffs_mkdir("/nand/x/t",0666);
3505 try_opendir("nand/x/.");
3506 try_opendir("nand/x/r/..");
3507 try_opendir("nand/x/./");
3508 try_opendir("nand/x/r/../");
3509 try_opendir("/nand/x");
3510 try_opendir("/nand/x/");
3511 try_opendir("nand/x");
3512 try_opendir("nand/sym");
3513 try_opendir("nand/sym/");
3517 void try_rmdir(const char *str)
3521 ret= yaffs_rmdir(str);
3523 printf("rmdir(\"%s\") --> %d, errno %d\n", str, ret, yaffs_get_error());
3527 void rmdir_test2(void)
3531 yaffs_mount("/nand/");
3532 yaffs_mkdir("/nand/z",0666);
3533 try_rmdir("/nand/z");
3534 yaffs_mkdir("/nand/z",0666);
3535 try_rmdir("/nand/z/");
3539 void dump_yaffs_malloc_usage(void)
3542 unsigned high_water;
3544 yaffsfs_get_malloc_values(¤t, &high_water);
3547 "***************************************\n"
3548 "Dump of yaffs malloc usage during run\n"
3549 "Currently allocated : %u bytes\n"
3550 "High water allocated : %u bytes\n"
3551 "Note, this is not accurate on all platforms\n",
3552 current, high_water);
3558 int simulate_power_failure;
3560 int main(int argc, char *argv[])
3563 //unlink("emfile-nand");
3566 atexit(dump_yaffs_malloc_usage);
3571 random_seed = time(NULL);
3572 //return long_test(argc,argv);
3574 //return cache_read_test();
3576 // resize_stress_test_no_grow("/flash/flash",20);
3577 //root_perm_remount("/flash/flash");
3579 //huge_directory_test_on_path("/ram2k");
3581 //yaffs_backward_scan_test("/flash/flash");
3582 // yaffs_device_flush_test("/flash/flash");
3584 //rename_over_test("//////////////////flash///////////////////yaffs1///////////");
3586 //fill_empty_files_test("/nand/");
3587 //resize_stress_test("/nand");
3588 //overwrite_test("/nand");
3590 //long_name_test("/nand");
3591 //link_test0("/nand");
3592 //link_test1("yaffs2");
3593 //scan_pattern_test("/flash",10000,10);
3594 //short_scan_test("/yflash2",40000,200);
3595 //short_scan_test("/nand128MB",40000,200);
3596 //small_mount_test("/flash/flash",1000);
3597 //small_overwrite_test("/flash/flash",1000);
3598 //seek_overwrite_test("/flash/flash",1000);
3599 //checkpoint_fill_test("/flash/flash",20);
3600 //checkpoint_upgrade_test("/flash/flash",20);
3601 //small_overwrite_test("/flash/flash",1000);
3602 //checkpoint_fill_test("/flash/flash",20);
3603 //random_small_file_test("/flash/flash",10000);
3604 // huge_array_test("/flash/flash",10);
3607 // handle_test("yaffs2/");
3609 //long_test_on_path("/ram2k");
3610 // long_test_on_path("/flash");
3611 //simple_rw_test("/flash/flash");
3612 //fill_n_file_test("/nand128MB", 50, 128000000/50);
3613 // rename_over_test("/flash");
3614 //lookup_test("/flash");
3615 //freespace_test("/flash/flash");
3617 //link_test("/flash/flash");
3619 // cache_bypass_bug_test();
3621 //free_space_check();
3623 //check_resize_gc_bug("/flash");
3625 //basic_xattr_test("/nand");
3626 //big_xattr_test("/nand");
3628 //null_name_test("yaffs2");
3630 //test_flash_traffic("yaffs2");
3631 // link_follow_test("/nand");
3632 //basic_utime_test("/nand");
3635 //format_test("/nand");
3637 //max_files_test("/nand");
3639 //start_twice("/nand");
3641 //large_file_test("/nand");
3642 //readdir_test("/nand");
3644 basic_utime_test("/nand");
3645 size_utime_test("/nand");
3646 //case_insensitive_test("/nand");
3649 //dir_rename_test("/nand");
3651 //dir_fd_test("/nand");
3653 //format_test("/nand");
3658 //create_delete_many_files_test("/nand");