From: Charles Manning Date: Tue, 2 Nov 2010 22:45:09 +0000 (+1300) Subject: yaffs: More clean up. X-Git-Tag: linux-mainline-patchset-4~137 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=4aab7ea4c9b8fb1bb9b375476a9faf70d29871b1 yaffs: More clean up. Signed-off-by: Charles Manning --- diff --git a/devextras.h b/devextras.h deleted file mode 100644 index baadeff..0000000 --- a/devextras.h +++ /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 - * - * 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 -#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 -#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 -#include -#include - -#endif - - -#endif diff --git a/direct/basic-test/Makefile b/direct/basic-test/Makefile index 6074e00..542efba 100644 --- a/direct/basic-test/Makefile +++ b/direct/basic-test/Makefile @@ -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 diff --git a/direct/basic-test/yaffs_fileem.c b/direct/basic-test/yaffs_fileem.c index f92fa8f..702acbe 100644 --- a/direct/basic-test/yaffs_fileem.c +++ b/direct/basic-test/yaffs_fileem.c @@ -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 #include #include diff --git a/direct/basic-test/yaffs_fileem2k.c b/direct/basic-test/yaffs_fileem2k.c index 072e2f1..d8fde73 100644 --- a/direct/basic-test/yaffs_fileem2k.c +++ b/direct/basic-test/yaffs_fileem2k.c @@ -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 #include diff --git a/direct/basic-test/yaffs_norif1.c b/direct/basic-test/yaffs_norif1.c index 2484bec..7be6295 100644 --- a/direct/basic-test/yaffs_norif1.c +++ b/direct/basic-test/yaffs_norif1.c @@ -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 diff --git a/direct/basic-test/yaffs_ramdisk.c b/direct/basic-test/yaffs_ramdisk.c index e202028..babddde 100644 --- a/direct/basic-test/yaffs_ramdisk.c +++ b/direct/basic-test/yaffs_ramdisk.c @@ -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" diff --git a/direct/basic-test/yaffs_ramem2k.c b/direct/basic-test/yaffs_ramem2k.c index 0310357..7f88b7c 100644 --- a/direct/basic-test/yaffs_ramem2k.c +++ b/direct/basic-test/yaffs_ramem2k.c @@ -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" diff --git a/direct/python/Makefile b/direct/python/Makefile index 6fc217e..f571cf4 100644 --- a/direct/python/Makefile +++ b/direct/python/Makefile @@ -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 \ diff --git a/direct/tests/Makefile b/direct/tests/Makefile index 302d5b4..cb90c29 100644 --- a/direct/tests/Makefile +++ b/direct/tests/Makefile @@ -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\ diff --git a/direct/yaffs_flashif.c b/direct/yaffs_flashif.c index d9c7cb1..8595804 100644 --- a/direct/yaffs_flashif.c +++ b/direct/yaffs_flashif.c @@ -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 diff --git a/direct/yaffs_nandif.c b/direct/yaffs_nandif.c index 0e2c14a..9a22f7f 100644 --- a/direct/yaffs_nandif.c +++ b/direct/yaffs_nandif.c @@ -13,7 +13,6 @@ #include "yportenv.h" #include "yaffs_guts.h" -#include "devextras.h" #include "yaffs_nandif.h" diff --git a/direct/yaffscfg.h b/direct/yaffscfg.h index 3387802..42fd78c 100644 --- a/direct/yaffscfg.h +++ b/direct/yaffscfg.h @@ -23,8 +23,7 @@ #define __YAFFSCFG_H__ -#include "yportenv.h" -#include "devextras.h" +#include "yportenv.h" #define YAFFSFS_N_HANDLES 100 diff --git a/direct/ydirectenv.h b/direct/ydirectenv.h index ea224cc..ee6e8f5 100644 --- a/direct/ydirectenv.h +++ b/direct/ydirectenv.h @@ -43,6 +43,11 @@ #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 index 0000000..22afb06 --- /dev/null +++ b/direct/yportenv.h @@ -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 + * + * 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 +#include +#include +#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 + * + * 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 +#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 +#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 diff --git a/patch-ker.sh b/patch-ker.sh index caa7eae..0cfa9d9 100755 --- a/patch-ker.sh +++ b/patch-ker.sh @@ -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 diff --git a/yaffs_guts.c b/yaffs_guts.c index 19a5b39..cd1bb12 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -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; -} diff --git a/yaffs_guts.h b/yaffs_guts.h index b4ee59f..13a2e87 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -17,7 +17,6 @@ #define __YAFFS_GUTS_H__ #include "yportenv.h" -#include "devextras.h" #define YAFFS_OK 1 #define YAFFS_FAIL 0 diff --git a/yaffs_linux.h b/yaffs_linux.h index e5ecb8a..9c463a9 100644 --- a/yaffs_linux.h +++ b/yaffs_linux.h @@ -16,7 +16,6 @@ #ifndef __YAFFS_LINUX_H__ #define __YAFFS_LINUX_H__ -#include "devextras.h" #include "yportenv.h" struct yaffs_linux_context { diff --git a/yaffs_mtdif.h b/yaffs_mtdif.h index 198bca3..6665074 100644 --- a/yaffs_mtdif.h +++ b/yaffs_mtdif.h @@ -18,10 +18,6 @@ #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 index 4a4981b..0000000 --- a/yaffs_qsort.h +++ /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 - * - * 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 - -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 diff --git a/yaffs_yaffs2.c b/yaffs_yaffs2.c index 0bac099..d5b167f 100644 --- a/yaffs_yaffs2.c +++ b/yaffs_yaffs2.c @@ -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(); diff --git a/yportenv.h b/yportenv_multi.h similarity index 96% rename from yportenv.h rename to yportenv_multi.h index ebb4f92..3295ca0 100644 --- a/yportenv.h +++ b/yportenv_multi.h @@ -41,7 +41,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)) #include #endif - +#include #include #include #include @@ -50,6 +50,10 @@ #include #include #include +#include +#include +#include +#include #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 index 0000000..42892b8 --- /dev/null +++ b/yportenv_single.h @@ -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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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