2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Timothy Manning <timothy@yaffs.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
16 static int EXIT_ON_ERROR = 1;
17 static int PRINT_LEVEL = 2; //This sets the level of detail which is printed. There are 3 levels 0,1,2 and 3
18 //0 just prints the number of tests passed and failed.
19 //1 is the basic print level. it will print the details of a failed test.
20 //2 will print if a test passes and cleans.
21 void set_print_level(int new_level)
23 PRINT_LEVEL=new_level;
26 void set_exit_on_error(int num)
31 int get_exit_on_error(void)
40 output=yaffs_remount(YAFFS_MOUNT_POINT,1,1);
42 print_message("failed to remount yaffs\n",2);
51 output= yaffs_remount(YAFFS_MOUNT_POINT,1,0);
53 print_message("failed to remount yaffs\n",2);
60 int set_up_ELOOP(void){
65 output1=yaffs_symlink(ELOOP_PATH,ELOOP2_PATH);
67 error=yaffs_get_error();
68 if (abs(error)==EEXIST){
75 output2=yaffs_symlink(ELOOP2_PATH,ELOOP_PATH);
78 error=yaffs_get_error();
79 if (abs(error)==EEXIST){
87 yaffs_set_error(0); /*reset the last error to 0 */
88 return (output1|output2);
91 void join_paths(char *path1,char *path2,char *new_path )
94 //strcat(new_path,path1); /*since all functions have this then pull it out*/
95 if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') {
96 /*paths are compatiable. concatanate them. note -2 is because of \0*/
97 strcat(new_path,path1);
98 strcat(new_path,path2);
99 //char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))];
100 //strcpy(new_path,strcat(path1,path2));
102 } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]=='/') {
103 /*paths are compatiable. concatanate them*/
104 strcat(new_path,path1);
105 strcat(new_path,path2);
107 } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') {
108 /*need to add a "/". */
109 strcat(new_path,path1);
110 strcat(new_path,"/");
111 strcat(new_path,path2);
113 } else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') {
114 /*need to remove a "/". */
115 /*yaffs does not mind the extra slash. */
116 strcat(new_path,path1);
117 strcat(new_path,path2);
125 void print_message(char *message,char print_level)
127 if (print_level <= PRINT_LEVEL){