Example #1
0
/* return 1 if this is not super block */
static int print_super_block(struct buffer_head *bh)
{
	struct reiserfs_super_block *rs =
	    (struct reiserfs_super_block *)(bh->b_data);
	int skipped, data_blocks;
	char *version;
	char b[BDEVNAME_SIZE];

	if (is_reiserfs_3_5(rs)) {
		version = "3.5";
	} else if (is_reiserfs_3_6(rs)) {
		version = "3.6";
	} else if (is_reiserfs_jr(rs)) {
		version = ((sb_version(rs) == REISERFS_VERSION_2) ?
			   "3.6" : "3.5");
	} else {
		return 1;
	}

	printk("%s\'s super block is in block %llu\n", bdevname(bh->b_bdev, b),
	       (unsigned long long)bh->b_blocknr);
	printk("Reiserfs version %s\n", version);
	printk("Block count %u\n", sb_block_count(rs));
	printk("Blocksize %d\n", sb_blocksize(rs));
	printk("Free blocks %u\n", sb_free_blocks(rs));
	// FIXME: this would be confusing if
	// someone stores reiserfs super block in some data block ;)
//    skipped = (bh->b_blocknr * bh->b_size) / sb_blocksize(rs);
	skipped = bh->b_blocknr;
	data_blocks = sb_block_count(rs) - skipped - 1 - sb_bmap_nr(rs) -
	    (!is_reiserfs_jr(rs) ? sb_jp_journal_size(rs) +
	     1 : sb_reserved_for_journal(rs)) - sb_free_blocks(rs);
	printk
	    ("Busy blocks (skipped %d, bitmaps - %d, journal (or reserved) blocks - %d\n"
	     "1 super block, %d data blocks\n", skipped, sb_bmap_nr(rs),
	     (!is_reiserfs_jr(rs) ? (sb_jp_journal_size(rs) + 1) :
	      sb_reserved_for_journal(rs)), data_blocks);
	printk("Root block %u\n", sb_root_block(rs));
	printk("Journal block (first) %d\n", sb_jp_journal_1st_block(rs));
	printk("Journal dev %d\n", sb_jp_journal_dev(rs));
	printk("Journal orig size %d\n", sb_jp_journal_size(rs));
	printk("FS state %d\n", sb_fs_state(rs));
	printk("Hash function \"%s\"\n",
	       reiserfs_hashname(sb_hash_function_code(rs)));

	printk("Tree height %d\n", sb_tree_height(rs));
	return 0;
}
/* return 1 if this is not super block */
static int print_super_block (struct buffer_head * bh)
{
    struct reiserfs_super_block * rs = (struct reiserfs_super_block *)(bh->b_data);
    int skipped, data_blocks;
    char *version;
    

    if (strncmp (rs->s_magic,  REISERFS_SUPER_MAGIC_STRING,
                 strlen ( REISERFS_SUPER_MAGIC_STRING)) == 0) {
        version = "3.5";
    } else if( strncmp (rs->s_magic,  REISER2FS_SUPER_MAGIC_STRING,
                        strlen ( REISER2FS_SUPER_MAGIC_STRING)) == 0) {
        version = "3.6";
    } else {
	return 1;
    }

    printk ("%s\'s super block in block %ld\n======================\n",
            kdevname (bh->b_dev), bh->b_blocknr);
    printk ("Reiserfs version %s\n", version );
    printk ("Block count %u\n", sb_block_count(rs));
    printk ("Blocksize %d\n", sb_blocksize(rs));
    printk ("Free blocks %u\n", sb_free_blocks(rs));
    // FIXME: this would be confusing if
    // someone stores reiserfs super block in some data block ;)
//    skipped = (bh->b_blocknr * bh->b_size) / sb_blocksize(rs);
    skipped = bh->b_blocknr;
    data_blocks = sb_block_count(rs) - skipped - 1 -
                  sb_bmap_nr(rs) - (sb_orig_journal_size(rs) + 1) -
                  sb_free_blocks(rs);
    printk ("Busy blocks (skipped %d, bitmaps - %d, journal blocks - %d\n"
	    "1 super blocks, %d data blocks\n", 
	    skipped, sb_bmap_nr(rs), 
	    (sb_orig_journal_size(rs) + 1), data_blocks);
    printk ("Root block %u\n", sb_root_block(rs));
    printk ("Journal block (first) %d\n", sb_journal_block(rs));
    printk ("Journal dev %d\n", sb_journal_dev(rs));
    printk ("Journal orig size %d\n", sb_orig_journal_size(rs));
    printk ("Filesystem state %s\n", 
	    (sb_state(rs) == REISERFS_VALID_FS) ? "VALID" : "ERROR");
    printk ("Hash function \"%s\"\n",
            reiserfs_hashname(sb_hash_function_code(rs)));

    printk ("Tree height %d\n", sb_tree_height(rs));
    return 0;
}
Example #3
0
/* Finds out which hash names are sorted with */
static int
what_hash(struct reiserfs_mount *rmp)
{
	uint32_t code;
	struct reiserfs_sb_info *sbi = rmp->rm_reiserfs;

	find_hash_out(rmp);
	code = sb_hash_function_code(SB_DISK_SUPER_BLOCK(sbi));

	/*
	 * reiserfs_hash_detect() == true if any of the hash mount options
	 * were used. We must check them to make sure the user isn't using a
	 * bad hash value
	 */
	if (code == UNSET_HASH || reiserfs_hash_detect(sbi))
		code = find_hash_out(rmp);

	if (code != UNSET_HASH && reiserfs_hash_detect(sbi)) {
		/*
		 * Detection has found the hash, and we must check against
		 * the mount options
		 */
		if (reiserfs_rupasov_hash(sbi) && code != YURA_HASH) {
			reiserfs_log(LOG_ERR, "error, %s hash detected, "
			    "unable to force rupasov hash",
			    reiserfs_hashname(code));
			code = UNSET_HASH;
		} else if (reiserfs_tea_hash(sbi) && code != TEA_HASH) {
			reiserfs_log(LOG_ERR, "error, %s hash detected, "
			    "unable to force tea hash",
			    reiserfs_hashname(code));
			code = UNSET_HASH;
		} else if (reiserfs_r5_hash(sbi) && code != R5_HASH) {
			reiserfs_log(LOG_ERR, "error, %s hash detected, "
			    "unable to force r5 hash",
			    reiserfs_hashname(code));
			code = UNSET_HASH;
		}
	} else {
		/*
		 * Find_hash_out was not called or could not determine
		 * the hash
		 */
		if (reiserfs_rupasov_hash(sbi)) {
			code = YURA_HASH;
		} else if (reiserfs_tea_hash(sbi)) {
			code = TEA_HASH;
		} else if (reiserfs_r5_hash(sbi)) {
			code = R5_HASH;
		}
	}

	/* TODO Not supported yet */
#if 0
	/* If we are mounted RW, and we have a new valid hash code, update
	 * the super */
	if (code != UNSET_HASH &&
	    !(s->s_flags & MS_RDONLY) &&
	    code != sb_hash_function_code(SB_DISK_SUPER_BLOCK(s))) {
		set_sb_hash_function_code(SB_DISK_SUPER_BLOCK(s), code);
	}
#endif

	return (code);
}