yaffs: More clean up.
authorCharles Manning <cdhmanning@gmail.com>
Tue, 2 Nov 2010 22:45:09 +0000 (11:45 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Tue, 2 Nov 2010 22:45:09 +0000 (11:45 +1300)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
23 files changed:
devextras.h [deleted file]
direct/basic-test/Makefile
direct/basic-test/yaffs_fileem.c
direct/basic-test/yaffs_fileem2k.c
direct/basic-test/yaffs_norif1.c
direct/basic-test/yaffs_ramdisk.c
direct/basic-test/yaffs_ramem2k.c
direct/python/Makefile
direct/tests/Makefile
direct/yaffs_flashif.c
direct/yaffs_nandif.c
direct/yaffscfg.h
direct/ydirectenv.h
direct/yportenv.h [new file with mode: 0644]
patch-ker.sh
yaffs_guts.c
yaffs_guts.h
yaffs_linux.h
yaffs_mtdif.h
yaffs_qsort.h [deleted file]
yaffs_yaffs2.c
yportenv_multi.h [moved from yportenv.h with 96% similarity]
yportenv_single.h [new file with mode: 0644]

diff --git a/devextras.h b/devextras.h
deleted file mode 100644 (file)
index baadeff..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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 Charles Manning <charles@aleph1.co.uk>
- *
- * 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.
- */
-
-/*
- * This file is just holds extra declarations of macros that would normally
- * be providesd in the Linux kernel. These macros have been written from
- * scratch but are functionally equivalent to the Linux ones.
- *
- */
-
-#ifndef __EXTRAS_H__
-#define __EXTRAS_H__
-
-
-#include "yportenv.h"
-
-#if !(defined __KERNEL__)
-
-/* Definition of types */
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned u32;
-
-#endif
-
-
-#if !(defined __KERNEL__)
-
-
-#ifndef WIN32
-#include <sys/stat.h>
-#endif
-
-
-#ifdef CONFIG_YAFFS_PROVIDE_DEFS
-/* File types */
-
-
-#define DT_UNKNOWN     0
-#define DT_FIFO                1
-#define DT_CHR         2
-#define DT_DIR         4
-#define DT_BLK         6
-#define DT_REG         8
-#define DT_LNK         10
-#define DT_SOCK                12
-#define DT_WHT         14
-
-
-#ifndef WIN32
-#include <sys/stat.h>
-#endif
-
-/*
- * Attribute flags.  These should be or-ed together to figure out what
- * has been changed!
- */
-#define ATTR_MODE      1
-#define ATTR_UID       2
-#define ATTR_GID       4
-#define ATTR_SIZE      8
-#define ATTR_ATIME     16
-#define ATTR_MTIME     32
-#define ATTR_CTIME     64
-
-struct iattr {
-       unsigned int ia_valid;
-       unsigned ia_mode;
-       unsigned ia_uid;
-       unsigned ia_gid;
-       unsigned ia_size;
-       unsigned ia_atime;
-       unsigned ia_mtime;
-       unsigned ia_ctime;
-       unsigned int ia_attr_flags;
-};
-
-#endif
-
-#else
-
-#include <linux/types.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-
-#endif
-
-
-#endif
index 6074e00153b2ee9af195aa4903817fb3b74d3951..542efba4a469d485f1e5b2c257feb198ab9779c4 100644 (file)
@@ -49,12 +49,12 @@ YAFFSTESTOBJS  = $(COMMONTESTOBJS) yaffs_test.o
 
 ALLOBJS = $(sort $(YAFFSTESTOBJS))
 
-YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
           yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \
           yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \
           yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
           yaffs_nameval.c yaffs_nameval.h \
-          yaffs_qsort.h yaffs_trace.h \
+          yaffs_trace.h \
           yaffs_allocator.c yaffs_allocator.h \
           yaffs_yaffs1.c yaffs_yaffs1.h \
           yaffs_yaffs2.c yaffs_yaffs2.h \
@@ -64,7 +64,7 @@ YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yp
 YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
                       yaffsfs.h yaffs_malloc.h ydirectenv.h \
                       yaffs_flashif.c yaffscfg.h yaffs_list.h \
-                      yaffs_qsort.c \
+                      yaffs_qsort.c yportenv.h \
                       yaffs_nandif.c yaffs_nandif.h yaffs_nandemul2k.h
 
 
index f92fa8f415fa9093ef583281aec2c2865bf01c9c..702acbeda33072c59ff8ff5573a57ad701343aea 100644 (file)
@@ -25,8 +25,6 @@ const char *yaffs_flashif_c_version = "$Id: yaffs_fileem.c,v 1.7 2010-02-18 01:1
 #include "yaffs_flashif.h"
 #include "yaffs_guts.h"
 
-#include "devextras.h"
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
index 072e2f11699bd4135f5e30b646bb10f1bf520cea..d8fde7382730e713e5496c5821e43e4ebf86e33c 100644 (file)
@@ -24,7 +24,6 @@ const char *yaffs_flashif2_c_version = "$Id: yaffs_fileem2k.c,v 1.24 2010-02-18
 
 #include "yaffs_flashif2.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
index 2484bec3452803e85e34cec7b40b571f2d461e48..7be629542f3a6ace80ae18397cf6b2ab5761d466 100644 (file)
@@ -45,8 +45,6 @@ const char *yaffs_norif1_c_version = "$Id: yaffs_norif1.c,v 1.6 2010-02-18 01:18
 #include "yaffs_flashif.h"
 #include "yaffs_guts.h"
 
-#include "devextras.h"
-
 #define SPARE_BYTES_PER_CHUNK  16
 #define M18_SKIP               16
 #define PROG_REGION_SIZE       1024
index e2020286801cab92c456d43b609ae1e43504bbd1..babddde3eda963e0a7189d6d3f4df2cb27f52047 100644 (file)
@@ -26,7 +26,6 @@ const char *yaffs_ramdisk_c_version = "$Id: yaffs_ramdisk.c,v 1.6 2010-01-11 04:
 
 #include "yaffs_ramdisk.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 #include "yaffs_packedtags1.h"
 
 
index 0310357a34e1cd68ee7de5a3ffac0ba843f70b6d..7f88b7c94a5ec018506a4812352a0dedfcffab86 100644 (file)
@@ -31,7 +31,6 @@ const char *yaffs_ramem2k_c_version = "$Id: yaffs_ramem2k.c,v 1.8 2010-02-18 01:
 
 #include "yaffs_nandemul2k.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 #include "yaffs_packedtags2.h"
 
 
index 6fc217e66be86facf23e0776cd1271a440a3941f..f571cf47db85e30de0e192c21210acd80c99b921 100644 (file)
@@ -47,12 +47,12 @@ YAFFSLIBOBJS  = $(COMMONTESTOBJS) yaffs_python_helper.o yaffs_error_converter.o
 
 
 
-YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
           yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h  \
           yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h  \
           yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
           yaffs_nameval.c yaffs_nameval.h \
-          yaffs_qsort.h yaffs_trace.h \
+          yaffs_trace.h \
           yaffs_allocator.c yaffs_allocator.h \
           yaffs_yaffs1.c yaffs_yaffs1.h \
           yaffs_yaffs2.c yaffs_yaffs2.h \
@@ -62,7 +62,8 @@ YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yp
 
 YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffsfs.h yaffscfg.h yaffs_malloc.h ydirectenv.h \
                       yaffs_flashif.c yaffs_flashif.h yaffs_flashif2.h yaffs_list.h \
-                      yaffs_nandif.c yaffs_nandif.h yaffs_qsort.c yaffs_nandemul2k.h
+                      yaffs_nandif.c yaffs_nandif.h yaffs_qsort.c yaffs_nandemul2k.h \
+                      yportenv.h
 
 DIRECTEXTRASYMLINKS =   yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
                         yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
index 302d5b4f5e796152b6edc90d95c8ffd9493f3016..cb90c293f6245db108e4b63004d016c6b3926104 100644 (file)
@@ -49,12 +49,12 @@ YAFFSTESTOBJS  = $(COMMONTESTOBJS) yaffs_test.o
 
 ALLOBJS = $(sort $(YAFFSTESTOBJS))
 
-YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
           yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h  yaffs_nandemul2k.h \
           yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \
           yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
           yaffs_nameval.c yaffs_nameval.h \
-          yaffs_qsort.h yaffs_trace.h \
+          yaffs_trace.h \
           yaffs_allocator.c yaffs_allocator.h \
           yaffs_yaffs1.c yaffs_yaffs1.h \
           yaffs_yaffs2.c yaffs_yaffs2.h \
@@ -65,7 +65,7 @@ YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
                       yaffsfs.h yaffs_malloc.h ydirectenv.h \
                       yaffs_flashif.c yaffscfg.h yaffs_qsort.c \
                       yaffs_nandemul2k.h yaffs_list.h \
-                      yaffs_nandif.c yaffs_nandif.h
+                      yaffs_nandif.c yaffs_nandif.h yportenv.h
 
 
 DIRECTEXTRASYMLINKS =  yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
index d9c7cb1ccd8709b581e6fe832307ad021f417e6d..85958044d0618bc2a03f2cda88a27349e64f4233 100644 (file)
@@ -19,7 +19,6 @@ const char *yaffs_flashif_c_version = "$Id: yaffs_flashif.c,v 1.3 2007-02-14 01:
 
 #include "yaffs_flashif.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 
 
 #define SIZE_IN_MB 16
index 0e2c14abc1db0d20ff8c3815e5e1c181bb06c46f..9a22f7fdd3bf552debff1f880ac6cb4050e44bba 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "yportenv.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 
 
 #include "yaffs_nandif.h"
index 3387802852eedf6ef7a8bb44f40813c53d123840..42fd78cc9c60d90dba19987d8a868d3399262d32 100644 (file)
@@ -23,8 +23,7 @@
 #define __YAFFSCFG_H__
 
 
-#include "yportenv.h"
-#include "devextras.h"
+#include "yportenv.h"     
 
 #define YAFFSFS_N_HANDLES 100
 
index ea224cc8d2f988b923f37d9870837e0273b343a0..ee6e8f5a2912d3d56713a1eed42828ee5390c7fa 100644 (file)
 #define yaffs_sprintf       sprintf
 #define yaffs_toupper(a)     toupper(a)
 
+void yaffs_qsort(void *aa, size_t n, size_t es,
+        int (*cmp)(const void *, const void *));
+
+#define yaffs_sort(base, n, sz, cmp_fn) yaffs_qsort(base, n, sz, cmp_fn)
+        
 #define YAFFS_PATH_DIVIDERS  "/"
 
 #ifdef NO_Y_INLINE
diff --git a/direct/yportenv.h b/direct/yportenv.h
new file mode 100644 (file)
index 0000000..22afb06
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * 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 Charles Manning <charles@aleph1.co.uk>
+ *
+ * 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 __YPORTENV_H__
+#define __YPORTENV_H__
+
+/*
+ * Define the MTD version in terms of Linux Kernel versions
+ * This allows yaffs to be used independantly of the kernel
+ * as well as with it.
+ */
+
+
+#if defined CONFIG_YAFFS_WINCE
+
+#include "ywinceenv.h"
+
+
+#elif defined CONFIG_YAFFS_DIRECT
+
+/* Direct interface */
+#include "ydirectenv.h"
+
+#elif defined CONFIG_YAFFS_UTIL
+
+/* Stuff for YAFFS utilities */
+
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+
+
+#define YMALLOC(x) malloc(x)
+#define YFREE(x)   free(x)
+#define YMALLOC_ALT(x) malloc(x)
+#define YFREE_ALT(x) free(x)
+
+#define YCHAR char
+#define YUCHAR unsigned char
+#define _Y(x)     x
+#define yaffs_strcat(a, b)     strcat(a, b)
+#define yaffs_strcpy(a, b)     strcpy(a, b)
+#define yaffs_strncpy(a, b, c) strncpy(a, b, c)
+#define yaffs_strnlen(s,m)            strnlen(s,m)
+#define yaffs_sprintf         sprintf
+#define yaffs_toupper(a)       toupper(a)
+
+#define Y_INLINE inline
+
+/* #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) */
+/* #define YALERT(s) YINFO(s) */
+
+#define TENDSTR "\n"
+#define TSTR(x) x
+#define TOUT(p) printf p
+
+#define YAFFS_LOSTNFOUND_NAME          "lost+found"
+#define YAFFS_LOSTNFOUND_PREFIX                "obj"
+/* #define YPRINTF(x) printf x */
+
+#define YAFFS_ROOT_MODE                        0755
+#define YAFFS_LOSTNFOUND_MODE          0700
+
+#define yaffs_sum_cmp(x, y) ((x) == (y))
+#define yaffs_strcmp(a, b) strcmp(a, b)
+
+#else
+/* Should have specified a configuration type */
+#error Unknown configuration
+
+#endif
+
+#if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
+
+#ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
+
+#ifndef O_RDONLY
+#define O_RDONLY        00
+#endif
+
+#ifndef O_WRONLY
+#define O_WRONLY       01
+#endif
+
+#ifndef O_RDWR
+#define O_RDWR         02
+#endif
+
+#ifndef O_CREAT                
+#define O_CREAT        0100
+#endif
+
+#ifndef O_EXCL
+#define O_EXCL         0200
+#endif
+
+#ifndef O_TRUNC
+#define O_TRUNC                01000
+#endif
+
+#ifndef O_APPEND
+#define O_APPEND       02000
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET       0
+#endif
+
+#ifndef SEEK_CUR
+#define SEEK_CUR       1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END       2
+#endif
+
+#ifndef EBUSY
+#define EBUSY  16
+#endif
+
+#ifndef ENODEV
+#define ENODEV 19
+#endif
+
+#ifndef EINVAL
+#define EINVAL 22
+#endif
+
+#ifndef ENFILE
+#define ENFILE 23
+#endif
+
+#ifndef EBADF
+#define EBADF  9
+#endif
+
+#ifndef EACCES
+#define EACCES 13
+#endif
+
+#ifndef EXDEV  
+#define EXDEV  18
+#endif
+
+#ifndef ENOENT
+#define ENOENT 2
+#endif
+
+#ifndef ENOSPC
+#define ENOSPC 28
+#endif
+
+#ifndef ERANGE
+#define ERANGE 34
+#endif
+
+#ifndef ENODATA
+#define ENODATA 61
+#endif
+
+#ifndef ENOTEMPTY
+#define ENOTEMPTY 39
+#endif
+
+#ifndef ENAMETOOLONG
+#define ENAMETOOLONG 36
+#endif
+
+#ifndef ENOMEM
+#define ENOMEM 12
+#endif
+
+#ifndef EEXIST
+#define EEXIST 17
+#endif
+
+#ifndef ENOTDIR
+#define ENOTDIR 20
+#endif
+
+#ifndef EISDIR
+#define EISDIR 21
+#endif
+
+
+// Mode flags
+
+#ifndef S_IFMT
+#define S_IFMT         0170000
+#endif
+
+#ifndef S_IFLNK
+#define S_IFLNK                0120000
+#endif
+
+#ifndef S_IFDIR
+#define S_IFDIR                0040000
+#endif
+
+#ifndef S_IFREG
+#define S_IFREG                0100000
+#endif
+
+#ifndef S_IREAD 
+#define S_IREAD                0000400
+#endif
+
+#ifndef S_IWRITE
+#define        S_IWRITE        0000200
+#endif
+
+#ifndef S_IEXEC
+#define        S_IEXEC 0000100
+#endif
+
+#ifndef XATTR_CREATE
+#define XATTR_CREATE 1
+#endif
+
+#ifndef XATTR_REPLACE
+#define XATTR_REPLACE 2
+#endif
+
+#ifndef R_OK
+#define R_OK   4
+#define W_OK   2
+#define X_OK   1
+#define F_OK   0
+#endif
+
+#else
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#endif
+
+#endif
+
+#ifndef Y_DUMP_STACK
+#define Y_DUMP_STACK() do { } while (0)
+#endif
+
+#ifndef YBUG
+#define YBUG() do {\
+       T(YAFFS_TRACE_BUG,\
+               (TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),\
+               __LINE__));\
+       Y_DUMP_STACK();\
+} while (0)
+#endif
+
+
+#endif
+
+/*
+ * 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 Charles Manning <charles@aleph1.co.uk>
+ *
+ * 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.
+ */
+
+/*
+ * This file is just holds extra declarations of macros that would normally
+ * be provided in the Linux kernel. These macros have been written from
+ * scratch but are functionally equivalent to the Linux ones.
+ *
+ */
+
+#ifndef __EXTRAS_H__
+#define __EXTRAS_H__
+
+
+/* Definition of types */
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned u32;
+
+
+#ifndef WIN32
+#include <sys/stat.h>
+#endif
+
+
+#ifdef CONFIG_YAFFS_PROVIDE_DEFS
+/* File types */
+
+
+#define DT_UNKNOWN     0
+#define DT_FIFO                1
+#define DT_CHR         2
+#define DT_DIR         4
+#define DT_BLK         6
+#define DT_REG         8
+#define DT_LNK         10
+#define DT_SOCK                12
+#define DT_WHT         14
+
+
+#ifndef WIN32
+#include <sys/stat.h>
+#endif
+
+/*
+ * Attribute flags.  These should be or-ed together to figure out what
+ * has been changed!
+ */
+#define ATTR_MODE      1
+#define ATTR_UID       2
+#define ATTR_GID       4
+#define ATTR_SIZE      8
+#define ATTR_ATIME     16
+#define ATTR_MTIME     32
+#define ATTR_CTIME     64
+
+struct iattr {
+       unsigned int ia_valid;
+       unsigned ia_mode;
+       unsigned ia_uid;
+       unsigned ia_gid;
+       unsigned ia_size;
+       unsigned ia_atime;
+       unsigned ia_mtime;
+       unsigned ia_ctime;
+       unsigned int ia_attr_flags;
+};
+
+#endif
+
+
+
+#endif
index caa7eaebef282a4fa4c9ac67f9d5c45802f80e85..0cfa9d97207548d5558b923857c519e1ee2b6b7b 100755 (executable)
@@ -56,10 +56,12 @@ if [ $MULTIORSINGLE = m ]; then
    VFS_CODE="yaffs_vfs_multi.c"
    MTD1_CODE="yaffs_mtdif1_multi.c"
    MTD2_CODE="yaffs_mtdif2_multi.c"
+   YPORTENV="yportenv_multi.h"
 elif [ $MULTIORSINGLE = s ]; then
    VFS_CODE="yaffs_vfs_single.c"
    MTD1_CODE="yaffs_mtdif1_single.c"
    MTD2_CODE="yaffs_mtdif2_single.c"
+   YPORTENV="yportenv_single.h"
 
    echo ""
    echo "*** Warning ***"
@@ -145,7 +147,9 @@ else
    $CPY $PWD/Kconfig $LINUXDIR/fs/yaffs2
    $CPY $PWD/*.c $PWD/*.h  $LINUXDIR/fs/yaffs2
    rm $LINUXDIR/fs/yaffs2/yaffs_vfs*.c $LINUXDIR/fs/yaffs2/yaffs_mtdif[12]*.c
+   rm $LINUXDIR/fs/yaffs2/yportenv*.h
    $CPY $PWD/$VFS_CODE $LINUXDIR/fs/yaffs2/yaffs_vfs.c
    $CPY $PWD/$MTD1_CODE $LINUXDIR/fs/yaffs2/yaffs_mtdif1.c
    $CPY $PWD/$MTD2_CODE $LINUXDIR/fs/yaffs2/yaffs_mtdif2.c
+   $CPY $PWD/$YPORTENV $LINUXDIR/fs/yaffs2/yportenv.h
 fi
index 19a5b39490fc14d0829af2464bfe31aec6b46485..cd1bb120bd0156a432698254d126b5ea7bf0ba8e 100644 (file)
@@ -69,7 +69,6 @@ static struct yaffs_obj *yaffs_new_obj(struct yaffs_dev *dev, int number,
 static int yaffs_apply_xattrib_mod(struct yaffs_obj *obj, char *buffer, struct yaffs_xattr_mod *xmod);
 
 static void yaffs_remove_obj_from_dir(struct yaffs_obj *obj);
-static int yaffs_check_structures(void);
 static int yaffs_generic_obj_del(struct yaffs_obj *in);
 
 static int yaffs_check_chunk_erased(struct yaffs_dev *dev,
@@ -5020,13 +5019,6 @@ int yaffs_guts_initialise(struct yaffs_dev *dev)
                return YAFFS_FAIL;
        }
 
-       /* This is really a compilation check. */
-       if (!yaffs_check_structures()) {
-               T(YAFFS_TRACE_ALWAYS,
-                 (TSTR("yaffs_check_structures failed\n" TENDSTR)));
-               return YAFFS_FAIL;
-       }
-
        if (dev->is_mounted) {
                T(YAFFS_TRACE_ALWAYS,
                  (TSTR("yaffs: device already mounted\n" TENDSTR)));
@@ -5350,28 +5342,3 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev)
        return n_free;
 
 }
-
-
-/*---------------------------------------- YAFFS test code ----------------------*/
-
-#define yaffs_check_struct(structure, syze, name) \
-       do { \
-               if (sizeof(structure) != syze) { \
-                       T(YAFFS_TRACE_ALWAYS, (TSTR("%s should be %d but is %d\n" TENDSTR),\
-                               name, syze, (int) sizeof(structure))); \
-                       return YAFFS_FAIL; \
-               } \
-       } while (0)
-
-static int yaffs_check_structures(void)
-{
-/*      yaffs_check_struct(struct yaffs_tags,8,"struct yaffs_tags"); */
-/*      yaffs_check_struct(union yaffs_tags_union,8,"union yaffs_tags_union"); */
-/*      yaffs_check_struct(struct yaffs_spare,16,"struct yaffs_spare"); */
-/*     yaffs_check_struct(struct yaffs_tnode, 2 * YAFFS_NTNODES_LEVEL0, "struct yaffs_tnode"); */
-
-#ifndef CONFIG_YAFFS_WINCE
-       yaffs_check_struct(struct yaffs_obj_hdr, 512, "struct yaffs_obj_hdr");
-#endif
-       return YAFFS_OK;
-}
index b4ee59fde923eb82acdd4c532714b92a99a31986..13a2e877798b6319657d9939bf89306d7d93ee31 100644 (file)
@@ -17,7 +17,6 @@
 #define __YAFFS_GUTS_H__
 
 #include "yportenv.h"
-#include "devextras.h"
 
 #define YAFFS_OK       1
 #define YAFFS_FAIL  0
index e5ecb8a2ff20af445cfd327f1a6584832092dd16..9c463a92c375fac07b6d7578255152cf7e1f2c4b 100644 (file)
@@ -16,7 +16,6 @@
 #ifndef __YAFFS_LINUX_H__
 #define __YAFFS_LINUX_H__
 
-#include "devextras.h"
 #include "yportenv.h"
 
 struct yaffs_linux_context {
index 198bca399e7363c605839fa4a37cff0ce0d05285..666507417fece16e07ea37c33ec29a488848487b 100644 (file)
 
 #include "yaffs_guts.h"
 
-#if (MTD_VERSION_CODE < MTD_VERSION(2, 6, 18))
-extern struct nand_oobinfo yaffs_oobinfo;
-extern struct nand_oobinfo yaffs_noeccinfo;
-#endif
 int nandmtd_erase_block(struct yaffs_dev *dev, int block_no);
 int nandmtd_initialise(struct yaffs_dev *dev);
 #endif
diff --git a/yaffs_qsort.h b/yaffs_qsort.h
deleted file mode 100644 (file)
index 4a4981b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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 Charles Manning <charles@aleph1.co.uk>
- *
- * 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_QSORT_H__
-#define __YAFFS_QSORT_H__
-
-#ifdef __KERNEL__
-#include <linux/sort.h>
-
-extern void yaffs_qsort(void *const base, size_t total_elems, size_t size,
-                       int (*cmp)(const void *, const void *)){
-       sort(base, total_elems, size, cmp, NULL);
-}
-
-#else
-
-extern void yaffs_qsort(void *const base, size_t total_elems, size_t size,
-                       int (*cmp)(const void *, const void *));
-
-#endif
-#endif
index 0bac099728540221eac9d16cf8b2faee747b1fc9..d5b167ffcee942820405576590319bf35e685975 100644 (file)
@@ -17,7 +17,6 @@
 #include "yaffs_yaffs2.h"
 #include "yaffs_checkptrw.h"
 #include "yaffs_bitmap.h"
-#include "yaffs_qsort.h"
 #include "yaffs_nand.h"
 #include "yaffs_getblockinfo.h"
 #include "yaffs_verify.h"
@@ -892,18 +891,18 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size)
 }
 
 
-typedef struct {
+struct yaffs_block_index{
        int seq;
        int block;
-} yaffs_block_index;
+};
 
 
 static int yaffs2_ybicmp(const void *a, const void *b)
 {
-       register int aseq = ((yaffs_block_index *)a)->seq;
-       register int bseq = ((yaffs_block_index *)b)->seq;
-       register int ablock = ((yaffs_block_index *)a)->block;
-       register int bblock = ((yaffs_block_index *)b)->block;
+       int aseq = ((struct yaffs_block_index *)a)->seq;
+       int bseq = ((struct yaffs_block_index *)b)->seq;
+       int ablock = ((struct yaffs_block_index *)a)->block;
+       int bblock = ((struct yaffs_block_index *)b)->block;
        if (aseq == bseq)
                return ablock - bblock;
        else
@@ -941,7 +940,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
        int alloc_failed = 0;
 
 
-       yaffs_block_index *block_index = NULL;
+       struct yaffs_block_index *block_index = NULL;
        int alt_block_index = 0;
 
        T(YAFFS_TRACE_SCAN,
@@ -952,10 +951,10 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
 
        dev->seq_number = YAFFS_LOWEST_SEQUENCE_NUMBER;
 
-       block_index = YMALLOC(n_blocks * sizeof(yaffs_block_index));
+       block_index = YMALLOC(n_blocks * sizeof(struct yaffs_block_index));
 
        if (!block_index) {
-               block_index = YMALLOC_ALT(n_blocks * sizeof(yaffs_block_index));
+               block_index = YMALLOC_ALT(n_blocks * sizeof(struct yaffs_block_index));
                alt_block_index = 1;
        }
 
@@ -1035,7 +1034,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
        YYIELD();
 
        /* Sort the blocks by sequence number*/
-       yaffs_qsort(block_index, n_to_scan, sizeof(yaffs_block_index), yaffs2_ybicmp);
+       yaffs_sort(block_index, n_to_scan, sizeof(struct yaffs_block_index), yaffs2_ybicmp);
 
        YYIELD();
 
similarity index 96%
rename from yportenv.h
rename to yportenv_multi.h
index ebb4f92041dd1e582f89e1e96b8eadf7e40e677b..3295ca0aeebc13e118001cdebe94ef38eec835a0 100644 (file)
@@ -41,7 +41,7 @@
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
 #include <linux/config.h>
 #endif
-
+#include <linux/version.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/vmalloc.h>
 #include <linux/xattr.h>
 #include <linux/list.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/stat.h>
+#include <linux/sort.h>
 
 #define YCHAR char
 #define YUCHAR unsigned char
@@ -61,6 +65,8 @@
 #define yaffs_strnlen(s,m)     strnlen(s,m)
 #define yaffs_sprintf         sprintf
 #define yaffs_toupper(a)       toupper(a)
+#define yaffs_sort(base, n, sz, cmp_fn) sort(base, n, sz, cmp_fn, NULL)
+
 
 #define Y_INLINE __inline__
 
diff --git a/yportenv_single.h b/yportenv_single.h
new file mode 100644 (file)
index 0000000..42892b8
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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 Charles Manning <charles@aleph1.co.uk>
+ *
+ * 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 __YPORTENV_LINUX_H__
+#define __YPORTENV_LINUX_H__
+
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/xattr.h>
+#include <linux/list.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/stat.h>
+#include <linux/sort.h>
+
+#define YCHAR char
+#define YUCHAR unsigned char
+#define _Y(x)     x
+#define yaffs_strcat(a, b)     strcat(a, b)
+#define yaffs_strcpy(a, b)     strcpy(a, b)
+#define yaffs_strncpy(a, b, c) strncpy(a, b, c)
+#define yaffs_strncmp(a, b, c) strncmp(a, b, c)
+#define yaffs_strnlen(s,m)     strnlen(s,m)
+#define yaffs_sprintf         sprintf
+#define yaffs_toupper(a)       toupper(a)
+
+#define yaffs_sort(base, n, sz, cmp_fn)        sort(base, n, sz, cmp_fn, NULL)
+
+#define Y_INLINE __inline__
+
+#define YAFFS_LOSTNFOUND_NAME          "lost+found"
+#define YAFFS_LOSTNFOUND_PREFIX                "obj"
+
+#define YMALLOC(x) kmalloc(x, GFP_NOFS)
+#define YFREE(x)   kfree(x)
+#define YMALLOC_ALT(x) vmalloc(x)
+#define YFREE_ALT(x)   vfree(x)
+#define YMALLOC_DMA(x) YMALLOC(x)
+
+#define YYIELD() schedule()
+#define Y_DUMP_STACK() dump_stack()
+
+#define YAFFS_ROOT_MODE                        0755
+#define YAFFS_LOSTNFOUND_MODE          0700
+
+
+#define Y_CURRENT_TIME CURRENT_TIME.tv_sec
+#define Y_TIME_CONVERT(x) (x).tv_sec
+#define yaffs_sum_cmp(x, y) ((x) == (y))
+#define yaffs_strcmp(a, b) strcmp(a, b)
+
+#define TENDSTR "\n"
+#define TSTR(x) KERN_DEBUG x
+#define TCONT(x) x
+#define TOUT(p) printk p
+
+#define compile_time_assertion(assertion) \
+       ({ int x = __builtin_choose_expr(assertion, 0, (void)0); (void) x; })
+
+
+
+#ifndef Y_DUMP_STACK
+#define Y_DUMP_STACK() do { } while (0)
+#endif
+
+#ifndef YBUG
+#define YBUG() do {\
+       T(YAFFS_TRACE_BUG,\
+               (TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),\
+               __LINE__));\
+       Y_DUMP_STACK();\
+} while (0)
+#endif
+
+
+#endif