]> 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 9e0b5458d9c072bc76e4fa6825e2b02163e4e0c4..9d0521451f5943964f6cd223d025f3561b580de7 100644 (file)
@@ -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);
        }
 }
@@ -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... */
@@ -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;
@@ -293,6 +296,7 @@ static void jffs2_put_super (struct super_block *sb)
                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);
 
@@ -320,6 +324,18 @@ 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)"
@@ -327,11 +343,12 @@ static int __init init_jffs2_fs(void)
 #ifdef CONFIG_JFFS2_SUMMARY
               " (SUMMARY) "
 #endif
-              " (C) 2001-2003 Red Hat, Inc.\n");
+              " (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");