Exemplo n.º 1
0
int			add_tetri_in_map(t_env *e, int nb_tetri)
{
	int		i;
	int		j;

	i = -1;
	while (++i < 4)
	{
		j = -1;
		while (++j < 4)
		{
			if (TETRI_CONTENT(nb_tetri)[i][j] != '#')
				continue;
			if (TETRI_Y(nb_tetri) + i - TETRI_YS(nb_tetri) < 0
			|| TETRI_Y(nb_tetri) + i - TETRI_YS(nb_tetri) >= MAP_WIDTH
			|| TETRI_X(nb_tetri) + j - TETRI_XS(nb_tetri) < 0
			|| TETRI_X(nb_tetri) + j - TETRI_XS(nb_tetri) >= MAP_WIDTH
			|| MAP[TETRI_Y(nb_tetri) + i - TETRI_YS(nb_tetri)][TETRI_X(nb_tetri)
			+ j - TETRI_XS(nb_tetri)] != 0)
				return (add_tetri_in_map2(e, nb_tetri));
			MAP[TETRI_Y(nb_tetri) + i - TETRI_YS(nb_tetri)]
				[TETRI_X(nb_tetri)+ j - TETRI_XS(nb_tetri)] = nb_tetri + '0';

		}
	}
	MAP_SIZE = calc_map_size(e);
	return (0);
}
Exemplo n.º 2
0
int32 validfs( HFILE device )
{
    uint64	num_log_blocks;
    int32	rc;
    uint64	first_block, last_block;
    uint32	length, inode_address;
    uint64	index;
    struct dinode	inode_buffer;
    int64	total_nblocks;

    /*
     * Initialize internal block map
     */
    num_log_blocks = sb.s_size >> sb.s_l2bfactor;

    rc = calc_map_size( num_log_blocks, sb.s_bsize, sb.s_agsize );
    if( rc != 0 ) {
	printf("Failure creating internal block map.\n");
    }

    /*
     * Mark fixed items allocated; these are only the items which aren't mapped
     * by one of the inode tables.
     */
    /*
     * Reserved blocks
     */
    length = AGGR_RSVD_BYTES >> sb.s_l2bsize;
    first_block = 0;
    last_block = first_block + length;
    for( index = first_block; index < last_block; index++ ) {
	markit( index, 0 );
    }

    /*
     * Primary superblock
     */
    length = SIZE_OF_SUPER >> sb.s_l2bsize;
    first_block = SUPER1_OFF >> sb.s_l2bsize;
    last_block = first_block + length;
    for( index = first_block; index < last_block; index++ ) {
	markit( index, 0 );
    }

    /*
     * Secondary superblock
     */
    first_block = SUPER2_OFF >> sb.s_l2bsize;
    last_block = first_block + length;
    for( index = first_block; index < last_block; index++ ) {
	markit( index, 0 );
    }

    /*
     * Walk aggregate inode table; marking blocks seen
     */
    rc = ujfs_rwinode( device, &inode_buffer, AGGREGATE_I, GET, sb.s_bsize,
			AGGREGATE_I );
    if( rc != 0 ) return(rc);

    rc = walk_ait( device, &inode_buffer, TRUE );
    if( rc != 0 ) {
	printf(
	"Failed walking aggregate inode table, or difference in inode maps.\n");
    }

    /*
     * Walk secondary aggregate inode table; marking blocks seen
     */
    inode_address = (AGGREGATE_I * sizeof(struct dinode)) +
			( addressPXD(&(sb.s_ait2)) << sb.s_l2bsize );
    rc = ujfs_rw_diskblocks( device, inode_address, sizeof(struct dinode),
				&inode_buffer, GET );
    if( rc != 0 ) return(rc);

    rc = walk_ait( device, &inode_buffer, FALSE );
    if( rc != 0 ) {
	printf(
	"Failed walking secondary inode table, or difference in inode maps.\n");
    }

    /*
     * Since we don't walk the inodes of the secondary inode table we need to
     * be sure and mark the blocks for the map's addressing structure
     */
    total_nblocks = 0;
    walk_inode_tree(device, (xtpage_t *)&inode_buffer.di_btroot,
			&total_nblocks, 0);
    if( inode_buffer.di_nblocks != total_nblocks )
    {
	error++;
	printf(
 "Secondary AIT Inode %d (fileset: %d) nblocks bad, disk: %lld, actual: %lld\n",
		inode_buffer.di_number, inode_buffer.di_fileset,
		inode_buffer.di_nblocks, total_nblocks);
    }

    /*
     * Now the bitmaps are marked, fill in the rest of the maps and compare
     * with the maps on disk
     */
    rc = compare_maps( device, num_log_blocks, sb.s_bsize );

    return(rc);
}