2545 static int ext4_fill_super(struct super_block *sb, void *data, intsilent) 2546 __releases(kernel_lock) 2547 __acquires(kernel_lock) 2548 { 2549 char *orig_data = kstrdup(data, GFP_KERNEL); 2550 struct buffer_head *bh; 2551 struct ext4_super_block *es = NULL; 2552 struct ext4_sb_info *sbi; 2553 ext4_fsblk_t block; 2554 ext4_fsblk_t sb_block = get_sb_block(&data); 2555 ext4_fsblk_t logical_sb_block; 2556 unsigned long offset = 0; …… 2580 } 2581 sb->s_fs_info = sbi; 2582 sbi->s_mount_opt = 0; 2583 sbi->s_resuid = EXT4_DEF_RESUID; 2584 sbi->s_resgid = EXT4_DEF_RESGID; 2585 sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; 2586 sbi->s_sb_block = sb_block; 2587 if (sb->s_bdev->bd_part) 2588 sbi->s_sectors_written_start = 2589 part_stat_read(sb->s_bdev->bd_part, sectors[1]); 2590 2591 unlock_kernel(); 2592 2593 /* Cleanup superblock name */ 2594 for (cp = sb->s_id; (cp = strchr(cp, '/'));) 2595 *cp = '!'; 2596 2597 ret = -EINVAL; 2598 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); 2599 if (!blocksize) { 2600 ext4_msg(sb, KERN_ERR, "unable to set blocksize"); 2601 goto out_fail; 2602 } 2603 2604 /* 2605 * The ext4 superblock will not be buffer aligned for other than 1kB 2606 * block sizes. We need to calculate the offset from buffer start. 2607 */ 2608 if (blocksize != EXT4_MIN_BLOCK_SIZE) { 2609 logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE; 2610 offset = do_div(logical_sb_block, blocksize); 2611 } else { 2612 logical_sb_block = sb_block; 2613 } 2614 2615 if (!(bh = sb_bread(sb, logical_sb_block))) { 2616 ext4_msg(sb, KERN_ERR, "unable to read superblock"); 2617 goto out_fail; 2618 } …… 2649 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA) 2650 set_opt(sbi->s_mount_opt, JOURNAL_DATA); 2651 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED) 2652 set_opt(sbi->s_mount_opt, ORDERED_DATA); 2653 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK) 2654 set_opt(sbi->s_mount_opt, WRITEBACK_DATA); 2655 2656 if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC) 2657 set_opt(sbi->s_mount_opt, ERRORS_PANIC); 2658 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_CONTINUE) 2659 set_opt(sbi->s_mount_opt, ERRORS_CONT); 2660 else 2661 set_opt(sbi->s_mount_opt, ERRORS_RO); 2662 if (def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY) 2663 set_opt(sbi->s_mount_opt, BLOCK_VALIDITY); 2664 if (def_mount_opts & EXT4_DEFM_DISCARD) 2665 set_opt(sbi->s_mount_opt, DISCARD); …… 2931 * set up enough so that it can read an inode 2932 */ 2933 if (!test_opt(sb, NOLOAD) && 2934 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) 2935 sb->s_op = &ext4_sops; 2936 else 2937 sb->s_op = &ext4_nojournal_sops; 2938 sb->s_export_op = &ext4_export_ops; 2939 sb->s_xattr = ext4_xattr_handlers; 2940 #ifdef CONFIG_QUOTA 2941 sb->s_qcop = &ext4_qctl_operations; 2942 sb->dq_op = &ext4_quota_operations; 2943 #endif …… 3052 root = ext4_iget(sb, EXT4_ROOT_INO); 3053 if (IS_ERR(root)) { 3054 ext4_msg(sb, KERN_ERR, "get root inode failed"); 3055 ret = PTR_ERR(root); 3056 goto failed_mount4; 3057 } 3058 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 3059 iput(root); 3060 ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); 3061 goto failed_mount4; 3062 } 3063 sb->s_root = d_alloc_root(root); 3064 if (!sb->s_root) { 3065 ext4_msg(sb, KERN_ERR, "get root dentry failed"); 3066 iput(root); 3067 ret = -ENOMEM; 3068 goto failed_mount4; 3069 } 3070 3071 ext4_setup_super(sb, es, sb->s_flags & MS_RDONLY); 3072
|