Fix df size problem
[yaffs2.git] / yaffs_fs.c
index f25bccc..7b4a8b0 100644 (file)
  */
 
 
-const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.1 2004-12-17 04:39:04 charles Exp $";
+const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.5 2005-04-29 07:01:18 charles Exp $";
 extern const char *yaffs_guts_c_version;
 
 
+
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -63,7 +64,6 @@ extern const char *yaffs_guts_c_version;
 
 #endif
 
-
 #include <asm/uaccess.h>
 
 #include "yportenv.h"
@@ -72,8 +72,8 @@ extern const char *yaffs_guts_c_version;
 
 
 
-//unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS | YAFFS_TRACE_BAD_BLOCKS;
-unsigned yaffs_traceMask = 0xFFFFFFFF;
+unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS | YAFFS_TRACE_BAD_BLOCKS;
+//unsigned yaffs_traceMask = 0xFFFFFFFF;
 
 
 #ifdef CONFIG_YAFFS_RAM_ENABLED
@@ -643,8 +643,11 @@ static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
                switch (obj->st_mode & S_IFMT) 
                {
                        default: // fifo, device or socket
-                               init_special_inode(inode, obj->st_mode,(dev_t)(obj->st_rdev));
-                               break;
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
+                               init_special_inode(inode, obj->st_mode,old_decode_dev(obj->st_rdev));
+#else
+                                 init_special_inode(inode, obj->st_mode,(dev_t)(obj->st_rdev));
+#endif                         break;
                        case S_IFREG:   // file         
                                inode->i_op = &yaffs_file_inode_operations;
                                inode->i_fop = &yaffs_file_operations;
@@ -926,8 +929,11 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int r
                default:
                        // Special (socket, fifo, device...)
                        T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making special\n"));
-                       obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
-                       break;
+#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));
+#else
+                        obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->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);
@@ -1206,20 +1212,35 @@ static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
 #endif
 {
+
+       
        yaffs_Device *dev = yaffs_SuperToDevice(sb);
        T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_statfs\n"));
 
        yaffs_GrossLock(dev);
        
+       
        buf->f_type = YAFFS_MAGIC;
        buf->f_bsize = sb->s_blocksize;
        buf->f_namelen = 255;
-       buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * YAFFS_CHUNKS_PER_BLOCK/
-                                               (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
+       if(sb->s_blocksize > dev->nBytesPerChunk)
+       {
+               
+               buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * dev->nChunksPerBlock/
+                                               (sb->s_blocksize/dev->nBytesPerChunk);
+               buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev)/
+                                               (sb->s_blocksize/dev->nBytesPerChunk);
+       }
+       else
+       {
+               
+               buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * dev->nChunksPerBlock *
+                                               (dev->nBytesPerChunk/sb->s_blocksize);
+               buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev) *
+                                               (dev->nBytesPerChunk/sb->s_blocksize);
+       }
        buf->f_files = 0;
        buf->f_ffree = 0;
-       buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev)/
-                                               (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
        buf->f_bavail =  buf->f_bfree;
        
        yaffs_GrossUnlock(dev);
@@ -1613,8 +1634,8 @@ static struct file_system_type yaffs_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "yaffs",
        .get_sb         = yaffs_read_super,
-//     .kill_sb        = kill_block_super,
-       .kill_sb        = kill_litter_super,
+       .kill_sb        = kill_block_super,
+//     .kill_sb        = kill_litter_super,
        .fs_flags       = FS_REQUIRES_DEV,
 };
 #else
@@ -1643,8 +1664,8 @@ static struct file_system_type yaffs2_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "yaffs2",
        .get_sb         = yaffs2_read_super,
-//     .kill_sb        = kill_block_super,
-       .kill_sb        = kill_litter_super,
+       .kill_sb        = kill_block_super,
+//     .kill_sb        = kill_litter_super,
        .fs_flags       = FS_REQUIRES_DEV,
 };
 #else
@@ -1673,8 +1694,8 @@ 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_block_super,
+//     .kill_sb        = kill_litter_super,
        .fs_flags       = FS_SINGLE,
 };
 #else
@@ -1702,8 +1723,8 @@ 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_block_super,
+//     .kill_sb        = kill_litter_super,
        .fs_flags       = FS_SINGLE,
 };
 #else
@@ -1913,3 +1934,4 @@ MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system");
 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002,2003,2004");
 MODULE_LICENSE("GPL");
 
+