Ejemplo n.º 1
0
void fill_disk(const char *path,int nfiles)
{
	int h;
	int n;
	int result;
	int f;

        static char xx[600];	
	char str[50];
	
	for(n = 0; n < nfiles; n++)
	{
		sprintf(str,"%s/%d",path,n);
		
		h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
		
		printf("writing file %s handle %d ",str, h);
		
		while ((result = yaffs_write(h,xx,600)) == 600)
		{
			f = yaffs_freespace(path);
		}
		result = yaffs_close(h);
		printf(" close %d\n",result);
	}
}
Ejemplo n.º 2
0
void cmd_yaffs_dev_ls(void)
{
	struct yaffs_dev *dev;
	int flash_dev;
	int free_space;

	yaffs_dev_rewind();

	while (1) {
		dev = yaffs_next_dev();
		if (!dev)
			return;
		flash_dev =
			((unsigned) dev->driver_context - (unsigned) nand_info)/
				sizeof(nand_info[0]);
		printf("%-10s %5d 0x%05x 0x%05x %s",
			dev->param.name, flash_dev,
			dev->param.start_block, dev->param.end_block,
			dev->param.inband_tags ? "using inband tags, " : "");

		free_space = yaffs_freespace(dev->param.name);
		if (free_space < 0)
			printf("not mounted\n");
		else
			printf("free 0x%x\n", free_space);

	}
}
Ejemplo n.º 3
0
void freespace_test(const char *mountpt)
{
	int i;
	int h;
	char a[100];
	char b[100];
	
	int  f0;
	int f1;
	int f2;
	int f3;
	sprintf(a,"%s/aaa",mountpt);
	
	yaffs_StartUp();
	
	yaffs_mount(mountpt);
	
	f0 = yaffs_freespace(mountpt);
	
	h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
	
	for(i = 0; i < 100; i++)
		yaffs_write(h,a,100);
	
	yaffs_close(h);
	
	f1 = yaffs_freespace(mountpt);
	
	yaffs_unlink(a);
	
	f2 = yaffs_freespace(mountpt);
	
		
	yaffs_unmount(mountpt);
	yaffs_mount(mountpt);
	
	f3 = yaffs_freespace(mountpt);
	
	printf("%d\n%d\n%d\n%d\n",f0, f1,f2,f3);
	
	
}
Ejemplo n.º 4
0
int free_space_check(void)
{
	int f;
	
		yaffs_StartUp();
		yaffs_mount("/boot");
	    fill_disk("/boot/",2);
	    f = yaffs_freespace("/boot");
	    
	    printf("%d free when disk full\n",f);           
	    return 1;
}
Ejemplo n.º 5
0
void huge_array_test(const char *mountpt,int n)
{

	char a[50];

	
	int i;
	int j;
	int h;
	
	int fnum;
	
	sprintf(a,"mount point %s",mountpt);
	

	
	yaffs_StartUp();

	yaffs_mount(mountpt);
	
	while(n>0){
		n--;
		fnum = 0;
		printf("\n\n START run\n\n");
		while(yaffs_freespace(mountpt) > 25000000){
			sprintf(a,"%s/file%d",mountpt,fnum);
			fnum++;
			printf("create file %s\n",a);
			create_file_of_size(a,10000000);
			printf("verifying file %s\n",a);
			verify_file_of_size(a,10000000);
		}
		
		printf("\n\n\ verification/deletion\n\n");
		
		for(i = 0; i < fnum; i++){
			sprintf(a,"%s/file%d",mountpt,i);
			printf("verifying file %s\n",a);
			verify_file_of_size(a,10000000);
			printf("deleting file %s\n",a);
			yaffs_unlink(a);
		}
		printf("\n\n\ done \n\n");
			
		   
	}
}
Ejemplo n.º 6
0
void dumpDirFollow(const char *dname)
{
	yaffs_DIR *d;
	yaffs_dirent *de;
	struct yaffs_stat s;
	char str[100];
			
	d = yaffs_opendir(dname);
	
	if(!d)
	{
		printf("opendir failed\n");
	}
	else
	{
		while((de = yaffs_readdir(d)) != NULL)
		{
			sprintf(str,"%s/%s",dname,de->d_name);
			
			yaffs_stat(str,&s);
			
			printf("%s ino %d length %d mode %X ",de->d_name,(int)s.st_ino,(int)s.st_size,s.st_mode);
			switch(s.st_mode & S_IFMT)
			{
				case S_IFREG: printf("data file"); break;
				case S_IFDIR: printf("directory"); break;
				case S_IFLNK: printf("symlink -->");
							  if(yaffs_readlink(str,str,100) < 0)
								printf("no alias");
							  else
								printf("\"%s\"",str);    
							  break;
				default: printf("unknown"); break;
			}
			
			printf("\n");           
		}
		
		yaffs_closedir(d);
	}
	printf("\n");
	
	printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));

}
Ejemplo n.º 7
0
int test_yaffs_freespace_NULL(void)
{
	int output=0;
	int error=0;
	output = yaffs_freespace(NULL);
	if (output<0){
		error=yaffs_get_error();
		if (abs(error)==EFAULT){
			return 1;
		} else {
			print_message("different error than expected\n",2);
			return -1;
		}
	} else {
		print_message("got the free space of a NULL mountpoint (which is a bad thing)\n",2);
		return -1;
	}
}
Ejemplo n.º 8
0
void ListDir(const char *DirName)
{
	yaffs_DIR *d;
	yaffs_dirent *de;
	struct yaffs_stat s;
	char str[100];
			
	d = yaffs_opendir(DirName);
	
	if(!d)
	{
		printf("opendir failed\n");
	}
	else
	{
		printf("%s\n", DirName);
		while((de = yaffs_readdir(d)) != NULL)
		{
			sprintf(str,"%s/%s",DirName,de->d_name);
			yaffs_lstat(str,&s);
			printf("%20s        %8d     %5d    ", de->d_name, s.yst_size, s.yst_mode);
			
			switch(s.yst_mode & S_IFMT)
			{
				case S_IFREG: printf("data file"); break;
				case S_IFDIR: printf("directory"); break;
				case S_IFLNK: printf("symlink");   break;
				default: printf("unknown"); break;
			}
		
			printf("\n");		
		}
		
		yaffs_closedir(d);
	}
	
	printf("FreeSpace: %d\n\n", yaffs_freespace(DirName));
}
Ejemplo n.º 9
0
static void dump_directory_tree(const char *dname)
{
	dump_directory_tree_worker(dname,1);
	printf("\n");
	printf("Free space in %s is %d\n\n",dname,(int)yaffs_freespace(dname));
}
Ejemplo n.º 10
0
void yaffs_bash_around(const char *mountpt, int n_cycles)
{
	char name[200];
	char name1[200];
	int  h[BASH_HANDLES];
	int i;
	int op;
	int pos;
	int n;
	int n1;
	int start_op;
	int op_max = 99;
	
	int cycle = 0;
	
	sprintf(name,"%s/bashdir",mountpt);
	
	yaffs_mkdir(name,0666);

	for(i = 0; i < BASH_HANDLES; i++)
		h[i] = -1;
		
	while(n_cycles){
		if(cycle % 100 == 0){
			printf("CYCLE %8d mo %2d inodes %d space %d ",cycle,op_max,
				yaffs_inodecount(mountpt),(int)yaffs_freespace(mountpt));
			for(i = 0; i < BASH_HANDLES; i++)
				printf("%2d ",h[i]);
			printf("\n");
		}
		cycle++;

		if(n_cycles > 0)
			n_cycles--;
		i = rand() % BASH_HANDLES;
		op = rand() % op_max;
		pos = rand() & 20000000;
		n = rand() % 100;
		n1 = rand() % 100;
		
		sprintf(name,"%s/bashdir/xx%d",mountpt,n);
		sprintf(name1,"%s/bashdir/xx%d",mountpt,n1);

		start_op = op;
		
		op-=1;
		if(op < 0){
			if(h[i]>= 0){
				yaffs_close(h[i]);
				h[i] = -1;
			}
			continue;
		}
		op-=1;
		if(op < 0){
			if(h[i] < 0)
				h[i] = yaffs_open(name,O_CREAT| O_RDWR, 0666);
			continue;
		}

		op-=5;
		if(op< 0){
			yaffs_lseek(h[i],pos,SEEK_SET);
			yaffs_write(h[i],name,n);
			continue;
		}
		op-=1;
		if(op < 0){
			yaffs_unlink(name);
			continue;
		}
		op-=1;
		if(op < 0){
			yaffs_rename(name,name1);
			continue;
		}
		op-=1;
		if(op < 0){
			yaffs_mkdir(name,0666);
			continue;
		}
		op-=1;
		if(op < 0){
			yaffs_rmdir(name);
			continue;
		}
		
		op_max = start_op-op;
	}
		
	
}