mtd/fs/jffs2/ecos/src fs-ecos.c,1.27,1.28 os-ecos.h,1.17,1.18

David Woodhouse dwmw2 at infradead.org
Wed Nov 26 19:03:27 EST 2003


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

Modified Files:
	fs-ecos.c os-ecos.h 
Log Message:
Read-only CDL option for JFFS2. With just enough ifdefs in fs-ecos.c to 
let function-sections and gc-sections throw away all the write code. 
Also no longer remove -Wpointer-arith from CFLAGS, and really disable the 
gcthread code.


Index: fs-ecos.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ecos/src/fs-ecos.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- fs-ecos.c	26 Nov 2003 22:10:18 -0000	1.27
+++ fs-ecos.c	27 Nov 2003 00:03:25 -0000	1.28
@@ -40,6 +40,7 @@
 static int jffs2_umount(cyg_mtab_entry * mte);
 static int jffs2_open(cyg_mtab_entry * mte, cyg_dir dir, const char *name,
 		      int mode, cyg_file * fte);
+#ifdef CYGOPT_FS_JFFS2_WRITE
 static int jffs2_ops_unlink(cyg_mtab_entry * mte, cyg_dir dir,
 			    const char *name);
 static int jffs2_ops_mkdir(cyg_mtab_entry * mte, cyg_dir dir, const char *name);
@@ -48,6 +49,7 @@
 			    const char *name1, cyg_dir dir2, const char *name2);
 static int jffs2_ops_link(cyg_mtab_entry * mte, cyg_dir dir1, const char *name1,
 			  cyg_dir dir2, const char *name2, int type);
+#endif
 static int jffs2_opendir(cyg_mtab_entry * mte, cyg_dir dir, const char *name,
 			 cyg_file * fte);
 static int jffs2_chdir(cyg_mtab_entry * mte, cyg_dir dir, const char *name,
@@ -61,7 +63,9 @@
 
 // File operations
 static int jffs2_fo_read(struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);
+#ifdef CYGOPT_FS_JFFS2_WRITE
 static int jffs2_fo_write(struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);
+#endif
 static int jffs2_fo_lseek(struct CYG_FILE_TAG *fp, off_t * pos, int whence);
 static int jffs2_fo_ioctl(struct CYG_FILE_TAG *fp, CYG_ADDRWORD com,
 			  CYG_ADDRWORD data);
@@ -90,6 +94,7 @@
 // For simplicity we use _FILESYSTEM synchronization for all accesses since
 // we should never block in any filesystem operations.
 
+#ifdef CYGOPT_FS_JFFS2_WRITE
 FSTAB_ENTRY(jffs2_fste, "jffs2", 0,
 	    CYG_SYNCMODE_FILE_FILESYSTEM | CYG_SYNCMODE_IO_FILESYSTEM,
 	    jffs2_mount,
@@ -102,6 +107,20 @@
 	    jffs2_ops_link,
 	    jffs2_opendir,
 	    jffs2_chdir, jffs2_stat, jffs2_getinfo, jffs2_setinfo);
+#else
+FSTAB_ENTRY(jffs2_fste, "jffs2", 0,
+	    CYG_SYNCMODE_FILE_FILESYSTEM | CYG_SYNCMODE_IO_FILESYSTEM,
+	    jffs2_mount,
+	    jffs2_umount,
+	    jffs2_open,
+	    (cyg_fsop_unlink *)cyg_fileio_erofs,
+	    (cyg_fsop_mkdir *)cyg_fileio_erofs,
+	    (cyg_fsop_rmdir *)cyg_fileio_erofs,
+	    (cyg_fsop_rename *)cyg_fileio_erofs,
+	    (cyg_fsop_link *)cyg_fileio_erofs,
+	    jffs2_opendir,
+	    jffs2_chdir, jffs2_stat, jffs2_getinfo, jffs2_setinfo);
+#endif
 
 // -------------------------------------------------------------------------
 // File operations.
@@ -109,7 +128,11 @@
 
 static cyg_fileops jffs2_fileops = {
 	jffs2_fo_read,
+#ifdef CYGOPT_FS_JFFS2_WRITE
 	jffs2_fo_write,
+#else
+	(cyg_fileop_write *) cyg_fileio_erofs,
+#endif
 	jffs2_fo_lseek,
 	jffs2_fo_ioctl,
 	cyg_fileio_seltrue,
@@ -539,7 +562,10 @@
 		jffs2_sb->s_root->i_count = 1;	// Ensures the root inode is always in ram until umount
 
 		D2(printf("jffs2_mount erasing pending blocks\n"));
-		jffs2_erase_pending_blocks(c,0);
+#ifdef CYGOPT_FS_JFFS2_WRITE
+		if (!jffs2_is_readonly(c))
+		    jffs2_erase_pending_blocks(c,0);
+#endif
 #ifdef CYGOPT_FS_JFFS2_GCTHREAD
 		jffs2_start_garbage_collect_thread(c);
 #endif
@@ -639,12 +665,16 @@
 	int err;
 
 	D2(printf("jffs2_open\n"));
-
+#ifndef CYGOPT_FS_JFFS2_WRITE
+	if (mode & (O_CREAT|O_TRUNC|O_WRONLY))
+		return EROFS;
+#endif
 	init_dirsearch(&ds, (struct _inode *) dir, name);
 
 	err = jffs2_find(&ds);
 
 	if (err == ENOENT) {
+#ifdef CYGOPT_FS_JFFS2_WRITE
 		if (ds.last && (mode & O_CREAT)) {
 
 			// No node there, if the O_CREAT bit is set then we must
@@ -660,6 +690,7 @@
 
 			err = ENOERR;
 		}
+#endif
 	} else if (err == ENOERR) {
 		// The node exists. If the O_CREAT and O_EXCL bits are set, we
 		// must fail the open.
@@ -683,6 +714,7 @@
 		return EISDIR;
 	}
 
+#ifndef CYGOPT_FS_JFFS2_WRITE
 	if (mode & O_TRUNC) {
 		struct jffs2_inode_info *f = JFFS2_INODE_INFO(node);
 		struct jffs2_sb_info *c = JFFS2_SB_INFO(node->i_sb);
@@ -693,7 +725,7 @@
 		// Update file times
 		node->i_ctime = node->i_mtime = cyg_timestamp();
 	}
-
+#endif
 	// Initialise the file object
 	file->f_flag |= mode & CYG_FILE_MODE_MASK;
 	file->f_type = CYG_FILE_TYPE_FILE;
@@ -705,6 +737,7 @@
 	return ENOERR;
 }
 
+#ifdef CYGOPT_FS_JFFS2_WRITE
 // -------------------------------------------------------------------------
 // jffs2_ops_unlink()
 // Remove a file link from its directory.
@@ -973,7 +1006,7 @@
 
 	return -err;
 }
-
+#endif /* CYGOPT_FS_JFFS2_WRITE */
 // -------------------------------------------------------------------------
 // jffs2_opendir()
 // Open a directory for reading.
@@ -1198,6 +1231,7 @@
 }
 
 
+#ifdef CYGOPT_FS_JFFS2_WRITE
 // -------------------------------------------------------------------------
 // jffs2_fo_write()
 // Write data to file.
@@ -1331,6 +1365,7 @@
 
 	return ENOERR;
 }
+#endif /* CYGOPT_FS_JFFS2_WRITE */
 
 // -------------------------------------------------------------------------
 // jffs2_fo_lseek()

Index: os-ecos.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/ecos/src/os-ecos.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- os-ecos.h	26 Nov 2003 15:55:35 -0000	1.17
+++ os-ecos.h	27 Nov 2003 00:03:25 -0000	1.18
@@ -69,8 +69,11 @@
 	return hash;
 }
 
- /* Read-only operation not currently implemented on eCos */
+#ifdef CYGOPT_FS_JFFS2_WRITE
 #define jffs2_is_readonly(c) (0)
+#else
+#define jffs2_is_readonly(c) (1)
+#endif
 
 /* NAND flash not currently supported on eCos */
 #define jffs2_can_mark_obsolete(c) (1)




More information about the linux-mtd-cvs mailing list