2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Charles Manning <charles@aleph1.co.uk>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
26 void dumpDir(const char *dname);
30 void copy_in_a_file(char *yaffsName,char *inName)
33 unsigned char buffer[100];
35 inh = open(inName,O_RDONLY);
36 outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
38 while((ni = read(inh,buffer,100)) > 0)
40 no = yaffs_write(outh,buffer,ni);
43 printf("problem writing yaffs file\n");
52 void make_a_file(char *yaffsName,char bval,int sizeOfFile)
56 unsigned char buffer[100];
58 outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
60 memset(buffer,bval,100);
67 yaffs_write(outh,buffer,i);
69 } while (sizeOfFile > 0);
76 void make_pattern_file(char *fn,int size)
81 outh = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
82 yaffs_lseek(outh,size-1,SEEK_SET);
83 yaffs_write(outh,"A",1);
85 for(i = 0; i < size; i+=256)
88 yaffs_lseek(outh,i,SEEK_SET);
89 yaffs_write(outh,&marker,sizeof(marker));
95 int check_pattern_file(char *fn)
103 h = yaffs_open(fn, O_RDWR,0);
104 size = yaffs_lseek(h,0,SEEK_END);
106 for(i = 0; i < size; i+=256)
108 yaffs_lseek(h,i,SEEK_SET);
109 yaffs_read(h,&marker,sizeof(marker));
113 printf("pattern check failed on file %s, size %d at position %d. Got %x instead of %x\n",
114 fn,size,i,marker,~i);
125 int dump_file_data(char *fn)
132 h = yaffs_open(fn, O_RDWR,0);
136 while(yaffs_read(h,&b,1)> 0)
153 void dump_file(const char *fn)
159 h = yaffs_open(fn,O_RDONLY,0);
162 printf("*****\nDump file %s does not exist\n",fn);
166 size = yaffs_lseek(h,0,SEEK_SET);
167 printf("*****\nDump file %s size %d\n",fn,size);
168 for(i = 0; i < size; i++)
175 void create_file_of_size(const char *fn,int syze)
183 int iterations = (syze + strlen(fn) -1)/ strlen(fn);
185 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
187 while (iterations > 0)
189 sprintf(xx,"%s %8d",fn,iterations);
191 result = yaffs_write(h,xx,n);
193 printf("Wrote %d, should have been %d\n",result,n);
199 void verify_file_of_size(const char *fn,int syze)
208 int iterations = (syze + strlen(fn) -1)/ strlen(fn);
210 h = yaffs_open(fn, O_RDONLY, S_IREAD | S_IWRITE);
212 while (iterations > 0)
214 sprintf(xx,"%s %8d",fn,iterations);
217 result = yaffs_read(h,yy,l);
221 printf("=====>>>>> verification of file %s failed near position %lld\n",fn,(long long)yaffs_lseek(h,0,SEEK_CUR));
228 void create_resized_file_of_size(const char *fn,int syze1,int reSyze, int syze2)
234 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
236 iterations = (syze1 + strlen(fn) -1)/ strlen(fn);
237 while (iterations > 0)
239 yaffs_write(h,fn,strlen(fn));
243 yaffs_ftruncate(h,reSyze);
245 yaffs_lseek(h,0,SEEK_SET);
246 iterations = (syze2 + strlen(fn) -1)/ strlen(fn);
247 while (iterations > 0)
249 yaffs_write(h,fn,strlen(fn));
257 void do_some_file_stuff(const char *path)
262 sprintf(fn,"%s/%s",path,"f1");
263 create_file_of_size(fn,10000);
265 sprintf(fn,"%s/%s",path,"fdel");
266 create_file_of_size(fn,10000);
269 sprintf(fn,"%s/%s",path,"f2");
271 create_resized_file_of_size(fn,10000,3000,4000);
274 void yaffs_backward_scan_test(const char *path)
282 do_some_file_stuff(path);
284 sprintf(fn,"%s/ddd",path);
288 do_some_file_stuff(fn);
295 void null_name_test(const char *path)
303 sprintf(fn,"%s",path);
305 h = yaffs_open(fn,O_CREAT| O_TRUNC| O_RDWR, 0666);
314 void yaffs_device_flush_test(const char *path)
324 do_some_file_stuff(path);
326 // Open and add some data to a few files
327 for(i = 0; i < 10; i++) {
329 sprintf(fn,"%s/ff%d",path,i);
331 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IWRITE | S_IREAD);
332 yaffs_write(h,xxzz,2000);
333 yaffs_write(h,xxzz,2000);
342 void short_scan_test(const char *path, int fsize, int niterations)
347 sprintf(fn,"%s/%s",path,"f1");
350 for(i = 0; i < niterations; i++)
352 printf("\n*****************\nIteration %d\n",i);
354 printf("\nmount: Directory look-up of %s\n",path);
356 make_a_file(fn,1,fsize);
363 void scan_pattern_test(const char *path, int fsize, int niterations)
370 sprintf(fn[0],"%s/%s",path,"f0");
371 sprintf(fn[1],"%s/%s",path,"f1");
372 sprintf(fn[2],"%s/%s",path,"f2");
376 for(i = 0; i < niterations; i++)
378 printf("\n*****************\nIteration %d\n",i);
380 printf("\nmount: Directory look-up of %s\n",path);
382 for(j = 0; j < 3; j++)
384 result = dump_file_data(fn[j]);
385 result = check_pattern_file(fn[j]);
386 make_pattern_file(fn[j],fsize);
387 result = dump_file_data(fn[j]);
388 result = check_pattern_file(fn[j]);
394 void fill_disk(const char *path,int nfiles)
403 for(n = 0; n < nfiles; n++)
405 sprintf(str,"%s/%d",path,n);
407 h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
409 printf("writing file %s handle %d ",str, h);
411 while ((result = yaffs_write(h,xx,600)) == 600)
413 f = yaffs_freespace(path);
415 result = yaffs_close(h);
416 printf(" close %d\n",result);
420 void fill_disk_and_delete(const char *path, int nfiles, int ncycles)
426 for(i = 0; i < ncycles; i++)
428 printf("@@@@@@@@@@@@@@ cycle %d\n",i);
429 fill_disk(path,nfiles);
431 for(j = 0; j < nfiles; j++)
433 sprintf(str,"%s/%d",path,j);
434 result = yaffs_unlink(str);
435 printf("unlinking file %s, result %d\n",str,result);
441 void fill_files(const char *path,int flags, int maxIterations,int siz)
451 sprintf(str,"%s/%d",path,i);
452 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
456 for(j = 0; j < siz; j++)
458 yaffs_write(h,str,1);
467 } while(h >= 0 && i < maxIterations);
473 sprintf(str,"%s/%d",path,i);
474 printf("unlink %s\n",str);
476 } while(yaffs_unlink(str) >= 0);
480 void leave_unlinked_file(char *path,int maxIterations,int siz)
489 sprintf(str,"%s/%d",path,i);
490 printf("create %s\n",str);
491 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
497 } while(h < 0 && i < maxIterations);
501 for(i = 0; i < siz; i++)
503 yaffs_write(h,str,1);
507 printf("Leaving file %s open\n",str);
511 void dumpDirFollow(const char *dname)
518 d = yaffs_opendir(dname);
522 printf("opendir failed\n");
526 while((de = yaffs_readdir(d)) != NULL)
528 sprintf(str,"%s/%s",dname,de->d_name);
532 printf("%s ino %d length %d mode %X ",de->d_name,(int)s.st_ino,(int)s.st_size,s.st_mode);
533 switch(s.st_mode & S_IFMT)
535 case S_IFREG: printf("data file"); break;
536 case S_IFDIR: printf("directory"); break;
537 case S_IFLNK: printf("symlink -->");
538 if(yaffs_readlink(str,str,100) < 0)
541 printf("\"%s\"",str);
543 default: printf("unknown"); break;
553 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
558 void dump_directory_tree_worker(const char *dname,int recursive)
565 d = yaffs_opendir(dname);
569 printf("opendir failed\n");
573 while((de = yaffs_readdir(d)) != NULL)
575 sprintf(str,"%s/%s",dname,de->d_name);
579 printf("%s inode %d obj %x length %d mode %X ",str,s.st_ino,de->d_dont_use,(int)s.st_size,s.st_mode);
580 switch(s.st_mode & S_IFMT)
582 case S_IFREG: printf("data file"); break;
583 case S_IFDIR: printf("directory"); break;
584 case S_IFLNK: printf("symlink -->");
585 if(yaffs_readlink(str,str,100) < 0)
588 printf("\"%s\"",str);
590 default: printf("unknown"); break;
595 if((s.st_mode & S_IFMT) == S_IFDIR && recursive)
596 dump_directory_tree_worker(str,1);
605 static void dump_directory_tree(const char *dname)
607 dump_directory_tree_worker(dname,1);
609 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
612 void dumpDir(const char *dname)
613 { dump_directory_tree_worker(dname,0);
615 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
619 static void PermissionsCheck(const char *path, mode_t tmode, int tflags,int expectedResult)
623 if(yaffs_chmod(path,tmode)< 0) printf("chmod failed\n");
625 fd = yaffs_open(path,tflags,0);
627 if((fd >= 0) != (expectedResult > 0))
629 printf("Permissions check %x %x %d failed\n",tmode,tflags,expectedResult);
633 printf("Permissions check %x %x %d OK\n",tmode,tflags,expectedResult);
642 int long_test(int argc, char *argv[])
653 struct yaffs_stat ystat;
657 yaffs_mount("/boot");
658 yaffs_mount("/data");
659 yaffs_mount("/flash");
662 printf("\nDirectory look-up of /boot\n");
664 printf("\nDirectory look-up of /data\n");
666 printf("\nDirectory look-up of /flash\n");
669 //leave_unlinked_file("/flash",20000,0);
670 //leave_unlinked_file("/data",20000,0);
672 leave_unlinked_file("/ram",20,0);
675 f = yaffs_open("/boot/b1", O_RDONLY,0);
677 printf("open /boot/b1 readonly, f=%d\n",f);
679 f = yaffs_open("/boot/b1", O_CREAT,S_IREAD | S_IWRITE);
681 printf("open /boot/b1 O_CREAT, f=%d\n",f);
684 r = yaffs_write(f,"hello",1);
685 printf("write %d attempted to write to a read-only file\n",r);
689 printf("close %d\n",r);
691 f = yaffs_open("/boot/b1", O_RDWR,0);
693 printf("open /boot/b1 O_RDWR,f=%d\n",f);
696 r = yaffs_write(f,"hello",2);
697 printf("write %d attempted to write to a writeable file\n",r);
698 r = yaffs_write(f,"world",3);
699 printf("write %d attempted to write to a writeable file\n",r);
701 r= yaffs_lseek(f,0,SEEK_END);
702 printf("seek end %d\n",r);
704 r = yaffs_read(f,buffer,10);
705 printf("read %d \"%s\"\n",r,buffer);
706 r= yaffs_lseek(f,0,SEEK_SET);
707 printf("seek set %d\n",r);
709 r = yaffs_read(f,buffer,10);
710 printf("read %d \"%s\"\n",r,buffer);
712 r = yaffs_read(f,buffer,10);
713 printf("read %d \"%s\"\n",r,buffer);
715 // Check values reading at end.
716 // A read past end of file should return 0 for 0 bytes read.
718 r= yaffs_lseek(f,0,SEEK_END);
719 r = yaffs_read(f,buffer,10);
720 printf("read at end returned %d\n",r);
721 r= yaffs_lseek(f,500,SEEK_END);
722 r = yaffs_read(f,buffer,10);
723 printf("read past end returned %d\n",r);
727 printf("close %d\n",r);
729 copy_in_a_file("/boot/yyfile","xxx");
731 // Create a file with a long name
733 copy_in_a_file("/boot/file with a long name","xxx");
736 printf("\nDirectory look-up of /boot\n");
740 r = yaffs_stat("/boot/file with a long name",&ystat);
744 r = yaffs_rename("/boot/file with a long name","/boot/r1");
746 printf("\nDirectory look-up of /boot\n");
750 r = yaffs_unlink("/boot/r1");
752 printf("\nDirectory look-up of /boot\n");
757 r = yaffs_mkdir("/boot/directory1",0);
759 printf("\nDirectory look-up of /boot\n");
761 printf("\nDirectory look-up of /boot/directory1\n");
762 dumpDir("/boot/directory1");
764 // add a file to the directory
765 copy_in_a_file("/boot/directory1/file with a long name","xxx");
767 printf("\nDirectory look-up of /boot\n");
769 printf("\nDirectory look-up of /boot/directory1\n");
770 dumpDir("/boot/directory1");
772 // Attempt to delete directory (should fail)
774 r = yaffs_rmdir("/boot/directory1");
776 printf("\nDirectory look-up of /boot\n");
778 printf("\nDirectory look-up of /boot/directory1\n");
779 dumpDir("/boot/directory1");
781 // Delete file first, then rmdir should work
782 r = yaffs_unlink("/boot/directory1/file with a long name");
783 r = yaffs_rmdir("/boot/directory1");
786 printf("\nDirectory look-up of /boot\n");
788 printf("\nDirectory look-up of /boot/directory1\n");
789 dumpDir("/boot/directory1");
792 fill_disk_and_delete("/boot",20,20);
794 printf("\nDirectory look-up of /boot\n");
798 yaffs_symlink("yyfile","/boot/slink");
800 yaffs_readlink("/boot/slink",str,100);
801 printf("symlink alias is %s\n",str);
806 printf("\nDirectory look-up of /boot\n");
808 printf("\nDirectory look-up of /boot (using stat instead of lstat)\n");
809 dumpDirFollow("/boot");
810 printf("\nDirectory look-up of /boot/directory1\n");
811 dumpDir("/boot/directory1");
813 h = yaffs_open("/boot/slink",O_RDWR,0);
815 printf("file length is %d\n",(int)yaffs_lseek(h,0,SEEK_END));
819 yaffs_unlink("/boot/slink");
822 printf("\nDirectory look-up of /boot\n");
827 yaffs_stat("/boot/yyfile",&ystat);
828 temp_mode = ystat.st_mode;
830 yaffs_chmod("/boot/yyfile",0x55555);
831 printf("\nDirectory look-up of /boot\n");
834 yaffs_chmod("/boot/yyfile",temp_mode);
835 printf("\nDirectory look-up of /boot\n");
838 // Permission checks...
839 PermissionsCheck("/boot/yyfile",0, O_WRONLY,0);
840 PermissionsCheck("/boot/yyfile",0, O_RDONLY,0);
841 PermissionsCheck("/boot/yyfile",0, O_RDWR,0);
843 PermissionsCheck("/boot/yyfile",S_IREAD, O_WRONLY,0);
844 PermissionsCheck("/boot/yyfile",S_IREAD, O_RDONLY,1);
845 PermissionsCheck("/boot/yyfile",S_IREAD, O_RDWR,0);
847 PermissionsCheck("/boot/yyfile",S_IWRITE, O_WRONLY,1);
848 PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDONLY,0);
849 PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDWR,0);
851 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_WRONLY,1);
852 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDONLY,1);
853 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDWR,1);
855 yaffs_chmod("/boot/yyfile",temp_mode);
857 //create a zero-length file and unlink it (test for scan bug)
859 h = yaffs_open("/boot/zlf",O_CREAT | O_TRUNC | O_RDWR,0);
862 yaffs_unlink("/boot/zlf");
865 yaffs_DumpDevStruct("/boot");
867 fill_disk_and_delete("/boot",20,20);
869 yaffs_DumpDevStruct("/boot");
871 fill_files("/boot",1,10000,0);
872 fill_files("/boot",1,10000,5000);
873 fill_files("/boot",2,10000,0);
874 fill_files("/boot",2,10000,5000);
876 leave_unlinked_file("/data",20000,0);
877 leave_unlinked_file("/data",20000,5000);
878 leave_unlinked_file("/data",20000,5000);
879 leave_unlinked_file("/data",20000,5000);
880 leave_unlinked_file("/data",20000,5000);
881 leave_unlinked_file("/data",20000,5000);
883 yaffs_DumpDevStruct("/boot");
884 yaffs_DumpDevStruct("/data");
892 int huge_directory_test_on_path(char *path)
912 // Create a large number of files
914 for(i = 0; i < 2000; i++)
916 sprintf(str,"%s/%d",path,i);
918 f = yaffs_open(str,O_CREAT,S_IREAD | S_IWRITE);
924 d = yaffs_opendir(path);
927 while((de = yaffs_readdir(d)) != NULL) {
928 if (total >lastTotal+100*9*1024||(i & 1023)==0){
929 printf("files = %d, total = %d\n",i, total);
933 sprintf(str,"%s/%s",path,de->d_name);
935 switch(s.st_mode & S_IFMT){
937 //printf("data file");
949 int yaffs_scan_test(const char *path)
955 void rename_over_test(const char *mountpt)
962 sprintf(a,"%s/a",mountpt);
963 sprintf(b,"%s/b",mountpt);
964 sprintf(c,"%s/c",mountpt);
968 yaffs_mount(mountpt);
970 printf("Existing files\n");
971 dumpDirFollow(mountpt);
975 i = yaffs_open(c,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
976 printf("File c handle is %d\n",i);
978 i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
980 i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
982 yaffs_rename(a,b); // rename over
983 yaffs_rename(b,a); // rename back again (not renaimng over)
984 yaffs_rename(a,b); // rename back again (not renaimng over)
987 yaffs_unmount(mountpt);
992 int resize_stress_test(const char *path)
1007 sprintf(aname,"%s%s",path,"/a");
1008 sprintf(bname,"%s%s",path,"/b");
1010 memset(abuffer,'a',1000);
1011 memset(bbuffer,'b',1000);
1013 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1014 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1016 printf(" %s %d %s %d\n",aname,a,bname,b);
1020 for(j = 0; j < 100; j++)
1022 yaffs_lseek(a,0,SEEK_END);
1025 for(i = 0; i <20000; i++)
1027 //r = yaffs_lseek(b,i,SEEK_SET);
1028 //r = yaffs_write(b,bbuffer,1000);
1033 int syz = yaffs_lseek(a,0,SEEK_END);
1036 if(syz < 0) syz = 0;
1037 yaffs_ftruncate(a,syz);
1043 r = yaffs_lseek(a,i * 500,SEEK_SET);
1044 r = yaffs_write(a,abuffer,1000);
1056 int overwrite_test(const char *path)
1068 sprintf(aname,"%s%s",path,"/a");
1069 sprintf(bname,"%s%s",path,"/b");
1071 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1072 for(j= 0; j < 500; j++){
1073 yaffs_write(b,bname,100);
1074 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1075 for(i = 0; i < rand() % 20000; i++)
1076 yaffs_write(a,&a,sizeof(a));
1085 int root_perm_remount(const char *path)
1087 struct yaffs_stat s;
1093 yaffs_stat(path,&s);
1094 printf("root perms after mount %x\n",s.st_mode);
1096 yaffs_chmod(path, 0777);
1098 yaffs_stat(path,&s);
1099 printf("root perms after setting to 0777 is %x\n",s.st_mode);
1101 yaffs_unmount(path);
1108 int resize_stress_test_no_grow_complex(const char *path,int iters)
1124 sprintf(aname,"%s%s",path,"/a");
1125 sprintf(bname,"%s%s",path,"/b");
1127 memset(abuffer,'a',1000);
1128 memset(bbuffer,'b',1000);
1130 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1131 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1133 printf(" %s %d %s %d\n",aname,a,bname,b);
1137 for(j = 0; j < iters; j++)
1139 yaffs_lseek(a,0,SEEK_END);
1142 for(i = 0; i <20000; i++)
1144 //r = yaffs_lseek(b,i,SEEK_SET);
1145 //r = yaffs_write(b,bbuffer,1000);
1150 int syz = yaffs_lseek(a,0,SEEK_END);
1156 if(syz < 0) syz = 0;
1157 yaffs_ftruncate(a,syz);
1158 syz = yaffs_lseek(a,0,SEEK_END);
1159 printf("shrink to %d\n",syz);
1167 r = yaffs_lseek(a,500,SEEK_END);
1168 r = yaffs_write(a,abuffer,1000);
1175 printf("file size is %lld\n",(long long)yaffs_lseek(a,0,SEEK_END));
1183 int resize_stress_test_no_grow(const char *path,int iters)
1198 sprintf(aname,"%s%s",path,"/a");
1199 sprintf(bname,"%s%s",path,"/b");
1201 memset(abuffer,'a',1000);
1202 memset(bbuffer,'b',1000);
1204 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1205 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1207 printf(" %s %d %s %d\n",aname,a,bname,b);
1211 for(j = 0; j < iters; j++)
1213 yaffs_lseek(a,0,SEEK_END);
1216 for(i = 0; i <20000; i++)
1218 //r = yaffs_lseek(b,i,SEEK_SET);
1219 //r = yaffs_write(b,bbuffer,1000);
1224 int syz = yaffs_lseek(a,0,SEEK_END);
1230 if(syz < 0) syz = 0;
1231 yaffs_ftruncate(a,syz);
1232 syz = yaffs_lseek(a,0,SEEK_END);
1233 printf("shrink to %d\n",syz);
1241 r = yaffs_lseek(a,-500,SEEK_END);
1242 r = yaffs_write(a,abuffer,1000);
1248 printf("file size is %lld\n",(long long)yaffs_lseek(a,0,SEEK_END));
1256 int directory_rename_test(void)
1261 yaffs_mount("/ram");
1262 yaffs_mkdir("/ram/a",0);
1263 yaffs_mkdir("/ram/a/b",0);
1264 yaffs_mkdir("/ram/c",0);
1266 printf("\nDirectory look-up of /ram\n");
1269 dumpDir("/ram/a/b");
1271 printf("Do rename (should fail)\n");
1273 r = yaffs_rename("/ram/a","/ram/a/b/d");
1274 printf("\nDirectory look-up of /ram\n");
1277 dumpDir("/ram/a/b");
1279 printf("Do rename (should not fail)\n");
1281 r = yaffs_rename("/ram/c","/ram/a/b/d");
1282 printf("\nDirectory look-up of /ram\n");
1285 dumpDir("/ram/a/b");
1292 int cache_read_test(void)
1296 int sizeOfFiles = 500000;
1301 yaffs_mount("/boot");
1303 make_a_file("/boot/a",'a',sizeOfFiles);
1304 make_a_file("/boot/b",'b',sizeOfFiles);
1306 a = yaffs_open("/boot/a",O_RDONLY,0);
1307 b = yaffs_open("/boot/b",O_RDONLY,0);
1308 c = yaffs_open("/boot/c", O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
1312 if (i > 100) i = 100;
1314 yaffs_read(a,buffer,i);
1315 yaffs_read(b,buffer,i);
1316 yaffs_write(c,buffer,i);
1317 } while(sizeOfFiles > 0);
1325 int cache_bypass_bug_test(void)
1327 // This test reporoduces a bug whereby YAFFS caching *was* buypassed
1328 // resulting in erroneous reads after writes.
1329 // This bug has been fixed.
1335 memset(buffer1,0,sizeof(buffer1));
1336 memset(buffer2,0,sizeof(buffer2));
1340 yaffs_mount("/boot");
1342 // Create a file of 2000 bytes.
1343 make_a_file("/boot/a",'X',2000);
1345 a = yaffs_open("/boot/a",O_RDWR, S_IREAD | S_IWRITE);
1347 // Write a short sequence to the file.
1348 // This will go into the cache.
1349 yaffs_lseek(a,0,SEEK_SET);
1350 yaffs_write(a,"abcdefghijklmnopqrstuvwxyz",20);
1352 // Read a short sequence from the file.
1353 // This will come from the cache.
1354 yaffs_lseek(a,0,SEEK_SET);
1355 yaffs_read(a,buffer1,30);
1357 // Read a page size sequence from the file.
1358 yaffs_lseek(a,0,SEEK_SET);
1359 yaffs_read(a,buffer2,512);
1361 printf("buffer 1 %s\n",buffer1);
1362 printf("buffer 2 %s\n",buffer2);
1364 if(strncmp(buffer1,buffer2,20))
1366 printf("Cache bypass bug detected!!!!!\n");
1374 int free_space_check(void)
1379 yaffs_mount("/boot");
1380 fill_disk("/boot/",2);
1381 f = yaffs_freespace("/boot");
1383 printf("%d free when disk full\n",f);
1387 int truncate_test(void)
1397 yaffs_mount("/boot");
1399 yaffs_unlink("/boot/trunctest");
1401 a = yaffs_open("/boot/trunctest", O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1403 yaffs_write(a,"abcdefghijklmnopqrstuvwzyz",26);
1405 yaffs_ftruncate(a,3);
1406 l= yaffs_lseek(a,0,SEEK_END);
1408 printf("truncated length is %d\n",l);
1410 yaffs_lseek(a,5,SEEK_SET);
1411 yaffs_write(a,"1",1);
1413 yaffs_lseek(a,0,SEEK_SET);
1415 r = yaffs_read(a,y,10);
1417 printf("read %d bytes:",r);
1419 for(i = 0; i < r; i++) printf("[%02X]",y[i]);
1431 void fill_disk_test(const char *mountpt)
1436 for(i = 0; i < 5; i++)
1438 yaffs_mount(mountpt);
1439 fill_disk_and_delete(mountpt,100,i+1);
1440 yaffs_unmount(mountpt);
1446 void fill_files_test(const char *mountpt)
1451 for(i = 0; i < 5; i++)
1453 yaffs_mount(mountpt);
1454 fill_files(mountpt,2,3,100);
1455 yaffs_unmount(mountpt);
1460 void fill_empty_files_test(const char *mountpt)
1469 for(i = 0; i < 5; i++)
1471 yaffs_mount(mountpt);
1472 for(d = 0; result >= 0 && d < 1000; d++){
1473 sprintf(name,"%s/%d",mountpt,d);
1474 result= yaffs_mkdir(name,0);
1475 printf("creating directory %s result %d\n",name,result);
1477 for(f = 0; result >= 0 && f < 100; f++){
1478 sprintf(name,"%s/%d/%d",mountpt,d,f);
1479 result= yaffs_open(name,O_CREAT, 0);
1480 yaffs_close(result);
1481 printf("creating file %s result %d\n",name,result);
1484 yaffs_unmount(mountpt);
1489 void long_name_test(const char *mountpt)
1493 char fullName[1000];
1499 // Make a 256 byte name
1500 memset(name,0,sizeof(name));
1501 for(i = 0; i < 256; i++)
1502 name[i] = '0' + i % 10;
1504 sprintf(fullName,"%s/%s",mountpt,name);
1506 for(i = 0; i < 1; i++)
1508 yaffs_mount(mountpt);
1510 printf("Files at start\n");
1513 printf("Creating file %s\n",fullName);
1515 f = yaffs_open(fullName,O_CREAT | O_RDWR,0);
1518 printf("Result %d\n",f);
1523 printf("Deleting %s\n",fullName);
1524 result = yaffs_unlink(fullName);
1525 printf("Result %d\n",result);
1531 yaffs_unmount(mountpt);
1537 void lookup_test(const char *mountpt)
1549 yaffs_mount(mountpt);
1551 d = yaffs_opendir(mountpt);
1555 printf("opendir failed\n");
1560 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1562 printf("unlinking %s\n",de->d_name);
1563 yaffs_unlink(de->d_name);
1566 printf("%d files deleted\n",i);
1570 for(i = 0; i < 2000; i++){
1571 sprintf(a,"%s/%d",mountpt,i);
1572 h = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0);
1577 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1579 printf("%d %s\n",i,de->d_name);
1582 printf("%d files listed\n\n\n",i);
1589 for(i = 0; i < 2000; i++){
1590 sprintf(a,"%s/%d",mountpt,i);
1595 yaffs_unmount(mountpt);
1599 void link_test0(const char *mountpt)
1608 yaffs_mount(mountpt);
1611 sprintf(namea,"%s/a",mountpt);
1612 sprintf(nameb,"%s/b",mountpt);
1614 printf("mounted\n");
1617 yaffs_unlink(namea);
1618 printf("a unlinked\n");
1621 yaffs_unlink(nameb);
1622 printf("b unlinked\n");
1625 result = yaffs_open(namea,O_CREAT| O_RDWR,0666);
1626 yaffs_close(result);
1627 printf("a created\n");
1630 yaffs_link(namea,nameb);
1633 yaffs_unlink(namea);
1634 printf("a ulinked\n");
1636 yaffs_unlink(nameb);
1637 printf("b unlinked\n");
1640 yaffs_unmount(mountpt);
1644 void link_test1(const char *mountpt)
1652 sprintf(a,"%s/aaa",mountpt);
1653 sprintf(b,"%s/bbb",mountpt);
1654 sprintf(c,"%s/ccc",mountpt);
1658 yaffs_mount(mountpt);
1661 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1662 for(i = 0; i < 100; i++)
1663 yaffs_write(h,a,100);
1676 yaffs_unmount(mountpt);
1677 yaffs_mount(mountpt);
1679 printf("link test done\n");
1682 void handle_test(const char *mountpt)
1689 sprintf(a,"%s/aaa",mountpt);
1693 yaffs_mount(mountpt);
1695 for(cycle = 0; cycle < 5; cycle++){
1696 printf("Start cycle %d\n",cycle);
1699 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1700 printf("%d handle %d\n",i,h);
1710 yaffs_unmount(mountpt);
1713 void freespace_test(const char *mountpt)
1723 sprintf(a,"%s/aaa",mountpt);
1727 yaffs_mount(mountpt);
1729 f0 = yaffs_freespace(mountpt);
1731 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1733 for(i = 0; i < 100; i++)
1734 yaffs_write(h,a,100);
1738 f1 = yaffs_freespace(mountpt);
1742 f2 = yaffs_freespace(mountpt);
1745 yaffs_unmount(mountpt);
1746 yaffs_mount(mountpt);
1748 f3 = yaffs_freespace(mountpt);
1750 printf("%d\n%d\n%d\n%d\n",f0, f1,f2,f3);
1755 void simple_rw_test(const char *mountpt)
1764 sprintf(a,"%s/aaa",mountpt);
1768 yaffs_mount(mountpt);
1772 h = yaffs_open(a,O_CREAT| O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1774 for(i = 100000;i < 200000; i++){
1775 result = yaffs_write(h,&i,sizeof(i));
1779 printf("write error\n");
1786 // h = yaffs_open(a,O_RDWR, S_IREAD | S_IWRITE);
1789 yaffs_lseek(h,0,SEEK_SET);
1791 for(i = 100000; i < 200000; i++){
1792 result = yaffs_read(h,&x,sizeof(x));
1794 if(result != 4 || x != i){
1795 printf("read error %d %x %x\n",i,result,x);
1799 printf("Simple rw test passed\n");
1806 void scan_deleted_files_test(const char *mountpt)
1818 sprintf(sub,"%s/sdir",mountpt);
1821 for(j = 0; j < 10; j++)
1823 printf("\n\n>>>>>>> Run %d <<<<<<<<<<<<<\n\n",j);
1824 yaffs_mount(mountpt);
1828 p = (j & 0) ? mountpt: sub;
1830 for(i = 0; i < 100; i++)
1832 sprintf(fn,"%s/%d",p,i);
1836 h = yaffs_open(fn,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1837 for(k = 0; k < 1000; k++)
1838 yaffs_write(h,fn,100);
1845 for(i = 0; i < 10; i++)
1847 sprintf(fn,"%s/%d",p,i);
1855 yaffs_unmount(mountpt);
1864 void write_10k(int h)
1867 const char *s="0123456789";
1868 for(i = 0; i < 1000; i++)
1869 yaffs_write(h,s,10);
1872 void write_200k_file(const char *fn, const char *fdel, const char *fdel1)
1878 h1 = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1880 for(i = 0; i < 100000; i+= 10000)
1885 offs = yaffs_lseek(h1,0,SEEK_CUR);
1888 printf("Could not write file\n");
1892 for(i = 0; i < 100000; i+= 10000)
1897 offs = yaffs_lseek(h1,0,SEEK_CUR);
1900 printf("Could not write file\n");
1904 yaffs_unlink(fdel1);
1909 void verify_200k_file(const char *fn)
1914 const char *s="0123456789";
1917 h1 = yaffs_open(fn, O_RDONLY, 0);
1919 for(i = 0; i < 200000 && errCount < 10; i+= 10)
1921 yaffs_read(h1,x,10);
1922 if(strncmp(x,s,10) != 0)
1924 printf("File %s verification failed at %d\n",fn,i);
1929 printf("Too many errors... aborted\n");
1936 void check_resize_gc_bug(const char *mountpt)
1945 sprintf(a,"%s/a",mountpt);
1946 sprintf(b,"%s/b",mountpt);
1947 sprintf(c,"%s/c",mountpt);
1953 yaffs_mount(mountpt);
1957 for(i = 0; i < 50; i++)
1959 printf("A\n");write_200k_file(a,"",c);
1960 printf("B\n");verify_200k_file(a);
1961 printf("C\n");write_200k_file(b,a,c);
1962 printf("D\n");verify_200k_file(b);
1963 yaffs_unmount(mountpt);
1964 yaffs_mount(mountpt);
1965 printf("E\n");verify_200k_file(a);
1966 printf("F\n");verify_200k_file(b);
1972 void multi_mount_test(const char *mountpt,int nmounts)
1980 sprintf(a,"%s/a",mountpt);
1984 for(i = 0; i < nmounts; i++){
1990 static char xx[1000];
1992 printf("############### Iteration %d Start\n",i);
1993 if(1 || i == 0 || i == 5)
1994 yaffs_mount(mountpt);
1996 dump_directory_tree(mountpt);
2001 sprintf(xx,"%s/0",a);
2002 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2004 sprintf(xx,"%s/1",a);
2005 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2008 for(j = 0; j < 200; j++){
2009 yaffs_write(h0,xx,1000);
2010 yaffs_write(h1,xx,1000);
2013 while(yaffs_write(h0,xx,1000) > 0){
2015 yaffs_write(h1,xx,1000);
2018 len0 = yaffs_lseek(h0,0,SEEK_END);
2019 len1 = yaffs_lseek(h1,0,SEEK_END);
2021 yaffs_lseek(h0,0,SEEK_SET);
2022 yaffs_lseek(h1,0,SEEK_SET);
2024 for(j = 0; j < 200; j++){
2025 yaffs_read(h0,xx,1000);
2026 yaffs_read(h1,xx,1000);
2030 // yaffs_truncate(h0,0);
2034 printf("########### %d\n",i);
2035 dump_directory_tree(mountpt);
2037 if(1 || i == 4 || i == nmounts -1)
2038 yaffs_unmount(mountpt);
2043 void small_mount_test(const char *mountpt,int nmounts)
2057 sprintf(a,"%s/a",mountpt);
2063 for(i = 0; i < nmounts; i++){
2065 static char xx[1000];
2067 printf("############### Iteration %d Start\n",i);
2068 if(1 || i == 0 || i == 5)
2069 yaffs_mount(mountpt);
2071 dump_directory_tree(mountpt);
2075 sprintf(xx,"%s/0",a);
2078 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2079 for(j = 0; j < 130; j++)
2080 yaffs_write(h0,xx,1000);
2084 h0 = yaffs_open(xx,O_RDONLY,0);
2086 sprintf(xx,"%s/1",a);
2087 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2089 while((nread = yaffs_read(h0,xx,1000)) > 0)
2090 yaffs_write(h1,xx,nread);
2093 len0 = yaffs_lseek(h0,0,SEEK_END);
2094 len1 = yaffs_lseek(h1,0,SEEK_END);
2096 yaffs_lseek(h0,0,SEEK_SET);
2097 yaffs_lseek(h1,0,SEEK_SET);
2099 for(j = 0; j < 200; j++){
2100 yaffs_read(h0,xx,1000);
2101 yaffs_read(h1,xx,1000);
2107 printf("########### %d\n",i);
2108 dump_directory_tree(mountpt);
2110 if(1 || i == 4 || i == nmounts -1)
2111 yaffs_unmount(mountpt);
2118 void small_overwrite_test(const char *mountpt,int nmounts)
2129 sprintf(a,"%s/a",mountpt);
2135 for(i = 0; i < nmounts; i++){
2137 static char xx[8000];
2139 printf("############### Iteration %d Start\n",i);
2141 yaffs_mount(mountpt);
2143 dump_directory_tree(mountpt);
2147 sprintf(xx,"%s/0",a);
2148 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2149 sprintf(xx,"%s/1",a);
2150 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2152 for(j = 0; j < 1000000; j+=1000){
2153 yaffs_ftruncate(h0,j);
2154 yaffs_lseek(h0,j,SEEK_SET);
2155 yaffs_write(h0,xx,7000);
2156 yaffs_write(h1,xx,7000);
2164 printf("########### %d\n",i);
2165 dump_directory_tree(mountpt);
2168 yaffs_unmount(mountpt);
2173 void seek_overwrite_test(const char *mountpt,int nmounts)
2184 sprintf(a,"%s/f",mountpt);
2188 yaffs_mount(mountpt);
2191 for(i = 0; i < nmounts; i++){
2193 h0 = yaffs_open(a, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2195 for(j = 0; j < 100000; j++){
2196 yaffs_lseek(h0,0,SEEK_SET);
2197 yaffs_write(h0,xx,5000);
2198 yaffs_lseek(h0,0x100000,SEEK_SET);
2199 yaffs_write(h0,xx,5000);
2211 void yaffs_touch(const char *fn)
2213 yaffs_chmod(fn, S_IREAD | S_IWRITE);
2216 void checkpoint_fill_test(const char *mountpt,int nmounts)
2227 sprintf(a,"%s/a",mountpt);
2234 for(i = 0; i < nmounts; i++){
2235 printf("############### Iteration %d Start\n",i);
2236 yaffs_mount(mountpt);
2237 dump_directory_tree(mountpt);
2240 sprintf(b,"%s/zz",a);
2242 h = yaffs_open(b,O_CREAT | O_RDWR,S_IREAD |S_IWRITE);
2245 while(yaffs_write(h,c,50) == 50){}
2249 for(j = 0; j < 2; j++){
2250 printf("touch %d\n",j);
2252 yaffs_unmount(mountpt);
2253 yaffs_mount(mountpt);
2256 dump_directory_tree(mountpt);
2257 yaffs_unmount(mountpt);
2262 int make_file2(const char *name1, const char *name2,int syz)
2272 h1 = yaffs_open(name1,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2274 h2 = yaffs_open(name2,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2276 while(syz > 0 && n > 0){
2277 i = (syz > 2500) ? 2500 : syz;
2278 n = yaffs_write(h1,xx,i);
2279 n = yaffs_write(h2,xx,i);
2288 extern void SetCheckpointReservedBlocks(int n);
2290 void checkpoint_upgrade_test(const char *mountpt,int nmounts)
2300 sprintf(a,"%s/a",mountpt);
2305 printf("Create start condition\n");
2307 yaffs_mount(mountpt);
2309 sprintf(b,"%s/zz",a);
2310 sprintf(c,"%s/xx",a);
2311 make_file2(b,c,2000000);
2312 sprintf(d,"%s/aa",a);
2313 make_file2(d,NULL,500000000);
2314 dump_directory_tree(mountpt);
2316 printf("Umount/mount attempt full\n");
2317 yaffs_unmount(mountpt);
2319 yaffs_mount(mountpt);
2321 printf("unlink small file\n");
2323 dump_directory_tree(mountpt);
2325 printf("Umount/mount attempt\n");
2326 yaffs_unmount(mountpt);
2327 yaffs_mount(mountpt);
2329 for(j = 0; j < 500; j++){
2330 printf("***** touch %d\n",j);
2331 dump_directory_tree(mountpt);
2333 yaffs_unmount(mountpt);
2334 yaffs_mount(mountpt);
2337 for(j = 0; j < 500; j++){
2338 printf("***** touch %d\n",j);
2339 dump_directory_tree(mountpt);
2341 yaffs_unmount(mountpt);
2342 yaffs_mount(mountpt);
2346 void huge_array_test(const char *mountpt,int n)
2357 sprintf(a,"mount point %s",mountpt);
2363 yaffs_mount(mountpt);
2368 printf("\n\n START run\n\n");
2369 while((space = yaffs_freespace(mountpt)) > 25000000){
2370 sprintf(a,"%s/file%d",mountpt,fnum);
2372 printf("create file %s, free space %d\n",a,space);
2373 create_file_of_size(a,10000000);
2374 printf("verifying file %s\n",a);
2375 verify_file_of_size(a,10000000);
2378 printf("\n\n verification/deletion\n\n");
2380 for(i = 0; i < fnum; i++){
2381 sprintf(a,"%s/file%d",mountpt,i);
2382 printf("verifying file %s\n",a);
2383 verify_file_of_size(a,10000000);
2384 printf("deleting file %s\n",a);
2387 printf("\n\n done \n\n");
2394 void random_write(int h)
2396 static char buffer[12000];
2399 n = random() & 0x1FFF;
2400 yaffs_write(h,buffer,n);
2403 void random_seek(int h)
2406 n = random() & 0xFFFFF;
2407 yaffs_lseek(h,n,SEEK_SET);
2410 void random_truncate(int h, char * name)
2414 n = random() & 0xFFFFF;
2415 flen = yaffs_lseek(h,0,SEEK_END);
2418 yaffs_ftruncate(h,n);
2419 yaffs_lseek(h,n,SEEK_SET);
2423 #define NSMALLFILES 10
2424 void random_small_file_test(const char *mountpt,int iterations)
2427 char a[NSMALLFILES][50];
2438 yaffs_mount(mountpt);
2440 for(i = 0; i < NSMALLFILES; i++){
2445 for(n = 0; n < iterations; n++){
2447 for(i = 0; i < NSMALLFILES; i++) {
2450 if(strlen(a[i]) == 0){
2451 sprintf(a[i],"%s/%dx%d",mountpt,n,i);
2452 h[i] = yaffs_open(a[i],O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2456 printf("Could not open yaffs file %d %d error %d\n",n,i,h[i]);
2466 random_truncate(h[i],a[i]);
2469 case 5: random_seek(h[i]);
2486 for(i = 0; i < NSMALLFILES; i++)
2489 yaffs_unmount(mountpt);
2492 void rmdir_test(const char *mountpt)
2497 yaffs_mount(mountpt);
2499 strcpy(name,mountpt);
2501 strcat(name,"hello");
2502 yaffs_mkdir(name,0666);
2504 yaffs_unmount(mountpt);
2509 static void print_xattrib_val(const char *path, const char *name)
2514 n = yaffs_getxattr(path,name,buffer,sizeof(buffer));
2516 __u8 *b = (__u8 *)buffer;
2518 printf("%d bytes:",n);
2522 printf("[%02X]",*b);
2528 printf(" Novalue result %d\n",n);
2531 static void list_xattr(const char *path)
2538 list_len = yaffs_listxattr(path,list,sizeof(list));
2539 printf("xattribs for %s, result is %d\n",path,list_len);
2540 while(n < list_len){
2541 len = strlen(list + n);
2542 printf("\"%s\" value ",list+n);
2543 print_xattrib_val(path,list + n);
2549 void basic_xattr_test(const char *mountpt)
2559 yaffs_mount(mountpt);
2561 strcpy(name,mountpt);
2563 strcat(name,"xfile");
2566 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2572 printf("Add an attribute\n");
2574 result = yaffs_setxattr(name,"foo",&val1,sizeof(val1),0);
2575 printf("wrote attribute foo: result %d\n",result);
2577 printf("Add an attribute\n");
2579 result = yaffs_setxattr(name,"bar",&val1,sizeof(val1),0);
2580 printf("wrote attribute bar: result %d\n",result);
2583 printf("Get non-existanrt attribute\n");
2584 print_xattrib_val(name,"not here");
2586 printf("Delete non existing attribute\n");
2587 yaffs_removexattr(name,"not here");
2590 printf("Remove foo\n");
2591 yaffs_removexattr(name,"foo");
2594 printf("Remove bar\n");
2595 yaffs_removexattr(name,"bar");
2600 void big_xattr_test(const char *mountpt)
2610 yaffs_mount(mountpt);
2612 strcpy(name,mountpt);
2614 strcat(name,"xfile");
2617 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2623 printf("Add a large attribute\n");
2624 memset(val,0x1,sizeof(val));
2625 result = yaffs_setxattr(name,"aaa",val,200,0);
2626 printf("wrote attribute aaa: result %d\n",result);
2629 printf("Add a large attribute\n");
2630 memset(val,0x2,sizeof(val));
2631 result = yaffs_setxattr(name,"bbb",val,1000,0);
2632 printf("wrote attribute bbb: result %d\n",result);
2635 printf("Replace attribute\n");
2636 memset(val,0x3,sizeof(val));
2637 result = yaffs_setxattr(name,"aaa",val,1000,0);
2638 printf("wrote attribute aaa: result %d\n",result);
2645 int simulate_power_failure;
2647 int main(int argc, char *argv[])
2649 random_seed = time(NULL);
2650 //return long_test(argc,argv);
2652 //return cache_read_test();
2654 // resize_stress_test_no_grow("/flash/flash",20);
2655 //root_perm_remount("/flash/flash");
2657 //huge_directory_test_on_path("/ram2k");
2659 //yaffs_backward_scan_test("/flash/flash");
2660 // yaffs_device_flush_test("/flash/flash");
2662 //rename_over_test("//////////////////flash///////////////////yaffs1///////////");
2664 //fill_empty_files_test("/yaffs2/");
2665 //resize_stress_test("/yaffs2");
2666 //overwrite_test("/yaffs2");
2668 //long_name_test("/yaffs2");
2669 //link_test0("/yaffs2");
2670 //link_test1("yaffs2");
2671 //scan_pattern_test("/flash",10000,10);
2672 //short_scan_test("/flash/flash",40000,200);
2673 //small_mount_test("/flash/flash",1000);
2674 //small_overwrite_test("/flash/flash",1000);
2675 //seek_overwrite_test("/flash/flash",1000);
2676 //checkpoint_fill_test("/flash/flash",20);
2677 //checkpoint_upgrade_test("/flash/flash",20);
2678 //small_overwrite_test("/flash/flash",1000);
2679 //checkpoint_fill_test("/flash/flash",20);
2680 // random_small_file_test("/flash/flash",10000);
2681 // huge_array_test("/flash/flash",10);
2684 // handle_test("yaffs2/");
2686 //long_test_on_path("/ram2k");
2687 // long_test_on_path("/flash");
2688 //simple_rw_test("/flash/flash");
2689 //fill_disk_test("/flash/flash");
2690 // rename_over_test("/flash");
2691 //lookup_test("/flash");
2692 //freespace_test("/flash/flash");
2694 //link_test("/flash/flash");
2699 // cache_bypass_bug_test();
2701 //free_space_check();
2703 //check_resize_gc_bug("/flash");
2705 //basic_xattr_test("/yaffs2");
2706 //big_xattr_test("/yaffs2");
2708 null_name_test("yaffs2");