yaffs Commiting changes to yaffs_importer.py yaffs_browser.py and yaffs_tester.c
authorTimothy Manning <tfhmanning@gmail.com>
Wed, 20 Oct 2010 00:29:09 +0000 (13:29 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Wed, 20 Oct 2010 00:29:09 +0000 (13:29 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/python/yaffs_browser.py
direct/python/yaffs_importer.py
direct/timothy_tests/yaffs_tester.c
direct/timothy_tests/yaffs_tester.h

index 23fa936882dafacea81e0f19bdee68612d6e87f8..28fb49f3655839caac943e9df995172e48ecca52 100755 (executable)
@@ -88,6 +88,7 @@ class editor():
 def load_dir():
     global current_directory_dict
     print "loading a new directory*******************************************************************"
+    ##deleate current items in text box
     name_list_box.delete(0, tk.END)
     current_directory_dict=yaffs_ls(mount_list_text_variable.get())
     print "new directory", current_directory_dict
index dc72785cd46a4670ec7a4542921647bf473e9d48..1a6937b921073af5b141860b8b94b3eb6b2cc681 100644 (file)
@@ -4,11 +4,11 @@ import sys
 import ctypes
 
 
-#dir_in_snapshot=[]
-#files_in_snapshot=[]
-#symlinks_in_snapshot=[]
-#unknown_in_snapshot=[]
-#is_mount_in_snapshot=[]
+dir_in_snapshot=[]
+files_in_snapshot=[]
+symlinks_in_snapshot=[]
+unknown_in_snapshot=[]
+is_mount_in_snapshot=[]
 def check_for_yaffs_errors(output):
     if output<0:
         ##error has happened
@@ -18,7 +18,7 @@ def check_for_yaffs_errors(output):
         debug_message(("error code", error),  0)
 
 def debug_message(message, debug_level):
-    """notew that debug level 0 will always be printed"""
+    """note: 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)"""
     """level 2 all process are shown"""
@@ -98,10 +98,10 @@ def create_file(file):
     
     
     length_of_file=len(data_to_be_written)
-    debug_message (("length of data to be written",length_of_file), 2
+    debug_message (("length of data to be written",length_of_file), 3
     output=yaffs_write(current_handle,data_to_be_written , length_of_file)
     if output>=0:
-        debug_message(( "writing file:", output), 2)
+        debug_message(( "writing to ", file_path," ",  output), 1)
     else :
         debug_message(( "error writing file:", output), 0)
         check_for_yaffs_errors(output)
@@ -133,25 +133,31 @@ def create_dir(dir, scanned_path, yaffs_path):
     debug_message( ("creating dir:", absolute_dir_path), 2)
     debug_message (("mode(in octal", oct(dir["mode"])), 2)
 
-
-    ##if there is already a dir in yaffs then remove the dir . this is to clean the yaffs folder if it already exists.
-    if yaffs_access(absolute_dir_path, 0)==0:##the 0 means does it exist. 
-        debug_message ("folder already exists in yaffs", 2)
-        output=yaffs_unlink(absolute_dir_path)
-        debug_message(("unlinking", absolute_dir_path, output), 2)
-        check_for_yaffs_errors(output)
-        
-    ##shis is a bug in yaffs which will not make a dir if there is a slash on the end
+       ##this is a bug in yaffs which will not make a dir if there is a slash on the end
     if absolute_dir_path[len(absolute_dir_path)-1]=="/":
         absolute_dir_path=absolute_dir_path[0:len(absolute_dir_path)-1]
         debug_message (("path has slash on the end. removing slash new path is:",absolute_dir_path) , 4)
         
+        
+    ##if there is already a dir in yaffs then remove the dir . this is to clean the yaffs folder if it already exists.
+    ##in yaffs all of the files in the dir to be removed must be empty.
+    ##need to create a reverse ls to delete all of the files first.
+#    if yaffs_access(absolute_dir_path, 0)==0:##the 0 means does it exist. 
+#        debug_message ("folder already exists in yaffs", 2)
+#        output=yaffs_rmdir(absolute_dir_path)
+#        debug_message(("unlinking", absolute_dir_path, output), 2)
+#        check_for_yaffs_errors(output)
+        
+        
     output=yaffs_mkdir(absolute_dir_path, dir["mode"] )
     if output>=0:
-        debug_message(( "creating dir:", output), 2)
+        debug_message(( "created dir:", absolute_dir_path," ", output), 1)
     else :
-        debug_message(( "error creating dir:", output), 0)
+        debug_message(( "error creating dir ", absolute_dir_path, " ", output), 0)
         check_for_yaffs_errors(output)
+        if output==17:
+            printf("the directory already exists")
     
     
 
@@ -179,11 +185,16 @@ def is_dir_hidden(dir):
     
 def scan_dir(path, search_hidden_directories=True, ):
     """this function scans all of the files and directories in a directory. The function then calls its self on any of the directories that it found. this causes it to build up a tree of all the files and directories """
-    files_in_snapshot=[]
-    symlinks_in_snapshot=[]
-    dir_in_snapshot=[]
+    global files_in_snapshot
+    global symlinks_in_snapshot
+    global dir_in_snapshot
     dir_in_current_dir=[]
-    unknown_in_snapshot=[]
+    global unknown_in_snapshot
+#    files_in_snapshot=[]
+#    symlinks_in_snapshot=[]
+#    dir_in_snapshot=[]
+#    dir_in_current_dir=[]
+#    unknown_in_snapshot=[]
     if os.path.exists(path)==False:
         debug_message ("error#############################",0)
         debug_message (("path:", path, "  doesnot exist"), 0)
@@ -192,7 +203,7 @@ def scan_dir(path, search_hidden_directories=True, ):
     for i in range(0, len(dir_snapshot)):
 
         current_snapshot=os.path.join(path, dir_snapshot[i])
-        debug_message (("current snapshot:", current_snapshot), 2)
+        ##debug_message (("current snapshot:", current_snapshot), 2)
         isDir=os.path.isdir(current_snapshot)
         isFile=os.path.isfile(current_snapshot)
         isLink=os.path.islink(current_snapshot)
@@ -228,7 +239,15 @@ def scan_dir(path, search_hidden_directories=True, ):
             unknown_in_snapshot.append(current_snapshot)
             
     for i in range(0, len(dir_in_current_dir)):
-        scan_dir(dir_in_current_dir[i])
+        debug_message(("scanning dir", dir_in_current_dir[i]) , 2)
+        scan_dir(dir_in_current_dir[i], search_hidden_directories)
+        
+#        #debug_message(("data 0", data[0][0]), 2)
+#        if len(files)
+#        files_in_snapshot.append(data[0][0])
+#        dir_in_snapshot.append(data[1][0])
+#        symlinks_in_snapshot.append(data[2][0])
+#        unknown_in_snapshot.append(data[3][0])
     return (files_in_snapshot, dir_in_snapshot, symlinks_in_snapshot, unknown_in_snapshot)
 ##
 ##def print_scanned_dir_list():
index e615ec3211ac15765c913aa40e2584813077ad39..3c7c8efb6a4972ea1c153b9e8d77be05ccd0e742 100644 (file)
@@ -16,14 +16,20 @@ int main()
        char yaffs_mount_dir[]="/yaffs2/";
        printf("welcome to the yaffs tester\n");
        init(yaffs_test_dir,yaffs_mount_dir);
-       test(yaffs_test_dir);
-
+       //test(yaffs_test_dir);
+       add_to_buffer(&message_buffer,"message1\0");
+       add_to_buffer(&message_buffer,"message2\0");
+       add_to_buffer(&message_buffer,"message3\0");
+       add_to_buffer(&message_buffer,"message4\0");
+       add_to_buffer(&message_buffer,"message5\0");
+       print_buffer(&message_buffer);
        yaffs_unmount(yaffs_mount_dir);
        return 0;
 }
 
 void add_to_buffer(buffer *p_Buffer, char message[])
 {
+       //add a thing to add \0 on the end of the message
        if (p_Buffer->head+1==p_Buffer->tail)
        {
                p_Buffer->tail++;
@@ -34,13 +40,20 @@ void add_to_buffer(buffer *p_Buffer, char message[])
        p_Buffer->head++;
        if (p_Buffer->head >BUFFER_SIZE) p_Buffer->head -= BUFFER_SIZE;
 
-       strcpy(p_Buffer->buffer[p_Buffer->head],message);
+       strcpy(p_Buffer->message[p_Buffer->head],message);
 
 }
 void print_buffer(buffer *p_Buffer)
 {
+       printf("print buffer\n");
+       printf("buffer head:%d\n",p_Buffer->head);
+       printf("buffer tail:%d\n",p_Buffer->tail);
+       int x;
        for (x=p_Buffer->head; x>=p_Buffer->tail; x--)
        {
+               printf("x:%d\n",x);
+               if (x<0) x = BUFFER_SIZE;
+               printf("%s",p_Buffer->message[x]);
                
        }
 
@@ -62,7 +75,7 @@ void yaffs_check_for_errors(char output)
        if (output==-1)
        {
                printf("error####");
-               print_buffer(message_buffer);
+               print_buffer(&message_buffer);
        }
 }
 
index 4c551106806d248db5752ac65f440a138dc38773..1f96591ea4fc72a565646bab1d99a60b4911c21d 100644 (file)
@@ -12,7 +12,7 @@
        #define BUFFER_SIZE 50                  /*number of messages in buffer*/
        typedef struct buffer_template
        {
-               char buffer[BUFFER_SIZE][BUFFER_MESSAGE_LENGTH];
+               char message[BUFFER_SIZE][BUFFER_MESSAGE_LENGTH];
                char head;
                char tail;
        }buffer;