Esempio n. 1
0
int check_region(unsigned int from, unsigned int num)
{
	if (from > IO_BITMAP_SIZE*32)
		return 0;
	if (from + num > IO_BITMAP_SIZE*32)
		num = IO_BITMAP_SIZE*32 - from;
	return check_bitmap(ioport_registrar, from, num);
}
Esempio n. 2
0
int check_fs(FILE *fp, check_fs_config_t *config)
{
	int res;
	check_context_t ctx;
	int bsize;
	omfs_super_t super;
	omfs_root_t root;
	omfs_info_t info = { 
		.dev = fp, 
		.super = &super,
		.root = &root
	};

	ctx.config = config;

	if (omfs_read_super(&info))
	{
		fix_problem(E_READ_SUPER, &ctx);
		return 0;
	}
	if (omfs_read_root_block(&info))
	{
		fix_problem(E_READ_ROOT, &ctx);
		return 0;
	}

	ctx.omfs_info = &info;
	omfs_load_bitmap(&info);
	ctx.bitmap = info.bitmap->bmap;
	bsize = (swap_be64(info.super->s_num_blocks) + 7) / 8;
	ctx.visited = calloc(1, bsize);

	/* FIXME error codes are all over the place. */
	res = dirscan_begin(&info, on_node, &ctx);

	if (res < 0)
	{
		fix_problem(E_SCAN, &ctx);
		return 0;
	}
	if (res != 0)
		return 0;

	res = check_bitmap(&ctx);
	
	if (ctx.bitmap) 
		free(ctx.bitmap);
	free(ctx.visited);
	return res;
}
Esempio n. 3
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;
}
Esempio n. 4
0
static void ofono_cdma_sms_process_wmt_deliver(struct ofono_cdma_sms *cdma_sms,
						const struct cdma_sms *incoming)
{
	char *message;
	const char *oaddr;
	const struct cdma_sms_ud *ud;

	ud = &incoming->p2p_msg.bd.wmt_deliver.ud;

	/*
	 * If incoming message does not contain USER DATA, still
	 * send indication to upper layer but with empty string.
	 */
	if (check_bitmap(incoming->p2p_msg.bd.subparam_bitmap,
				CDMA_SMS_SUBPARAM_ID_USER_DATA) == FALSE)
		message = g_new0(char, 1);
	else
Esempio n. 5
0
File: fs.c Progetto: MG47/JOS-MG
// Initialize the file system
void
fs_init(void)
{
	static_assert(sizeof(struct File) == 256);

       // Find a JOS disk.  Use the second IDE disk (number 1) if availabl
       if (ide_probe_disk1())
               ide_set_disk(1);
       else
               ide_set_disk(0);
	bc_init();

	// Set "super" to point to the super block.
	super = diskaddr(1);
	check_super();

	// Set "bitmap" to the beginning of the first bitmap block.
	bitmap = diskaddr(2);
	check_bitmap();
}
Esempio n. 6
0
/*
  return terrain height in meters above average sea level (WGS84) for
  a given position

  This is the base function that other height calculations are derived
  from. The functions below are more convenient for most uses
 */
bool AP_Terrain::height_amsl(const Location &loc, float &height)
{
    if (!enable) {
        return false;
    }

    // quick access for home altitude
    if (loc.lat == home_loc.lat &&
        loc.lng == home_loc.lng) {
        height = home_height;
        return true;
    }

    struct grid_info info;

    calculate_grid_info(loc, info);

    // find the grid
    const struct grid_block &grid = find_grid_cache(info).grid;

    /*
      note that we rely on the one square overlap to ensure these
      calculations don't go past the end of the arrays
     */
    ASSERT_RANGE(info.idx_x, 0, TERRAIN_GRID_BLOCK_SIZE_X-2);
    ASSERT_RANGE(info.idx_y, 0, TERRAIN_GRID_BLOCK_SIZE_Y-2);


    // check we have all 4 required heights
    if (!check_bitmap(grid, info.idx_x,   info.idx_y) ||
        !check_bitmap(grid, info.idx_x,   info.idx_y+1) ||
        !check_bitmap(grid, info.idx_x+1, info.idx_y) ||
        !check_bitmap(grid, info.idx_x+1, info.idx_y+1)) {
        return false;
    }

    // hXY are the heights of the 4 surrounding grid points
    int16_t h00, h01, h10, h11;

    h00 = grid.height[info.idx_x+0][info.idx_y+0];
    h01 = grid.height[info.idx_x+0][info.idx_y+1];
    h10 = grid.height[info.idx_x+1][info.idx_y+0];
    h11 = grid.height[info.idx_x+1][info.idx_y+1];

    // do a simple dual linear interpolation. We could do something
    // fancier, but it probably isn't worth it as long as the
    // grid_spacing is kept small enough
    float avg1 = (1.0f-info.frac_x) * h00  + info.frac_x * h10;
    float avg2 = (1.0f-info.frac_x) * h01  + info.frac_x * h11;
    float avg  = (1.0f-info.frac_y) * avg1 + info.frac_y * avg2;

    height = avg;

    if (loc.lat == ahrs.get_home().lat &&
        loc.lng == ahrs.get_home().lng) {
        // remember home altitude as a special case
        home_height = height;
        home_loc = loc;
    }

    return true;
}