fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / hpfs / super.c
index 63e88d7..d4abc1a 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/parser.h>
 #include <linux/init.h>
 #include <linux/statfs.h>
+#include <linux/magic.h>
 
 /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */
 
@@ -45,21 +46,17 @@ static void unmark_dirty(struct super_block *s)
 }
 
 /* Filesystem error... */
+static char err_buf[1024];
 
-#define ERR_BUF_SIZE 1024
-
-void hpfs_error(struct super_block *s, char *m,...)
+void hpfs_error(struct super_block *s, const char *fmt, ...)
 {
-       char *buf;
-       va_list l;
-       va_start(l, m);
-       if (!(buf = kmalloc(ERR_BUF_SIZE, GFP_KERNEL)))
-               printk("HPFS: No memory for error message '%s'\n",m);
-       else if (vsprintf(buf, m, l) >= ERR_BUF_SIZE)
-               printk("HPFS: Grrrr... Kernel memory corrupted ... going on, but it'll crash very soon :-(\n");
-       printk("HPFS: filesystem error: ");
-       if (buf) printk("%s", buf);
-       else printk("%s\n",m);
+       va_list args;
+
+       va_start(args, fmt);
+       vsnprintf(err_buf, sizeof(err_buf), fmt, args);
+       va_end(args);
+
+       printk("HPFS: filesystem error: %s", err_buf);
        if (!hpfs_sb(s)->sb_was_error) {
                if (hpfs_sb(s)->sb_err == 2) {
                        printk("; crashing the system because you wanted it\n");
@@ -75,7 +72,6 @@ void hpfs_error(struct super_block *s, char *m,...)
                } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n");
                else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n");
        } else printk("\n");
-       kfree(buf);
        hpfs_sb(s)->sb_was_error = 1;
 }
 
@@ -135,8 +131,9 @@ static unsigned count_bitmaps(struct super_block *s)
        return count;
 }
 
-static int hpfs_statfs(struct super_block *s, struct kstatfs *buf)
+static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
+       struct super_block *s = dentry->d_sb;
        struct hpfs_sb_info *sbi = hpfs_sb(s);
        lock_kernel();
 
@@ -158,12 +155,12 @@ static int hpfs_statfs(struct super_block *s, struct kstatfs *buf)
        return 0;
 }
 
-static kmem_cache_t * hpfs_inode_cachep;
+static struct kmem_cache * hpfs_inode_cachep;
 
 static struct inode *hpfs_alloc_inode(struct super_block *sb)
 {
        struct hpfs_inode_info *ei;
-       ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_NOFS);
+       ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, GFP_NOFS);
        if (!ei)
                return NULL;
        ei->vfs_inode.i_version = 1;
@@ -175,14 +172,14 @@ static void hpfs_destroy_inode(struct inode *inode)
        kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode));
 }
 
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
 {
        struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo;
 
        if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
            SLAB_CTOR_CONSTRUCTOR) {
-               init_MUTEX(&ei->i_sem);
-               init_MUTEX(&ei->i_parent);
+               mutex_init(&ei->i_mutex);
+               mutex_init(&ei->i_parent_mutex);
                inode_init_once(&ei->vfs_inode);
        }
 }
@@ -191,7 +188,8 @@ static int init_inodecache(void)
 {
        hpfs_inode_cachep = kmem_cache_create("hpfs_inode_cache",
                                             sizeof(struct hpfs_inode_info),
-                                            0, SLAB_RECLAIM_ACCOUNT,
+                                            0, (SLAB_RECLAIM_ACCOUNT|
+                                               SLAB_MEM_SPREAD),
                                             init_once, NULL);
        if (hpfs_inode_cachep == NULL)
                return -ENOMEM;
@@ -200,8 +198,7 @@ static int init_inodecache(void)
 
 static void destroy_inodecache(void)
 {
-       if (kmem_cache_destroy(hpfs_inode_cachep))
-               printk(KERN_INFO "hpfs_inode_cache: not all structures were freed\n");
+       kmem_cache_destroy(hpfs_inode_cachep);
 }
 
 /*
@@ -459,11 +456,10 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
 
        int o;
 
-       sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
+       sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
        if (!sbi)
                return -ENOMEM;
        s->s_fs_info = sbi;
-       memset(sbi, 0, sizeof(*sbi));
 
        sbi->sb_bmp_dir = NULL;
        sbi->sb_cp_table = NULL;
@@ -661,10 +657,11 @@ bail0:
        return -EINVAL;
 }
 
-static struct super_block *hpfs_get_sb(struct file_system_type *fs_type,
-       int flags, const char *dev_name, void *data)
+static int hpfs_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, hpfs_fill_super);
+       return get_sb_bdev(fs_type, flags, dev_name, data, hpfs_fill_super,
+                          mnt);
 }
 
 static struct file_system_type hpfs_fs_type = {