Hi!
This one allows to build yaffs2 in main kernel tree. Just copy yaffs2/ to
the fs/ tree, remove anything but *.[ch] from yaffs2/ (Makefile and 2
directories), apply the patch, make menuconfig and enjoy.
It also contains a small fix for mtdif.c (ecc always failed without it, no
matter NAND ECC or YAFFS).
Everything's against 2.6.12. Ah, my "compile" patch is also in here.
Somebody who is responsible for the CVS tree, please either remove that part
(I posted it yesterday) or ignore "already applied" rejects.
=== Cut ===
diff -urN linux-2.6.12.orig/fs/Kconfig linux-2.6.12/fs/Kconfig
--- linux-2.6.12.orig/fs/Kconfig 2005-07-26 13:37:05.000000000 -0700
+++ linux-2.6.12/fs/Kconfig 2005-07-26 13:58:32.000000000 -0700
@@ -1023,6 +1023,10 @@
To compile the EFS file system support as a module, choose M here: the
module will be called efs.
+
+# Patched by YAFFS
+source "fs/yaffs2/Kconfig"
+
config JFFS_FS
tristate "Journalling Flash File System (JFFS) support"
depends on MTD
diff -urN linux-2.6.12.orig/fs/Makefile linux-2.6.12/fs/Makefile
--- linux-2.6.12.orig/fs/Makefile 2005-07-26 13:37:05.000000000 -0700
+++ linux-2.6.12/fs/Makefile 2005-07-26 13:58:32.000000000 -0700
@@ -97,3 +97,6 @@
obj-$(CONFIG_HOSTFS) += hostfs/
obj-$(CONFIG_HPPFS) += hppfs/
obj-$(CONFIG_DEBUG_FS) += debugfs/
+
+# Patched by YAFFS
+obj-$(CONFIG_YAFFS_FS) += yaffs2/
diff -urN linux-2.6.12.orig/fs/yaffs2/Kconfig linux-2.6.12/fs/yaffs2/Kconfig
--- linux-2.6.12.orig/fs/yaffs2/Kconfig 1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.12/fs/yaffs2/Kconfig 2005-07-26 13:58:32.000000000 -0700
@@ -0,0 +1,105 @@
+#
+# YAFFS file system configurations
+#
+
+config YAFFS_FS
+ tristate "YAFFS file system support"
+ select YAFFS_MTD_ENABLED
+ help
+ YAFFS2, or Yet Another Flash Filing System, is a filing system
+ optimised for NAND Flash chips.
+
+ To compile the YAFFS2 file system support as a module, choose M here:
+ the module will be called yaffs2.
+
+ If unsure, say N.
+
+ Further information on YAFFS2 is available at
+ <<a href="http://www.aleph1.co.uk/yaffs/">http://www.aleph1.co.uk/yaffs/</a>>.
+
+config YAFFS_YAFFS2
+ bool "YAFFS2 - 2k page NAND support"
+ depends on YAFFS_FS
+ select YAFFS2_MTD_ENABLED
+ help
+ This adds the yaffs support for 2k page NAND devices
+
+config YAFFS_MTD_ENABLED
+ bool "NAND mtd support - 512 byte / page devices"
+ depends on YAFFS_FS
+ help
+ This adds the yaffs file system support for working with a NAND mtd.
+
+ If unsure, say Y.
+
+config YAFFS2_MTD_ENABLED
+ bool "NAND mtd support - 2048 byte / page devices"
+ depends on YAFFS_FS
+ help
+ This adds the yaffs2 file system support for working with a NAND mtd.
+
+ If unsure, say Y.
+
+config YAFFS_USE_NANDECC
+ bool "Use ECC functions of the generic MTD-NAND driver"
+ depends on YAFFS_FS
+ default y
+ help
+ This enables the ECC functions of the generic MTD-NAND driver.
+ This will not work if you are using the old mtd.
+
+ NB Use NAND ECC does not work at present with yaffsram.
+
+ If unsure, say Y.
+
+config YAFFS_ECC_WRONG_ORDER
+ bool "Use the same ecc byte order as Steven Hill's nand_ecc.c"
+ depends on YAFFS_FS && !YAFFS_USE_NANDECC
+ help
+ This makes yaffs_ecc.c use the same ecc byte order as
+ Steven Hill's nand_ecc.c. If not set, then you get the
+ same ecc byte order as SmartMedia.
+
+ If unsure, say N.
+
+config YAFFS_DISABLE_CHUNK_ERASED_CHECK
+ bool "Turn off debug chunk erase check"
+ depends on YAFFS_FS
+ default y
+ help
+ Enabling this turns off the test that chunks are erased in flash
+ before writing to them. This is safe, since the write verification
+ will fail. Suggest enabling the test (ie. say N)
+ during development to help debug things.
+
+ If unsure, say Y.
+
+config YAFFS_USE_CHUNK_SIZE
+ bool "use chunk size as file block size"
+ depends on YAFFS_FS
+ default n
+ help
+ Enable this to set file blocksize to the yaffs chunk size.
+ Disable it to use the page cache size as the file block size.
+
+ If unsure, say N.
+
+config YAFFS_TNODE_LIST_DEBUG
+ bool "enable tnode debuging"
+ depends on YAFFS_FS
+ default n
+ help
+ Turn on tnode debugging.
+
+ If unsure, say N.
+
+config YAFFS_SHORT_NAMES_IN_RAM
+ bool "Cache short names in RAM"
+ depends on YAFFS_FS
+ default y
+ help
+ If this config is set, then short names are stored with the
+ yaffs_Object. This costs an extra 16 bytes of RAM per object,
+ but makes look-ups faster.
+
+ If unsure, say Y.
diff -urN linux-2.6.12.orig/fs/yaffs2/Makefile linux-2.6.12/fs/yaffs2/Makefile
--- linux-2.6.12.orig/fs/yaffs2/Makefile 1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.12/fs/yaffs2/Makefile 2005-07-26 13:58:32.000000000 -0700
@@ -0,0 +1,13 @@
+#
+# Makefile for the linux YAFFS filesystem routines.
+#
+
+obj-$(CONFIG_YAFFS_FS) += yaffs.o
+
+yaffs-y := yaffs_ecc.o yaffs_fs.o yaffs_guts.o
+yaffs-y += yaffs_packedtags2.o yaffs_ramem.o yaffs_ramem2k.o
+yaffs-y += yaffs_tagscompat.o yaffs_tagsvalidity.o
+yaffs-y += yaffs_mtdif.o yaffs_mtdif2.o
+
+#yaffs2-$(CONFIG_YAFFS2_MTD_ENABLED) += yaffs_mtdif.o yaffs_mtdif2.o
+#yaffs2-$(CONFIG_YAFFS2_RAM_ENABLED) += yaffs_ramem.o
diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_ecc.c linux-2.6.12/fs/yaffs2/yaffs_ecc.c
--- linux-2.6.12.orig/fs/yaffs2/yaffs_ecc.c 2005-03-15 20:00:36.000000000 -0800
+++ linux-2.6.12/fs/yaffs2/yaffs_ecc.c 2005-07-26 13:58:32.000000000 -0700
@@ -32,6 +32,7 @@
const char *yaffs_ecc_c_version = "$Id: yaffs_ecc.c,v 1.2 2005/03/16 04:00:36 charles Exp $";
+#include <linux/config.h>
#include "yaffs_ecc.h"
static const unsigned char column_parity_table[] = {
diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_fs.c linux-2.6.12/fs/yaffs2/yaffs_fs.c
--- linux-2.6.12.orig/fs/yaffs2/yaffs_fs.c 2005-07-19 13:41:59.000000000 -0700
+++ linux-2.6.12/fs/yaffs2/yaffs_fs.c 2005-07-26 14:00:32.000000000 -0700
@@ -180,63 +180,63 @@
static struct address_space_operations yaffs_file_address_operations = {
- .readpage: yaffs_readpage,
- .writepage: yaffs_writepage,
- .prepare_write: yaffs_prepare_write,
- .commit_write: yaffs_commit_write
+ .readpage = yaffs_readpage,
+ .writepage = yaffs_writepage,
+ .prepare_write = yaffs_prepare_write,
+ .commit_write = yaffs_commit_write
};
static struct file_operations yaffs_file_operations = {
- .read: generic_file_read,
- .write: generic_file_write,
+ .read = generic_file_read,
+ .write = generic_file_write,
- .mmap: generic_file_mmap,
- .flush: yaffs_file_flush,
- .fsync: yaffs_sync_object,
+ .mmap = generic_file_mmap,
+ .flush = yaffs_file_flush,
+ .fsync = yaffs_sync_object,
};
static struct inode_operations yaffs_file_inode_operations = {
- .setattr: yaffs_setattr,
+ .setattr = yaffs_setattr,
};
struct inode_operations yaffs_symlink_inode_operations =
{
- .readlink: yaffs_readlink,
- .follow_link: yaffs_follow_link,
- .setattr: yaffs_setattr
+ .readlink = yaffs_readlink,
+ .follow_link = yaffs_follow_link,
+ .setattr = yaffs_setattr
};
static struct inode_operations yaffs_dir_inode_operations = {
- .create: yaffs_create,
- .lookup: yaffs_lookup,
- .link: yaffs_link,
- .unlink: yaffs_unlink,
- .symlink: yaffs_symlink,
- .mkdir: yaffs_mkdir,
- .rmdir: yaffs_unlink,
- .mknod: yaffs_mknod,
- .rename: yaffs_rename,
- .setattr: yaffs_setattr,
+ .create = yaffs_create,
+ .lookup = yaffs_lookup,
+ .link = yaffs_link,
+ .unlink = yaffs_unlink,
+ .symlink = yaffs_symlink,
+ .mkdir = yaffs_mkdir,
+ .rmdir = yaffs_unlink,
+ .mknod = yaffs_mknod,
+ .rename = yaffs_rename,
+ .setattr = yaffs_setattr,
};
static struct file_operations yaffs_dir_operations = {
- .read: generic_read_dir,
- .readdir: yaffs_readdir,
- .fsync: yaffs_sync_object,
+ .read = generic_read_dir,
+ .readdir = yaffs_readdir,
+ .fsync = yaffs_sync_object,
};
static struct super_operations yaffs_super_ops = {
- .statfs: yaffs_statfs,
- .read_inode: yaffs_read_inode,
- .put_inode: yaffs_put_inode,
- .put_super: yaffs_put_super,
- .delete_inode: yaffs_delete_inode,
- .clear_inode: yaffs_clear_inode,
+ .statfs = yaffs_statfs,
+ .read_inode = yaffs_read_inode,
+ .put_inode = yaffs_put_inode,
+ .put_super = yaffs_put_super,
+ .delete_inode = yaffs_delete_inode,
+ .clear_inode = yaffs_clear_inode,
};
@@ -918,6 +918,8 @@
yaffs_Object *parent = yaffs_InodeToObject(dir);
int error = -ENOSPC;
+ uid_t uid = current->fsuid;
+ gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
if(parent)
{
@@ -943,18 +945,18 @@
// Special (socket, fifo, device...)
T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making special\n"));
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
- obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,old_encode_dev(rdev));
+ obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,uid, gid,old_encode_dev(rdev));
#else
- obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
+ obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,uid, gid,rdev);
#endif
break;
case S_IFREG: // file
T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
- obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,current->uid, current->gid);
+ obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,uid, gid);
break;
case S_IFDIR: // directory
T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making directory\n"));
- obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,current->uid, current->gid);
+ obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,uid, gid);
break;
case S_IFLNK: // symlink
T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
@@ -1090,13 +1092,15 @@
{
yaffs_Object *obj;
yaffs_Device *dev;
+ uid_t uid = current->fsuid;
+ gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_symlink\n"));
dev = yaffs_InodeToObject(dir)->myDev;
yaffs_GrossLock(dev);
obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
- S_IFLNK | S_IRWXUGO, current->uid, current->gid,
+ S_IFLNK | S_IRWXUGO, uid, gid,
symname);
yaffs_GrossUnlock(dev);
diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_guts.h linux-2.6.12/fs/yaffs2/yaffs_guts.h
--- linux-2.6.12.orig/fs/yaffs2/yaffs_guts.h 2005-07-25 20:05:28.000000000 -0700
+++ linux-2.6.12/fs/yaffs2/yaffs_guts.h 2005-07-26 14:19:21.000000000 -0700
@@ -20,6 +20,7 @@
#ifndef __YAFFS_GUTS_H__
#define __YAFFS_GUTS_H__
+#include <linux/config.h>
#include "devextras.h"
#include "yportenv.h"
@@ -121,7 +122,7 @@
typedef struct
{
- unsigned chunkId:20;
+ unsigned chunkId:20;
unsigned serialNumber:2;
unsigned byteCount:10;
unsigned objectId:18;
diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_mtdif2.c linux-2.6.12/fs/yaffs2/yaffs_mtdif2.c
--- linux-2.6.12.orig/fs/yaffs2/yaffs_mtdif2.c 2005-07-20 11:57:05.000000000 -0700
+++ linux-2.6.12/fs/yaffs2/yaffs_mtdif2.c 2005-07-26 13:58:32.000000000 -0700
@@ -17,6 +17,7 @@
const char *yaffs_mtdif2_c_version = "$Id: yaffs_mtdif2.c,v 1.3 2005/07/20 18:57:05 charles Exp $";
+#include <linux/config.h>
#ifdef CONFIG_YAFFS_MTD_ENABLED
#include "yportenv.h"
diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_mtdif.c linux-2.6.12/fs/yaffs2/yaffs_mtdif.c
--- linux-2.6.12.orig/fs/yaffs2/yaffs_mtdif.c 2005-07-19 13:41:59.000000000 -0700
+++ linux-2.6.12/fs/yaffs2/yaffs_mtdif.c 2005-07-26 14:01:25.000000000 -0700
@@ -15,6 +15,7 @@
const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.2 2005/07/19 20:41:59 charles Exp $";
+#include <linux/config.h>
#ifdef CONFIG_YAFFS_MTD_ENABLED
#include "yportenv.h"
@@ -30,12 +31,16 @@
#endif
struct nand_oobinfo yaffs_oobinfo = {
- useecc: 1,
- eccpos: {8, 9, 10, 13, 14, 15}
+ .useecc = MTD_NANDECC_PLACE,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8))
+// this is for versions of mtd nand driver in kernel 2.6.8 and later
+ .eccbytes = 6,
+#endif
+ .eccpos = {8, 9, 10, 13, 14, 15}
};
struct nand_oobinfo yaffs_noeccinfo = {
- useecc: 0,
+ .useecc = MTD_NANDECC_OFF,
};
diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_tagscompat.c linux-2.6.12/fs/yaffs2/yaffs_tagscompat.c
--- linux-2.6.12.orig/fs/yaffs2/yaffs_tagscompat.c 2005-03-15 20:00:36.000000000 -0800
+++ linux-2.6.12/fs/yaffs2/yaffs_tagscompat.c 2005-07-26 13:58:32.000000000 -0700
@@ -13,6 +13,7 @@
* $Id: yaffs_tagscompat.c,v 1.2 2005/03/16 04:00:36 charles Exp $
*/
+#include <linux/config.h>
#include "yaffs_guts.h"
#include "yaffs_tagscompat.h"
#include "yaffs_ecc.h"
diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_tagsvalidity.c linux-2.6.12/fs/yaffs2/yaffs_tagsvalidity.c
--- linux-2.6.12.orig/fs/yaffs2/yaffs_tagsvalidity.c 2005-04-29 11:09:16.000000000 -0700
+++ linux-2.6.12/fs/yaffs2/yaffs_tagsvalidity.c 2005-07-26 13:58:32.000000000 -0700
@@ -15,6 +15,7 @@
*/
//yaffs_tagsvalidity.c
+#include <linux/config.h>
#include "yaffs_tagsvalidity.h"
diff -urN linux-2.6.12.orig/fs/yaffs2/yaffs_guts.c linux-2.6.12/fs/yaffs2/yaffs_guts.c
--- linux-2.6.12.orig/fs/yaffs2/yaffs_guts.c 2005-07-25 20:05:28.000000000 -0700
+++ linux-2.6.12/fs/yaffs2/yaffs_guts.c 2005-07-26 15:37:37.000000000 -0700
@@ -16,6 +16,7 @@
const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.10 2005/07/26 03:05:28 charles Exp $";
+#include <linux/config.h>
#include "yportenv.h"
#include "yaffsinterface.h"
@@ -3135,13 +3136,14 @@
{
// yaffs_SpareInitialise(&spare);
+#if 0
#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
//read data before write, to ensure correct ecc
//if we're using MTD verification under Linux
yaffs_ReadChunkFromNAND(dev,chunkId,NULL,&spare,0);
#endif
-
+#endif
yaffs_InitialiseTags(&tags);
tags.chunkDeleted = 1;
=== Cut ===
---
******************************************************************
* KSI@home KOI8 Net < > The impossible we do immediately. *
* Las Vegas NV, USA < > Miracles require 24-hour notice. *
******************************************************************