From: Timothy Manning Date: Fri, 22 Oct 2010 02:45:59 +0000 (+1300) Subject: yaffs commiting changes to timothy_tests X-Git-Tag: linux-mainline-rc-01~5 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=1006cb30d2977365c64e4dd544b445b088750061 yaffs commiting changes to timothy_tests Signed-off-by: Timothy Manning --- diff --git a/direct/python/README_yaffs_browser_py.txt b/direct/python/README_yaffs_browser_py.txt new file mode 100644 index 0000000..fad0b6f --- /dev/null +++ b/direct/python/README_yaffs_browser_py.txt @@ -0,0 +1,25 @@ +Readme for the yaffs_browser.py file +by Timothy Manning 2010 + +to run yaffs_browser: + python yaffs_browser.py + + +the yaffs browser is a gui interface used for browsing a yaffs emfile. +python and tkinter must be installed for browser to run. + sudo apt-get install python python-tk + +the yaffs_browser.py file must be run in yaffs/direct/python/ directory due to linking issues with python. + +browsing other emfiles + yaffs will mount the emfile in the same directory as the browser as default + to look at a emfile in a diffrent directory create a symbolic link to the emfile you wish to browse. + ln -s [target path] [emfile name] + + + +TODO list + Add scroll bars to all windows. + Add Ctrl + S short cut to save a file + Make the brower and editor window entry and list boxes resize when the window is maximized. + diff --git a/direct/python/README_yaffs_import_py.txt b/direct/python/README_yaffs_import_py.txt index 4f93cc4..fa9140e 100644 --- a/direct/python/README_yaffs_import_py.txt +++ b/direct/python/README_yaffs_import_py.txt @@ -1,4 +1,5 @@ Readme for the yaffs_import.py file +by Timothy Manning 2010 python yaffs_import [scanning_path] [optional flags] @@ -9,6 +10,7 @@ directories above this path and copy the all files in these directories. example: $ yaffs_importer.py /home/timothy/work/yaffs/ +yaffs_import.py must be run in yaffs/direct/python/ directory. flags: -d [number] @@ -44,3 +46,8 @@ Clear Yaffs the emfile-2k-0 file. this file is stored in the yaffs2/direct/python/ folder. the command is: rm emfile-2k-0 + +TODO list + Add fix the problem of yaffs_write() returning -1 when the disk is full.(generate a error message) + Add a yaffs error code refrence (prints a text message about the error) + diff --git a/direct/timothy_tests/error_handler.c b/direct/timothy_tests/error_handler.c index b41f732..90b3fad 100644 --- a/direct/timothy_tests/error_handler.c +++ b/direct/timothy_tests/error_handler.c @@ -1,19 +1,34 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * error_handler.c contains code for checking yaffs function calls for errors. + */ #include "error_handler.h" void yaffs_check_for_errors(char output, buffer *message_buffer,char error_message[],char success_message[]) { + char dummy='0'; if (output==-1) { - add_to_buffer(message_buffer, "error##########",MESSAGE_LEVEL_ERROR); - add_to_buffer(message_buffer, error_message,MESSAGE_LEVEL_ERROR); - add_to_buffer(message_buffer, "error_code",MESSAGE_LEVEL_ERROR); - if (MESSAGE_LEVEL_ERROR<=DEBUG_LEVEL) printf("%d\n",yaffs_get_error()); /*cannot yet add int types to buffer. this is a quick fix*/ - + add_to_buffer(message_buffer, "\nerror##########",MESSAGE_LEVEL_ERROR,PRINT); + add_to_buffer(message_buffer, error_message,MESSAGE_LEVEL_ERROR,PRINT); + add_to_buffer(message_buffer, "error_code: ",MESSAGE_LEVEL_ERROR,PRINT); + if (MESSAGE_LEVEL_ERROR<=DEBUG_LEVEL) printf("%d\n\n\n",yaffs_get_error()); /*cannot yet add int types to buffer. this is a quick fix*/ + scanf("%c",dummy); //print_buffer(message_buffer,PRINT_ALL); - + } else{ - add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS); + add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS,PRINT); } } diff --git a/direct/timothy_tests/error_handler.h b/direct/timothy_tests/error_handler.h index fad1ef8..c7cc3fd 100644 --- a/direct/timothy_tests/error_handler.h +++ b/direct/timothy_tests/error_handler.h @@ -1,3 +1,17 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning timothy@yaffs.net + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + #ifndef __error_handler_h__ #define __error_handler_h__ #include diff --git a/direct/timothy_tests/found_bugs.txt b/direct/timothy_tests/found_bugs.txt new file mode 100644 index 0000000..418f1dc --- /dev/null +++ b/direct/timothy_tests/found_bugs.txt @@ -0,0 +1,6 @@ +Found bugs in yaffs + +Error code 0 bug (run out of handles) + By opening lots of files and not closing them yaffs can run out of handles. + The error code given by yaffs_get_error() returns 0. this error is not defined in yportenv.h + diff --git a/direct/timothy_tests/message_buffer.c b/direct/timothy_tests/message_buffer.c index fe64a6b..58c3038 100644 --- a/direct/timothy_tests/message_buffer.c +++ b/direct/timothy_tests/message_buffer.c @@ -1,49 +1,72 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * message_buffer.c contains code for a message buffer . + */ + #include "message_buffer.h" +void append_to_buffer(buffer *p_Buffer, char *message,char message_level,char print){ + /*wrapper function for add_to_buffer_root_function*/ + add_to_buffer_root_function(p_Buffer,message, message_level,APPEND_MESSAGE,print); +} -void add_to_buffer(buffer *p_Buffer, char *message,char message_level){ - unsigned int x=0; - /*move the head up one. the head always points at the last written data*/ - p_Buffer->head++; +void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print){ + /*wrapper function for add_to_buffer_root_function*/ + add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); +} -// printf("p_Buffer->tail=%d\n",p_Buffer->tail); -// printf("p_Buffer->head=%d\n",p_Buffer->head); - if (p_Buffer->head >=BUFFER_SIZE-1) { -// printf("buffer overflow\n"); - p_Buffer->head -= (BUFFER_SIZE-1); /*wrap the head around the buffer*/ -// printf("new p_Buffer->head=%d\n",p_Buffer->head); - } - /*if the buffer is full then delete last entry by moving the tail*/ - if (p_Buffer->head==p_Buffer->tail){ -// printf("moving buffer tail from %d to ",p_Buffer->tail); - p_Buffer->tail++; - if (p_Buffer->tail >=BUFFER_SIZE) p_Buffer->tail -= BUFFER_SIZE;/*wrap the tail around the buffer*/ -// printf("%d\n",p_Buffer->tail); +void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print){ + if (append==APPEND_MESSAGE){ /* append current message*/ + strncat(p_Buffer->message[p_Buffer->head],message,BUFFER_MESSAGE_LENGTH); } + else { + /*move the head up one. the head always points at the last written data*/ + p_Buffer->head++; + /*printf("p_Buffer->tail=%d\n",p_Buffer->tail);*/ + /*printf("p_Buffer->head=%d\n",p_Buffer->head);*/ + if (p_Buffer->head >=BUFFER_SIZE-1) { + /*printf("buffer overflow\n");*/ + p_Buffer->head -= (BUFFER_SIZE-1); /*wrap the head around the buffer*/ + /*printf("new p_Buffer->head=%d\n",p_Buffer->head);*/ + } + /*if the buffer is full then delete last entry by moving the tail*/ + if (p_Buffer->head==p_Buffer->tail){ + /*printf("moving buffer tail from %d to ",p_Buffer->tail);*/ + p_Buffer->tail++; + if (p_Buffer->tail >=BUFFER_SIZE) p_Buffer->tail -= BUFFER_SIZE;/*wrap the tail around the buffer*/ + /*printf("%d\n",p_Buffer->tail);*/ + } - - - - p_Buffer->message_level[p_Buffer->head]=message_level; /*copy the message level*/ - x=p_Buffer->head; - - - - strcpy(p_Buffer->message[p_Buffer->head],message); /*copy the message*/ -// printf("copied %s into p_Buffer->message[p_Buffer->head]: %s\n",message,p_Buffer->message[p_Buffer->head]); -// printf("extra %s\n",p_Buffer->message[p_Buffer->head]); - - if (p_Buffer->message_level[p_Buffer->head]<=DEBUG_LEVEL){ -// printf("printing buffer 1\n"); - /* the print buffer sfunction is not working this is just a quick fix*/ -// print_buffer(p_Buffer,1); /*if the debug level is higher enough then print the new message*/ + p_Buffer->message_level[p_Buffer->head]=message_level; /*copy the message level*/ + strncpy(p_Buffer->message[p_Buffer->head],message,BUFFER_MESSAGE_LENGTH); /*copy the message*/ + /*printf("copied %s into p_Buffer->message[p_Buffer->head]: %s\n",message,p_Buffer->message[p_Buffer->head]); + printf("extra %s\n",p_Buffer->message[p_Buffer->head]);*/ + } + if ((p_Buffer->message_level[p_Buffer->head]<=DEBUG_LEVEL)&& (print==PRINT)){ + /*printf("printing buffer 1\n"); + // the print buffer function is not working this is just a quick fix + print_buffer(p_Buffer,1); //if the debug level is higher enough then print the new message + */ printf("%s\n",p_Buffer->message[p_Buffer->head]); } } + + + void print_buffer(buffer *p_Buffer, int number_of_messages_to_print){ int x=0; int i=0; diff --git a/direct/timothy_tests/message_buffer.h b/direct/timothy_tests/message_buffer.h index 5669f74..33f12dd 100644 --- a/direct/timothy_tests/message_buffer.h +++ b/direct/timothy_tests/message_buffer.h @@ -1,9 +1,26 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + #ifndef __message_buffer__ #define __message_buffer__ #include #include - +#define PRINT 1 +#define NPRINT 0 +#define APPEND_MESSAGE 1 +#define DO_NOT_APPEND_MESSAGE 0 #define PRINT_ALL -1 /*this is used to print all of the messages in a buffer*/ #define BUFFER_MESSAGE_LENGTH 60 /*number of char in message*/ #define BUFFER_SIZE 50 /*number of messages in buffer*/ @@ -17,7 +34,11 @@ typedef struct buffer_template{ }buffer; #include "error_handler.h" /*include this for the debug level*/ -void add_to_buffer(buffer *p_Buffer, char *message,char message_level); /*code for buffer*/ + void print_buffer(buffer *p_Buffer,int number_of_messages_to_print); /*print messages in the buffer*/ +/*wrapper functions for add_to_buffer_root_function*/ +void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); +void append_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); +void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print); #endif diff --git a/direct/timothy_tests/yaffs_tester.c b/direct/timothy_tests/yaffs_tester.c index b050e00..e8d8671 100644 --- a/direct/timothy_tests/yaffs_tester.c +++ b/direct/timothy_tests/yaffs_tester.c @@ -1,4 +1,18 @@ -/*yaffs_tester.c*/ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * yaffs_tester.c designed to stress test yaffs2 direct. + */ + #include "yaffs_tester.h" @@ -24,17 +38,21 @@ int main(){ void init(char *yaffs_test_dir,char *yaffs_mount_dir){ + char output=0; /*these variables are already set to zero, but it is better not to take chances*/ message_buffer.head=0; message_buffer.tail=0; - add_to_buffer(&message_buffer,"welcome to the yaffs tester",MESSAGE_LEVEL_BASIC_TASKS);/* print boot up message*/ + add_to_buffer(&message_buffer,"welcome to the yaffs tester",MESSAGE_LEVEL_BASIC_TASKS,PRINT);/* print boot up message*/ yaffs_start_up(); yaffs_mount(yaffs_mount_dir); if (yaffs_access(yaffs_test_dir,0)) { - yaffs_mkdir(yaffs_test_dir,S_IREAD | S_IWRITE); + add_to_buffer(&message_buffer,"creating dir: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer,yaffs_test_dir,MESSAGE_LEVEL_BASIC_TASKS,PRINT); + output=yaffs_mkdir(yaffs_test_dir,S_IREAD | S_IWRITE); + yaffs_check_for_errors(output, &message_buffer,"could not create dir","created dir\n\n"); } } @@ -44,9 +62,10 @@ void join_paths(char *path1,char *path2,char *new_path ){ printf("strlen path2:%d\n",strlen(path2)); printf("path1; %s\n",path1); */ - //add_to_buffer(&message_buffer, "joining paths\0",MESSAGE_LEVEL_BASIC_TASKS); - add_to_buffer(&message_buffer,path1,MESSAGE_LEVEL_BASIC_TASKS); - add_to_buffer(&message_buffer, path2,MESSAGE_LEVEL_BASIC_TASKS); + add_to_buffer(&message_buffer, "joining paths:",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer,path1,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer, " and ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer, path2,MESSAGE_LEVEL_BASIC_TASKS,PRINT); if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') { /*paths are compatiable. concatanate them. note -2 is because of \0*/ strcat(new_path,path1); @@ -115,8 +134,8 @@ void test(char*yaffs_test_dir){ path[0]='\0';// this should clear the path generate_random_string(name); join_paths(yaffs_test_dir,name,path); - add_to_buffer(&message_buffer,"trying to open file",MESSAGE_LEVEL_BASIC_TASKS); - add_to_buffer(&message_buffer,path,MESSAGE_LEVEL_BASIC_TASKS); + add_to_buffer(&message_buffer,"trying to open file: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer,path,MESSAGE_LEVEL_BASIC_TASKS,PRINT); output=yaffs_open(path,O_CREAT | O_TRUNC| O_RDWR, S_IREAD | S_IWRITE); yaffs_check_for_errors(output, &message_buffer,"failed to open file","opened file"); } @@ -124,12 +143,17 @@ void test(char*yaffs_test_dir){ void generate_random_string(char *ptr){ unsigned int x; unsigned int length=((rand() %MAX_FILE_NAME_SIZE)+1); /*creates a int with the number of charecters been between 1 and 51*/ + char letter='\0'; //printf("generating string\n"); //printf("string length is %d\n",length); for (x=0; x <= (length-2) &&length>2 ; x++) { //printf("x=%d\n",x); - ptr[x]=(rand() % 126-32)+32; /*generate a number between 32 and 126 and uses it as a charecter (letter) */ + /* keep generating a charecter until the charecter is legal*/ + while((letter=='\0' )||(letter=='/')||(letter=='\\')){ + letter=(rand() % 126-32)+32; /*generate a number between 32 and 126 and uses it as a charecter (letter) */ + } + ptr[x]=letter; //printf("charecter generated is %c\n",ptr[x]); } ptr[x+1]='\0'; /*adds NULL charecter to turn it into a string*/ diff --git a/direct/timothy_tests/yaffs_tester.h b/direct/timothy_tests/yaffs_tester.h index 6ca547f..1584b1a 100644 --- a/direct/timothy_tests/yaffs_tester.h +++ b/direct/timothy_tests/yaffs_tester.h @@ -1,4 +1,17 @@ -/*yaffs_tester.h */ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning timothy@yaffs.net + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + #ifndef __YAFFS_TESTER_H__ #define __YAFFS_TESTER_H__