yaffs Working on timothy_tests and have updated yaffs_importer.py
authorTimothy Manning <tfhmanning@gmail.com>
Thu, 21 Oct 2010 23:38:35 +0000 (12:38 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Thu, 21 Oct 2010 23:38:35 +0000 (12:38 +1300)
yaffs_importer has had more command line options added.
see README_yaffs_import_py.txt for more infomation.
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/python/README_yaffs_import_py.txt
direct/python/yaffs_browser.py
direct/python/yaffs_importer.py
direct/timothy_tests/error_handler.c
direct/timothy_tests/message_buffer.c
direct/timothy_tests/message_buffer.h
direct/timothy_tests/yaffs_tester.c
direct/timothy_tests/yaffs_tester.h

index d497819..4f93cc4 100644 (file)
@@ -13,7 +13,6 @@ example:
 flags:
        -d [number] 
                set the debugging message level.
-               that debug level 0 will always be printed unless debug_level is set to -1
                level 0 error messages
                level 1 basic tasks are shown(creating, deleating,ect)(this is set as the
                default and is recommended)
@@ -22,15 +21,26 @@ flags:
                level 4 is used for bug hunting and shows each step and in detail 
        -ignore_hidden_directories
                will not copy hidden (./) directories if used.
+       
+       -o [yaffs_path]
+               chooses the path where the branch will be copyied into yaffs.
+               note this path must start with "/yaffs2/" 
+               example: python yaffs_importer.py /home/timothy/work/yaffs/yaffs_importer_test_dir -o /yaffs2/apple/
 
-Deleating files and folders
+       -yaffs_trace [number]
+               this sets the yaffs_trace() function with the number inputed.
+               this number must be in the range of char.
+               yaffs_importer saves the current yaffs_trace value and restores the value after the branch has been imported.
+               setting this flag to -1 will run yaffs_importer with the default yaffs_trace value.  
+
+Deleting files and folders
        to deleate files and folders in yaffs use the yaffs_browser (the documentation still needs to be written).
        to run the browser use this: "python yaffs_browser"
        to deleate a file or a folder select the file or folder then go
        Edit->Delete selected.
 
 Clear Yaffs
-       the easiest way to clear yaffs of all files and folders is to remove
+       the easiest way to clear the yaffs file system of all files and folders is to remove
        the emfile-2k-0 file. this file is stored in the
        yaffs2/direct/python/ folder. 
-       the command is: rm emfile-2k-0  
\ No newline at end of file
+       the command is: rm emfile-2k-0  
index 28fb49f..22073e6 100755 (executable)
@@ -4,7 +4,7 @@ from yaffsfs import *
 #import examples
 import ctypes
 
-yaffs_StartUp()
+yaffs_start_up()
 yaffs_mount("/yaffs2/")
 root_window =tk.Tk()
 root_window.title("YAFFS Browser")
index 1a6937b..84760a6 100644 (file)
@@ -353,7 +353,7 @@ def copy_scanned_files_into_yaffs(files_in_snapshot, dir_in_snapshot,  symlinks_
         debug_message( ("unknown object in snapshot:", unknown_in_snapshot[i]), 0)
     
     
-def import_into_yaffs(file_path, yaffs_path="/yaffs2/", debug_level=1,  copy_hidden_dir=True ,new_yaffs_trace_val=0 ):
+def import_into_yaffs(file_path, yaffs_path="/yaffs2/", debug_level=1,  copy_hidden_dir=True ,new_yaffs_trace_val=-1 ):
 #    global current_debug_level
 #    global search_hidden_directories
 #    global yaffs_root_dir_path
@@ -364,7 +364,8 @@ def import_into_yaffs(file_path, yaffs_path="/yaffs2/", debug_level=1,  copy_hid
 #    yaffs_root_dir_path=yaffs_path
 #    path=file_path
     old_yaffs_trace_val=yaffs_get_trace()
-    yaffs_set_trace(new_yaffs_trace_val)
+    if new_yaffs_trace_val!=-1:
+        yaffs_set_trace(new_yaffs_trace_val)
     
     data=scan_dir(file_path, copy_hidden_dir)
     copy_scanned_files_into_yaffs(data[0], data[1], data[2], data[3],file_path,  yaffs_path)
@@ -373,14 +374,15 @@ def import_into_yaffs(file_path, yaffs_path="/yaffs2/", debug_level=1,  copy_hid
     
     
 if __name__=="__main__":
-    yaffs_StartUp()
+    yaffs_start_up()
     yaffs_mount("/yaffs2/")
-    yaffs_set_trace(0)
+    #yaffs_set_trace(0)
 #    absolute_path = os.path.abspath(os.path.curdir)
     #print "absolute path:", absolute_path
     current_debug_level=1
     search_hidden_directories=True
-    yaffs_root_dir_path="/yaffs2/scanning/"
+    yaffs_root_dir_path="/yaffs2/"
+    yaffs_trace=-1
     #print sys.argv
     path=sys.argv[1]
     for i in range(2, len(sys.argv)):
@@ -388,13 +390,17 @@ if __name__=="__main__":
             current_debug_level=int( sys.argv[i+1])
         if sys.argv[i]=="-ignore_hidden_directories":
             search_hidden_directories=False
+        if sys.argv[i]=="-o":
+            yaffs_root_dir_path=sys.argv[i+1]
+        if sys.argv[i]=="-yaffs_trace":
+            yaffs_trace=int(sys.argv[i+1])
 #
 #
 #    path="/home/timothy/work/yaffs/git/yaffs2"
 #    path="/home/timothy/my_stuff/old_laptop/timothy/programming_lejos/"
 
 
-    import_into_yaffs(path, yaffs_root_dir_path, current_debug_level,  search_hidden_directories, 0 )
+    import_into_yaffs(path, yaffs_root_dir_path, current_debug_level,  search_hidden_directories, yaffs_trace )
 #    scan_dir(path)
 #    copy_scanned_files_into_yaffs()
     #print_scanned_dir_list()
index f060caf..b41f732 100644 (file)
@@ -7,7 +7,7 @@ void yaffs_check_for_errors(char output, buffer *message_buffer,char error_messa
                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);
-                printf("%d\n",yaffs_get_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*/             
 
                //print_buffer(message_buffer,PRINT_ALL);
        
index f8a9a8e..fe64a6b 100644 (file)
@@ -1,31 +1,32 @@
 #include "message_buffer.h"
 
 
-void add_to_buffer(buffer *p_Buffer, char message[],char message_level){
+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++;
 
-       printf("p_Buffer->tail=%d\n",p_Buffer->tail);
-       printf("p_Buffer->head=%d\n",p_Buffer->head);
-       if (p_Buffer->head >=BUFFER_SIZE) {
-               printf("buffer overflow\n");
-               p_Buffer->head -= BUFFER_SIZE;  /*wrap the head around the buffer*/
-               printf("new p_Buffer->head=%d\n",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);
+//             printf("moving buffer tail from %d to ",p_Buffer->tail);
                p_Buffer->tail++;
-               printf("%d\n",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);
+
        }
 
-       /*move the head up one. the head always points at the last written data*/
+
 
 
        
-       }
+       
 
        p_Buffer->message_level[p_Buffer->head]=message_level; /*copy the message level*/
        x=p_Buffer->head;
@@ -33,28 +34,31 @@ void add_to_buffer(buffer *p_Buffer, char message[],char message_level){
 
        
        strcpy(p_Buffer->message[p_Buffer->head],message); /*copy the message*/
-/*     
-       //convert the message into a string so it can be printed cleanly
-       if (message[length_of_message-1]!='\0') p_Buffer->message[p_Buffer->head][x+1]='\0';    
-*/
+//     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");
-                print_buffer(p_Buffer,1); /*if the debug level is higher enough then print the new message*/
+               /* 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*/
+               printf("%s\n",p_Buffer->message[p_Buffer->head]);
        }
 }
 void print_buffer(buffer *p_Buffer, int number_of_messages_to_print){  
-/*     printf("print buffer\n");
+       int x=0;
+       int i=0;
+       printf("print buffer\n");
        printf("buffer head:%d\n",p_Buffer->head);
        printf("buffer tail:%d\n",p_Buffer->tail);
-*/     int x;
-       int i;
+
        if (number_of_messages_to_print==PRINT_ALL) number_of_messages_to_print=BUFFER_SIZE;
 //     printf("number_of_messages_to_print=%d\n",number_of_messages_to_print);
-       for (i=0,x=p_Buffer->head; (x>=p_Buffer->tail) && (i<number_of_messages_to_print); i++, x--){
-//             printf("printing bufer\n");
-               //printf("x:%d\n",x);
-               if (x<0) x = BUFFER_SIZE;               /*wrap x around buffer*/
-               printf("%s\n",p_Buffer->message[x]);
+       for (i=0,x=0; (x>=p_Buffer->tail) && (i<number_of_messages_to_print); i++, x--){
+//             printf("printing buffer\n");
+//             printf("x:%d\n",x);
+               if (x<0) x = BUFFER_SIZE-1;             /*wrap x around buffer*/
+               printf("%s\n",p_Buffer->message[p_Buffer->head]);
+               printf("printed buffer\n");
        }
 
 }
index 66cccae..5669f74 100644 (file)
@@ -17,7 +17,7 @@ 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 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*/ 
 
 #endif
index 7aa97e2..b050e00 100644 (file)
@@ -13,8 +13,8 @@ buffer message_buffer;        /*create  message_buffer */
 
 
 int main(){    
-       char yaffs_test_dir[]="/yaffs2/test_dir\0";     /*the path to the directory where all of the testing will take place*/
-       char yaffs_mount_dir[]="/yaffs2/\0";            /*the path to the mount point which yaffs will mount*/
+       char yaffs_test_dir[] ="/yaffs2/test_dir";      /*the path to the directory where all of the testing will take place*/
+       char yaffs_mount_dir[]="/yaffs2/";              /*the path to the mount point which yaffs will mount*/
        
        init(yaffs_test_dir,yaffs_mount_dir);
        test(yaffs_test_dir);
@@ -23,12 +23,12 @@ int main(){
 }
 
 
-void init(char yaffs_test_dir[],char yaffs_mount_dir[]){
+void init(char *yaffs_test_dir,char *yaffs_mount_dir){
        /*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\0",MESSAGE_LEVEL_BASIC_TASKS);/* print boot up message*/     
+       add_to_buffer(&message_buffer,"welcome to the yaffs tester",MESSAGE_LEVEL_BASIC_TASKS);/* print boot up message*/       
        yaffs_start_up();
        yaffs_mount(yaffs_mount_dir);
 
@@ -38,28 +38,29 @@ void init(char yaffs_test_dir[],char yaffs_mount_dir[]){
        }
        
 }
-void join_paths(char path1[],char path2[],char *new_path ){
-       unsigned int i=0;
-       unsigned int x=0;
-       printf("strlen path1:%d\n",strlen(path1));
+void join_paths(char *path1,char *path2,char *new_path ){
+
+/*     printf("strlen path1:%d\n",strlen(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);
-       char cat[10]="cat\0";
-       strcat(cat,"dog\0");
        add_to_buffer(&message_buffer,path1,MESSAGE_LEVEL_BASIC_TASKS);
        add_to_buffer(&message_buffer, path2,MESSAGE_LEVEL_BASIC_TASKS);
        if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') {
                /*paths are compatiable. concatanate them. note -2 is because of \0*/  
+               strcat(new_path,path1);
+               strcat(new_path,path2);         
                //char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))];
-               strcpy(new_path,strcat(path1,path2)); 
+               //strcpy(new_path,strcat(path1,path2)); 
                //return new_path;
        }       
        else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]=='/') {
                /*paths are compatiable. concatanate them*/  
+               strcat(new_path,path1);
+               strcat(new_path,path2);         
                //char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))];
-               strcpy(new_path,strcat(path1,path2)); 
+               //strcpy(new_path,strcat(path1,path2)); 
                //return new_path;
        }
        else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') {
@@ -69,7 +70,8 @@ void join_paths(char path1[],char path2[],char *new_path ){
                strcat(new_path,path2);
                //strcpy(new_path,strcat(path1,strcat("/\0",path2)));
 
-/*             copy_array(path1,new_path,0,0);
+#if 0
+               copy_array(path1,new_path,0,0);
                copy_array('\0',new_path,0,(sizeof(path1)/sizeof(char)));
                copy_array(path2,new_path,0,(sizeof(path1)/sizeof(char))+1);
  old method now trying to use copy_array
@@ -81,13 +83,18 @@ void join_paths(char path1[],char path2[],char *new_path ){
                for (x=(sizeof(path1)/sizeof(char)) ,i=0 ;i<=(sizeof(path2)/sizeof(char));x++,i++){ 
                        new_path[x]=path2[i]; 
                }
-*/
+#endif
+
                //return new_path;
        }
        else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') {
-               /*need to remove a "/". */  
+               /*need to remove a "/". */
+               /*yaffs does not mind the extra slash. */
                //char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))-1];
-               strcpy(new_path,strcat(path1,strncat("",path2,(sizeof(path1)/sizeof(char))-1))); 
+               
+               strcat(new_path,path1);
+               strcat(new_path,path2);
+               //strcpy(new_path,strcat(path1,strncat("",path2,(sizeof(path1)/sizeof(char))-1))); 
                //return new_path;
        } 
        else{
@@ -95,23 +102,13 @@ void join_paths(char path1[],char path2[],char *new_path ){
                //return -1;
        }
 }
-/*
-void copy_array(char from[],char *to, unsigned int from_offset,unsigned int to_offset){        
-       unsigned int x=0;
-       for (x=0+from_offset; x<(sizeof(from)/sizeof(char));x++){
-               //add_to_buffer(&message_buffer, x,MESSAGE_LEVEL_BASIC_TASKS);
-               //add_to_buffer(&message_buffer,from[x],MESSAGE_LEVEL_BASIC_TASKS);
-               printf("x=%d\n",x);
-               printf("char in from: %c\n\n",from[x]);
-               
-               to[x+to_offset]=from[x];
-       }
-}
-*/
-void test(char yaffs_test_dir[]){
+
+
+
+void test(char*yaffs_test_dir){
        char output=0;
        char name[MAX_FILE_NAME_SIZE+3 ]="apple\0";
-       char path[MAX_FILE_NAME_SIZE+strlen(yaffs_test_dir)];
+       char path[MAX_FILE_NAME_SIZE];
        join_paths(yaffs_test_dir,name,path);
        while(1)
        {
index 712563f..6ca547f 100644 (file)
@@ -12,9 +12,9 @@
 
 #define MAX_FILE_NAME_SIZE 51
 
-void init(char yaffs_test_dir[],char yaffs_mount_dir[]);       /*sets up yaffs and mounts yaffs */
-void test(char yaffs_test_dir[]);                              /*contains the test code*/
+void init(char *yaffs_test_dir,char *yaffs_mount_dir); /*sets up yaffs and mounts yaffs */
+void test(char *yaffs_test_dir);                               /*contains the test code*/
 void generate_random_string(char *ptr);                                /*generates a random string of letters to be used for a name*/
-void join_paths(char path1[],char path2[],char *newpath );
-void copy_array(char from[],char *to, unsigned int from_offset,unsigned int to_offset);
+void join_paths(char *path1,char *path2,char *newpath );
+void copy_array(char *from,char *to, unsigned int from_offset,unsigned int to_offset);
 #endif