X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Ftest-framework%2Ftimothy_tests%2Fquick_tests%2Flib.c;h=2063d2c667e701dcc1b02c0fa458bd81ba8a04b2;hp=50723c3e1e6efbb907f64e836757706e51479a4e;hb=e40cfb32abd2a9147f6fc956fef433e794baadd0;hpb=e5daa72b0083831ab762a650860687fe7d25d6b3 diff --git a/direct/test-framework/timothy_tests/quick_tests/lib.c b/direct/test-framework/timothy_tests/quick_tests/lib.c index 50723c3..2063d2c 100644 --- a/direct/test-framework/timothy_tests/quick_tests/lib.c +++ b/direct/test-framework/timothy_tests/quick_tests/lib.c @@ -1,8 +1,7 @@ /* * YAFFS: Yet another FFS. A NAND-flash specific file system. * - * Copyright (C) 2002-2011 Aleph One Ltd. - * for Toby Churchill Ltd and Brightstar Engineering + * Copyright (C) 2002-2018 Aleph One Ltd. * * Created by Timothy Manning * @@ -37,6 +36,7 @@ int get_exit_on_error(void) int EROFS_setup(void) { int output= -1; + output=yaffs_remount(YAFFS_MOUNT_POINT,1,1); if (output<0){ print_message("failed to remount yaffs\n",2); @@ -125,9 +125,58 @@ void join_paths(char *path1,char *path2,char *new_path ) void print_message(char *message,char print_level) { if (print_level <= PRINT_LEVEL){ - printf(message); + printf("%s",message); } } - +/*same as forcing the rmdir of a directory*/ +int delete_dir(char *dir_name) +{ + char message[200]; + yaffs_DIR *d; + struct yaffs_dirent *de; + struct yaffs_stat s; + char str[300]; + d = yaffs_opendir(dir_name); + //printf("%s\n",dir_name); + if(!d) + { + sprintf(message,"\nfailed to open dir %s \n was trying to delete this",dir_name); + print_message(message,1); + + + get_error(); + return -1; + } + + while((de = yaffs_readdir(d)) != NULL) { + //stats the file + sprintf(str,"%s/%s",dir_name,de->d_name); + yaffs_lstat(str,&s); + + if ((s.st_mode & S_IFMT) == S_IFDIR){ + //it is a directory. call the function recursivly. + delete_dir(str); + yaffs_rmdir(str); + }else{ + yaffs_unlink(str); + } + } + yaffs_rmdir(dir_name); + yaffs_closedir(d); + return 1; +} + +void get_error(void) +{ + int error_code=0; + char message[30]; + message[0]='\0'; + + error_code=yaffs_get_error(); + sprintf(message,"yaffs_error code %d\n",error_code); + print_message(message,1); + sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code)); + print_message(message,1); +}