linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / affs / super.c
index ad83ec3..aaec015 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/stat.h>
-#include <linux/time.h>
-#include <linux/affs_fs.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/genhd.h>
-#include <linux/amigaffs.h>
-#include <linux/major.h>
-#include <linux/blkdev.h>
 #include <linux/init.h>
-#include <linux/smp_lock.h>
-#include <linux/buffer_head.h>
-#include <linux/vfs.h>
+#include <linux/statfs.h>
 #include <linux/parser.h>
-#include <asm/system.h>
-#include <asm/uaccess.h>
+#include "affs.h"
 
 extern struct timezone sys_tz;
 
@@ -44,17 +28,15 @@ affs_put_super(struct super_block *sb)
        pr_debug("AFFS: put_super()\n");
 
        if (!(sb->s_flags & MS_RDONLY)) {
-               AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = be32_to_cpu(1);
+               AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = cpu_to_be32(1);
                secs_to_datestamp(get_seconds(),
                                  &AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change);
                affs_fix_checksum(sb, sbi->s_root_bh);
                mark_buffer_dirty(sbi->s_root_bh);
        }
 
-       affs_brelse(sbi->s_bmap_bh);
-       if (sbi->s_prefix)
-               kfree(sbi->s_prefix);
-       kfree(sbi->s_bitmap);
+       kfree(sbi->s_prefix);
+       affs_free_bitmap(sb);
        affs_brelse(sbi->s_root_bh);
        kfree(sbi);
        sb->s_fs_info = NULL;
@@ -71,7 +53,7 @@ affs_write_super(struct super_block *sb)
                //      if (sbi->s_bitmap[i].bm_bh) {
                //              if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) {
                //                      clean = 0;
-               AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = be32_to_cpu(clean);
+               AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = cpu_to_be32(clean);
                secs_to_datestamp(get_seconds(),
                                  &AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change);
                affs_fix_checksum(sb, sbi->s_root_bh);
@@ -116,7 +98,7 @@ static int init_inodecache(void)
 {
        affs_inode_cachep = kmem_cache_create("affs_inode_cache",
                                             sizeof(struct affs_inode_info),
-                                            0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+                                            0, SLAB_RECLAIM_ACCOUNT,
                                             init_once, NULL);
        if (affs_inode_cachep == NULL)
                return -ENOMEM;
@@ -215,10 +197,9 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s
                        *mount_opts |= SF_MUFS;
                        break;
                case Opt_prefix:
-                       if (*prefix) {          /* Free any previous prefix */
-                               kfree(*prefix);
-                               *prefix = NULL;
-                       }
+                       /* Free any previous prefix */
+                       kfree(*prefix);
+                       *prefix = NULL;
                        *prefix = match_strdup(&args[0]);
                        if (!*prefix)
                                return 0;
@@ -288,6 +269,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
        gid_t                    gid;
        int                      reserved;
        unsigned long            mount_flags;
+       int                      tmp_flags;     /* fix remount prototype... */
 
        pr_debug("AFFS: read_super(%s)\n",data ? (const char *)data : "no options");
 
@@ -387,7 +369,7 @@ got_root:
                printk(KERN_ERR "AFFS: Cannot read boot block\n");
                goto out_error;
        }
-       chksum = be32_to_cpu(*(u32 *)boot_bh->b_data);
+       chksum = be32_to_cpu(*(__be32 *)boot_bh->b_data);
        brelse(boot_bh);
 
        /* Dircache filesystems are compatible with non-dircache ones
@@ -399,7 +381,6 @@ got_root:
                printk(KERN_NOTICE "AFFS: Dircache FS - mounting %s read only\n",
                        sb->s_id);
                sb->s_flags |= MS_RDONLY;
-               sbi->s_flags |= SF_READONLY;
        }
        switch (chksum) {
                case MUFS_FS:
@@ -455,8 +436,10 @@ got_root:
        sbi->s_root_bh = root_bh;
        /* N.B. after this point s_root_bh must be released */
 
-       if (affs_init_bitmap(sb))
+       tmp_flags = sb->s_flags;
+       if (affs_init_bitmap(sb, &tmp_flags))
                goto out_error;
+       sb->s_flags = tmp_flags;
 
        /* set up enough so that it can read an inode */
 
@@ -477,11 +460,9 @@ got_root:
 out_error:
        if (root_inode)
                iput(root_inode);
-       if (sbi->s_bitmap)
-               kfree(sbi->s_bitmap);
+       kfree(sbi->s_bitmap);
        affs_brelse(root_bh);
-       if (sbi->s_prefix)
-               kfree(sbi->s_prefix);
+       kfree(sbi->s_prefix);
        kfree(sbi);
        sb->s_fs_info = NULL;
        return -EINVAL;
@@ -498,7 +479,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
        int                      reserved;
        int                      root_block;
        unsigned long            mount_flags;
-       unsigned long            read_only = sbi->s_flags & SF_READONLY;
+       int                      res = 0;
 
        pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data);
 
@@ -507,7 +488,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
        if (!parse_options(data,&uid,&gid,&mode,&reserved,&root_block,
            &blocksize,&sbi->s_prefix,sbi->s_volume,&mount_flags))
                return -EINVAL;
-       sbi->s_flags = mount_flags | read_only;
+       sbi->s_flags = mount_flags;
        sbi->s_mode  = mode;
        sbi->s_uid   = uid;
        sbi->s_gid   = gid;
@@ -518,14 +499,11 @@ affs_remount(struct super_block *sb, int *flags, char *data)
                sb->s_dirt = 1;
                while (sb->s_dirt)
                        affs_write_super(sb);
-               sb->s_flags |= MS_RDONLY;
-       } else if (!(sbi->s_flags & SF_READONLY)) {
-               sb->s_flags &= ~MS_RDONLY;
-       } else {
-               affs_warning(sb,"remount","Cannot remount fs read/write because of errors");
-               return -EINVAL;
-       }
-       return 0;
+               affs_free_bitmap(sb);
+       } else
+               res = affs_init_bitmap(sb, flags);
+
+       return res;
 }
 
 static int