]> err.no Git - linux-2.6/blobdiff - fs/jffs2/super.c
[JFFS2] Don't trust node headers before the CRC is checked.
[linux-2.6] / fs / jffs2 / super.c
index aaf9475cfb6ad866e05660121fd1a516650345b0..9d0521451f5943964f6cd223d025f3561b580de7 100644 (file)
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: super.c,v 1.107 2005/07/12 16:37:08 dedekind Exp $
+ * $Id: super.c,v 1.110 2005/11/07 11:14:42 gleixner Exp $
  *
  */
 
@@ -51,7 +51,7 @@ static void jffs2_i_init_once(void * foo, kmem_cache_t * cachep, unsigned long f
 
        if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
            SLAB_CTOR_CONSTRUCTOR) {
-               init_MUTEX_LOCKED(&ei->sem);
+               init_MUTEX(&ei->sem);
                inode_init_once(&ei->vfs_inode);
        }
 }
@@ -62,7 +62,7 @@ static int jffs2_sync_fs(struct super_block *sb, int wait)
 
        down(&c->alloc_sem);
        jffs2_flush_wbuf_pad(c);
-       up(&c->alloc_sem);      
+       up(&c->alloc_sem);
        return 0;
 }
 
@@ -112,7 +112,7 @@ static int jffs2_sb_set(struct super_block *sb, void *data)
 }
 
 static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type,
-                                             int flags, const char *dev_name, 
+                                             int flags, const char *dev_name,
                                              void *data, struct mtd_info *mtd)
 {
        struct super_block *sb;
@@ -151,8 +151,11 @@ static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type,
 
        sb->s_op = &jffs2_super_operations;
        sb->s_flags = flags | MS_NOATIME;
-
-       ret = jffs2_do_fill_super(sb, data, (flags&MS_VERBOSE)?1:0);
+       sb->s_xattr = jffs2_xattr_handlers;
+#ifdef CONFIG_JFFS2_FS_POSIX_ACL
+       sb->s_flags |= MS_POSIXACL;
+#endif
+       ret = jffs2_do_fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
 
        if (ret) {
                /* Failure case... */
@@ -172,7 +175,7 @@ static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type,
 }
 
 static struct super_block *jffs2_get_sb_mtdnr(struct file_system_type *fs_type,
-                                             int flags, const char *dev_name, 
+                                             int flags, const char *dev_name,
                                              void *data, int mtdnr)
 {
        struct mtd_info *mtd;
@@ -201,7 +204,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type,
 
        /* The preferred way of mounting in future; especially when
           CONFIG_BLK_DEV is implemented - we specify the underlying
-          MTD device by number or by name, so that we don't require 
+          MTD device by number or by name, so that we don't require
           block device support to be present in the kernel. */
 
        /* FIXME: How to do the root fs this way? */
@@ -225,7 +228,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type,
                } else if (isdigit(dev_name[3])) {
                        /* Mount by MTD device number name */
                        char *endptr;
-                       
+
                        mtdnr = simple_strtoul(dev_name+3, &endptr, 0);
                        if (!*endptr) {
                                /* It was a valid number */
@@ -235,7 +238,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type,
                }
        }
 
-       /* Try the old way - the hack where we allowed users to mount 
+       /* Try the old way - the hack where we allowed users to mount
           /dev/mtdblock$(n) but didn't actually _use_ the blkdev */
 
        err = path_lookup(dev_name, LOOKUP_FOLLOW, &nd);
@@ -257,7 +260,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type,
        }
 
        if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR) {
-               if (!(flags & MS_VERBOSE)) /* Yes I mean this. Strangely */
+               if (!(flags & MS_SILENT))
                        printk(KERN_NOTICE "Attempt to mount non-MTD device \"%s\" as JFFS2\n",
                               dev_name);
                goto out;
@@ -282,14 +285,18 @@ static void jffs2_put_super (struct super_block *sb)
        down(&c->alloc_sem);
        jffs2_flush_wbuf_pad(c);
        up(&c->alloc_sem);
+
+       jffs2_sum_exit(c);
+
        jffs2_free_ino_caches(c);
        jffs2_free_raw_node_refs(c);
-       if (c->mtd->flags & MTD_NO_VIRTBLOCKS)
+       if (jffs2_blocks_use_vmalloc(c))
                vfree(c->blocks);
        else
                kfree(c->blocks);
        jffs2_flash_cleanup(c);
        kfree(c->inocache_list);
+       jffs2_clear_xattr_subsystem(c);
        if (c->mtd->sync)
                c->mtd->sync(c->mtd);
 
@@ -317,15 +324,31 @@ static int __init init_jffs2_fs(void)
 {
        int ret;
 
+       /* Paranoia checks for on-medium structures. If we ask GCC
+          to pack them with __attribute__((packed)) then it _also_
+          assumes that they're not aligned -- so it emits crappy
+          code on some architectures. Ideally we want an attribute
+          which means just 'no padding', without the alignment
+          thing. But GCC doesn't have that -- we have to just
+          hope the structs are the right sizes, instead. */
+       BUG_ON(sizeof(struct jffs2_unknown_node) != 12);
+       BUG_ON(sizeof(struct jffs2_raw_dirent) != 40);
+       BUG_ON(sizeof(struct jffs2_raw_inode) != 68);
+       BUG_ON(sizeof(struct jffs2_raw_summary) != 32);
+
        printk(KERN_INFO "JFFS2 version 2.2."
 #ifdef CONFIG_JFFS2_FS_WRITEBUFFER
               " (NAND)"
 #endif
-              " (C) 2001-2003 Red Hat, Inc.\n");
+#ifdef CONFIG_JFFS2_SUMMARY
+              " (SUMMARY) "
+#endif
+              " (C) 2001-2006 Red Hat, Inc.\n");
 
        jffs2_inode_cachep = kmem_cache_create("jffs2_i",
                                             sizeof(struct jffs2_inode_info),
-                                            0, SLAB_RECLAIM_ACCOUNT,
+                                            0, (SLAB_RECLAIM_ACCOUNT|
+                                               SLAB_MEM_SPREAD),
                                             jffs2_i_init_once, NULL);
        if (!jffs2_inode_cachep) {
                printk(KERN_ERR "JFFS2 error: Failed to initialise inode cache\n");
@@ -370,5 +393,5 @@ module_exit(exit_jffs2_fs);
 
 MODULE_DESCRIPTION("The Journalling Flash File System, v2");
 MODULE_AUTHOR("Red Hat, Inc.");
-MODULE_LICENSE("GPL"); // Actually dual-licensed, but it doesn't matter for 
+MODULE_LICENSE("GPL"); // Actually dual-licensed, but it doesn't matter for
                       // the sake of this tag. It's Free Software.