fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / cramfs / inode.c
index 9efcc3a..6db03fb 100644 (file)
@@ -30,7 +30,7 @@
 static struct super_operations cramfs_ops;
 static struct inode_operations cramfs_dir_inode_operations;
 static const struct file_operations cramfs_directory_operations;
-static struct address_space_operations cramfs_aops;
+static const struct address_space_operations cramfs_aops;
 
 static DEFINE_MUTEX(read_mutex);
 
@@ -73,7 +73,6 @@ static int cramfs_iget5_set(struct inode *inode, void *opaque)
        inode->i_uid = cramfs_inode->uid;
        inode->i_size = cramfs_inode->size;
        inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1;
-       inode->i_blksize = PAGE_CACHE_SIZE;
        inode->i_gid = cramfs_inode->gid;
        /* Struct copy intentional */
        inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime;
@@ -181,9 +180,7 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
                struct page *page = NULL;
 
                if (blocknr + i < devsize) {
-                       page = read_cache_page(mapping, blocknr + i,
-                               (filler_t *)mapping->a_ops->readpage,
-                               NULL);
+                       page = read_mapping_page(mapping, blocknr + i, NULL);
                        /* synchronous error? */
                        if (IS_ERR(page))
                                page = NULL;
@@ -244,11 +241,10 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
 
        sb->s_flags |= MS_RDONLY;
 
-       sbi = kmalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
+       sbi = kzalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
        if (!sbi)
                return -ENOMEM;
        sb->s_fs_info = sbi;
-       memset(sbi, 0, sizeof(struct cramfs_sb_info));
 
        /* Invalidate the read buffers on mount: think disk change.. */
        mutex_lock(&read_mutex);
@@ -322,8 +318,10 @@ out:
        return -EINVAL;
 }
 
-static int cramfs_statfs(struct super_block *sb, struct kstatfs *buf)
+static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
+       struct super_block *sb = dentry->d_sb;
+
        buf->f_type = CRAMFS_MAGIC;
        buf->f_bsize = PAGE_CACHE_SIZE;
        buf->f_blocks = CRAMFS_SB(sb)->blocks;
@@ -340,7 +338,7 @@ static int cramfs_statfs(struct super_block *sb, struct kstatfs *buf)
  */
 static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct super_block *sb = inode->i_sb;
        char *buf;
        unsigned int offset;
@@ -483,6 +481,8 @@ static int cramfs_readpage(struct file *file, struct page * page)
                pgdata = kmap(page);
                if (compr_len == 0)
                        ; /* hole */
+               else if (compr_len > (PAGE_CACHE_SIZE << 1))
+                       printk(KERN_ERR "cramfs: bad compressed blocksize %u\n", compr_len);
                else {
                        mutex_lock(&read_mutex);
                        bytes_filled = cramfs_uncompress_block(pgdata,
@@ -501,7 +501,7 @@ static int cramfs_readpage(struct file *file, struct page * page)
        return 0;
 }
 
-static struct address_space_operations cramfs_aops = {
+static const struct address_space_operations cramfs_aops = {
        .readpage = cramfs_readpage
 };
 
@@ -528,10 +528,11 @@ static struct super_operations cramfs_ops = {
        .statfs         = cramfs_statfs,
 };
 
-static struct super_block *cramfs_get_sb(struct file_system_type *fs_type,
-       int flags, const char *dev_name, void *data)
+static int cramfs_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
 {
-       return get_sb_bdev(fs_type, flags, dev_name, data, cramfs_fill_super);
+       return get_sb_bdev(fs_type, flags, dev_name, data, cramfs_fill_super,
+                          mnt);
 }
 
 static struct file_system_type cramfs_fs_type = {
@@ -544,8 +545,15 @@ static struct file_system_type cramfs_fs_type = {
 
 static int __init init_cramfs_fs(void)
 {
-       cramfs_uncompress_init();
-       return register_filesystem(&cramfs_fs_type);
+       int rv;
+
+       rv = cramfs_uncompress_init();
+       if (rv < 0)
+               return rv;
+       rv = register_filesystem(&cramfs_fs_type);
+       if (rv < 0)
+               cramfs_uncompress_exit();
+       return rv;
 }
 
 static void __exit exit_cramfs_fs(void)