mtd/fs/jffs2/ecos/src dir-ecos.c,1.1,1.2 file-ecos.c,1.1,1.2 fs-ecos.c,1.5,1.6 jffs2port.h,1.1,1.2 malloc-ecos.c,1.1,1.2 os-ecos.h,1.1,1.2

David Woodhouse dwmw2 at infradead.org
Thu Jan 9 08:53:47 EST 2003


Update of /home/cvs/mtd/fs/jffs2/ecos/src
In directory phoenix.infradead.org:/tmp/cvs-serv28046/src

Modified Files:
	dir-ecos.c file-ecos.c fs-ecos.c jffs2port.h malloc-ecos.c 
	os-ecos.h 
Log Message:
Update to current CVS tree

Index: dir-ecos.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ecos/src/dir-ecos.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dir-ecos.c	11 Jul 2002 10:55:30 -0000	1.1
+++ dir-ecos.c	9 Jan 2003 13:53:44 -0000	1.2
@@ -11,6 +11,7 @@
  *
  */
 
+#include <linux/kernel.h>
 #include "nodelist.h"
 #include "crc32.h"
 
@@ -29,7 +30,7 @@
 	uint32_t ino = 0;
 	struct inode *inode = NULL;
 
-	D1(printk(KERN_DEBUG "jffs2_lookup()\n"));
+	D1(printk("jffs2_lookup()\n"));
 
 	dir_f = JFFS2_INODE_INFO(dir_i);
 	c = JFFS2_SB_INFO(dir_i->i_sb);
@@ -51,7 +52,7 @@
 	if (ino) {
 		inode = iget(dir_i->i_sb, ino);
 		if (!inode) {
-			printk(KERN_WARNING "iget() failed for ino #%u\n", ino);
+			printk("iget() failed for ino #%u\n", ino);
 			return (ERR_PTR(-EIO));
 		}
 	}
@@ -122,7 +123,8 @@
 
 	ret = jffs2_do_unlink(c, dir_f, d_name->name, 
 			       d_name->len, dead_f);
-	d_inode->i_nlink = dead_f->inocache->nlink;
+	if (dead_f->inocache)
+		d_inode->i_nlink = dead_f->inocache->nlink;
 	return ret;
 }
 /***********************************************************************/
@@ -192,8 +194,8 @@
 
 	f = JFFS2_INODE_INFO(inode);
 
-	ri->data_crc = 0;
-	ri->node_crc = crc32(0, ri, sizeof(*ri)-8);
+	ri->data_crc = cpu_to_je32(0);
+	ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
 	
 	fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, &writtenlen);
 
@@ -239,19 +241,19 @@
 	dir_f = JFFS2_INODE_INFO(dir_i);
 	down(&dir_f->sem);
 
-	rd->magic = JFFS2_MAGIC_BITMASK;
-	rd->nodetype = JFFS2_NODETYPE_DIRENT;
-	rd->totlen = sizeof(*rd) + namelen;
-	rd->hdr_crc = crc32(0, rd, sizeof(struct jffs2_unknown_node)-4);
-
-	rd->pino = dir_i->i_ino;
-	rd->version = ++dir_f->highest_version;
-	rd->ino = inode->i_ino;
-	rd->mctime = CURRENT_TIME;
+	rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+	rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT);
+	rd->totlen = cpu_to_je32(sizeof(*rd) + namelen);
+	rd->hdr_crc = cpu_to_je32(crc32(0, rd, sizeof(struct jffs2_unknown_node)-4));
+
+	rd->pino = cpu_to_je32(dir_i->i_ino);
+	rd->version = cpu_to_je32(++dir_f->highest_version);
+	rd->ino = cpu_to_je32(inode->i_ino);
+	rd->mctime = cpu_to_je32(cyg_timestamp());
 	rd->nsize = namelen;
 	rd->type = DT_DIR;
-	rd->node_crc = crc32(0, rd, sizeof(*rd)-8);
-	rd->name_crc = crc32(0, d_name->name, namelen);
+	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
+	rd->name_crc = cpu_to_je32(crc32(0, d_name->name, namelen));
 
 	fd = jffs2_write_dirent(c, dir_f, rd, d_name->name, namelen, phys_ofs, &writtenlen);
 	
@@ -292,8 +294,39 @@
 {
 	int ret;
 	struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb);
+	struct jffs2_inode_info *victim_f = NULL;
 	uint8_t type;
 
+#if 0 /* FIXME -- this really doesn't belong in individual file systems. 
+	 The fileio code ought to do this for us, or at least part of it */
+	if (new_dentry->d_inode) {
+		if (S_ISDIR(d_inode->i_mode) && 
+		    !S_ISDIR(new_dentry->d_inode->i_mode)) {
+			/* Cannot rename directory over non-directory */
+			return -EINVAL;
+		}
+
+		victim_f = JFFS2_INODE_INFO(new_dentry->d_inode);
+
+		if (S_ISDIR(new_dentry->d_inode->i_mode)) {
+			struct jffs2_full_dirent *fd;
+
+			if (!S_ISDIR(d_inode->i_mode)) {
+				/* Cannot rename non-directory over directory */
+				return -EINVAL;
+			}
+			down(&victim_f->sem);
+			for (fd = victim_f->dents; fd; fd = fd->next) {
+				if (fd->ino) {
+					up(&victim_f->sem);
+					return -ENOTEMPTY;
+				}
+			}
+			up(&victim_f->sem);
+		}
+	}
+#endif
+
 	/* XXX: We probably ought to alloc enough space for
 	   both nodes at the same time. Writing the new link, 
 	   then getting -ENOSPC, is quite bad :)
@@ -312,20 +345,30 @@
 	if (ret)
 		return ret;
 
+	if (victim_f) {
+		/* There was a victim. Kill it off nicely */
+		/* Don't oops if the victim was a dirent pointing to an
+		   inode which didn't exist. */
+		if (victim_f->inocache) {
+			down(&victim_f->sem);
+			victim_f->inocache->nlink--;
+			up(&victim_f->sem);
+		}
+	}
+
 	/* Unlink the original */
 	ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), 
 		      old_d_name->name, old_d_name->len, NULL);
 
-	/* We don't touch inode->i_nlink */
-
 	if (ret) {
 		/* Oh shit. We really ought to make a single node which can do both atomically */
 		struct jffs2_inode_info *f = JFFS2_INODE_INFO(d_inode);
 		down(&f->sem);
-		d_inode->i_nlink = f->inocache->nlink++;
+		if (f->inocache)
+			d_inode->i_nlink = f->inocache->nlink++;
 		up(&f->sem);
 
-               printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret);
+		printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret);
 	}
 	return ret;
 }

Index: file-ecos.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ecos/src/file-ecos.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- file-ecos.c	11 Jul 2002 10:55:30 -0000	1.1
+++ file-ecos.c	9 Jan 2003 13:53:44 -0000	1.2
@@ -11,12 +11,12 @@
  *
  */
 
-//#include <linux/kernel.h>
+#include <linux/kernel.h>
 //#include <linux/mtd/compatmac.h> /* for min() */
 //#include <linux/slab.h>
 //#include <linux/fs.h>
 //#include <linux/pagemap.h>
-#include "jffs2.h"
+#include <linux/jffs2.h>
 #include "nodelist.h"
 #include "crc32.h"
 
@@ -80,8 +80,6 @@
 	uint32_t pageofs = pg->index << PAGE_CACHE_SHIFT;
 	int ret = 0;
 
-	down(&f->sem);
-	//D1(printk(KERN_DEBUG "jffs2_prepare_write() nrpages %ld\n", inode->i_mapping->nrpages));
 	D1(printk(KERN_DEBUG "jffs2_prepare_write()\n"));
 
 	if (pageofs > inode->i_size) {
@@ -95,30 +93,31 @@
 			  (unsigned int)inode->i_size, pageofs));
 
 		ret = jffs2_reserve_space(c, sizeof(ri), &phys_ofs, &alloc_len, ALLOC_NORMAL);
-		if (ret) {
-			up(&f->sem);
+		if (ret)
 			return ret;
-		}
+
+		down(&f->sem);
 		memset(&ri, 0, sizeof(ri));
 
-		ri.magic = JFFS2_MAGIC_BITMASK;
-		ri.nodetype = JFFS2_NODETYPE_INODE;
-		ri.totlen = sizeof(ri);
-		ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node)-4);
-
-		ri.ino = f->inocache->ino;
-		ri.version = ++f->highest_version;
-		ri.mode = inode->i_mode;
-		ri.uid = inode->i_uid;
-		ri.gid = inode->i_gid;
-		ri.isize = max((uint32_t)inode->i_size, pageofs);
-		ri.atime = ri.ctime = ri.mtime = CURRENT_TIME;
-		ri.offset = inode->i_size;
-		ri.dsize = pageofs - inode->i_size;
-		ri.csize = 0;
+		ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+		ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
+		ri.totlen = cpu_to_je32(sizeof(ri));
+		ri.hdr_crc = cpu_to_je32(crc32(0, &ri, sizeof(struct jffs2_unknown_node)-4));
+
+		ri.ino = cpu_to_je32(f->inocache->ino);
+		ri.version = cpu_to_je32(++f->highest_version);
+		ri.mode = cpu_to_je32(inode->i_mode);
+		ri.uid = cpu_to_je16(inode->i_uid);
+		ri.gid = cpu_to_je16(inode->i_gid);
+
+		ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
+		ri.atime = ri.ctime = ri.mtime = cpu_to_je32(cyg_timestamp());
+		ri.offset = cpu_to_je32(inode->i_size);
+		ri.dsize = cpu_to_je32(pageofs - inode->i_size);
+		ri.csize = cpu_to_je32(0);
 		ri.compr = JFFS2_COMPR_ZERO;
-		ri.node_crc = crc32(0, &ri, sizeof(ri)-8);
-		ri.data_crc = 0;
+		ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
+		ri.data_crc = cpu_to_je32(0);
 		
 		fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, NULL);
 		jffs2_complete_reservation(c);
@@ -141,16 +140,18 @@
 			return ret;
 		}
 		inode->i_size = pageofs;
+		up(&f->sem);
 	}
 	
 
-	/* Read in the page if it wasn't already present */
+	/* Read in the page if it wasn't already present, unless it's a whole page */
         // eCos has no concept of uptodate and by default always reads pages afresh
-	if (!Page_Uptodate(pg) && (start || end < PAGE_SIZE))
+	if (!Page_Uptodate(pg) && (start || end < PAGE_CACHE_SIZE)) {
+		down(&f->sem);
 		ret = jffs2_do_readpage_nolock(inode, pg);
-	//D1(printk(KERN_DEBUG "end prepare_write(). nrpages %ld\n", inode->i_mapping->nrpages));
+		up(&f->sem);
+	}
 	D1(printk(KERN_DEBUG "end prepare_write()\n"));
-	up(&f->sem);
 	return ret;
 }
 
@@ -178,16 +179,16 @@
 	}
 
 	/* Set the fields that the generic jffs2_write_inode_range() code can't find */
-	ri->ino = inode->i_ino;
-	ri->mode = inode->i_mode;
-	ri->uid = inode->i_uid;
-	ri->gid = inode->i_gid;
-	ri->isize = (uint32_t)inode->i_size;
-	ri->atime = ri->ctime = ri->mtime = CURRENT_TIME;
+	ri->ino = cpu_to_je32(inode->i_ino);
+	ri->mode = cpu_to_je32(inode->i_mode);
+	ri->uid = cpu_to_je16(inode->i_uid);
+	ri->gid = cpu_to_je16(inode->i_gid);
+	ri->isize = cpu_to_je32((uint32_t)inode->i_size);
+	ri->atime = ri->ctime = ri->mtime = cpu_to_je32(cyg_timestamp());
 
-	/* We rely on the fact that generic_file_write() currently kmaps the page for us. */
 	ret = jffs2_write_inode_range(c, f, ri, page_address(pg) + start,
-				      (pg->index << PAGE_CACHE_SHIFT) + start, end - start, &writtenlen);
+				      (pg->index << PAGE_CACHE_SHIFT) + start,
+				      end - start, &writtenlen);
 
 	if (ret) {
 		/* There was an error writing. */
@@ -197,7 +198,7 @@
 	if (writtenlen) {
 		if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) {
 			inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen;
-			inode->i_ctime = inode->i_mtime = ri->ctime;
+			inode->i_ctime = inode->i_mtime = je32_to_cpu(ri->ctime);
 		}
 	}
 

Index: fs-ecos.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ecos/src/fs-ecos.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- fs-ecos.c	24 Sep 2002 21:53:40 -0000	1.5
+++ fs-ecos.c	9 Jan 2003 13:53:44 -0000	1.6
@@ -12,10 +12,13 @@
  *
  */
 
+#include <linux/types.h>
+#include <linux/stat.h>
+#include <linux/kernel.h>
 #include "jffs2port.h"
-#include "jffs2.h"
-#include "jffs2_fs_sb.h"
-#include "jffs2_fs_i.h"
+#include <linux/jffs2.h>
+#include <linux/jffs2_fs_sb.h>
+#include <linux/jffs2_fs_i.h>
 #include "nodelist.h"
 
 #include <errno.h>
@@ -437,7 +440,6 @@
 	D1(printk(KERN_DEBUG "jffs2: read_super\n"));
 
 	c = JFFS2_SB_INFO(sb);
-	memset(c, 0, sizeof (*c));
 
 	len = sizeof (ds);
 	err = cyg_io_get_config(sb->s_dev,
@@ -461,6 +463,7 @@
 
 	c->sector_size = bs.block_size;
 	c->flash_size = ds.dev_size;
+	c->cleanmarker_size = sizeof(struct jffs2_unknown_node);
 
 	err = jffs2_do_mount_fs(c);
 	if (err)
@@ -530,16 +533,24 @@
 		jffs2_sb = malloc(sizeof (struct super_block));
 
 		if (jffs2_sb == NULL)
-			return ENOSPC;
+			return ENOMEM;
 
 		c = JFFS2_SB_INFO(jffs2_sb);
 		memset(jffs2_sb, 0, sizeof (struct super_block));
 		jffs2_sb->s_dev = t;
 
+		c->inocache_list = malloc(sizeof(struct jffs2_inode_cache *) * INOCACHE_HASHSIZE);
+		if (!c->inocache_list) {
+			free(jffs2_sb);
+			return ENOMEM;
+		}
+		memset(c->inocache_list, 0, sizeof(struct jffs2_inode_cache *) * INOCACHE_HASHSIZE);
+		printf("Allocated inocache_list at %p (c %p)\n", c->inocache_list, c);
 		err = jffs2_read_super(jffs2_sb);
 
 		if (err) {
 			free(jffs2_sb);
+			free(c->inocache_list);
 			return err;
 		}
 
@@ -550,7 +561,6 @@
 
 		D2(printf("jffs2_mount erasing pending blocks\n"));
 		jffs2_erase_pending_blocks(c);
-		jffs2_mark_erased_blocks(c);
 	}
 	mte->data = (CYG_ADDRWORD) jffs2_sb;
 
@@ -593,10 +603,10 @@
 		jffs2_free_ino_caches(c);
 		jffs2_free_raw_node_refs(c);
 		free(c->blocks);
-
+		free(c->inocache_list);
+		free(jffs2_sb);
 		// Clear root pointer
 		mte->root = CYG_DIR_NULL;
-
 		mte->fs->data = 0;	// fstab entry, visible to all mounts. No current mount
 		// That's all folks.
 		D2(printf("jffs2_umount No current mounts\n"));
@@ -1776,7 +1786,7 @@
 	D2(printf("make_bad_inode\n"));
 
 	inode->i_mode = S_IFREG;
-	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+	inode->i_atime = inode->i_mtime = inode->i_ctime = cyg_timestamp();
 	inode->i_op = EIO_ERROR;
 	inode->i_fop = EIO_ERROR;
 }
@@ -1941,3 +1951,99 @@
 
 // -------------------------------------------------------------------------
 // EOF jffs2.c
+void jffs2_clear_inode (struct inode *inode)
+{
+        /* We can forget about this inode for now - drop all
+         *  the nodelists associated with it, etc.
+         */
+        struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+        struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
+
+        D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode));
+
+        jffs2_do_clear_inode(c, f);
+}
+
+
+/* jffs2_new_inode: allocate a new inode and inocache, add it to the hash,
+   fill in the raw_inode while you're at it. */
+struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri)
+{
+	struct inode *inode;
+	struct super_block *sb = dir_i->i_sb;
+	struct jffs2_sb_info *c;
+	struct jffs2_inode_info *f;
+	int ret;
+
+	D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode));
+
+	c = JFFS2_SB_INFO(sb);
+	
+	inode = new_inode(sb);
+	
+	if (!inode)
+		return ERR_PTR(-ENOMEM);
+
+	f = JFFS2_INODE_INFO(inode);
+	jffs2_init_inode_info(f);
+
+	memset(ri, 0, sizeof(*ri));
+	/* Set OS-specific defaults for new inodes */
+	ri->uid = ri->gid = cpu_to_je16(0);
+	ri->mode =  cpu_to_je32(mode);
+	ret = jffs2_do_new_inode (c, f, mode, ri);
+	if (ret) {
+		make_bad_inode(inode);
+		iput(inode);
+		return ERR_PTR(ret);
+	}
+	inode->i_nlink = 1;
+	inode->i_ino = je32_to_cpu(ri->ino);
+	inode->i_mode = je32_to_cpu(ri->mode);
+	inode->i_gid = je16_to_cpu(ri->gid);
+	inode->i_uid = je16_to_cpu(ri->uid);
+	inode->i_atime = inode->i_ctime = inode->i_mtime = cyg_timestamp();
+	ri->atime = ri->mtime = ri->ctime = cpu_to_je32(inode->i_mtime);
+
+	inode->i_size = 0;
+
+	insert_inode_hash(inode);
+
+	return inode;
+}
+
+
+void jffs2_read_inode (struct inode *inode)
+{
+	struct jffs2_inode_info *f;
+	struct jffs2_sb_info *c;
+	struct jffs2_raw_inode latest_node;
+	int ret;
+
+	D1(printk(KERN_DEBUG "jffs2_read_inode(): inode->i_ino == %lu\n", inode->i_ino));
+
+	f = JFFS2_INODE_INFO(inode);
+	c = JFFS2_SB_INFO(inode->i_sb);
+
+	jffs2_init_inode_info(f);
+	
+	ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node);
+
+	if (ret) {
+		make_bad_inode(inode);
+		up(&f->sem);
+		return;
+	}
+	inode->i_mode = je32_to_cpu(latest_node.mode);
+	inode->i_uid = je16_to_cpu(latest_node.uid);
+	inode->i_gid = je16_to_cpu(latest_node.gid);
+	inode->i_size = je32_to_cpu(latest_node.isize);
+	inode->i_atime = je32_to_cpu(latest_node.atime);
+	inode->i_mtime = je32_to_cpu(latest_node.mtime);
+	inode->i_ctime = je32_to_cpu(latest_node.ctime);
+
+	inode->i_nlink = f->inocache->nlink;
+	up(&f->sem);
+
+	D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
+}

Index: jffs2port.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ecos/src/jffs2port.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jffs2port.h	11 Jul 2002 10:55:30 -0000	1.1
+++ jffs2port.h	9 Jan 2003 13:53:44 -0000	1.2
@@ -30,8 +30,8 @@
 #include <cyg/io/flash.h>
 
 #include <pkgconf/fs_jffs2.h>
-
-#include "list.h"
+#include <linux/types.h>
+#include <linux/list.h>
 
 // ARM related constants
 #define PAGE_SHIFT 0xC
@@ -43,26 +43,12 @@
 
 // Linux types
 #define printf diag_printf
-#define printk diag_printf
 #define BUG() diag_printf("BUG()\n")
 
-#define uint8_t cyg_uint8
-#define uint16_t cyg_uint16
-#define uint32_t cyg_uint32
-#define loff_t off_t
-
 #define min(x,y) (x<y?x:y)
 #define max(x,y) (x<y?y:x)
 #define min_t(t, x,y) ((t)x<(t)y?(t)x:(t)y)
 
-#define atomic_t int
-#define atomic_inc(atom) (*atom)++
-#define atomic_dec(atom) (*atom)--
-#define atomic_read(atom) (*atom)
-
-#define kmalloc(a,b) malloc(a)
-#define kfree(a) free(a)
-
 #define PageLocked(pg) 1
 #define Page_Uptodate(pg) 0
 #define UnlockPage(pg) 
@@ -72,48 +58,6 @@
 #define ClearPageError(pg)
 #define SetPageUptodate(pg)
 
-#define jiffies 100
-
-#define ERR_PTR(err) (void*)(err)
-#define PTR_ERR(err) (cyg_int32)(err)
-#define IS_ERR(err) (err==NULL)
-
-#define CURRENT_TIME cyg_timestamp()
-
-//#define spinlock_t cyg_spinlock_t
-typedef struct { } spinlock_t;
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
-#define spin_lock_init(lock) do{} while (0)
-#define spin_lock(lock) do{} while (0)
-#define spin_unlock(lock) do{} while (0)
-#define spin_lock_bh(lock) do{} while (0)
-#define spin_unlock_bh(lock) do{} while (0)
-
-struct semaphore {
-	cyg_drv_mutex_t x;
-};
-
-#define init_MUTEX(sem) cyg_drv_mutex_init((cyg_drv_mutex_t *)sem)
-#define init_MUTEX_LOCKED(sem) do { cyg_drv_mutex_init((cyg_drv_mutex_t *)sem); cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem); } while(0)
-#define down(sem) cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem)
-#define down_interruptible(sem) ({ cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem), 0; })
-#define up(sem) cyg_drv_mutex_unlock((cyg_drv_mutex_t *)sem)
-
-#define wait_queue_head_t cyg_uint32
-#define init_waitqueue_head(wait) do{} while (0)
-#define add_wait_queue(wait,new_wait) do{} while (0)
-#define remove_wait_queue(wait,old_wait) do{} while (0)
-#define DECLARE_WAITQUEUE(wait,current) do{} while (0)
-
-#define	KERN_EMERG              "<0>" // system is unusable
-#define	KERN_ALERT              "<1>" // action must be taken immediately
-#define	KERN_CRIT               "<2>" // critical conditions
-#define	KERN_ERR                "<3>" // error conditions
-#define	KERN_WARNING            "<4>" // warning conditions
-#define	KERN_NOTICE             "<5>" // normal but significant condition
-#define	KERN_INFO               "<6>" // informational
-#define	KERN_DEBUG              "<7>" // debug-level messages
-
 // Structures used by VFS
 
 typedef unsigned short kdev_t;
@@ -127,7 +71,7 @@
 #define DNAME_INLINE_LEN 16
 
 struct dentry {
-	atomic_t d_count;
+	//	atomic_t d_count;
 	unsigned int d_flags;
 	struct inode  * d_inode;	/* Where the name belongs to - NULL is negative */
 	struct dentry * d_parent;	/* parent directory */
@@ -225,33 +169,12 @@
 	//int (*getattr) (struct dentry *, struct iattr *);
 };
 
-/*
- * File types
- */
-#define DT_UNKNOWN	0
-#define DT_DIR		4
-#define DT_REG		8
 
 struct iovec {
         void *iov_base;
         ssize_t iov_len; 
 };
 
-// FIXME: we must provide some translation so that Linux-created jffs2
-// partitions can be read on eCos and vice versa
-
-#define S_IFMT 0xF9 // Quick fix for clash on ecos / linux mode bits
-#define S_IFDIR __stat_mode_DIR
-#define S_IFREG __stat_mode_REG
-#define S_IFBLK __stat_mode_BLK
-#define S_IFCHR __stat_mode_CHR
-#define S_IFLNK 0x101
-#define S_IFSOCK 0x102
-#define S_IFIFO __stat_mode_FIFO
-#define S_IRUGO 0x103
-#define S_IXUGO 0x104
-#define S_IRWXUGO 0x105
-
 
 // called by JFFS2
 
@@ -291,8 +214,6 @@
 int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *vecs, unsigned long count, loff_t to, size_t *retlen);
 cyg_bool jffs2_flash_erase(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
 
-static inline void wake_up(wait_queue_head_t *erase_wait)
-{ /* Only used for waking up threads blocks on erases. Not used in eCos */ }
 
 // calls to JFFS2
 

Index: malloc-ecos.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ecos/src/malloc-ecos.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- malloc-ecos.c	11 Jul 2002 10:55:30 -0000	1.1
+++ malloc-ecos.c	9 Jan 2003 13:53:44 -0000	1.2
@@ -11,6 +11,7 @@
  *
  */
 
+#include <linux/kernel.h>
 #include "nodelist.h"
 
 struct jffs2_full_dirent *jffs2_alloc_full_dirent(int namesize)

Index: os-ecos.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ecos/src/os-ecos.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- os-ecos.h	11 Jul 2002 10:55:30 -0000	1.1
+++ os-ecos.h	9 Jan 2003 13:53:44 -0000	1.2
@@ -15,6 +15,9 @@
 #define __JFFS2_OS_ECOS_H__
 
 #include <cyg/io/io.h>
+#include <sys/types.h>
+#include <asm/atomic.h>
+#include "jffs2port.h"
 
 #define CONFIG_JFFS2_FS_DEBUG 0
 
@@ -131,5 +134,28 @@
 //int jffs2_commit_write (struct file *, struct page *, unsigned, unsigned);
 int jffs2_commit_write (struct inode *d_inode, struct page *pg, unsigned start, unsigned end);
 
+#ifndef CONFIG_JFFS2_FS_NAND
+#define jffs2_can_mark_obsolete(c) (1)
+#define jffs2_cleanmarker_oob(c) (0)
+#define jffs2_write_nand_cleanmarker(c,jeb) (-EIO)
+
+#define jffs2_flush_wbuf(c, flag) do { ; } while(0)
+#define jffs2_nand_read_failcnt(c,jeb) do { ; } while(0)
+#define jffs2_write_nand_badblock(c,jeb) do { ; } while(0)
+#define jffs2_flash_writev jffs2_flash_writev
+#define jffs2_wbuf_timeout NULL
+#define jffs2_wbuf_process NULL
+#else
+#error no nand yet
+#endif
+struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri);
+void jffs2_clear_inode (struct inode *inode);
+void jffs2_read_inode (struct inode *inode);
+
+static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
+{
+	memset(f, 0, sizeof(*f));
+	init_MUTEX_LOCKED(&f->sem);
+}
 
 #endif /* __JFFS2_OS_ECOS_H__ */





More information about the linux-mtd-cvs mailing list