+
+void fill_files(char *path,int flags, int maxIterations,int siz)
+{
+ int i;
+ int j;
+ char str[50];
+ int h;
+
+ i = 0;
+
+ do{
+ sprintf(str,"%s/%d",path,i);
+ h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
+ yaffs_close(h);
+
+ if(h >= 0)
+ {
+ for(j = 0; j < siz; j++)
+ {
+ yaffs_write(h,str,1);
+ }
+ }
+
+ if( flags & 1)
+ {
+ yaffs_unlink(str);
+ }
+ i++;
+ } while(h >= 0 && i < maxIterations);
+
+ if(flags & 2)
+ {
+ i = 0;
+ do{
+ sprintf(str,"%s/%d",path,i);
+ printf("unlink %s\n",str);
+ i++;
+ } while(yaffs_unlink(str) >= 0);
+ }
+}
+
+void leave_unlinked_file(char *path,int maxIterations,int siz)
+{
+ int i;
+ char str[50];
+ int h;
+
+ i = 0;
+
+ do{
+ sprintf(str,"%s/%d",path,i);
+ printf("create %s\n",str);
+ h = yaffs_open(str, O_CREAT | O_TRUNC | O_RDWR,S_IREAD | S_IWRITE);
+ if(h >= 0)
+ {
+ yaffs_unlink(str);
+ }
+ i++;
+ } while(h < 0 && i < maxIterations);
+
+ if(h >= 0)
+ {
+ for(i = 0; i < siz; i++)
+ {
+ yaffs_write(h,str,1);
+ }
+ }
+
+ printf("Leaving file %s open\n",str);
+
+}
+