Apply Luc's patches
authorcharles <charles>
Tue, 19 Jul 2005 20:41:59 +0000 (20:41 +0000)
committercharles <charles>
Tue, 19 Jul 2005 20:41:59 +0000 (20:41 +0000)
yaffs_fs.c
yaffs_mtdif.c
yaffs_mtdif.h
yaffs_mtdif2.c
yaffs_nandemul.h
yaffs_ramem.c

index a697752..9cde750 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 
-const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.8 2005-07-18 23:16:04 charles Exp $";
+const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.9 2005-07-19 20:41:59 charles Exp $";
 extern const char *yaffs_guts_c_version;
 
 
@@ -165,75 +165,78 @@ static void yaffs_delete_inode(struct inode *);
 static void yaffs_clear_inode(struct inode *);
 
 static int yaffs_readpage(struct file *file, struct page * page);
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+static int yaffs_writepage(struct page *page, struct writeback_control *wbc);
+#else
 static int yaffs_writepage(struct page *page);
+#endif
 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
 
-static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen);
+static int yaffs_readlink(struct dentry *dentry, char __user *buffer, int buflen);
 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
 
 
 
 
 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,
-//     remount_fs:
-       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,
 };
 
 
@@ -252,7 +255,7 @@ static void yaffs_GrossUnlock(yaffs_Device *dev)
 
 }
 
-static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen)
+static int yaffs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
 {
        unsigned char *alias;
        int ret;
@@ -463,8 +466,12 @@ static int yaffs_readpage_nolock(struct file *f, struct page * pg)
        dev = obj->myDev;
        
        
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+        BUG_ON(!PageLocked(pg));
+#else
        if (!PageLocked(pg))
                 PAGE_BUG(pg);
+#endif
 
        pg_buf = kmap(pg);
        /* FIXME: Can kmap fail? */
@@ -508,7 +515,11 @@ static int yaffs_readpage(struct file *f, struct page * pg)
 // writepage inspired by/stolen from smbfs
 //
 
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+static int yaffs_writepage(struct page *page, struct writeback_control *wbc)
+#else
 static int yaffs_writepage(struct page *page)
+#endif
 {
        struct address_space *mapping = page->mapping;
        struct inode *inode;
@@ -648,7 +659,8 @@ static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
                                init_special_inode(inode, obj->yst_mode,old_decode_dev(obj->yst_rdev));
 #else
                                  init_special_inode(inode, obj->yst_mode,(dev_t)(obj->yst_rdev));
-#endif                         break;
+#endif                         
+                        break;
                        case S_IFREG:   // file         
                                inode->i_op = &yaffs_file_inode_operations;
                                inode->i_fop = &yaffs_file_operations;
@@ -934,7 +946,8 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int r
                         obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,old_encode_dev(rdev));
 #else
                         obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
-#endif                 break;
+#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);
@@ -1201,7 +1214,8 @@ static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
                        error = -EPERM;
                }
                yaffs_GrossUnlock(dev);
-               error = inode_setattr(inode,attr);
+               if (!error)
+                       error = inode_setattr(inode,attr);
        }
        return error;
 }
@@ -1436,13 +1450,13 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,int useRam
                        return NULL;
                }
 
-               T(YAFFS_TRACE_OS,(" erase %x\n",mtd->erase));
-               T(YAFFS_TRACE_OS,(" read %x\n",mtd->read));
-               T(YAFFS_TRACE_OS,(" write %x\n",mtd->write));
-               T(YAFFS_TRACE_OS,(" readoob %x\n",mtd->read_oob));
-               T(YAFFS_TRACE_OS,(" writeoob %x\n",mtd->write_oob));
-               T(YAFFS_TRACE_OS,(" block_isbad %x\n",mtd->block_isbad));
-               T(YAFFS_TRACE_OS,(" block_markbad %x\n",mtd->block_markbad));
+               T(YAFFS_TRACE_OS,(" erase %p\n",mtd->erase));
+               T(YAFFS_TRACE_OS,(" read %p\n",mtd->read));
+               T(YAFFS_TRACE_OS,(" write %p\n",mtd->write));
+               T(YAFFS_TRACE_OS,(" readoob %p\n",mtd->read_oob));
+               T(YAFFS_TRACE_OS,(" writeoob %p\n",mtd->write_oob));
+               T(YAFFS_TRACE_OS,(" block_isbad %p\n",mtd->block_isbad));
+               T(YAFFS_TRACE_OS,(" block_markbad %p\n",mtd->block_markbad));
                T(YAFFS_TRACE_OS,(" oobblock %d\n",mtd->oobblock));
                T(YAFFS_TRACE_OS,(" oobsize %d\n",mtd->oobsize));
                T(YAFFS_TRACE_OS,(" erasesize %d\n",mtd->erasesize));
@@ -1693,7 +1707,7 @@ static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super, FS_REQUIRES_D
 static struct super_block *yaffs_ram_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
 {
 
-    return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_ram);
+    return get_sb_nodev(fs, flags, data, yaffs_internal_read_super_ram);
 }
 
 
@@ -1701,8 +1715,7 @@ static struct file_system_type yaffs_ram_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "yaffsram",
        .get_sb         = yaffs_ram_read_super,
-       .kill_sb        = kill_block_super,
-//     .kill_sb        = kill_litter_super,
+       .kill_sb        = kill_litter_super,
        .fs_flags       = 0 ,
 };
 #else
@@ -1722,7 +1735,7 @@ static DECLARE_FSTYPE(yaffs_ram_fs_type, "yaffsram", yaffs_ram_read_super, FS_SI
 static struct super_block *yaffs2_ram_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
 {
 
-    return get_sb_bdev(fs, flags, dev_name, data, yaffs2_internal_read_super_ram);
+    return get_sb_nodev(fs, flags, data, yaffs2_internal_read_super_ram);
 }
 
 
@@ -1730,8 +1743,7 @@ static struct file_system_type yaffs2_ram_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "yaffs2ram",
        .get_sb         = yaffs2_ram_read_super,
-       .kill_sb        = kill_block_super,
-//     .kill_sb        = kill_litter_super,
+       .kill_sb        = kill_litter_super,
        .fs_flags       = 0 ,
 };
 #else
index 2dfc705..2f418b9 100644 (file)
@@ -13,7 +13,7 @@
  *
  */
 
-const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.1 2004-12-17 04:39:04 charles Exp $";
+const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.2 2005-07-19 20:41:59 charles Exp $";
 
 #ifdef CONFIG_YAFFS_MTD_ENABLED
  
@@ -39,7 +39,7 @@ struct nand_oobinfo yaffs_noeccinfo = {
 };
 
 
-int nandmtd_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_Spare *spare)
+int nandmtd_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_Spare *spare)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
        size_t dummy;
index 2e99813..959d923 100644 (file)
@@ -14,7 +14,7 @@
  *
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  *
- * $Id: yaffs_mtdif.h,v 1.1 2004-12-17 04:39:04 charles Exp $
+ * $Id: yaffs_mtdif.h,v 1.2 2005-07-19 20:41:59 charles Exp $
  */
 
 #ifndef __YAFFS_MTDIF_H__
@@ -22,7 +22,7 @@
 
 #include "yaffs_guts.h"
 
-int nandmtd_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_Spare *spare);
+int nandmtd_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_Spare *spare);
 int nandmtd_ReadChunkFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaffs_Spare *spare);
 int nandmtd_EraseBlockInNAND(yaffs_Device *dev, int blockNumber);
 int nandmtd_InitialiseNAND(yaffs_Device *dev);
index 9ddf799..c8bccfe 100644 (file)
@@ -15,7 +15,7 @@
 
 // mtd interface for YAFFS2
 
-const char *yaffs_mtdif2_c_version = "$Id: yaffs_mtdif2.c,v 1.1 2004-12-17 04:39:04 charles Exp $";
+const char *yaffs_mtdif2_c_version = "$Id: yaffs_mtdif2.c,v 1.2 2005-07-19 20:41:59 charles Exp $";
 
 #ifdef CONFIG_YAFFS_MTD_ENABLED
  
@@ -43,7 +43,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __
 
        yaffs_PackedTags2 pt;
        
-       T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %08x tags %08x" TENDSTR),chunkInNAND,data,tags));      
+       T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p" TENDSTR),chunkInNAND,data,tags));  
 
        if(tags)
        {
@@ -87,7 +87,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *
        
        yaffs_PackedTags2 pt;
 
-       T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_ReadChunkWithTagsToNAND chunk %d data %08x tags %08x" TENDSTR),chunkInNAND,data,tags));       
+       T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_ReadChunkWithTagsToNAND chunk %d data %p tags %p" TENDSTR),chunkInNAND,data,tags));   
 
 #ifndef        CONFIG_YAFFS_USE_OLD_MTD
        if(data && tags)
index 8503331..55b5715 100644 (file)
@@ -15,7 +15,7 @@
  *
  * yaffs_nandemul.h: Interface to emulated NAND functions
  *
- * $Id: yaffs_nandemul.h,v 1.1 2004-12-17 04:39:04 charles Exp $
+ * $Id: yaffs_nandemul.h,v 1.2 2005-07-19 20:41:59 charles Exp $
  */
  
 #ifndef __YAFFS_NANDEMUL_H__
@@ -29,7 +29,7 @@
  * transferred.
  */
  
-int nandemul_WriteChunkToNAND(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, yaffs_Spare *spare);
+int nandemul_WriteChunkToNAND(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, const yaffs_Spare *spare);
 int nandemul_ReadChunkFromNAND(struct yaffs_DeviceStruct *dev,int chunkInNAND, __u8 *data, yaffs_Spare *spare);
 int nandemul_EraseBlockInNAND(struct yaffs_DeviceStruct *dev,int blockInNAND);
 int nandemul_InitialiseNAND(struct yaffs_DeviceStruct *dev);
index 15dbabf..da9a2ad 100644 (file)
@@ -15,7 +15,7 @@
  //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.1 2004-12-17 04:39:04 charles Exp $";
+const char *yaffs_ramem_c_version = "$Id: yaffs_ramem.c,v 1.2 2005-07-19 20:41:59 charles Exp $";
 
 #ifndef __KERNEL__
 #define CONFIG_YAFFS_RAM_ENABLED
@@ -33,10 +33,10 @@ const char *yaffs_ramem_c_version = "$Id: yaffs_ramem.c,v 1.1 2004-12-17 04:39:0
 
 #define EM_SIZE_IN_MEG 2
 
-#define BLOCK_SIZE (32 * 528)
+#define YAFFS_BLOCK_SIZE (32 * 528)
 #define BLOCKS_PER_MEG ((1024*1024)/(32 * 512))
 #define FILE_SIZE_IN_BLOCKS (FILE_SIZE_IN_MEG * BLOCKS_PER_MEG)
-#define FILE_SIZE_IN_BYTES (FILE_SIZE_IN_BLOCKS * BLOCK_SIZE)
+#define FILE_SIZE_IN_BYTES (FILE_SIZE_IN_BLOCKS * YAFFS_BLOCK_SIZE)
 
 
 
@@ -178,7 +178,7 @@ static int  CheckInit(void)
        return 1;
 }
 
-int nandemul_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_Spare *spare)
+int nandemul_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, const yaffs_Spare *spare)
 {
        int blk;
        int pg;