Merge branch 'mainlining'
authorCharles Manning <cdhmanning@gmail.com>
Fri, 7 Jan 2011 01:19:08 +0000 (14:19 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Fri, 7 Jan 2011 01:19:08 +0000 (14:19 +1300)
direct/timothy_tests/mirror_tests/Makefile
direct/timothy_tests/mirror_tests/linux_test_unlink.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/linux_test_unlink.h [new file with mode: 0644]
direct/timothy_tests/mirror_tests/mirror_tests.c
direct/timothy_tests/mirror_tests/mirror_tests.h
direct/timothy_tests/mirror_tests/yaffs_test_unlink.c [new file with mode: 0644]
direct/timothy_tests/mirror_tests/yaffs_test_unlink.h [new file with mode: 0644]
yaffs_vfs_multi.c
yaffs_vfs_single.c
yportenv_multi.h
yportenv_single.h

index d252e4b7fe427821cf7cc70f748960e6726529c6..4362cd9a90664dd3cf3c867272459c60fe9c5b71 100644 (file)
@@ -48,7 +48,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \
 
 TESTFILES =    mirror_tests.o lib.o\
                linux_test_open.o yaffs_test_open.o\
-               linux_test_truncate.o yaffs_test_truncate.o
+               linux_test_truncate.o yaffs_test_truncate.o \
+               linux_test_unlink.o yaffs_test_unlink.o
 
 
                  
diff --git a/direct/timothy_tests/mirror_tests/linux_test_unlink.c b/direct/timothy_tests/mirror_tests/linux_test_unlink.c
new file mode 100644 (file)
index 0000000..f22a57b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#include "linux_test_unlink.h"
+
+int linux_test_unlink(arg_temp *args_struct)
+{
+       char path[250];
+       char message[150];
+       int output;
+       join_paths(linux_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output= unlink(path);
+       
+       if (output<0) {
+               print_message(3,"failed to unlink file\n");
+               return -1;
+       } else {
+               return 1;
+       }
+}
diff --git a/direct/timothy_tests/mirror_tests/linux_test_unlink.h b/direct/timothy_tests/mirror_tests/linux_test_unlink.h
new file mode 100644 (file)
index 0000000..aac3bcd
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * YAFFS: Yet another Flash File System . 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 Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __linux_test_unlink_h__
+#define __linux_test_unlink_h__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int linux_test_unlink(arg_temp *args_struct);
+
+#endif
index a022e4db30e79429a809709fcfb88f464396b0de..88c509f07787f1e8d323c5204ad5e8538fa093c1 100644 (file)
@@ -31,16 +31,18 @@ typedef struct test_temp2 {
 }test_temp;
 
 test_temp yaffs_tests={
-       2,
+       3,
        {{"yaffs_test_open",yaffs_test_open},
-       {"yaffs_test_truncate",yaffs_test_truncate}
+       {"yaffs_test_truncate",yaffs_test_truncate},
+       {"yaffs_test_unlink",yaffs_test_unlink}
        }
 };
 
 test_temp linux_tests={
-       2,
+       3,
        {{"linux_test_open",linux_test_open},
-       {"linux_test_truncate",linux_test_truncate}
+       {"linux_test_truncate",linux_test_truncate},
+       {"linux_test_unlink",linux_test_unlink}
        }
 };
 
@@ -62,9 +64,9 @@ int main(int argc, char *argv[])
        print_message(3,message);
        sprintf(message,"yaffs_num_of_tests: %d\n",yaffs_tests.num_of_tests);
        print_message(3,message);
-       for (x=0;x<num_of_random_tests;x++){
-               run_random_test();
-       }
+
+       run_random_test(num_of_random_tests);
+       compare_linux_and_yaffs();
        yaffs_unmount("yaffs2");
        return 0;
 }
@@ -75,8 +77,9 @@ void init(int argc, char *argv[])
        dir[0]='\0';
        int x=-1;
        char message[100];
-       
+
        srand((unsigned)time(NULL));
+       yaffs_set_trace(0);
        linux_struct.type_of_test =LINUX;
        yaffs_struct.type_of_test =YAFFS;
 
@@ -101,6 +104,8 @@ void init(int argc, char *argv[])
                        printf("\t-q //quiet mode nothing is printed.\n");
                        printf("\t-n [number] //sets the number of random tests to run.\n");
                        printf("\t-s [number] //seeds rand with the number\n");
+                       printf("\t-t [number] //sets yaffs_trace to the number\n");
+                       printf("\t-clean //removes emfile and test dir\n");
                        exit(0);
                } else if (strcmp(argv[x],"-yaffs_path")==0){
                        strcpy(yaffs_struct.root_path, argv[x+1]);
@@ -114,13 +119,18 @@ void init(int argc, char *argv[])
                        set_print_level(-1);
                } else if (strcmp(argv[x],"-n")==0){
                        num_of_random_tests=atoi(argv[x+1]);
-               } else if (strcmp(argv[x],"-n")==0){
-                       //srand(atoi(argv[x+1]));
+               } else if (strcmp(argv[x],"-s")==0){
+                       srand(atoi(argv[x+1]));
+               } else if (strcmp(argv[x],"-t")==0){
+                       yaffs_set_trace(atoi(argv[x+1]));
+               } else if (strcmp(argv[x],"-clean")==0){
+                       clean_dir();
+                       exit(0);
                }
        }
-
+       clean_dir();
        yaffs_start_up();
-       print_message(message,"\nmounting yaffs\n");
+       print_message(2,"\nmounting yaffs\n");
        x=yaffs_mount("yaffs2");
        if (x<0) {
                print_message(3,"failed to mount yaffs\n");
@@ -149,36 +159,39 @@ void init(int argc, char *argv[])
        }
 }
 
-int run_random_test(void)
+int run_random_test(int num_of_random_tests)
 {
+       int y=0;
        int x=-1;
        int id=0;
        int test_id=-1;
-       int num_of_tests=1;
+       int num_of_tests_before_check=10;
        char message[100];
        arg_temp args_struct;
-       for (x=0;x<num_of_tests;x++) {
-               errno=0;
-               yaffs_set_error(0);
-               test_id = select_test_id(yaffs_tests.num_of_tests);
-               sprintf(message,"running test_id %d\n",test_id);
-               print_message(3,message);
-               generate_random_numbers(&args_struct);
-               run_yaffs_test(test_id, &args_struct);
-               run_linux_test(test_id, &args_struct);
-               if      ((abs(yaffs_get_error())!=abs(errno)) &&
-                       (abs(yaffs_get_error())!=EISDIR && abs(errno) != 0) &&
-                       (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)
-                       ){
-                       print_message(2,"\ndiffrence in returned errors######################################\n");
-                       get_error_yaffs();
-                       get_error_linux();
-                       if (get_exit_on_error()){ 
-                               exit(0);
+       for (y=0;(y*num_of_tests_before_check)<num_of_random_tests;y++){
+               for (x=0;x<num_of_tests_before_check;x++) {
+                       errno=0;
+                       yaffs_set_error(0);
+                       test_id = select_test_id(yaffs_tests.num_of_tests);
+                       sprintf(message,"running test_id %d\n",test_id);
+                       print_message(3,message);
+                       generate_random_numbers(&args_struct);
+                       run_yaffs_test(test_id, &args_struct);
+                       run_linux_test(test_id, &args_struct);
+                       if      ((abs(yaffs_get_error())!=abs(errno)) &&
+                               (abs(yaffs_get_error())!=EISDIR && abs(errno) != 0) &&
+                               (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)
+                               ){
+                               print_message(2,"\ndifference in returned errors######################################\n");
+                               get_error_yaffs();
+                               get_error_linux();
+                               if (get_exit_on_error()){ 
+                                       exit(0);
+                               }
                        }
-               }
-       }
-       compare_linux_and_yaffs(); 
+               }       
+               compare_linux_and_yaffs();
+       } 
 }
 
 int select_test_id(int test_len)
@@ -193,6 +206,52 @@ int select_test_id(int test_len)
 
 int compare_linux_and_yaffs(void)
 {
+       int x=0;
+       yaffs_DIR *yaffs_open_dir;
+       yaffs_dirent *yaffs_current_file;
+       
+       DIR *linux_open_dir;
+       struct dirent *linux_current_file;
+
+       yaffs_open_dir = yaffs_opendir(yaffs_struct.root_path);
+       if (yaffs_open_dir) {
+               for (x=0;NULL!=yaffs_readdir(yaffs_open_dir);x++){}
+               printf("number of files in yaffs dir= %d\n",x);
+               
+               char yaffs_file_list[x][100];
+               yaffs_rewinddir(yaffs_open_dir);
+       
+               for (x=0 ;NULL!=yaffs_current_file;x++)
+               {
+                       yaffs_current_file =yaffs_readdir(yaffs_open_dir);
+                       if (NULL!=yaffs_current_file){
+                               strcpy(yaffs_file_list[x],yaffs_current_file->d_name);
+                       }
+               }
+       }
+
+       linux_open_dir = opendir(linux_struct.root_path);
+       if (linux_open_dir){
+               for (x=0;NULL!=readdir(linux_open_dir);x++){}
+               printf("number of files in linux dir= %d\n",(x-2));     
+               //the -2 is because linux shows 2 extra files which are automaticly created. 
+       
+               char linux_file_list[x][100];
+       
+               for (x=0 ;NULL!=linux_current_file;x++)
+               {
+                       linux_current_file =readdir(linux_open_dir);
+                       if (NULL!=linux_current_file){
+                               strcpy(linux_file_list[x],linux_current_file->d_name);
+                       }
+               }
+       }
+
+
+
+
+       
+       //printf("file_name %s\n", yaffs_current_file->d_name);
 //     generate_array_of_objects_in_yaffs(); 
 //     generate_array_of_objects_in_linux();
        //first do a check to see if both sides have the same objects on both sides. 
@@ -278,3 +337,37 @@ void get_error_linux(void)
        print_message(1,message);
 }
 
+void clean_dir(void)
+{
+       char string[200]; 
+       char file[200];
+       char message[200];
+       DIR *linux_open_dir;
+       struct dirent *linux_current_file;
+       int x=0;
+       
+       getcwd(string,200);
+       strcat(string,"/emfile-2k-0");
+       sprintf(message,"\n\nunlinking emfile at this path: %s\n",string);
+       print_message(3,message);
+       unlink(string);
+       
+
+       linux_open_dir = opendir(linux_struct.root_path);
+       if (linux_open_dir){
+               for (x=0 ;NULL!=linux_current_file   ;x++)
+               {
+                       linux_current_file =readdir(linux_open_dir);
+                       if (NULL!=linux_current_file){
+                               
+                               strcpy(file,linux_struct.root_path);
+                               strcat(file,linux_current_file->d_name);
+                               sprintf(message,"unlinking file %d\n",linux_current_file->d_name);
+                               print_message(3,message);
+                               unlink(file);
+                       }
+               }
+               unlink(linux_struct.root_path);
+       }
+       
+}
index 0ae4be5cb091d9d7e87773c80fc0169d1fdebca4..208f845643e2602806719bf9d8fac4204e6731a8 100644 (file)
@@ -17,6 +17,7 @@
 #define __mirror_tests_h__
 
 #include <stdio.h>
+#include <dirent.h>
 #include <unistd.h>    //used for getting the current directory. 
 #include <string.h>
 #include <errno.h>
 #include "lib.h"
 #include <time.h>
 
+
 #include "linux_test_open.h"
 #include "yaffs_test_open.h"
 #include "linux_test_truncate.h"
 #include "yaffs_test_truncate.h"
-
+#include "linux_test_unlink.h"
+#include "yaffs_test_unlink.h"
 
 #define LINUX 1
 #define YAFFS 2
@@ -38,7 +41,7 @@
 
 
 void init(int argc, char *argv[]);
-int run_random_test(void);
+int run_random_test(int num_of_random_tests);
 int compare_linux_and_yaffs(void);
 void get_error_yaffs(void);
 void get_error_linux(void);
@@ -46,6 +49,7 @@ int select_test_id(int test_len);
 void generate_random_numbers(arg_temp *args_struct);
 void run_yaffs_test(int id,arg_temp *args_struct);
 void run_linux_test(int id,arg_temp *args_struct);
+void clean_dir(void);
 //void generate_array_of_objects_in_yaffs(void); 
 //void generate_array_of_objects_in_linux(void);
 
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_unlink.c b/direct/timothy_tests/mirror_tests/yaffs_test_unlink.c
new file mode 100644 (file)
index 0000000..a6f1497
--- /dev/null
@@ -0,0 +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.
+ */
+
+#include "yaffs_test_unlink.h"
+
+int yaffs_test_unlink(arg_temp *args_struct)
+{
+       char path[250];
+       char message[150];
+       int output;
+       join_paths(yaffs_struct.root_path,args_struct->string1, path );
+       sprintf(message,"file path: %s\n",path);        
+       print_message(3,message);
+
+       output= yaffs_unlink(path);
+
+       if (output<0) {
+               print_message(3,"failed to unlink file\n");
+               return -1;
+       } else {
+               return 1;
+       }
+
+}
diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_unlink.h b/direct/timothy_tests/mirror_tests/yaffs_test_unlink.h
new file mode 100644 (file)
index 0000000..4d1b881
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * YAFFS: Yet another Flash File System . 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 Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __yaffs_test_unlink_h__
+#define __yaffs_test_unlink_h__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "yaffsfs.h"
+#include "lib.h"
+
+int yaffs_test_unlink(arg_temp *args_struct);
+
+#endif
index 85df2d75ff1ead531a1a5d0c66b6f845d76c2974..9feecdf82ef85eeb63e941607feaf36f190ad265 100644 (file)
@@ -866,7 +866,7 @@ static void yaffs_evict_inode(struct inode *inode)
        yaffs_trace(YAFFS_TRACE_OS,
                "yaffs_evict_inode: ino %d, count %d %s",
                (int)inode->i_ino, atomic_read(&inode->i_count),
-               obj ? "object exists" : "null object"));
+               obj ? "object exists" : "null object");
 
        if (!inode->i_nlink && !is_bad_inode(inode))
                deleteme = 1;
index d5b875314005a36afe115ba7abd656bf6b3eff39..2cd604769db07aad88d20a5f52cfa69bce1ed148 100644 (file)
@@ -59,9 +59,6 @@
 
 #include <linux/statfs.h>
 
-#define UnlockPage(p) unlock_page(p)
-#define Page_Uptodate(page)    test_bit(PG_uptodate, &(page)->flags)
-
 #define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf)
 
 #define YPROC_ROOT  NULL
@@ -1177,7 +1174,7 @@ static int yaffs_readpage_nolock(struct file *f, struct page *pg)
 static int yaffs_readpage_unlock(struct file *f, struct page *pg)
 {
        int ret = yaffs_readpage_nolock(f, pg);
-       UnlockPage(pg);
+       unlock_page(pg);
        return ret;
 }
 
@@ -1334,7 +1331,7 @@ static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
        }
        yaffs_trace(YAFFS_TRACE_OS,
                "start yaffs_write_begin index %d(%x) uptodate %d",
-               (int)index, (int)index, Page_Uptodate(pg) ? 1 : 0);
+               (int)index, (int)index, PageUptodate(pg) ? 1 : 0);
 
        /* Get fs space */
        space_held = yaffs_hold_space(filp);
@@ -1346,7 +1343,7 @@ static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
 
        /* Update page if required */
 
-       if (!Page_Uptodate(pg))
+       if (!PageUptodate(pg))
                ret = yaffs_readpage_nolock(filp, pg);
 
        if (ret)
index 4dddf63ebb2469f15429cb56f518ec6dbd023a3a..10e284e8ec7b4e0271f5837f18ef04ef9973f862 100644 (file)
@@ -24,7 +24,9 @@
 
 #define MTD_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
 
+#ifdef YAFFS_OUT_OF_TREE
 #include "moduleconfig.h"
+#endif
 
 #include <linux/version.h>
 #define MTD_VERSION_CODE LINUX_VERSION_CODE
@@ -75,7 +77,7 @@
 #endif
 
 #define yaffs_trace(msk, fmt, ...) do { \
-       if(yaffs_trace_mask & ((msk) | YAFFS_TRACE_ALWAYS)) \
+       if(yaffs_trace_mask & (msk)) \
                printk(KERN_DEBUG "yaffs: " fmt "\n", ##__VA_ARGS__); \
 } while(0)
 
index 236f5793eccfdc4d099918771d332eb5c55245a0..8183425448cde06732aa5499156c661fe1314e90 100644 (file)
@@ -54,7 +54,7 @@
 #endif
 
 #define yaffs_trace(msk, fmt, ...) do { \
-       if(yaffs_trace_mask & ((msk) | YAFFS_TRACE_ALWAYS)) \
+       if(yaffs_trace_mask & (msk)) \
                printk(KERN_DEBUG "yaffs: " fmt "\n", ##__VA_ARGS__); \
 } while(0)