Exemplo n.º 1
0
void simple_rw_test(const char *mountpt)
{
	int i;
	int h;
	char a[100];
	
	int x;
	int result;

	sprintf(a,"%s/aaa",mountpt);
	
	yaffs_StartUp();
	
	yaffs_mount(mountpt);
	
	yaffs_unlink(a);
	
	h = yaffs_open(a,O_CREAT| O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
	
	for(i = 100000;i < 200000; i++){
		result = yaffs_write(h,&i,sizeof(i));
		
		if(result != 4)
		{
			printf("write error\n");
			exit(1);
		}
	}
	
	//yaffs_close(h);
	
	// h = yaffs_open(a,O_RDWR, S_IREAD | S_IWRITE);
	
	
	yaffs_lseek(h,0,SEEK_SET);
	
	for(i = 100000; i < 200000; i++){
		result = yaffs_read(h,&x,sizeof(x));
		
		if(result != 4 || x != i){
			printf("read error %d %x %x\n",i,result,x);
		}
	}
	
	printf("Simple rw test passed\n");
	
	
	
}
Exemplo n.º 2
0
void basic_xattr_test(const char *mountpt)
{
	char name[100];
	int h;
	int result;
	int val1;

	yaffs_StartUp();

	yaffs_mount(mountpt);

	strcpy(name,mountpt);
	strcat(name,"/");
	strcat(name,"xfile");

	yaffs_unlink(name);
	h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
	yaffs_close(h);

	printf("Start\n");
	list_xattr(name);

	printf("Add an attribute\n");
	val1 = 0x123456;
	result = yaffs_setxattr(name,"foo",&val1,sizeof(val1),0);
	printf("wrote attribute foo: result %d\n",result);
	list_xattr(name);
	printf("Add an attribute\n");
	val1 = 0x7890;
	result = yaffs_setxattr(name,"bar",&val1,sizeof(val1),0);
	printf("wrote attribute bar: result %d\n",result);
	list_xattr(name);

	printf("Get non-existanrt attribute\n");
	print_xattrib_val(name,"not here");

	printf("Delete non existing attribute\n");
	yaffs_removexattr(name,"not here");
	list_xattr(name);

	printf("Remove foo\n");
	yaffs_removexattr(name,"foo");
	list_xattr(name);

	printf("Remove bar\n");
	yaffs_removexattr(name,"bar");
	list_xattr(name);

}
Exemplo n.º 3
0
void do_some_file_stuff(const char *path)
{

	char fn[100];

	sprintf(fn,"%s/%s",path,"f1");
	create_file_of_size(fn,10000);

	sprintf(fn,"%s/%s",path,"fdel");
	create_file_of_size(fn,10000);
	yaffs_unlink(fn);

	sprintf(fn,"%s/%s",path,"f2");
	
	create_resized_file_of_size(fn,10000,3000,4000);
}
Exemplo n.º 4
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");
			
		   
	}
}
Exemplo n.º 5
0
void long_name_test(const char *mountpt)
{
	int i;
	yaffs_StartUp();
	char fullName[1000];
	char name[300];
	int result = 0;
	
	int f;
	
	// Make a 256 byte name
	memset(name,0,sizeof(name));
	for(i = 0; i < 256; i++)
		name[i] = '0' + i % 10;
		
	sprintf(fullName,"%s/%s",mountpt,name);

	for(i = 0; i < 1; i++)
	{
		yaffs_mount(mountpt);
		
		printf("Files at start\n");
		dumpDir(mountpt);
		
		printf("Creating file %s\n",fullName);
		
		f = yaffs_open(fullName,O_CREAT | O_RDWR,0);
		yaffs_close(f);
		
		printf("Result %d\n",f);
			
		printf("Files\n");
		dumpDir(mountpt);
		
		printf("Deleting %s\n",fullName);
		result = yaffs_unlink(fullName);
		printf("Result %d\n",result);
		
		printf("Files\n");
		
		dumpDir(mountpt);
		
		yaffs_unmount(mountpt);
	}
	
}
Exemplo n.º 6
0
int test_yaffs_link_ENOENT4_clean(void)
{
	int output=0;	
	int error =0;
	output= yaffs_unlink(HARD_LINK_PATH);
	if (output<0){
		error=yaffs_get_error();
		if (abs(error)==ENOENT){
			//if the file does not exist then the error should be ENOENT.
			return 1;
		} else {
			print_message("different error than expected\n",2);
			return -1;
		}
	} else {
		return 1;	/* the file failed to open so there is no need to close it */
	}
}
Exemplo n.º 7
0
int test_yaffs_unlink_NULL(void)
{
	int error_code=0;

	handle=yaffs_unlink(NULL);
	if (handle==-1){
		error_code=yaffs_get_error();
		if (abs(error_code) == EFAULT){
			return 1;
		} else {
			print_message("different error than expected\n",2);
			return -1;
		}
	} else {
		print_message("NULL path unlinked.(which is a bad thing)\n",2);
		return -1;
	}

}
int test_yaffs_rename_file_to_dir_clean(void)
{
    int output = 0;
    test_yaffs_open();
    if (0 ==  yaffs_access(RENAME_DIR_PATH,0)) {
        output = yaffs_unlink(RENAME_DIR_PATH);
        if (output < 0) {
            print_message("failed to unlink the file\n",2);
            return -1;
        }
        output = test_yaffs_open();
        if (output < 0) {
            print_message("failed to open a new\n",2);
            return -1;
        }
    }
    return 1;

}
Exemplo n.º 9
0
void fill_disk_and_delete(const char *path, int nfiles, int ncycles)
{
	int i,j;
	char str[50];
	int result;
	
	for(i = 0; i < ncycles; i++)
	{
		printf("@@@@@@@@@@@@@@ cycle %d\n",i);
		fill_disk(path,nfiles);
		
		for(j = 0; j < nfiles; j++)
		{
			sprintf(str,"%s/%d",path,j);
			result = yaffs_unlink(str);
			printf("unlinking file %s, result %d\n",str,result);
		}
	}
}
Exemplo n.º 10
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);
	
	
}
Exemplo n.º 11
0
void big_xattr_test(const char *mountpt)
{
	char name[100];
	int h;
	int result;
	char val[1000];

	yaffs_StartUp();

	yaffs_mount(mountpt);

	strcpy(name,mountpt);
	strcat(name,"/");
	strcat(name,"xfile");

	yaffs_unlink(name);
	h = yaffs_open(name,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE);
	yaffs_close(h);

	printf("Start\n");
	list_xattr(name);

	printf("Add a large  attribute\n");
	memset(val,0x1,sizeof(val));
	result = yaffs_setxattr(name,"aaa",val,200,0);
	printf("wrote attribute aaa: result %d\n",result);
	list_xattr(name);

	printf("Add a large  attribute\n");
	memset(val,0x2,sizeof(val));
	result = yaffs_setxattr(name,"bbb",val,1000,0);
	printf("wrote attribute bbb: result %d\n",result);
	list_xattr(name);

	printf("Replace attribute\n");
	memset(val,0x3,sizeof(val));
	result = yaffs_setxattr(name,"aaa",val,1000,0);
	printf("wrote attribute aaa: result %d\n",result);
	list_xattr(name);

}
int test_yaffs_rename_dir_clean(void)
{
	int output = 0;
	if (0 ==  yaffs_access("/yaffs2/new_directory/file",0)) {
		output = yaffs_unlink("/yaffs2/new_directory/file");
		if (output < 0) {
			print_message("failed to remove file\n",2);
			return -1;
		}
	}

	if (0 ==  yaffs_access(RENAME_DIR_PATH,0)) {
		output = yaffs_rename(RENAME_DIR_PATH,DIR_PATH);
		if (output < 0) {
			print_message("failed to rename the dir\n",2);
			return -1;
		}
	}
	return 1;

}
Exemplo n.º 13
0
int test_yaffs_rename_EEXISTS_clean(void)
{
	int output = 0;
	if (0 ==  yaffs_access("/yaffs2/dir2/file",0) ) {
		output = yaffs_unlink("/yaffs2/dir2/file");
		if (output < 0) {
			print_message("failed to remove the file\n",2);
			return -1;
		}
	}
	if (0 ==  yaffs_access(RENAME_PATH,0) && 0 != yaffs_access(DIR_PATH,0)) {
		output = yaffs_rename(RENAME_PATH,FILE_PATH);
		if (output < 0) {
			print_message("failed to remove the directory\n",2);
			return -1;
		}
	}
	
	return 1;

}
Exemplo n.º 14
0
int truncate_test(void)
{
	int a;
	int r;
	int i;
	int l;

	char y[10];

	yaffs_StartUp();
	yaffs_mount("/boot");

	yaffs_unlink("/boot/trunctest");
	
	a = yaffs_open("/boot/trunctest", O_CREAT | O_TRUNC | O_RDWR,  S_IREAD | S_IWRITE);
	
	yaffs_write(a,"abcdefghijklmnopqrstuvwzyz",26);
	
	yaffs_ftruncate(a,3);
	l= yaffs_lseek(a,0,SEEK_END);
	
	printf("truncated length is %d\n",l);

	yaffs_lseek(a,5,SEEK_SET);
	yaffs_write(a,"1",1);

	yaffs_lseek(a,0,SEEK_SET);
	
	r = yaffs_read(a,y,10);

	printf("read %d bytes:",r);

	for(i = 0; i < r; i++) printf("[%02X]",y[i]);

	printf("\n");

	return 0;

}
Exemplo n.º 15
0
V5MF_HANDLE V5M_fopen(char *filename, char *rwmode)
{
	/*if (strcmp(rwmode, "wb") == 0)
		return yaffs_open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
	else */
	V5MF_HANDLE fp;

	
	if (strcmp(rwmode, "rb") == 0)
	{
		fp = yaffs_open(filename, O_RDONLY,  S_IREAD | S_IWRITE);
		if (fp == -1)
			return 0;
		return fp;
	}
	else if (strcmp(rwmode, "wb") == 0)
	{
		yaffs_unlink(filename);
		return yaffs_open(filename,  O_CREAT | O_RDWR | O_TRUNC,  S_IREAD | S_IWRITE);
	}
	else return 0;
}
Exemplo n.º 16
0
int test_yaffs_unlink_ENOTDIR(void)
{
	int output=0;
	int error_code=0;
	if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){
		print_message("failed to create file before remounting\n",1);
		return -1;
	}
	output=yaffs_unlink("/yaffs2/test_dir/foo/file");
	if (output==-1){
		error_code=yaffs_get_error();
		if (abs(error_code)==ENOTDIR){
			return 1;
		} else {
			print_message("different error than expected\n",2);
			return -1;
		}
	} else {
		print_message("non existant directory opened.(which is a bad thing)\n",2);
		return -1;
	}


}
Exemplo n.º 17
0
static int __yaffs_unlink(mount_point_t *point, const char *path)
{
    return yaffs_unlink(vfs_path_add_mount_point(path));
Exemplo n.º 18
0
int test_yaffs_symlink_EROFS_clean(void)
{
	return (EROFS_clean() && yaffs_unlink(SYMLINK_PATH));
}
Exemplo n.º 19
0
int long_test(int argc, char *argv[])
{

	int f;
	int r;
	char buffer[20];
	
	char str[100];
	
	int h;
	mode_t temp_mode;
	struct yaffs_stat ystat;
	
	yaffs_StartUp();
	
	yaffs_mount("/boot");
	yaffs_mount("/data");
	yaffs_mount("/flash");
	yaffs_mount("/ram");
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	printf("\nDirectory look-up of /data\n");
	dumpDir("/data");
	printf("\nDirectory look-up of /flash\n");
	dumpDir("/flash");

	//leave_unlinked_file("/flash",20000,0);
	//leave_unlinked_file("/data",20000,0);
	
	leave_unlinked_file("/ram",20,0);
	

	f = yaffs_open("/boot/b1", O_RDONLY,0);
	
	printf("open /boot/b1 readonly, f=%d\n",f);
	
	f = yaffs_open("/boot/b1", O_CREAT,S_IREAD | S_IWRITE);
	
	printf("open /boot/b1 O_CREAT, f=%d\n",f);
	
	
	r = yaffs_write(f,"hello",1);
	printf("write %d attempted to write to a read-only file\n",r);
	
	r = yaffs_close(f);
	
	printf("close %d\n",r);

	f = yaffs_open("/boot/b1", O_RDWR,0);
	
	printf("open /boot/b1 O_RDWR,f=%d\n",f);
	
	
	r = yaffs_write(f,"hello",2);
	printf("write %d attempted to write to a writeable file\n",r);
	r = yaffs_write(f,"world",3);
	printf("write %d attempted to write to a writeable file\n",r);
	
	r= yaffs_lseek(f,0,SEEK_END);
	printf("seek end %d\n",r);
	memset(buffer,0,20);
	r = yaffs_read(f,buffer,10);
	printf("read %d \"%s\"\n",r,buffer);
	r= yaffs_lseek(f,0,SEEK_SET);
	printf("seek set %d\n",r);
	memset(buffer,0,20);
	r = yaffs_read(f,buffer,10);
	printf("read %d \"%s\"\n",r,buffer);
	memset(buffer,0,20);
	r = yaffs_read(f,buffer,10);
	printf("read %d \"%s\"\n",r,buffer);

	// Check values reading at end.
	// A read past end of file should return 0 for 0 bytes read.
		
	r= yaffs_lseek(f,0,SEEK_END);
	r = yaffs_read(f,buffer,10);
	printf("read at end returned  %d\n",r); 
	r= yaffs_lseek(f,500,SEEK_END);
	r = yaffs_read(f,buffer,10);
	printf("read past end returned  %d\n",r);       
	
	r = yaffs_close(f);
	
	printf("close %d\n",r);
	
	copy_in_a_file("/boot/yyfile","xxx");
	
	// Create a file with a long name
	
	copy_in_a_file("/boot/file with a long name","xxx");
	
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");

	// Check stat
	r = yaffs_stat("/boot/file with a long name",&ystat);
	
	// Check rename
	
	r = yaffs_rename("/boot/file with a long name","/boot/r1");
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	
	// Check unlink
	r = yaffs_unlink("/boot/r1");
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");

	// Check mkdir
	
	r = yaffs_mkdir("/boot/directory1",0);
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	printf("\nDirectory look-up of /boot/directory1\n");
	dumpDir("/boot/directory1");

	// add a file to the directory                  
	copy_in_a_file("/boot/directory1/file with a long name","xxx");
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	printf("\nDirectory look-up of /boot/directory1\n");
	dumpDir("/boot/directory1");
	
	//  Attempt to delete directory (should fail)
	
	r = yaffs_rmdir("/boot/directory1");
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	printf("\nDirectory look-up of /boot/directory1\n");
	dumpDir("/boot/directory1");
	
	// Delete file first, then rmdir should work
	r = yaffs_unlink("/boot/directory1/file with a long name");
	r = yaffs_rmdir("/boot/directory1");
	
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	printf("\nDirectory look-up of /boot/directory1\n");
	dumpDir("/boot/directory1");

#if 0
	fill_disk_and_delete("/boot",20,20);
			
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
#endif

	yaffs_symlink("yyfile","/boot/slink");
	
	yaffs_readlink("/boot/slink",str,100);
	printf("symlink alias is %s\n",str);
	
	
	
	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	printf("\nDirectory look-up of /boot (using stat instead of lstat)\n");
	dumpDirFollow("/boot");
	printf("\nDirectory look-up of /boot/directory1\n");
	dumpDir("/boot/directory1");

	h = yaffs_open("/boot/slink",O_RDWR,0);
	
	printf("file length is %d\n",(int)yaffs_lseek(h,0,SEEK_END));
	
	yaffs_close(h);
	
	yaffs_unlink("/boot/slink");

	
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	
	// Check chmod
	
	yaffs_stat("/boot/yyfile",&ystat);
	temp_mode = ystat.st_mode;
	
	yaffs_chmod("/boot/yyfile",0x55555);
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	
	yaffs_chmod("/boot/yyfile",temp_mode);
	printf("\nDirectory look-up of /boot\n");
	dumpDir("/boot");
	
	// Permission checks...
	PermissionsCheck("/boot/yyfile",0, O_WRONLY,0);
	PermissionsCheck("/boot/yyfile",0, O_RDONLY,0);
	PermissionsCheck("/boot/yyfile",0, O_RDWR,0);

	PermissionsCheck("/boot/yyfile",S_IREAD, O_WRONLY,0);
	PermissionsCheck("/boot/yyfile",S_IREAD, O_RDONLY,1);
	PermissionsCheck("/boot/yyfile",S_IREAD, O_RDWR,0);

	PermissionsCheck("/boot/yyfile",S_IWRITE, O_WRONLY,1);
	PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDONLY,0);
	PermissionsCheck("/boot/yyfile",S_IWRITE, O_RDWR,0);
	
	PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_WRONLY,1);
	PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDONLY,1);
	PermissionsCheck("/boot/yyfile",S_IREAD | S_IWRITE, O_RDWR,1);

	yaffs_chmod("/boot/yyfile",temp_mode);
	
	//create a zero-length file and unlink it (test for scan bug)
	
	h = yaffs_open("/boot/zlf",O_CREAT | O_TRUNC | O_RDWR,0);
	yaffs_close(h);
	
	yaffs_unlink("/boot/zlf");
	
	
	yaffs_DumpDevStruct("/boot");
	
	fill_disk_and_delete("/boot",20,20);
	
	yaffs_DumpDevStruct("/boot");
	
	fill_files("/boot",1,10000,0);
	fill_files("/boot",1,10000,5000);
	fill_files("/boot",2,10000,0);
	fill_files("/boot",2,10000,5000);
	
	leave_unlinked_file("/data",20000,0);
	leave_unlinked_file("/data",20000,5000);
	leave_unlinked_file("/data",20000,5000);
	leave_unlinked_file("/data",20000,5000);
	leave_unlinked_file("/data",20000,5000);
	leave_unlinked_file("/data",20000,5000);
	
	yaffs_DumpDevStruct("/boot");
	yaffs_DumpDevStruct("/data");
	
		
		
	return 0;

}
Exemplo n.º 20
0
int test_yaffs_symlink_EEXIST_clean(void)
{
		return yaffs_unlink(SYMLINK_PATH);
}
Exemplo n.º 21
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;
	}
		
	
}
Exemplo n.º 22
0
void random_small_file_test(const char *mountpt,int iterations)
{

	char a[NSMALLFILES][50];

	
	int i;
	int n;
	int h[NSMALLFILES];
	int r;
	
	
	yaffs_StartUp();

	yaffs_mount(mountpt);
	
	for(i = 0; i < NSMALLFILES; i++){
		h[i]=-1;
		strcpy(a[i],"");
	}
	
	for(n = 0; n < iterations; n++){
				
		for(i = 0; i < NSMALLFILES; i++) {
			r = random();
			
			if(strlen(a[i]) == 0){
				sprintf(a[i],"%s/%dx%d",mountpt,n,i);
				h[i] = yaffs_open(a[i],O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
			}
			
			if(h[i] < -1)
				printf("Could not open yaffs file %d %d error %d\n",n,i,h[i]);
			else {
				r = r & 7;
				switch(r){
					case 0:
					case 1:
					case 2:
						random_write(h[i]);
						break;
					case 3:
						random_truncate(h[i],a[i]);
						break;
					case 4:
					case 5:	random_seek(h[i]);
						break;
					case 6:
						yaffs_close(h[i]);
						h[i] = -1;
						break;
					case 7:
						yaffs_close(h[i]);
						yaffs_unlink(a[i]);
						strcpy(a[i],"");
						h[i] = -1;
				}
			}
		}
		   
	}
	
	for(i = 0; i < NSMALLFILES; i++)
		yaffs_close(h[i]);
		
	yaffs_unmount(mountpt);
}
Exemplo n.º 23
0
void lookup_test(const char *mountpt)
{
	int i;
	int h;
	char a[100];
	

	yaffs_DIR *d;
	yaffs_dirent *de;

	yaffs_StartUp();
	
	yaffs_mount(mountpt);
				
	d = yaffs_opendir(mountpt);
	
	if(!d)
	{
		printf("opendir failed\n");
	}
	else
	{
		
		for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
		{
			printf("unlinking %s\n",de->d_name);
			yaffs_unlink(de->d_name);
		}
		
		printf("%d files deleted\n",i);
	}
	
	
	for(i = 0; i < 2000; i++){
	sprintf(a,"%s/%d",mountpt,i);
		h =  yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, 0);
		yaffs_close(h);
	}

	yaffs_rewinddir(d);
	for(i = 0; (de = yaffs_readdir(d)) != NULL; i++)
	{
		printf("%d  %s\n",i,de->d_name);
	}	
	
	printf("%d files listed\n\n\n",i);
	
	yaffs_rewinddir(d);
	yaffs_readdir(d);
	yaffs_readdir(d);
	yaffs_readdir(d);
	
	for(i = 0; i < 2000; i++){
		sprintf(a,"%s/%d",mountpt,i);
		yaffs_unlink(a);
	}
	
		
	yaffs_unmount(mountpt);
	
}