Exemplo n.º 1
0
/* and cause everyone elses programs to grind to a halt, or crash */
int check_bb (BB_struct * bp)
{

  int i;
  int n, nco, nc;

  n = bp->ntsb;
  nc = bp->ncsb;
  nco = (bp->nc[0] + 2) * (bp->nc[1] + 2) * (bp->nc[2] + 2);

  for (i = 0; i < bp->ntsb; i++) {

    /*       fprintf(stderr,"Checking subblock %i\n",i); */
    check_sb (bp, i);
    if (realloc (bp->sb[i], sizeof (SB_struct)) == NULL)
      fprintf (stderr, "checkblock error 1");
  }

  realloc (bp->sb, n * sizeof (SB_struct *));
  realloc (bp->c_fs_values->block_array, n * sizeof (CA_FLOAT *));
  realloc (bp->c_fs_values, sizeof (Value_struct));

  realloc (bp->sch_fs_values->block_array, n * sizeof (CA_FLOAT *));
  realloc (bp->sch_fs_values, sizeof (Value_struct));
  realloc (bp->c_sol_values->block_array, n * sizeof (CA_FLOAT *));
  realloc (bp->c_sol_values, sizeof (Value_struct));
  realloc (bp->c_sol_alloy_values->block_array, n * sizeof (CA_FLOAT *));
  realloc (bp->c_sol_alloy_values, sizeof (Value_struct));

  realloc (bp->gr_array, n * sizeof (int *));

  realloc (bp->c_elm_array, n * sizeof (int *));

  realloc (bp->ftmp_one, nco * sizeof (CA_FLOAT));
  realloc (bp->ftmp_two, nco * sizeof (CA_FLOAT));
  realloc (bp->ftmp_three, nco * sizeof (CA_FLOAT));

#ifdef OLD_TUNDER
  realloc (bp->old_Tunder, nco * sizeof (CA_FLOAT));
#endif /*OLD_TUNDER */

  realloc (bp->itmp_one, nco * sizeof (int));

  /*check the grains */
  /*   fprintf(stderr,"Checking the grains\n"); */
  for (i = 0; i < bp->nprops.ngr; i++)
    realloc (bp->gr[i], sizeof (Ind_grain));

  realloc (bp->gr, bp->nprops.gd_max_total * sizeof (Ind_grain *));

  realloc (bp->ctrl->rgbp, sizeof (RGB_struct));

  return (0);
}
Exemplo n.º 2
0
int
main(int argc, char **argv)
{
#ifdef HOST
	hostcompat_init(argc, argv);
#endif

	if (argc!=2) {
		errx(EXIT_USAGE, "Usage: sfsck device/diskfile");
	}

	assert(sizeof(struct sfs_super)==SFS_BLOCKSIZE);
	assert(sizeof(struct sfs_inode)==SFS_BLOCKSIZE);
	assert(SFS_BLOCKSIZE % sizeof(struct sfs_dir) == 0);

	opendisk(argv[1]);

	check_sb();
	check_root_dir();
	check_bitmap();
	adjust_filelinks();

	closedisk();

	warnx("%lu blocks used (of %lu); %lu directories; %lu files",
	      count_blocks, (unsigned long) nblocks, count_dirs, count_files);

	switch (badness) {
	    case EXIT_USAGE:
	    case EXIT_FATAL:
	    default:
		/* not supposed to happen here */
		assert(0);
		break;
	    case EXIT_UNRECOV:
		warnx("WARNING - unrecoverable errors. Maybe try again?");
		break;
	    case EXIT_RECOV:
		warnx("Caution - filesystem modified. Run again for luck.");
		break;
	    case EXIT_CLEAN:
		break;
	}

	return badness;
}
Exemplo n.º 3
0
void check_dent_int (struct dentry *dentry, int parent)
{
	if (parent) {
		printk (KERN_DEBUG "*  parent(%d) dentry: %.*s\n", 
			parent, (int) dentry->d_name.len, dentry->d_name.name);
	} else {
		printk (KERN_DEBUG "*  checking dentry: %.*s\n",
			 (int) dentry->d_name.len, dentry->d_name.name);
	}
	check_inode (dentry->d_inode);
	printk (KERN_DEBUG "*   d_count=%d", dentry->d_count);
	check_sb (dentry->d_sb, 'd');
	if (dentry->d_op == NULL) {
		printk (" (d_op is NULL)\n");
	} else {
		printk (" (d_op is UNKNOWN: %p)\n", dentry->d_op);
	}
}
Exemplo n.º 4
0
Arquivo: auto_ai.c Projeto: shouya/bar
static void do_auto_move(void) {
  move_sb(impl.sb, 0, 1);
  if (check_sb(impl.bm, impl.sb) != 0) {
    move_sb(impl.sb, 0, -1);
    lines_killed += check_bm_lines(impl.bm, 0, 0);
    if (steady_sb(impl.bm, impl.sb, shift_queue(impl.queue), 3) != 0) {
/*    if (steady_sb(impl.bm, impl.sb, 6, 3) != 0) {*/
      /*printf("game over, you may press C-n to start a new game.\n");*/
      printf("this AI cleared lines: %d, spend: %.2fs\n", lines_killed,
             (util_getticks()-beg_time)/1000.0f);
      game_ctrl.automove_interval = -1;
      clear_blockmap(impl.bm);
      reset_shapebuf(impl.sb, -1);
      newgame();
    } else {
      impl.ai = ai_calc(impl.bm, impl.sb, 0, 0);
    }
  }
}
Exemplo n.º 5
0
void check_inode (struct inode *inode)
{
	if (inode) {
		printk (KERN_DEBUG "*   inode is %lu (i_count=%d, pos=%lu)",
			 inode->i_ino, inode->i_count, inode->u.umsdos_i.pos);
		check_sb (inode->i_sb, 'i');
		
		if (!list_empty(&inode->i_dentry)) {
			printk (" (has i_dentry)");
		} else {
			printk (" (NO i_dentry)");
		}
		
		printk (" (i_patched=%d)", inode->u.umsdos_i.i_patched);
		
		if (inode->i_op == NULL) {
			printk (" (i_op is NULL)\n");
		} else if (inode->i_op == &umsdos_dir_inode_operations) {
			printk (" (i_op is umsdos_dir_inode_operations)\n");
		} else if (inode->i_op == &umsdos_file_inode_operations) {
			printk (" (i_op is umsdos_file_inode_operations)\n");
		} else if (inode->i_op == &umsdos_file_inode_operations_no_bmap) {
			printk (" (i_op is umsdos_file_inode_operations_no_bmap)\n");
		} else if (inode->i_op == &umsdos_file_inode_operations_readpage) {
			printk (" (i_op is umsdos_file_inode_operations_readpage)\n");
		} else if (inode->i_op == &umsdos_rdir_inode_operations) {
			printk (" (i_op is umsdos_rdir_inode_operations)\n");
		} else if (inode->i_op == &umsdos_symlink_inode_operations) {
			printk (" (i_op is umsdos_symlink_inode_operations)\n");
		} else {
			printk (" (i_op is UNKNOWN: %p)\n", inode->i_op);
		}
	} else {
		printk (KERN_DEBUG "*   inode is NULL\n");
	}
}