-/*\r
- * YAFFS: Yet another FFS. A NAND-flash specific file system. \r
- * devextras.h\r
- *\r
- * Copyright (C) 2002 Aleph One Ltd.\r
- * for Toby Churchill Ltd and Brightstar Engineering\r
- *\r
- * Created by Charles Manning <charles@aleph1.co.uk>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU Lesser General Public License version 2.1 as\r
- * published by the Free Software Foundation.\r
- *\r
- * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.\r
- *\r
- * This file is just holds extra declarations used during development.\r
- * Most of these are from kernel includes placed here so we can use them in \r
- * applications.\r
- *\r
- */\r
- \r
-#ifndef __EXTRAS_H__\r
-#define __EXTRAS_H__\r
-\r
-#if defined WIN32\r
-#define __inline__ __inline\r
-#define new newHack\r
-#endif\r
-\r
-#if !(defined __KERNEL__) || (defined WIN32)\r
-\r
-// User space defines\r
-\r
-typedef unsigned char __u8;\r
-typedef unsigned short __u16;\r
-typedef unsigned __u32;\r
-\r
-\r
-/*\r
- * Simple doubly linked list implementation.\r
- *\r
- * Some of the internal functions ("__xxx") are useful when\r
- * manipulating whole lists rather than single entries, as\r
- * sometimes we already know the next/prev entries and we can\r
- * generate better code by using them directly rather than\r
- * using the generic single-entry routines.\r
- */\r
- \r
- #define prefetch(x) 1\r
- \r
-\r
-struct list_head {\r
- struct list_head *next, *prev;\r
-};\r
-\r
-#define LIST_HEAD_INIT(name) { &(name), &(name) }\r
-\r
-#define LIST_HEAD(name) \\r
- struct list_head name = LIST_HEAD_INIT(name)\r
-\r
-#define INIT_LIST_HEAD(ptr) do { \\r
- (ptr)->next = (ptr); (ptr)->prev = (ptr); \\r
-} while (0)\r
-\r
-/*\r
- * Insert a new entry between two known consecutive entries.\r
- *\r
- * This is only for internal list manipulation where we know\r
- * the prev/next entries already!\r
- */\r
-static __inline__ void __list_add(struct list_head * new,\r
- struct list_head * prev,\r
- struct list_head * next)\r
-{\r
- next->prev = new;\r
- new->next = next;\r
- new->prev = prev;\r
- prev->next = new;\r
-}\r
-\r
-/**\r
- * list_add - add a new entry\r
- * @new: new entry to be added\r
- * @head: list head to add it after\r
- *\r
- * Insert a new entry after the specified head.\r
- * This is good for implementing stacks.\r
- */\r
-static __inline__ void list_add(struct list_head *new, struct list_head *head)\r
-{\r
- __list_add(new, head, head->next);\r
-}\r
-\r
-/**\r
- * list_add_tail - add a new entry\r
- * @new: new entry to be added\r
- * @head: list head to add it before\r
- *\r
- * Insert a new entry before the specified head.\r
- * This is useful for implementing queues.\r
- */\r
-static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)\r
-{\r
- __list_add(new, head->prev, head);\r
-}\r
-\r
-/*\r
- * Delete a list entry by making the prev/next entries\r
- * point to each other.\r
- *\r
- * This is only for internal list manipulation where we know\r
- * the prev/next entries already!\r
- */\r
-static __inline__ void __list_del(struct list_head * prev,\r
- struct list_head * next)\r
-{\r
- next->prev = prev;\r
- prev->next = next;\r
-}\r
-\r
-/**\r
- * list_del - deletes entry from list.\r
- * @entry: the element to delete from the list.\r
- * Note: list_empty on entry does not return true after this, the entry is in an undefined state.\r
- */\r
-static __inline__ void list_del(struct list_head *entry)\r
-{\r
- __list_del(entry->prev, entry->next);\r
-}\r
-\r
-/**\r
- * list_del_init - deletes entry from list and reinitialize it.\r
- * @entry: the element to delete from the list.\r
- */\r
-static __inline__ void list_del_init(struct list_head *entry)\r
-{\r
- __list_del(entry->prev, entry->next);\r
- INIT_LIST_HEAD(entry);\r
-}\r
-\r
-/**\r
- * list_empty - tests whether a list is empty\r
- * @head: the list to test.\r
- */\r
-static __inline__ int list_empty(struct list_head *head)\r
-{\r
- return head->next == head;\r
-}\r
-\r
-/**\r
- * list_splice - join two lists\r
- * @list: the new list to add.\r
- * @head: the place to add it in the first list.\r
- */\r
-static __inline__ void list_splice(struct list_head *list, struct list_head *head)\r
-{\r
- struct list_head *first = list->next;\r
-\r
- if (first != list) {\r
- struct list_head *last = list->prev;\r
- struct list_head *at = head->next;\r
-\r
- first->prev = head;\r
- head->next = first;\r
-\r
- last->next = at;\r
- at->prev = last;\r
- }\r
-}\r
-\r
-/**\r
- * list_entry - get the struct for this entry\r
- * @ptr: the &struct list_head pointer.\r
- * @type: the type of the struct this is embedded in.\r
- * @member: the name of the list_struct within the struct.\r
- */\r
-#define list_entry(ptr, type, member) \\r
- ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))\r
-\r
-/**\r
- * list_for_each - iterate over a list\r
- * @pos: the &struct list_head to use as a loop counter.\r
- * @head: the head for your list.\r
- */\r
-#define list_for_each(pos, head) \\r
- for (pos = (head)->next, prefetch(pos->next); pos != (head); \\r
- pos = pos->next, prefetch(pos->next))\r
-\r
-/**\r
- * list_for_each_safe - iterate over a list safe against removal of list entry\r
- * @pos: the &struct list_head to use as a loop counter.\r
- * @n: another &struct list_head to use as temporary storage\r
- * @head: the head for your list.\r
- */\r
-#define list_for_each_safe(pos, n, head) \\r
- for (pos = (head)->next, n = pos->next; pos != (head); \\r
- pos = n, n = pos->next)\r
-\r
-\r
-\r
-\r
-/*\r
- * File types\r
- */\r
-#define DT_UNKNOWN 0\r
-#define DT_FIFO 1\r
-#define DT_CHR 2\r
-#define DT_DIR 4\r
-#define DT_BLK 6\r
-#define DT_REG 8\r
-#define DT_LNK 10\r
-#define DT_SOCK 12\r
-#define DT_WHT 14\r
-\r
-#ifndef WIN32\r
-#include <sys/stat.h>\r
-#endif\r
-\r
-/*\r
- * Attribute flags. These should be or-ed together to figure out what\r
- * has been changed!\r
- */\r
-#define ATTR_MODE 1\r
-#define ATTR_UID 2\r
-#define ATTR_GID 4\r
-#define ATTR_SIZE 8\r
-#define ATTR_ATIME 16\r
-#define ATTR_MTIME 32\r
-#define ATTR_CTIME 64\r
-#define ATTR_ATIME_SET 128\r
-#define ATTR_MTIME_SET 256\r
-#define ATTR_FORCE 512 /* Not a change, but a change it */\r
-#define ATTR_ATTR_FLAG 1024\r
-\r
-\r
-struct iattr {\r
- unsigned int ia_valid;\r
- unsigned ia_mode;\r
- unsigned ia_uid;\r
- unsigned ia_gid;\r
- unsigned ia_size;\r
- unsigned ia_atime;\r
- unsigned ia_mtime;\r
- unsigned ia_ctime;\r
- unsigned int ia_attr_flags;\r
-};\r
-\r
-#define KERN_DEBUG\r
-\r
-\r
-#else\r
-\r
-#ifndef WIN32\r
-#include <linux/types.h>\r
-#include <linux/list.h>\r
-#include <linux/fs.h>\r
-#include <linux/stat.h>\r
-#endif\r
-\r
-#endif\r
-\r
-\r
-\r
-#if defined WIN32\r
-#undef new\r
-#endif \r
-\r
-#endif\r
-\r
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ * devextras.h
+ *
+ * Copyright (C) 2002 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 used during development.
+ * Most of these are from kernel includes placed here so we can use them in
+ * applications.
+ *
+ * $Id: devextras.h,v 1.5 2002-09-27 20:50:50 charles Exp $
+ *
+ */
+
+#ifndef __EXTRAS_H__
+#define __EXTRAS_H__
+
+#if defined WIN32
+#define __inline__ __inline
+#define new newHack
+#endif
+
+#if !(defined __KERNEL__) || (defined WIN32)
+
+// User space defines
+
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+typedef unsigned __u32;
+
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+ #define prefetch(x) 1
+
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
+#define INIT_LIST_HEAD(ptr) do { \
+ (ptr)->next = (ptr); (ptr)->prev = (ptr); \
+} while (0)
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __inline__ void __list_add(struct list_head * new,
+ struct list_head * prev,
+ struct list_head * next)
+{
+ next->prev = new;
+ new->next = next;
+ new->prev = prev;
+ prev->next = new;
+}
+
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static __inline__ void list_add(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head, head->next);
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __inline__ void __list_del(struct list_head * prev,
+ struct list_head * next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
+ */
+static __inline__ void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static __inline__ void list_del_init(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ INIT_LIST_HEAD(entry);
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static __inline__ int list_empty(struct list_head *head)
+{
+ return head->next == head;
+}
+
+/**
+ * list_splice - join two lists
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static __inline__ void list_splice(struct list_head *list, struct list_head *head)
+{
+ struct list_head *first = list->next;
+
+ if (first != list) {
+ struct list_head *last = list->prev;
+ struct list_head *at = head->next;
+
+ first->prev = head;
+ head->next = first;
+
+ last->next = at;
+ at->prev = last;
+ }
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+
+/**
+ * list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop counter.
+ * @head: the head for your list.
+ */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next, prefetch(pos->next); pos != (head); \
+ pos = pos->next, prefetch(pos->next))
+
+/**
+ * list_for_each_safe - iterate over a list safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop counter.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+ for (pos = (head)->next, n = pos->next; pos != (head); \
+ pos = n, n = pos->next)
+
+
+
+
+/*
+ * 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
+#define ATTR_ATIME_SET 128
+#define ATTR_MTIME_SET 256
+#define ATTR_FORCE 512 /* Not a change, but a change it */
+#define ATTR_ATTR_FLAG 1024
+
+
+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;
+};
+
+#define KERN_DEBUG
+
+
+#else
+
+#ifndef WIN32
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/fs.h>
+#include <linux/stat.h>
+#endif
+
+#endif
+
+
+
+#if defined WIN32
+#undef new
+#endif
+
+#endif
+
* Copyright (C) 2000 Steven J. Hill (sjhill@cotw.com)
* Toshiba America Electronics Components, Inc.
*
- * $Id: nand_ecc.c,v 1.2 2002-09-17 04:45:48 charles Exp $
+ * $Id: nand_ecc.c,v 1.3 2002-09-27 20:50:50 charles Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
// Minor tweak by Charles Manning to prevent exporting symbols
// when compiled in with yaffs.
+const char *nand_ecc_c_version = "$Id: nand_ecc.c,v 1.3 2002-09-27 20:50:50 charles Exp $";
+
#if 0
#include <linux/types.h>
#include <linux/kernel.h>
#########################################################
# Makefile auto generated by Cygnus Source Navigator.
-# Target: yaffsdev_disk Date: Sep 18 2002 Time: 10:19:04 AM
+# Target: yaffsdev_disk Date: Sep 27 2002 Time: 09:05:11 AM
#
#include <linux/config.h>
#include <linux/mtd/mtd.h>
+cost char *mkyaffs_c_version = "$Id: mkyaffs.c,v 1.3 2002-09-27 20:50:50 charles Exp $";
// countBits is a quick way of counting the number of bits in a byte.
// ie. countBits[n] holds the number of 1 bits in a byte with the value n.
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
+ *
+ * Nick Bane modifications flagged NCB
+ *
*/
#include <stdlib.h>
#define MAX_OBJECTS 10000
+const char * mkyaffsimage_c_version = "$Id: mkyaffsimage.c,v 1.3 2002-09-27 20:50:50 charles Exp $";
+
// External functions for ECC on data
void nand_calculate_ecc (const u_char *dat, u_char *ecc_code);
int nand_correct_data (u_char *dat, u_char *read_ecc, u_char *calc_ecc);
-
-
-
typedef struct
{
dev_t dev;
return -1;
}
+// NCB added 10/9/2002
+static __u16 yaffs_CalcNameSum(const char *name)
+{
+ __u16 sum = 0;
+ __u16 i = 1;
+
+ __u8 *bname = (__u8 *)name;
+
+ while (*bname)
+ {
+ sum += (*bname) * i;
+ i++;
+ bname++;
+ }
+ return sum;
+}
void yaffs_CalcECC(const __u8 *data, yaffs_Spare *spare)
for(i = 0; i < 8; i++)
{
- for(j = 1; j &0x7f; j<<=1)
+// NCB modified 20-9-02 for(j = 1; j &0x7f; j<<=1)
+ for(j = 1; j &0xff; j<<=1)
{
bit++;
if(b[i] & j)
strncpy(oh->name,name,YAFFS_MAX_NAME_LENGTH);
+ // NCB added 10/9/2001
+ oh->sum = yaffs_CalcNameSum(oh->name);
+
if(t != YAFFS_OBJECT_TYPE_HARDLINK)
{
oh->st_mode = s->st_mode;
oh->st_uid = s->st_uid;
- oh->st_gid = s->st_uid;
+// NCB 12/9/02 oh->st_gid = s->st_uid;
+ oh->st_gid = s->st_gid;
oh->st_atime = s->st_atime;
oh->st_mtime = s->st_mtime;
oh->st_ctime = s->st_ctime;
{
printf("directory\n");
error = write_object_header(newObj, YAFFS_OBJECT_TYPE_DIRECTORY, &stats, parent, entry->d_name, -1, NULL);
- process_directory(1,full_name);
+// NCB modified 10/9/2001 process_directory(1,full_name);
+ process_directory(newObj,full_name);
}
}
}
* Acknowledgements:
* * Luc van OostenRyck for numerous patches.
* * Nick Bane for numerous patches.
+ * * Andras Toth for mknod rdev issue.
* * Some code bodily lifted from JFFS2.
*/
+const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.16 2002-09-27 20:50:50 charles Exp $";
+
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
yaffs_Device *dev;
T((KERN_DEBUG"yaffs_readpage at %08x, size %08x\n",
- pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE));
+ (unsigned)(pg->index << PAGE_CACHE_SHIFT), (unsigned)PAGE_CACHE_SIZE));
obj = yaffs_DentryToObject(f->f_dentry);
int nWritten;
unsigned spos = pos;
- unsigned saddr = addr;
+ unsigned saddr = (unsigned)addr;
T((KERN_DEBUG"yaffs_commit_write addr %x pos %x nBytes %d\n",saddr,spos,nBytes));
inode->i_size = ipos;
inode->i_blocks = (ipos + inode->i_blksize - 1)/ inode->i_blksize;
- T((KERN_DEBUG"yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,inode->i_blocks));
+ T((KERN_DEBUG"yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,(int)(inode->i_blocks)));
}
}
/*
* File creation. Allocate an inode, and we're done..
*/
-static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev)
+static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
{
struct inode *inode;
}
T(("yaffs_mknod: making oject for %s, mode %x dev %x\n",
- dentry->d_name.name, mode,dev));
+ dentry->d_name.name, mode,rdev));
dev = parent->myDev;
default:
// Special (socket, fifo, device...)
T((KERN_DEBUG"yaffs_mknod: making special\n"));
- obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,dev);
+ obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
break;
case S_IFREG: // file
T((KERN_DEBUG"yaffs_mknod: making file\n"));
if(obj)
{
- inode = yaffs_get_inode(dir->i_sb, mode, dev, obj);
+ inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
d_instantiate(dentry, inode);
T((KERN_DEBUG"yaffs_mknod created object %d count = %d\n",obj->objectId,atomic_read(&inode->i_count)));
error = 0;
yaffs_Device *dev;
- T((KERN_DEBUG"yaffs_unlink %d:%s\n",dir->i_ino,dentry->d_name.name));
+ T((KERN_DEBUG"yaffs_unlink %d:%s\n",(int)(dir->i_ino),dentry->d_name.name));
dev = yaffs_InodeToObject(dir)->myDev;
yaffs_GrossLock(dev);
- nlinks =
retVal = yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name);
yaffs_GrossLock(dev);
+
retVal = yaffs_RenameObject(yaffs_InodeToObject(old_dir),old_dentry->d_name.name,
yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
yaffs_GrossUnlock(dev);
sb->s_blocksize = PAGE_CACHE_SIZE;
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
#endif
- T(("yaffs_read_super: %s block size %d\n", useRam ? "RAM" : "MTD",sb->s_blocksize));
+ T(("yaffs_read_super: %s block size %d\n", useRam ? "RAM" : "MTD",(int)(sb->s_blocksize)));
#ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
T(("yaffs: Write verification disabled. All guarantees null and void\n");
return NULL;
}
- printk(KERN_DEBUG" erase %x\n",mtd->erase);
- printk(KERN_DEBUG" read %x\n",mtd->read);
- printk(KERN_DEBUG" write %x\n",mtd->write);
- printk(KERN_DEBUG" readoob %x\n",mtd->read_oob);
- printk(KERN_DEBUG" writeoob %x\n",mtd->write_oob);
- printk(KERN_DEBUG" oobblock %x\n",mtd->oobblock);
- printk(KERN_DEBUG" oobsize %x\n",mtd->oobsize);
+ //printk(KERN_DEBUG" erase %x\n",mtd->erase);
+ //printk(KERN_DEBUG" read %x\n",mtd->read);
+ //printk(KERN_DEBUG" write %x\n",mtd->write);
+ //printk(KERN_DEBUG" readoob %x\n",mtd->read_oob);
+ //printk(KERN_DEBUG" writeoob %x\n",mtd->write_oob);
+ //printk(KERN_DEBUG" oobblock %x\n",mtd->oobblock);
+ //printk(KERN_DEBUG" oobsize %x\n",mtd->oobsize);
if(!mtd->erase ||
buf +=sprintf(buf,"garbageCollections. %d\n",dev->garbageCollections);
buf +=sprintf(buf,"nRetriedWrites..... %d\n",dev->nRetriedWrites);
buf +=sprintf(buf,"nRetireBlocks...... %d\n",dev->nRetiredBlocks);
+ buf +=sprintf(buf,"eccFixed........... %d\n",dev->eccFixed);
+ buf +=sprintf(buf,"eccUnfixed......... %d\n",dev->eccUnfixed);
+ buf +=sprintf(buf,"tagsEccFixed....... %d\n",dev->tagsEccFixed);
+ buf +=sprintf(buf,"tagsEccUnfixed..... %d\n",dev->tagsEccUnfixed);
buf +=sprintf(buf,"cacheHits.......... %d\n",dev->cacheHits);
buf +=sprintf(buf,"nDeletedFiles...... %d\n",dev->nDeletedFiles);
buf +=sprintf(buf,"nUnlinkedFiles..... %d\n",dev->nUnlinkedFiles);
}
#ifdef CONFIG_YAFFS_RAM_ENABLED
-
+#if 0
my_proc_ram_write_entry = create_proc_entry("yaffs_ram",
S_IRUGO | S_IFREG,
&proc_root);
{
my_proc_ram_write_entry->write_proc = yaffs_proc_ram_write;
}
+#endif
+
error = register_filesystem(&yaffs_ram_fs_type);
if(error)
{
*/
//yaffs_guts.c
+const char *yaffs_guts_c_version="$Id: yaffs_guts.c,v 1.10 2002-09-27 20:50:50 charles Exp $";
+
#include "yportenv.h"
#include "yaffsinterface.h"
// Local prototypes
static int yaffs_CheckObjectHashSanity(yaffs_Device *dev);
static void yaffs_LoadTagsIntoSpare(yaffs_Spare *sparePtr, yaffs_Tags *tagsPtr);
-static void yaffs_GetTagsFromSpare(yaffs_Spare *sparePtr,yaffs_Tags *tagsPtr);
+static void yaffs_GetTagsFromSpare(yaffs_Device *dev, yaffs_Spare *sparePtr,yaffs_Tags *tagsPtr);
static int yaffs_PutChunkIntoFile(yaffs_Object *in,int chunkInInode, int chunkInNAND, int inScan);
static yaffs_Object *yaffs_CreateNewObject(yaffs_Device *dev,int number,yaffs_ObjectType type);
if(eccResult1>0)
{
T((TSTR("**>>ecc error fix performed on chunk %d:0" TENDSTR),chunkInNAND));
+ dev->eccFixed++;
}
else if(eccResult1<0)
{
T((TSTR("**>>ecc error unfixed on chunk %d:0" TENDSTR),chunkInNAND));
+ dev->eccUnfixed++;
}
if(eccResult2>0)
{
T((TSTR("**>>ecc error fix performed on chunk %d:1" TENDSTR),chunkInNAND));
+ dev->eccFixed++;
}
else if(eccResult2<0)
{
T((TSTR("**>>ecc error unfixed on chunk %d:1" TENDSTR),chunkInNAND));
+ dev->eccUnfixed++;
}
if(eccResult1 || eccResult2)
}
-void yaffs_CheckECCOnTags(yaffs_Tags *tags)
+int yaffs_CheckECCOnTags(yaffs_Tags *tags)
{
unsigned ecc = tags->ecc;
ecc ^= tags->ecc;
- if(ecc)
+ if(ecc && ecc <= 64)
{
- // Needs fixing
+ // TODO: Handle the failure better. Retire?
unsigned char *b = ((yaffs_TagsUnion *)tags)->asBytes;
ecc--;
// Now recvalc the ecc
yaffs_CalcTagsECC(tags);
+
+ return 1; // recovered error
+ }
+ else if(ecc)
+ {
+ // Wierd ecc failure value
+ // TODO Need to do somethiong here
+ return -1; //unrecovered error
}
+
+ return 0;
}
yaffs_ReadChunkFromNAND(dev,oldChunk,buffer, &spare,1);
- yaffs_GetTagsFromSpare(&spare,&tags);
+ yaffs_GetTagsFromSpare(dev,&spare,&tags);
+
tags.serialNumber++;
yaffs_LoadTagsIntoSpare(&spare,&tags);
sparePtr->tagByte7 = tu->asBytes[7];
}
-static void yaffs_GetTagsFromSpare(yaffs_Spare *sparePtr,yaffs_Tags *tagsPtr)
+static void yaffs_GetTagsFromSpare(yaffs_Device *dev, yaffs_Spare *sparePtr,yaffs_Tags *tagsPtr)
{
yaffs_TagsUnion *tu = (yaffs_TagsUnion *)tagsPtr;
+ int result;
tu->asBytes[0]= sparePtr->tagByte0;
tu->asBytes[1]= sparePtr->tagByte1;
tu->asBytes[6]= sparePtr->tagByte6;
tu->asBytes[7]= sparePtr->tagByte7;
- yaffs_CheckECCOnTags(tagsPtr);
+ result = yaffs_CheckECCOnTags(tagsPtr);
+ if(result> 0)
+ {
+ dev->tagsEccFixed++;
+ }
+ else if(result <0)
+ {
+ dev->tagsEccUnfixed++;
+ }
}
static void yaffs_SpareInitialise(yaffs_Spare *spare)
if(yaffs_ReadChunkFromNAND(dev,chunkInNAND,NULL,&spare,1) == YAFFS_OK)
{
*chunkDeleted = (yaffs_CountBits(spare.pageStatus) < 7) ? 1 : 0;
- yaffs_GetTagsFromSpare(&spare,tags);
+ yaffs_GetTagsFromSpare(dev,&spare,tags);
return YAFFS_OK;
}
else
#ifdef CONFIG_YAFFS_SHORT_OP_CACHE
yaffs_ChunkCache *cache;
-#else
- __u8 localBuffer[YAFFS_BYTES_PER_CHUNK];
#endif
+
+ __u8 localBuffer[YAFFS_BYTES_PER_CHUNK];
int chunk;
int start;
}
else
{
+#ifdef WIN32
+ // Under WinCE can't do direct transfer. Need to use a local buffer.
+ // This is because we otherwise screw up WinCE's memory mapper
+ yaffs_ReadChunkDataFromObject(in,chunk,localBuffer);
+ memcpy(buffer,localBuffer,YAFFS_BYTES_PER_CHUNK);
+#else
// A full chunk. Read directly into the supplied buffer.
yaffs_ReadChunkDataFromObject(in,chunk,buffer);
+#endif
}
n -= nToCopy;
}
else
{
+
+#ifdef WIN32
+ // Under WinCE can't do direct transfer. Need to use a local buffer.
+ // This is because we otherwise screw up WinCE's memory mapper
+ memcpy(localBuffer,buffer,YAFFS_BYTES_PER_CHUNK);
+ chunkWritten = yaffs_WriteChunkDataToObject(in,chunk,localBuffer,YAFFS_BYTES_PER_CHUNK,0);
+#else
// A full chunk. Write directly from the supplied buffer.
chunkWritten = yaffs_WriteChunkDataToObject(in,chunk,buffer,YAFFS_BYTES_PER_CHUNK,0);
+#endif
//T(("Write to chunk %d %d\n",chunk,chunkWritten));
}
// This block looks ok, now what's in this chunk?
- yaffs_GetTagsFromSpare(&spare,&tags);
+ yaffs_GetTagsFromSpare(dev,&spare,&tags);
if(yaffs_CountBits(spare.pageStatus) < 6)
{
dev->nDeletedFiles = 0;
dev->nBackgroundDeletions=0;
dev->nUnlinkedFiles = 0;
+ dev->eccFixed=0;
+ dev->eccUnfixed=0;
+ dev->tagsEccFixed=0;
+ dev->tagsEccUnfixed=0;
yaffs_InitialiseBlocks(dev,nBlocks);
*
*
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ *
+ * $Id: yaffs_guts.h,v 1.10 2002-09-27 20:50:50 charles Exp $
*/
#ifndef __YAFFS_GUTS_H__
int garbageCollections;
int nRetriedWrites;
int nRetiredBlocks;
+ int eccFixed;
+ int eccUnfixed;
+ int tagsEccFixed;
+ int tagsEccUnfixed;
yaffs_Object *rootDir;
yaffs_Object *lostNFoundDir;
* published by the Free Software Foundation.
*
*/
+
+const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.3 2002-09-27 20:50:50 charles Exp $";
+
#ifdef CONFIG_YAFFS_MTD_ENABLED
#include "yportenv.h"
*
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*
+ * $Id: yaffs_mtdif.h,v 1.4 2002-09-27 20:50:50 charles Exp $
*/
#ifndef __YAFFS_MTDIF_H__
*
* yaffs_nandemul.h: Interface to emulated NAND functions
*
+ * $Id: yaffs_nandemul.h,v 1.4 2002-09-27 20:50:50 charles Exp $
*/
#ifndef __YAFFS_NANDEMUL_H__
//yaffs_ramem.c
// Since this creates the RAM block at start up it is pretty useless for testing the scanner.
+const char *yaffs_ramem_c_version = "$Id: yaffs_ramem.c,v 1.5 2002-09-27 20:50:50 charles Exp $";
+
#ifndef __KERNEL__
#define CONFIG_YAFFS_RAM_ENABLED
#endif
-/*\r
- * YAFFS: Yet another FFS. A NAND-flash specific file system. \r
- * yportenv.h: Portable services used by yaffs. This is done to allow\r
- * simple migration from kernel space into app space for testing.\r
- *\r
- * Copyright (C) 2002 Aleph One Ltd.\r
- * for Toby Churchill Ltd and Brightstar Engineering\r
- *\r
- * Created by Charles Manning <charles@aleph1.co.uk>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU Lesser General Public License version 2.1 as\r
- * published by the Free Software Foundation.\r
- *\r
- *\r
- * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.\r
- *\r
- */\r
- \r
-#ifndef __PORTENV_H__\r
-#define __PORTENV_H__\r
-\r
-\r
-#if defined WIN32\r
-\r
-// Win32\r
-#include "stdlib.h"\r
-#include "stdio.h"\r
-#include "string.h"\r
-\r
-#define YMALLOC(x) malloc(x)\r
-#define YFREE(x) free(x)\r
-\r
-\r
-#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))\r
-#define YALERT(s) YINFO(s)\r
-\r
-#include <windows.h>\r
-\r
-#define YAFFS_LOSTNFOUND_NAME "LOST_CLUSTERS"\r
-#define YAFFS_LOSTNFOUND_PREFIX "OBJ"\r
-\r
-#define YPRINTF(x)\r
-\r
-// Always pass the sum compare to overcome the case insensitivity issue\r
-#define yaffs_SumCompare(x,y) 1\r
-#define yaffs_strcmp(a,b) _stricmp(a,b)\r
-\r
-\r
-#define u_char unsigned char\r
-#define loff_t int\r
-#define S_IFDIR 04000\r
-\r
-#define S_ISFIFO(x) 0\r
-#define S_ISCHR(x) 0\r
-#define S_ISBLK(x) 0\r
-#define S_ISSOCK(x) 0\r
-\r
-extern unsigned yfsd_U32FileTimeNow(void);\r
-\r
-#define CURRENT_TIME yfsd_U32FileTimeNow()\r
-#define YAFFS_ROOT_MODE FILE_ATTRIBUTE_ARCHIVE\r
-#define YAFFS_LOSTNFOUND_MODE (FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN)\r
-\r
-\r
-#define TENDSTR "\r\n"\r
-#define TSTR(x) TEXT(x)\r
-#define T(x) RETAILMSG(1, x)\r
-\r
-\r
-#elif defined __KERNEL__\r
-\r
-\r
-\r
-// Linux kernel\r
-#include "linux/kernel.h"\r
-#include "linux/mm.h"\r
-#include "linux/string.h"\r
-#include "linux/slab.h"\r
-#define YAFFS_LOSTNFOUND_NAME "lost+found"\r
-#define YAFFS_LOSTNFOUND_PREFIX "obj"\r
-\r
-#define YPRINTF(x) printk x\r
-#define YMALLOC(x) kmalloc(x,GFP_KERNEL)\r
-#define YFREE(x) kfree(x)\r
-\r
-#define YAFFS_ROOT_MODE 0666\r
-#define YAFFS_LOSTNFOUND_MODE 0666\r
-\r
-\r
-#define yaffs_SumCompare(x,y) ((x) == (y))\r
-#define yaffs_strcmp(a,b) strcmp(a,b)\r
-\r
-#define TENDSTR "\n"\r
-#define TSTR(x) KERN_DEBUG x\r
-#define T(x) printk x\r
-\r
-\r
-#else\r
-\r
-// Linux application\r
-#include "stdlib.h"\r
-#include "stdio.h"\r
-#include "string.h"\r
-\r
-#define YMALLOC(x) malloc(x)\r
-#define YFREE(x) free(x)\r
-\r
-\r
-#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))\r
-#define YALERT(s) YINFO(s)\r
-\r
-\r
-#define TENDSTR "\n"\r
-#define TSTR(x) x\r
-#define T(x) printf x\r
-\r
-\r
-#define YAFFS_LOSTNFOUND_NAME "lost+found"\r
-#define YAFFS_LOSTNFOUND_PREFIX "obj"\r
-#define YPRINTF(x) printf x\r
-\r
-#define CURRENT_TIME 0\r
-#define YAFFS_ROOT_MODE 0666\r
-#define YAFFS_LOSTNFOUND_MODE 0666\r
-\r
-#define yaffs_SumCompare(x,y) ((x) == (y))\r
-#define yaffs_strcmp(a,b) strcmp(a,b)\r
-\r
-#endif \r
-\r
-\r
-\r
-#undef YINFO\r
-\r
-\r
-#define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s))\r
-#define YALERT(s) YINFO(s)\r
-\r
-#define YBUG() do{YINFO("bug");} while(0)\r
-\r
-\r
-#endif\r
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ * yportenv.h: Portable services used by yaffs. This is done to allow
+ * simple migration from kernel space into app space for testing.
+ *
+ * Copyright (C) 2002 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.
+ *
+ * $Id: yportenv.h,v 1.5 2002-09-27 20:50:50 charles Exp $
+ *
+ */
+
+#ifndef __PORTENV_H__
+#define __PORTENV_H__
+
+
+#if defined WIN32
+
+// Win32
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+
+#define YMALLOC(x) malloc(x)
+#define YFREE(x) free(x)
+
+
+#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
+#define YALERT(s) YINFO(s)
+
+#include <windows.h>
+
+#define YAFFS_LOSTNFOUND_NAME "LOST_CLUSTERS"
+#define YAFFS_LOSTNFOUND_PREFIX "OBJ"
+
+#define YPRINTF(x)
+
+// Always pass the sum compare to overcome the case insensitivity issue
+#define yaffs_SumCompare(x,y) 1
+#define yaffs_strcmp(a,b) _stricmp(a,b)
+
+
+#define u_char unsigned char
+#define loff_t int
+#define S_IFDIR 04000
+
+#define S_ISFIFO(x) 0
+#define S_ISCHR(x) 0
+#define S_ISBLK(x) 0
+#define S_ISSOCK(x) 0
+
+extern unsigned yfsd_U32FileTimeNow(void);
+
+#define CURRENT_TIME yfsd_U32FileTimeNow()
+#define YAFFS_ROOT_MODE FILE_ATTRIBUTE_ARCHIVE
+#define YAFFS_LOSTNFOUND_MODE (FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN)
+
+
+#define TENDSTR "\r\n"
+#define TSTR(x) TEXT(x)
+#define T(x) RETAILMSG(1, x)
+
+
+#elif defined __KERNEL__
+
+
+
+// Linux kernel
+#include "linux/kernel.h"
+#include "linux/mm.h"
+#include "linux/string.h"
+#include "linux/slab.h"
+#define YAFFS_LOSTNFOUND_NAME "lost+found"
+#define YAFFS_LOSTNFOUND_PREFIX "obj"
+
+#define YPRINTF(x) printk x
+#define YMALLOC(x) kmalloc(x,GFP_KERNEL)
+#define YFREE(x) kfree(x)
+
+#define YAFFS_ROOT_MODE 0666
+#define YAFFS_LOSTNFOUND_MODE 0666
+
+
+#define yaffs_SumCompare(x,y) ((x) == (y))
+#define yaffs_strcmp(a,b) strcmp(a,b)
+
+#define TENDSTR "\n"
+#define TSTR(x) KERN_DEBUG x
+#define T(x) printk x
+
+
+#else
+
+// Linux application
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+
+#define YMALLOC(x) malloc(x)
+#define YFREE(x) free(x)
+
+
+#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
+#define YALERT(s) YINFO(s)
+
+
+#define TENDSTR "\n"
+#define TSTR(x) x
+#define T(x) printf x
+
+
+#define YAFFS_LOSTNFOUND_NAME "lost+found"
+#define YAFFS_LOSTNFOUND_PREFIX "obj"
+#define YPRINTF(x) printf x
+
+#define CURRENT_TIME 0
+#define YAFFS_ROOT_MODE 0666
+#define YAFFS_LOSTNFOUND_MODE 0666
+
+#define yaffs_SumCompare(x,y) ((x) == (y))
+#define yaffs_strcmp(a,b) strcmp(a,b)
+
+#endif
+
+
+
+#undef YINFO
+
+
+#define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s))
+#define YALERT(s) YINFO(s)
+
+#define YBUG() do{YINFO("bug");} while(0)
+
+
+#endif