yaffs commiting changes to timothy_tests
authorTimothy Manning <tfhmanning@gmail.com>
Fri, 22 Oct 2010 02:45:59 +0000 (15:45 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Fri, 22 Oct 2010 02:45:59 +0000 (15:45 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/python/README_yaffs_browser_py.txt [new file with mode: 0644]
direct/python/README_yaffs_import_py.txt
direct/timothy_tests/error_handler.c
direct/timothy_tests/error_handler.h
direct/timothy_tests/found_bugs.txt [new file with mode: 0644]
direct/timothy_tests/message_buffer.c
direct/timothy_tests/message_buffer.h
direct/timothy_tests/yaffs_tester.c
direct/timothy_tests/yaffs_tester.h

diff --git a/direct/python/README_yaffs_browser_py.txt b/direct/python/README_yaffs_browser_py.txt
new file mode 100644 (file)
index 0000000..fad0b6f
--- /dev/null
@@ -0,0 +1,25 @@
+Readme for the yaffs_browser.py file
+by Timothy Manning <timothy@yaffs.net> 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. 
+
index 4f93cc401fb0968ca043268ac94fda4421807ace..fa9140ea388332dafd0ea2849b85439968abdf51 100644 (file)
@@ -1,4 +1,5 @@
 Readme for the yaffs_import.py file
 Readme for the yaffs_import.py file
+by Timothy Manning <timothy@yaffs.net> 2010
 
 python yaffs_import [scanning_path] [optional flags]
 
 
 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/
 
 example:
        $  yaffs_importer.py /home/timothy/work/yaffs/
 
+yaffs_import.py must be run in yaffs/direct/python/ directory.
 
 flags:
        -d [number] 
 
 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  
        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)  
+
index b41f7327df12c956060238ac26a069286d9ab7dd..90b3fade0134003c009c431726464fe9d1821ffc 100644 (file)
@@ -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 <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.
+ *
+ * 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[])
 {
 #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)
        {
        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);
                //print_buffer(message_buffer,PRINT_ALL);
-       
+               
        }
        else{
        }
        else{
-               add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS);
+               add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS,PRINT);
        }
                
 }
        }
                
 }
index fad1ef85f69fcba39df52a3470588bbae04a5ec4..c7cc3fd5196cf540545a913074ba26a666aa8120 100644 (file)
@@ -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 <stdio.h>
 #ifndef __error_handler_h__
 #define __error_handler_h__
 #include <stdio.h>
diff --git a/direct/timothy_tests/found_bugs.txt b/direct/timothy_tests/found_bugs.txt
new file mode 100644 (file)
index 0000000..418f1dc
--- /dev/null
@@ -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
+
index fe64a6b0215dd1383ff8a731bc56cc2e0ecac5ce..58c3038934c4eba0afa1525901ad452126ca52e4 100644 (file)
@@ -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 <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.
+ *
+ * message_buffer.c contains code for a message buffer .
+ */
+
 #include "message_buffer.h"
 
 #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]);
        }
 }
                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;
 void print_buffer(buffer *p_Buffer, int number_of_messages_to_print){  
        int x=0;
        int i=0;
index 5669f74bcaa2eed64a648b9ad04f170d1585df1d..33f12ddfa493822c203fa09985593b56982e1d71 100644 (file)
@@ -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 <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 __message_buffer__
 #define __message_buffer__
 
 #include <stdio.h>
 #include <string.h>
 #ifndef __message_buffer__
 #define __message_buffer__
 
 #include <stdio.h>
 #include <string.h>
-
+#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*/
 #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*/
 
 }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*/ 
 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
 #endif
index b050e00a05a5ac38b8d4f1280d55040386f5ca0f..e8d86711bd20e5d47565a463169105adaabb84a1 100644 (file)
@@ -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 <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.
+ *
+ * yaffs_tester.c designed to stress test yaffs2 direct.
+ */
+
 
 #include "yaffs_tester.h"
 
 
 #include "yaffs_tester.h"
 
@@ -24,17 +38,21 @@ int main(){
 
 
 void init(char *yaffs_test_dir,char *yaffs_mount_dir){
 
 
 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;
        
        /*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_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);
 */
        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);
        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);
                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");
        }
                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*/           
 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);   
        //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*/
                //printf("charecter generated is %c\n",ptr[x]);
        }
        ptr[x+1]='\0';  /*adds NULL charecter to turn it into a string*/
index 6ca547fcb9a0224902d53021dd8f31afad1c7bb1..1584b1a76cbb7e5a05ebc72988f1a34940ff272c 100644 (file)
@@ -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__
 
 #ifndef __YAFFS_TESTER_H__
        #define __YAFFS_TESTER_H__