Esempio n. 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;
    

    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",
            sb_hash_function_code(rs) == TEA_HASH ? "tea" :
	    ( sb_hash_function_code(rs) == YURA_HASH ? "rupasov" : (sb_hash_function_code(rs) == R5_HASH ? "r5" : "unknown")));

    printk ("Tree height %d\n", sb_tree_height(rs));
    return 0;
}
Esempio n. 2
0
static int read_super_block (struct super_block * s, int size, int offset)
{
    struct buffer_head * bh;
    struct reiserfs_super_block * rs;
 

    bh = bread (s->s_dev, offset / size, size);
    if (!bh) {
      printk ("read_super_block: "
              "bread failed (dev %s, block %d, size %d)\n",
              kdevname (s->s_dev), offset / size, size);
      return 1;
    }
 
    rs = (struct reiserfs_super_block *)bh->b_data;
    if (!is_reiserfs_magic_string (rs)) {
      printk ("read_super_block: "
              "can't find a reiserfs filesystem on (dev %s, block %lu, size %d)\n",
              kdevname(s->s_dev), bh->b_blocknr, size);
      brelse (bh);
      return 1;
    }
 
    //
    // ok, reiserfs signature (old or new) found in at the given offset
    //    
    s->s_blocksize = sb_blocksize(rs);
    s->s_blocksize_bits = 0;
    while ((1 << s->s_blocksize_bits) != s->s_blocksize)
	s->s_blocksize_bits ++;

    brelse (bh);
    
    if (s->s_blocksize != size)
	set_blocksize (s->s_dev, s->s_blocksize);

    bh = reiserfs_bread (s, offset / s->s_blocksize, s->s_blocksize);
    if (!bh) {
	printk("read_super_block: "
                "bread failed (dev %s, block %d, size %d)\n",
                kdevname (s->s_dev), offset / size, size);
	return 1;
    }
    
    rs = (struct reiserfs_super_block *)bh->b_data;
    if (!is_reiserfs_magic_string (rs) ||
	sb_blocksize(rs) != s->s_blocksize) {
	printk ("read_super_block: "
		"can't find a reiserfs filesystem on (dev %s, block %lu, size %d)\n",
		kdevname(s->s_dev), bh->b_blocknr, size);
	brelse (bh);
	printk ("read_super_block: can't find a reiserfs filesystem on dev %s.\n", kdevname(s->s_dev));
	return 1;
    }
    /* must check to be sure we haven't pulled an old format super out
    ** of the old format's log.  This is a kludge of a check, but it
    ** will work.  If block we've just read in is inside the
    ** journal for that super, it can't be valid.  
    */
    if (bh->b_blocknr >= sb_journal_block(rs) && 
	bh->b_blocknr < (sb_journal_block(rs) + JOURNAL_BLOCK_COUNT)) {
	brelse(bh) ;
	printk("super-459: read_super_block: "
	       "super found at block %lu is within its own log. "
	       "It must not be of this format type.\n", bh->b_blocknr) ;
	return 1 ;
    }

    if ( rs->s_root_block == -1 ) {
	brelse(bh) ;
	printk("dev %s: Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
	       "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
	       "get newer reiserfsprogs package\n", kdevname (s->s_dev));
	return 1;
    }

    SB_BUFFER_WITH_SB (s) = bh;
    SB_DISK_SUPER_BLOCK (s) = rs;

    s->s_op = &reiserfs_sops;

    /* new format is limited by the 32 bit wide i_blocks field, want to
    ** be one full block below that.
    */
    s->s_maxbytes = (512LL << 32) - s->s_blocksize ;
    return 0;
}