Example #1
0
ssize_t write_meta_data(fs_context& fs)
{
    /*
     * Copy erase block usage info and the content of the inode map
     * into one continuous buffer so that we can initiate one
     * cluster-aligned write request into the first erase block.
     */

    size_t eb_usage_size = fs.neraseblocks * sizeof(eraseblock);
    memcpy(fs.buf, fs.eb_usage.data(), eb_usage_size);

    size_t ino_map_size = fs.nino * sizeof(uint32_t);
    memcpy(fs.buf + eb_usage_size, fs.ino_map.data(), ino_map_size);

    size_t meta_data_size = eb_usage_size + ino_map_size;
    uint64_t offset = fs.clustersize;

    ssize_t rc = write_raw(*fs.io_ctx, fs.buf, meta_data_size, offset);
    if (rc < 0)
    {
        log().error("writing meta data to first erase block failed");
        return rc;
    }
    debug_update(fs, debug_metric::write_raw, static_cast<uint64_t>(rc));
    return rc;
}
Example #2
0
static bool read_super(fs_context& fs)
{
    superblock sb;
    ssize_t rc = read_raw(*fs.io_ctx, &sb, sizeof(superblock), 0);
    if (rc < 0)
    {
        log().critical("reading super block failed");
        return false;
    }
    debug_update(fs, debug_metric::read_raw, static_cast<uint64_t>(rc));

    // The super block is only read once and its content is saved
    // inside the ffsp structure.
    fs.fsid = get_be32(sb.s_fsid);
    fs.flags = get_be32(sb.s_flags);
    fs.neraseblocks = get_be32(sb.s_neraseblocks);
    fs.nino = get_be32(sb.s_nino);
    fs.blocksize = get_be32(sb.s_blocksize);
    fs.clustersize = get_be32(sb.s_clustersize);
    fs.erasesize = get_be32(sb.s_erasesize);
    fs.ninoopen = get_be32(sb.s_ninoopen);
    fs.neraseopen = get_be32(sb.s_neraseopen);
    fs.nerasereserve = get_be32(sb.s_nerasereserve);
    fs.nerasewrites = get_be32(sb.s_nerasewrites);
    return true;
}
Example #3
0
static bool read_ino_map(fs_context& fs)
{
    fs.ino_map.resize(fs.nino);

    // size of the array holding the cluster ids in bytes
    uint64_t size = fs.nino * sizeof(uint32_t);
    uint64_t offset = fs.erasesize - size;

    ssize_t rc = read_raw(*fs.io_ctx, fs.ino_map.data(), size, offset);
    if (rc < 0)
    {
        log().critical("reading cluster ids failed");
        return false;
    }
    debug_update(fs, debug_metric::read_raw, static_cast<uint64_t>(rc));
    return true;
}
Example #4
0
static bool read_eb_usage(fs_context& fs)
{
    fs.eb_usage.resize(fs.neraseblocks);

    // size of all erase block meta information in bytes
    uint64_t size = fs.neraseblocks * sizeof(eraseblock);
    uint64_t offset = fs.clustersize;

    ssize_t rc = read_raw(*fs.io_ctx, fs.eb_usage.data(), size, offset);
    if (rc < 0)
    {
        log().critical("reading erase block info failed");
        return false;
    }
    debug_update(fs, debug_metric::read_raw, static_cast<uint64_t>(rc));
    return true;
}
Example #5
0
// call this regularly in loop()
void ServoEaser::update()
{
    if( ((millis() - lastMillis) < frameMillis) || !running ) {  // time yet?
        return;
    }
    lastMillis = millis();

    currPos = easingFunc( tick, startPos, changePos, tickCount );
    
    debug_update();

    if( !arrived ) tick++;
    if( tick == tickCount ) { // time for new position
        getNextPos(); 
    }
    float p = (flipped) ? 180.0 - currPos : currPos;
    if( useMicros ) {
        servo.writeMicroseconds( angleToMicros(p) );
    } else {
        servo.write( p );
    }
}
Example #6
0
//loop
//Executed each seconds
void loop() {
	//We update vriables that changes on each step
	loop_update();
	#ifdef DEBUG_ACTIVE
	debug_update();
	#endif

	#ifdef BREAK_NET
	if(game.isNetBroken()) {
		game.breakNet();
	}
	#endif

	//Depending on the time we call phase1 or phase2
	if(seconds < 90) {
	phase1_loop();
	} else {
	phase2_loop();
	}

	//Self-explanatory
	++seconds;
}