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);
298 void yaffs_device_flush_test(const char *path)
308 do_some_file_stuff(path);
310 // Open and add some data to a few files
311 for(i = 0; i < 10; i++) {
313 sprintf(fn,"%s/ff%d",path,i);
315 h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IWRITE | S_IREAD);
316 yaffs_write(h,xxzz,2000);
317 yaffs_write(h,xxzz,2000);
326 void short_scan_test(const char *path, int fsize, int niterations)
331 sprintf(fn,"%s/%s",path,"f1");
334 for(i = 0; i < niterations; i++)
336 printf("\n*****************\nIteration %d\n",i);
338 printf("\nmount: Directory look-up of %s\n",path);
340 make_a_file(fn,1,fsize);
347 void scan_pattern_test(const char *path, int fsize, int niterations)
354 sprintf(fn[0],"%s/%s",path,"f0");
355 sprintf(fn[1],"%s/%s",path,"f1");
356 sprintf(fn[2],"%s/%s",path,"f2");
360 for(i = 0; i < niterations; i++)
362 printf("\n*****************\nIteration %d\n",i);
364 printf("\nmount: Directory look-up of %s\n",path);
366 for(j = 0; j < 3; j++)
368 result = dump_file_data(fn[j]);
369 result = check_pattern_file(fn[j]);
370 make_pattern_file(fn[j],fsize);
371 result = dump_file_data(fn[j]);
372 result = check_pattern_file(fn[j]);
378 void fill_disk(const char *path,int nfiles)
387 for(n = 0; n < nfiles; n++)
389 sprintf(str,"%s/%d",path,n);
391 h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
393 printf("writing file %s handle %d ",str, h);
395 while ((result = yaffs_write(h,xx,600)) == 600)
397 f = yaffs_freespace(path);
399 result = yaffs_close(h);
400 printf(" close %d\n",result);
404 void fill_disk_and_delete(const char *path, int nfiles, int ncycles)
410 for(i = 0; i < ncycles; i++)
412 printf("@@@@@@@@@@@@@@ cycle %d\n",i);
413 fill_disk(path,nfiles);
415 for(j = 0; j < nfiles; j++)
417 sprintf(str,"%s/%d",path,j);
418 result = yaffs_unlink(str);
419 printf("unlinking file %s, result %d\n",str,result);
425 void fill_files(const char *path,int flags, int maxIterations,int siz)
435 sprintf(str,"%s/%d",path,i);
436 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
440 for(j = 0; j < siz; j++)
442 yaffs_write(h,str,1);
451 } while(h >= 0 && i < maxIterations);
457 sprintf(str,"%s/%d",path,i);
458 printf("unlink %s\n",str);
460 } while(yaffs_unlink(str) >= 0);
464 void leave_unlinked_file(char *path,int maxIterations,int siz)
473 sprintf(str,"%s/%d",path,i);
474 printf("create %s\n",str);
475 h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
481 } while(h < 0 && i < maxIterations);
485 for(i = 0; i < siz; i++)
487 yaffs_write(h,str,1);
491 printf("Leaving file %s open\n",str);
495 void dumpDirFollow(const char *dname)
502 d = yaffs_opendir(dname);
506 printf("opendir failed\n");
510 while((de = yaffs_readdir(d)) != NULL)
512 sprintf(str,"%s/%s",dname,de->d_name);
516 printf("%s ino %d length %d mode %X ",de->d_name,(int)s.st_ino,(int)s.st_size,s.st_mode);
517 switch(s.st_mode & S_IFMT)
519 case S_IFREG: printf("data file"); break;
520 case S_IFDIR: printf("directory"); break;
521 case S_IFLNK: printf("symlink -->");
522 if(yaffs_readlink(str,str,100) < 0)
525 printf("\"%s\"",str);
527 default: printf("unknown"); break;
537 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
542 void dump_directory_tree_worker(const char *dname,int recursive)
549 d = yaffs_opendir(dname);
553 printf("opendir failed\n");
557 while((de = yaffs_readdir(d)) != NULL)
559 sprintf(str,"%s/%s",dname,de->d_name);
563 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);
564 switch(s.st_mode & S_IFMT)
566 case S_IFREG: printf("data file"); break;
567 case S_IFDIR: printf("directory"); break;
568 case S_IFLNK: printf("symlink -->");
569 if(yaffs_readlink(str,str,100) < 0)
572 printf("\"%s\"",str);
574 default: printf("unknown"); break;
579 if((s.st_mode & S_IFMT) == S_IFDIR && recursive)
580 dump_directory_tree_worker(str,1);
589 static void dump_directory_tree(const char *dname)
591 dump_directory_tree_worker(dname,1);
593 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
596 void dumpDir(const char *dname)
597 { dump_directory_tree_worker(dname,0);
599 printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
603 static void PermissionsCheck(const char *path, mode_t tmode, int tflags,int expectedResult)
607 if(yaffs_chmod(path,tmode)< 0) printf("chmod failed\n");
609 fd = yaffs_open(path,tflags,0);
611 if((fd >= 0) != (expectedResult > 0))
613 printf("Permissions check %x %x %d failed\n",tmode,tflags,expectedResult);
617 printf("Permissions check %x %x %d OK\n",tmode,tflags,expectedResult);
626 int long_test(int argc, char *argv[])
637 struct yaffs_stat ystat;
641 yaffs_mount("/boot");
642 yaffs_mount("/data");
643 yaffs_mount("/flash");
646 printf("\nDirectory look-up of /boot\n");
648 printf("\nDirectory look-up of /data\n");
650 printf("\nDirectory look-up of /flash\n");
653 //leave_unlinked_file("/flash",20000,0);
654 //leave_unlinked_file("/data",20000,0);
656 leave_unlinked_file("/ram",20,0);
659 f = yaffs_open("/boot/b1", O_RDONLY,0);
661 printf("open /boot/b1 readonly, f=%d\n",f);
663 f = yaffs_open("/boot/b1", O_CREAT,S_IREAD | S_IWRITE);
665 printf("open /boot/b1 O_CREAT, f=%d\n",f);
668 r = yaffs_write(f,"hello",1);
669 printf("write %d attempted to write to a read-only file\n",r);
673 printf("close %d\n",r);
675 f = yaffs_open("/boot/b1", O_RDWR,0);
677 printf("open /boot/b1 O_RDWR,f=%d\n",f);
680 r = yaffs_write(f,"hello",2);
681 printf("write %d attempted to write to a writeable file\n",r);
682 r = yaffs_write(f,"world",3);
683 printf("write %d attempted to write to a writeable file\n",r);
685 r= yaffs_lseek(f,0,SEEK_END);
686 printf("seek end %d\n",r);
688 r = yaffs_read(f,buffer,10);
689 printf("read %d \"%s\"\n",r,buffer);
690 r= yaffs_lseek(f,0,SEEK_SET);
691 printf("seek set %d\n",r);
693 r = yaffs_read(f,buffer,10);
694 printf("read %d \"%s\"\n",r,buffer);
696 r = yaffs_read(f,buffer,10);
697 printf("read %d \"%s\"\n",r,buffer);
699 // Check values reading at end.
700 // A read past end of file should return 0 for 0 bytes read.
702 r= yaffs_lseek(f,0,SEEK_END);
703 r = yaffs_read(f,buffer,10);
704 printf("read at end returned %d\n",r);
705 r= yaffs_lseek(f,500,SEEK_END);
706 r = yaffs_read(f,buffer,10);
707 printf("read past end returned %d\n",r);
711 printf("close %d\n",r);
713 copy_in_a_file("/boot/yyfile","xxx");
715 // Create a file with a long name
717 copy_in_a_file("/boot/file with a long name","xxx");
720 printf("\nDirectory look-up of /boot\n");
724 r = yaffs_stat("/boot/file with a long name",&ystat);
728 r = yaffs_rename("/boot/file with a long name","/boot/r1");
730 printf("\nDirectory look-up of /boot\n");
734 r = yaffs_unlink("/boot/r1");
736 printf("\nDirectory look-up of /boot\n");
741 r = yaffs_mkdir("/boot/directory1",0);
743 printf("\nDirectory look-up of /boot\n");
745 printf("\nDirectory look-up of /boot/directory1\n");
746 dumpDir("/boot/directory1");
748 // add a file to the directory
749 copy_in_a_file("/boot/directory1/file with a long name","xxx");
751 printf("\nDirectory look-up of /boot\n");
753 printf("\nDirectory look-up of /boot/directory1\n");
754 dumpDir("/boot/directory1");
756 // Attempt to delete directory (should fail)
758 r = yaffs_rmdir("/boot/directory1");
760 printf("\nDirectory look-up of /boot\n");
762 printf("\nDirectory look-up of /boot/directory1\n");
763 dumpDir("/boot/directory1");
765 // Delete file first, then rmdir should work
766 r = yaffs_unlink("/boot/directory1/file with a long name");
767 r = yaffs_rmdir("/boot/directory1");
770 printf("\nDirectory look-up of /boot\n");
772 printf("\nDirectory look-up of /boot/directory1\n");
773 dumpDir("/boot/directory1");
776 fill_disk_and_delete("/boot",20,20);
778 printf("\nDirectory look-up of /boot\n");
782 yaffs_symlink("yyfile","/boot/slink");
784 yaffs_readlink("/boot/slink",str,100);
785 printf("symlink alias is %s\n",str);
790 printf("\nDirectory look-up of /boot\n");
792 printf("\nDirectory look-up of /boot (using stat instead of lstat)\n");
793 dumpDirFollow("/boot");
794 printf("\nDirectory look-up of /boot/directory1\n");
795 dumpDir("/boot/directory1");
797 h = yaffs_open("/boot/slink",O_RDWR,0);
799 printf("file length is %d\n",(int)yaffs_lseek(h,0,SEEK_END));
803 yaffs_unlink("/boot/slink");
806 printf("\nDirectory look-up of /boot\n");
811 yaffs_stat("/boot/yyfile",&ystat);
812 temp_mode = ystat.st_mode;
814 yaffs_chmod("/boot/yyfile",0x55555);
815 printf("\nDirectory look-up of /boot\n");
818 yaffs_chmod("/boot/yyfile",temp_mode);
819 printf("\nDirectory look-up of /boot\n");
822 // Permission checks...
823 PermissionsCheck("/boot/yyfile",0, O_WRONLY,0);
824 PermissionsCheck("/boot/yyfile",0, O_RDONLY,0);
825 PermissionsCheck("/boot/yyfile",0, O_RDWR,0);
827 PermissionsCheck("/boot/yyfile",S_IREAD, O_WRONLY,0);
828 PermissionsCheck("/boot/yyfile",S_IREAD, O_RDONLY,1);
829 PermissionsCheck("/boot/yyfile",S_IREAD, O_RDWR,0);
831 PermissionsCheck("/boot/yyfile",S_IWRITE, O_WRONLY,1);
832 PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDONLY,0);
833 PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDWR,0);
835 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_WRONLY,1);
836 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDONLY,1);
837 PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDWR,1);
839 yaffs_chmod("/boot/yyfile",temp_mode);
841 //create a zero-length file and unlink it (test for scan bug)
843 h = yaffs_open("/boot/zlf",O_CREAT | O_TRUNC | O_RDWR,0);
846 yaffs_unlink("/boot/zlf");
849 yaffs_DumpDevStruct("/boot");
851 fill_disk_and_delete("/boot",20,20);
853 yaffs_DumpDevStruct("/boot");
855 fill_files("/boot",1,10000,0);
856 fill_files("/boot",1,10000,5000);
857 fill_files("/boot",2,10000,0);
858 fill_files("/boot",2,10000,5000);
860 leave_unlinked_file("/data",20000,0);
861 leave_unlinked_file("/data",20000,5000);
862 leave_unlinked_file("/data",20000,5000);
863 leave_unlinked_file("/data",20000,5000);
864 leave_unlinked_file("/data",20000,5000);
865 leave_unlinked_file("/data",20000,5000);
867 yaffs_DumpDevStruct("/boot");
868 yaffs_DumpDevStruct("/data");
876 int huge_directory_test_on_path(char *path)
896 // Create a large number of files
898 for(i = 0; i < 2000; i++)
900 sprintf(str,"%s/%d",path,i);
902 f = yaffs_open(str,O_CREAT,S_IREAD | S_IWRITE);
908 d = yaffs_opendir(path);
911 while((de = yaffs_readdir(d)) != NULL) {
912 if (total >lastTotal+100*9*1024||(i & 1023)==0){
913 printf("files = %d, total = %d\n",i, total);
917 sprintf(str,"%s/%s",path,de->d_name);
919 switch(s.st_mode & S_IFMT){
921 //printf("data file");
933 int yaffs_scan_test(const char *path)
939 void rename_over_test(const char *mountpt)
946 sprintf(a,"%s/a",mountpt);
947 sprintf(b,"%s/b",mountpt);
948 sprintf(c,"%s/c",mountpt);
952 yaffs_mount(mountpt);
954 printf("Existing files\n");
955 dumpDirFollow(mountpt);
959 i = yaffs_open(c,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
960 printf("File c handle is %d\n",i);
962 i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
964 i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
966 yaffs_rename(a,b); // rename over
967 yaffs_rename(b,a); // rename back again (not renaimng over)
968 yaffs_rename(a,b); // rename back again (not renaimng over)
971 yaffs_unmount(mountpt);
976 int resize_stress_test(const char *path)
991 sprintf(aname,"%s%s",path,"/a");
992 sprintf(bname,"%s%s",path,"/b");
994 memset(abuffer,'a',1000);
995 memset(bbuffer,'b',1000);
997 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
998 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1000 printf(" %s %d %s %d\n",aname,a,bname,b);
1004 for(j = 0; j < 100; j++)
1006 yaffs_lseek(a,0,SEEK_END);
1009 for(i = 0; i <20000; i++)
1011 //r = yaffs_lseek(b,i,SEEK_SET);
1012 //r = yaffs_write(b,bbuffer,1000);
1017 int syz = yaffs_lseek(a,0,SEEK_END);
1020 if(syz < 0) syz = 0;
1021 yaffs_ftruncate(a,syz);
1027 r = yaffs_lseek(a,i * 500,SEEK_SET);
1028 r = yaffs_write(a,abuffer,1000);
1040 int overwrite_test(const char *path)
1052 sprintf(aname,"%s%s",path,"/a");
1053 sprintf(bname,"%s%s",path,"/b");
1055 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1056 for(j= 0; j < 500; j++){
1057 yaffs_write(b,bname,100);
1058 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1059 for(i = 0; i < rand() % 20000; i++)
1060 yaffs_write(a,&a,sizeof(a));
1069 int root_perm_remount(const char *path)
1071 struct yaffs_stat s;
1077 yaffs_stat(path,&s);
1078 printf("root perms after mount %x\n",s.st_mode);
1080 yaffs_chmod(path, 0777);
1082 yaffs_stat(path,&s);
1083 printf("root perms after setting to 0777 is %x\n",s.st_mode);
1085 yaffs_unmount(path);
1092 int resize_stress_test_no_grow_complex(const char *path,int iters)
1108 sprintf(aname,"%s%s",path,"/a");
1109 sprintf(bname,"%s%s",path,"/b");
1111 memset(abuffer,'a',1000);
1112 memset(bbuffer,'b',1000);
1114 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1115 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1117 printf(" %s %d %s %d\n",aname,a,bname,b);
1121 for(j = 0; j < iters; j++)
1123 yaffs_lseek(a,0,SEEK_END);
1126 for(i = 0; i <20000; i++)
1128 //r = yaffs_lseek(b,i,SEEK_SET);
1129 //r = yaffs_write(b,bbuffer,1000);
1134 int syz = yaffs_lseek(a,0,SEEK_END);
1140 if(syz < 0) syz = 0;
1141 yaffs_ftruncate(a,syz);
1142 syz = yaffs_lseek(a,0,SEEK_END);
1143 printf("shrink to %d\n",syz);
1151 r = yaffs_lseek(a,500,SEEK_END);
1152 r = yaffs_write(a,abuffer,1000);
1159 printf("file size is %lld\n",(long long)yaffs_lseek(a,0,SEEK_END));
1167 int resize_stress_test_no_grow(const char *path,int iters)
1182 sprintf(aname,"%s%s",path,"/a");
1183 sprintf(bname,"%s%s",path,"/b");
1185 memset(abuffer,'a',1000);
1186 memset(bbuffer,'b',1000);
1188 a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1189 b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1191 printf(" %s %d %s %d\n",aname,a,bname,b);
1195 for(j = 0; j < iters; j++)
1197 yaffs_lseek(a,0,SEEK_END);
1200 for(i = 0; i <20000; i++)
1202 //r = yaffs_lseek(b,i,SEEK_SET);
1203 //r = yaffs_write(b,bbuffer,1000);
1208 int syz = yaffs_lseek(a,0,SEEK_END);
1214 if(syz < 0) syz = 0;
1215 yaffs_ftruncate(a,syz);
1216 syz = yaffs_lseek(a,0,SEEK_END);
1217 printf("shrink to %d\n",syz);
1225 r = yaffs_lseek(a,-500,SEEK_END);
1226 r = yaffs_write(a,abuffer,1000);
1232 printf("file size is %lld\n",(long long)yaffs_lseek(a,0,SEEK_END));
1240 int directory_rename_test(void)
1245 yaffs_mount("/ram");
1246 yaffs_mkdir("/ram/a",0);
1247 yaffs_mkdir("/ram/a/b",0);
1248 yaffs_mkdir("/ram/c",0);
1250 printf("\nDirectory look-up of /ram\n");
1253 dumpDir("/ram/a/b");
1255 printf("Do rename (should fail)\n");
1257 r = yaffs_rename("/ram/a","/ram/a/b/d");
1258 printf("\nDirectory look-up of /ram\n");
1261 dumpDir("/ram/a/b");
1263 printf("Do rename (should not fail)\n");
1265 r = yaffs_rename("/ram/c","/ram/a/b/d");
1266 printf("\nDirectory look-up of /ram\n");
1269 dumpDir("/ram/a/b");
1276 int cache_read_test(void)
1280 int sizeOfFiles = 500000;
1285 yaffs_mount("/boot");
1287 make_a_file("/boot/a",'a',sizeOfFiles);
1288 make_a_file("/boot/b",'b',sizeOfFiles);
1290 a = yaffs_open("/boot/a",O_RDONLY,0);
1291 b = yaffs_open("/boot/b",O_RDONLY,0);
1292 c = yaffs_open("/boot/c", O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
1296 if (i > 100) i = 100;
1298 yaffs_read(a,buffer,i);
1299 yaffs_read(b,buffer,i);
1300 yaffs_write(c,buffer,i);
1301 } while(sizeOfFiles > 0);
1309 int cache_bypass_bug_test(void)
1311 // This test reporoduces a bug whereby YAFFS caching *was* buypassed
1312 // resulting in erroneous reads after writes.
1313 // This bug has been fixed.
1319 memset(buffer1,0,sizeof(buffer1));
1320 memset(buffer2,0,sizeof(buffer2));
1324 yaffs_mount("/boot");
1326 // Create a file of 2000 bytes.
1327 make_a_file("/boot/a",'X',2000);
1329 a = yaffs_open("/boot/a",O_RDWR, S_IREAD | S_IWRITE);
1331 // Write a short sequence to the file.
1332 // This will go into the cache.
1333 yaffs_lseek(a,0,SEEK_SET);
1334 yaffs_write(a,"abcdefghijklmnopqrstuvwxyz",20);
1336 // Read a short sequence from the file.
1337 // This will come from the cache.
1338 yaffs_lseek(a,0,SEEK_SET);
1339 yaffs_read(a,buffer1,30);
1341 // Read a page size sequence from the file.
1342 yaffs_lseek(a,0,SEEK_SET);
1343 yaffs_read(a,buffer2,512);
1345 printf("buffer 1 %s\n",buffer1);
1346 printf("buffer 2 %s\n",buffer2);
1348 if(strncmp(buffer1,buffer2,20))
1350 printf("Cache bypass bug detected!!!!!\n");
1358 int free_space_check(void)
1363 yaffs_mount("/boot");
1364 fill_disk("/boot/",2);
1365 f = yaffs_freespace("/boot");
1367 printf("%d free when disk full\n",f);
1371 int truncate_test(void)
1381 yaffs_mount("/boot");
1383 yaffs_unlink("/boot/trunctest");
1385 a = yaffs_open("/boot/trunctest", O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1387 yaffs_write(a,"abcdefghijklmnopqrstuvwzyz",26);
1389 yaffs_ftruncate(a,3);
1390 l= yaffs_lseek(a,0,SEEK_END);
1392 printf("truncated length is %d\n",l);
1394 yaffs_lseek(a,5,SEEK_SET);
1395 yaffs_write(a,"1",1);
1397 yaffs_lseek(a,0,SEEK_SET);
1399 r = yaffs_read(a,y,10);
1401 printf("read %d bytes:",r);
1403 for(i = 0; i < r; i++) printf("[%02X]",y[i]);
1415 void fill_disk_test(const char *mountpt)
1420 for(i = 0; i < 5; i++)
1422 yaffs_mount(mountpt);
1423 fill_disk_and_delete(mountpt,100,i+1);
1424 yaffs_unmount(mountpt);
1430 void fill_files_test(const char *mountpt)
1435 for(i = 0; i < 5; i++)
1437 yaffs_mount(mountpt);
1438 fill_files(mountpt,2,3,100);
1439 yaffs_unmount(mountpt);
1444 void fill_empty_files_test(const char *mountpt)
1453 for(i = 0; i < 5; i++)
1455 yaffs_mount(mountpt);
1456 for(d = 0; result >= 0 && d < 1000; d++){
1457 sprintf(name,"%s/%d",mountpt,d);
1458 result= yaffs_mkdir(name,0);
1459 printf("creating directory %s result %d\n",name,result);
1461 for(f = 0; result >= 0 && f < 100; f++){
1462 sprintf(name,"%s/%d/%d",mountpt,d,f);
1463 result= yaffs_open(name,O_CREAT, 0);
1464 yaffs_close(result);
1465 printf("creating file %s result %d\n",name,result);
1468 yaffs_unmount(mountpt);
1473 void long_name_test(const char *mountpt)
1477 char fullName[1000];
1483 // Make a 256 byte name
1484 memset(name,0,sizeof(name));
1485 for(i = 0; i < 256; i++)
1486 name[i] = '0' + i % 10;
1488 sprintf(fullName,"%s/%s",mountpt,name);
1490 for(i = 0; i < 1; i++)
1492 yaffs_mount(mountpt);
1494 printf("Files at start\n");
1497 printf("Creating file %s\n",fullName);
1499 f = yaffs_open(fullName,O_CREAT | O_RDWR,0);
1502 printf("Result %d\n",f);
1507 printf("Deleting %s\n",fullName);
1508 result = yaffs_unlink(fullName);
1509 printf("Result %d\n",result);
1515 yaffs_unmount(mountpt);
1521 void lookup_test(const char *mountpt)
1533 yaffs_mount(mountpt);
1535 d = yaffs_opendir(mountpt);
1539 printf("opendir failed\n");
1544 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1546 printf("unlinking %s\n",de->d_name);
1547 yaffs_unlink(de->d_name);
1550 printf("%d files deleted\n",i);
1554 for(i = 0; i < 2000; i++){
1555 sprintf(a,"%s/%d",mountpt,i);
1556 h = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0);
1561 for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
1563 printf("%d %s\n",i,de->d_name);
1566 printf("%d files listed\n\n\n",i);
1573 for(i = 0; i < 2000; i++){
1574 sprintf(a,"%s/%d",mountpt,i);
1579 yaffs_unmount(mountpt);
1583 void link_test0(const char *mountpt)
1592 yaffs_mount(mountpt);
1595 sprintf(namea,"%s/a",mountpt);
1596 sprintf(nameb,"%s/b",mountpt);
1598 printf("mounted\n");
1601 yaffs_unlink(namea);
1602 printf("a unlinked\n");
1605 yaffs_unlink(nameb);
1606 printf("b unlinked\n");
1609 result = yaffs_open(namea,O_CREAT| O_RDWR,0666);
1610 yaffs_close(result);
1611 printf("a created\n");
1614 yaffs_link(namea,nameb);
1617 yaffs_unlink(namea);
1618 printf("a ulinked\n");
1620 yaffs_unlink(nameb);
1621 printf("b unlinked\n");
1624 yaffs_unmount(mountpt);
1628 void link_test1(const char *mountpt)
1636 sprintf(a,"%s/aaa",mountpt);
1637 sprintf(b,"%s/bbb",mountpt);
1638 sprintf(c,"%s/ccc",mountpt);
1642 yaffs_mount(mountpt);
1645 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1646 for(i = 0; i < 100; i++)
1647 yaffs_write(h,a,100);
1660 yaffs_unmount(mountpt);
1661 yaffs_mount(mountpt);
1663 printf("link test done\n");
1666 void handle_test(const char *mountpt)
1673 sprintf(a,"%s/aaa",mountpt);
1677 yaffs_mount(mountpt);
1679 for(cycle = 0; cycle < 5; cycle++){
1680 printf("Start cycle %d\n",cycle);
1683 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1684 printf("%d handle %d\n",i,h);
1694 yaffs_unmount(mountpt);
1697 void freespace_test(const char *mountpt)
1707 sprintf(a,"%s/aaa",mountpt);
1711 yaffs_mount(mountpt);
1713 f0 = yaffs_freespace(mountpt);
1715 h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1717 for(i = 0; i < 100; i++)
1718 yaffs_write(h,a,100);
1722 f1 = yaffs_freespace(mountpt);
1726 f2 = yaffs_freespace(mountpt);
1729 yaffs_unmount(mountpt);
1730 yaffs_mount(mountpt);
1732 f3 = yaffs_freespace(mountpt);
1734 printf("%d\n%d\n%d\n%d\n",f0, f1,f2,f3);
1739 void simple_rw_test(const char *mountpt)
1748 sprintf(a,"%s/aaa",mountpt);
1752 yaffs_mount(mountpt);
1756 h = yaffs_open(a,O_CREAT| O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1758 for(i = 100000;i < 200000; i++){
1759 result = yaffs_write(h,&i,sizeof(i));
1763 printf("write error\n");
1770 // h = yaffs_open(a,O_RDWR, S_IREAD | S_IWRITE);
1773 yaffs_lseek(h,0,SEEK_SET);
1775 for(i = 100000; i < 200000; i++){
1776 result = yaffs_read(h,&x,sizeof(x));
1778 if(result != 4 || x != i){
1779 printf("read error %d %x %x\n",i,result,x);
1783 printf("Simple rw test passed\n");
1790 void scan_deleted_files_test(const char *mountpt)
1802 sprintf(sub,"%s/sdir",mountpt);
1805 for(j = 0; j < 10; j++)
1807 printf("\n\n>>>>>>> Run %d <<<<<<<<<<<<<\n\n",j);
1808 yaffs_mount(mountpt);
1812 p = (j & 0) ? mountpt: sub;
1814 for(i = 0; i < 100; i++)
1816 sprintf(fn,"%s/%d",p,i);
1820 h = yaffs_open(fn,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1821 for(k = 0; k < 1000; k++)
1822 yaffs_write(h,fn,100);
1829 for(i = 0; i < 10; i++)
1831 sprintf(fn,"%s/%d",p,i);
1839 yaffs_unmount(mountpt);
1848 void write_10k(int h)
1851 const char *s="0123456789";
1852 for(i = 0; i < 1000; i++)
1853 yaffs_write(h,s,10);
1856 void write_200k_file(const char *fn, const char *fdel, const char *fdel1)
1862 h1 = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
1864 for(i = 0; i < 100000; i+= 10000)
1869 offs = yaffs_lseek(h1,0,SEEK_CUR);
1872 printf("Could not write file\n");
1876 for(i = 0; i < 100000; i+= 10000)
1881 offs = yaffs_lseek(h1,0,SEEK_CUR);
1884 printf("Could not write file\n");
1888 yaffs_unlink(fdel1);
1893 void verify_200k_file(const char *fn)
1898 const char *s="0123456789";
1901 h1 = yaffs_open(fn, O_RDONLY, 0);
1903 for(i = 0; i < 200000 && errCount < 10; i+= 10)
1905 yaffs_read(h1,x,10);
1906 if(strncmp(x,s,10) != 0)
1908 printf("File %s verification failed at %d\n",fn,i);
1913 printf("Too many errors... aborted\n");
1920 void check_resize_gc_bug(const char *mountpt)
1929 sprintf(a,"%s/a",mountpt);
1930 sprintf(b,"%s/b",mountpt);
1931 sprintf(c,"%s/c",mountpt);
1937 yaffs_mount(mountpt);
1941 for(i = 0; i < 50; i++)
1943 printf("A\n");write_200k_file(a,"",c);
1944 printf("B\n");verify_200k_file(a);
1945 printf("C\n");write_200k_file(b,a,c);
1946 printf("D\n");verify_200k_file(b);
1947 yaffs_unmount(mountpt);
1948 yaffs_mount(mountpt);
1949 printf("E\n");verify_200k_file(a);
1950 printf("F\n");verify_200k_file(b);
1956 void multi_mount_test(const char *mountpt,int nmounts)
1964 sprintf(a,"%s/a",mountpt);
1968 for(i = 0; i < nmounts; i++){
1974 static char xx[1000];
1976 printf("############### Iteration %d Start\n",i);
1977 if(1 || i == 0 || i == 5)
1978 yaffs_mount(mountpt);
1980 dump_directory_tree(mountpt);
1985 sprintf(xx,"%s/0",a);
1986 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
1988 sprintf(xx,"%s/1",a);
1989 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
1992 for(j = 0; j < 200; j++){
1993 yaffs_write(h0,xx,1000);
1994 yaffs_write(h1,xx,1000);
1997 while(yaffs_write(h0,xx,1000) > 0){
1999 yaffs_write(h1,xx,1000);
2002 len0 = yaffs_lseek(h0,0,SEEK_END);
2003 len1 = yaffs_lseek(h1,0,SEEK_END);
2005 yaffs_lseek(h0,0,SEEK_SET);
2006 yaffs_lseek(h1,0,SEEK_SET);
2008 for(j = 0; j < 200; j++){
2009 yaffs_read(h0,xx,1000);
2010 yaffs_read(h1,xx,1000);
2014 // yaffs_truncate(h0,0);
2018 printf("########### %d\n",i);
2019 dump_directory_tree(mountpt);
2021 if(1 || i == 4 || i == nmounts -1)
2022 yaffs_unmount(mountpt);
2027 void small_mount_test(const char *mountpt,int nmounts)
2041 sprintf(a,"%s/a",mountpt);
2047 for(i = 0; i < nmounts; i++){
2049 static char xx[1000];
2051 printf("############### Iteration %d Start\n",i);
2052 if(1 || i == 0 || i == 5)
2053 yaffs_mount(mountpt);
2055 dump_directory_tree(mountpt);
2059 sprintf(xx,"%s/0",a);
2062 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2063 for(j = 0; j < 130; j++)
2064 yaffs_write(h0,xx,1000);
2068 h0 = yaffs_open(xx,O_RDONLY,0);
2070 sprintf(xx,"%s/1",a);
2071 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2073 while((nread = yaffs_read(h0,xx,1000)) > 0)
2074 yaffs_write(h1,xx,nread);
2077 len0 = yaffs_lseek(h0,0,SEEK_END);
2078 len1 = yaffs_lseek(h1,0,SEEK_END);
2080 yaffs_lseek(h0,0,SEEK_SET);
2081 yaffs_lseek(h1,0,SEEK_SET);
2083 for(j = 0; j < 200; j++){
2084 yaffs_read(h0,xx,1000);
2085 yaffs_read(h1,xx,1000);
2091 printf("########### %d\n",i);
2092 dump_directory_tree(mountpt);
2094 if(1 || i == 4 || i == nmounts -1)
2095 yaffs_unmount(mountpt);
2102 void small_overwrite_test(const char *mountpt,int nmounts)
2113 sprintf(a,"%s/a",mountpt);
2119 for(i = 0; i < nmounts; i++){
2121 static char xx[8000];
2123 printf("############### Iteration %d Start\n",i);
2125 yaffs_mount(mountpt);
2127 dump_directory_tree(mountpt);
2131 sprintf(xx,"%s/0",a);
2132 h0 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2133 sprintf(xx,"%s/1",a);
2134 h1 = yaffs_open(xx, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2136 for(j = 0; j < 1000000; j+=1000){
2137 yaffs_ftruncate(h0,j);
2138 yaffs_lseek(h0,j,SEEK_SET);
2139 yaffs_write(h0,xx,7000);
2140 yaffs_write(h1,xx,7000);
2148 printf("########### %d\n",i);
2149 dump_directory_tree(mountpt);
2152 yaffs_unmount(mountpt);
2157 void seek_overwrite_test(const char *mountpt,int nmounts)
2168 sprintf(a,"%s/f",mountpt);
2172 yaffs_mount(mountpt);
2175 for(i = 0; i < nmounts; i++){
2177 h0 = yaffs_open(a, O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2179 for(j = 0; j < 100000; j++){
2180 yaffs_lseek(h0,0,SEEK_SET);
2181 yaffs_write(h0,xx,5000);
2182 yaffs_lseek(h0,0x100000,SEEK_SET);
2183 yaffs_write(h0,xx,5000);
2195 void yaffs_touch(const char *fn)
2197 yaffs_chmod(fn, S_IREAD | S_IWRITE);
2200 void checkpoint_fill_test(const char *mountpt,int nmounts)
2211 sprintf(a,"%s/a",mountpt);
2218 for(i = 0; i < nmounts; i++){
2219 printf("############### Iteration %d Start\n",i);
2220 yaffs_mount(mountpt);
2221 dump_directory_tree(mountpt);
2224 sprintf(b,"%s/zz",a);
2226 h = yaffs_open(b,O_CREAT | O_RDWR,S_IREAD |S_IWRITE);
2229 while(yaffs_write(h,c,50) == 50){}
2233 for(j = 0; j < 2; j++){
2234 printf("touch %d\n",j);
2236 yaffs_unmount(mountpt);
2237 yaffs_mount(mountpt);
2240 dump_directory_tree(mountpt);
2241 yaffs_unmount(mountpt);
2246 int make_file2(const char *name1, const char *name2,int syz)
2256 h1 = yaffs_open(name1,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2258 h2 = yaffs_open(name2,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2260 while(syz > 0 && n > 0){
2261 i = (syz > 2500) ? 2500 : syz;
2262 n = yaffs_write(h1,xx,i);
2263 n = yaffs_write(h2,xx,i);
2272 extern void SetCheckpointReservedBlocks(int n);
2274 void checkpoint_upgrade_test(const char *mountpt,int nmounts)
2284 sprintf(a,"%s/a",mountpt);
2289 printf("Create start condition\n");
2291 yaffs_mount(mountpt);
2293 sprintf(b,"%s/zz",a);
2294 sprintf(c,"%s/xx",a);
2295 make_file2(b,c,2000000);
2296 sprintf(d,"%s/aa",a);
2297 make_file2(d,NULL,500000000);
2298 dump_directory_tree(mountpt);
2300 printf("Umount/mount attempt full\n");
2301 yaffs_unmount(mountpt);
2303 yaffs_mount(mountpt);
2305 printf("unlink small file\n");
2307 dump_directory_tree(mountpt);
2309 printf("Umount/mount attempt\n");
2310 yaffs_unmount(mountpt);
2311 yaffs_mount(mountpt);
2313 for(j = 0; j < 500; j++){
2314 printf("***** touch %d\n",j);
2315 dump_directory_tree(mountpt);
2317 yaffs_unmount(mountpt);
2318 yaffs_mount(mountpt);
2321 for(j = 0; j < 500; j++){
2322 printf("***** touch %d\n",j);
2323 dump_directory_tree(mountpt);
2325 yaffs_unmount(mountpt);
2326 yaffs_mount(mountpt);
2330 void huge_array_test(const char *mountpt,int n)
2341 sprintf(a,"mount point %s",mountpt);
2347 yaffs_mount(mountpt);
2352 printf("\n\n START run\n\n");
2353 while((space = yaffs_freespace(mountpt)) > 25000000){
2354 sprintf(a,"%s/file%d",mountpt,fnum);
2356 printf("create file %s, free space %d\n",a,space);
2357 create_file_of_size(a,10000000);
2358 printf("verifying file %s\n",a);
2359 verify_file_of_size(a,10000000);
2362 printf("\n\n verification/deletion\n\n");
2364 for(i = 0; i < fnum; i++){
2365 sprintf(a,"%s/file%d",mountpt,i);
2366 printf("verifying file %s\n",a);
2367 verify_file_of_size(a,10000000);
2368 printf("deleting file %s\n",a);
2371 printf("\n\n done \n\n");
2378 void random_write(int h)
2380 static char buffer[12000];
2383 n = random() & 0x1FFF;
2384 yaffs_write(h,buffer,n);
2387 void random_seek(int h)
2390 n = random() & 0xFFFFF;
2391 yaffs_lseek(h,n,SEEK_SET);
2394 void random_truncate(int h, char * name)
2398 n = random() & 0xFFFFF;
2399 flen = yaffs_lseek(h,0,SEEK_END);
2402 yaffs_ftruncate(h,n);
2403 yaffs_lseek(h,n,SEEK_SET);
2407 #define NSMALLFILES 10
2408 void random_small_file_test(const char *mountpt,int iterations)
2411 char a[NSMALLFILES][50];
2422 yaffs_mount(mountpt);
2424 for(i = 0; i < NSMALLFILES; i++){
2429 for(n = 0; n < iterations; n++){
2431 for(i = 0; i < NSMALLFILES; i++) {
2434 if(strlen(a[i]) == 0){
2435 sprintf(a[i],"%s/%dx%d",mountpt,n,i);
2436 h[i] = yaffs_open(a[i],O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
2440 printf("Could not open yaffs file %d %d error %d\n",n,i,h[i]);
2450 random_truncate(h[i],a[i]);
2453 case 5: random_seek(h[i]);
2470 for(i = 0; i < NSMALLFILES; i++)
2473 yaffs_unmount(mountpt);
2476 void rmdir_test(const char *mountpt)
2481 yaffs_mount(mountpt);
2483 strcpy(name,mountpt);
2485 strcat(name,"hello");
2486 yaffs_mkdir(name,0666);
2488 yaffs_unmount(mountpt);
2493 static void print_xattrib_val(const char *path, const char *name)
2498 n = yaffs_getxattr(path,name,buffer,sizeof(buffer));
2500 __u8 *b = (__u8 *)buffer;
2502 printf("%d bytes:",n);
2506 printf("[%02X]",*b);
2512 printf(" Novalue result %d\n",n);
2515 static void list_xattr(const char *path)
2522 list_len = yaffs_listxattr(path,list,sizeof(list));
2523 printf("xattribs for %s, result is %d\n",path,list_len);
2524 while(n < list_len){
2525 len = strlen(list + n);
2526 printf("\"%s\" value ",list+n);
2527 print_xattrib_val(path,list + n);
2533 void basic_xattr_test(const char *mountpt)
2543 yaffs_mount(mountpt);
2545 strcpy(name,mountpt);
2547 strcat(name,"xfile");
2550 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2556 printf("Add an attribute\n");
2558 result = yaffs_setxattr(name,"foo",&val1,sizeof(val1),0);
2559 printf("wrote attribute foo: result %d\n",result);
2561 printf("Add an attribute\n");
2563 result = yaffs_setxattr(name,"bar",&val1,sizeof(val1),0);
2564 printf("wrote attribute bar: result %d\n",result);
2567 printf("Get non-existanrt attribute\n");
2568 print_xattrib_val(name,"not here");
2570 printf("Delete non existing attribute\n");
2571 yaffs_removexattr(name,"not here");
2574 printf("Remove foo\n");
2575 yaffs_removexattr(name,"foo");
2578 printf("Remove bar\n");
2579 yaffs_removexattr(name,"bar");
2584 void big_xattr_test(const char *mountpt)
2594 yaffs_mount(mountpt);
2596 strcpy(name,mountpt);
2598 strcat(name,"xfile");
2601 h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
2607 printf("Add a large attribute\n");
2608 memset(val,0x1,sizeof(val));
2609 result = yaffs_setxattr(name,"aaa",val,200,0);
2610 printf("wrote attribute aaa: result %d\n",result);
2613 printf("Add a large attribute\n");
2614 memset(val,0x2,sizeof(val));
2615 result = yaffs_setxattr(name,"bbb",val,1000,0);
2616 printf("wrote attribute bbb: result %d\n",result);
2619 printf("Replace attribute\n");
2620 memset(val,0x3,sizeof(val));
2621 result = yaffs_setxattr(name,"aaa",val,1000,0);
2622 printf("wrote attribute aaa: result %d\n",result);
2629 int simulate_power_failure;
2631 int main(int argc, char *argv[])
2633 random_seed = time(NULL);
2634 //return long_test(argc,argv);
2636 //return cache_read_test();
2638 // resize_stress_test_no_grow("/flash/flash",20);
2639 //root_perm_remount("/flash/flash");
2641 //huge_directory_test_on_path("/ram2k");
2643 //yaffs_backward_scan_test("/flash/flash");
2644 // yaffs_device_flush_test("/flash/flash");
2646 //rename_over_test("//////////////////flash///////////////////yaffs1///////////");
2648 //fill_empty_files_test("/yaffs2/");
2649 //resize_stress_test("/yaffs2");
2650 //overwrite_test("/yaffs2");
2652 //long_name_test("/yaffs2");
2653 //link_test0("/yaffs2");
2654 //link_test1("yaffs2");
2655 //scan_pattern_test("/flash",10000,10);
2656 //short_scan_test("/flash/flash",40000,200);
2657 //small_mount_test("/flash/flash",1000);
2658 //small_overwrite_test("/flash/flash",1000);
2659 //seek_overwrite_test("/flash/flash",1000);
2660 //checkpoint_fill_test("/flash/flash",20);
2661 //checkpoint_upgrade_test("/flash/flash",20);
2662 //small_overwrite_test("/flash/flash",1000);
2663 //checkpoint_fill_test("/flash/flash",20);
2664 // random_small_file_test("/flash/flash",10000);
2665 // huge_array_test("/flash/flash",10);
2668 // handle_test("yaffs2/");
2670 //long_test_on_path("/ram2k");
2671 // long_test_on_path("/flash");
2672 //simple_rw_test("/flash/flash");
2673 //fill_disk_test("/flash/flash");
2674 // rename_over_test("/flash");
2675 //lookup_test("/flash");
2676 //freespace_test("/flash/flash");
2678 //link_test("/flash/flash");
2683 // cache_bypass_bug_test();
2685 //free_space_check();
2687 //check_resize_gc_bug("/flash");
2689 basic_xattr_test("/yaffs2");
2690 big_xattr_test("/yaffs2");