示例#1
0
int
dfs_open(const char *path,
         struct fuse_file_info *info)
{
        pentry_t *pe = NULL;
        int fd = -1;
        int ret = -1;
        enum state_mode mode;

        info->fh = 0;
        LOG(LOG_DEBUG, "path=%s %s 0%o",
            path, flags_to_str(info->flags), info->flags);

        pe = g_hash_table_lookup(hash, path);
        if (! pe) {
                LOG(LOG_INFO, "'%s': entry not found in hashtable", path);
                if (-1 == populate_hash(hash, path, &pe)) {
                        ret = -1;
                        goto err;
                }
                LOG(LOG_INFO, "adding file '%s' to the hashtable", path);
        } else {
                fd = pentry_get_fd(pe);
                if (FILE_LOCAL == pentry_get_placeholder(pe))
                        LOG(LOG_INFO, "%s: found in the hashtable, and the "
                            "file is on disk (fd=%d)", path, fd);
                else
                        LOG(LOG_INFO, "%s: found in hashtable, but the file "
                            "isn't downloaded (fd=%d)", path, fd);
        }

        info->fh = (uint64_t)pe;
        pentry_inc_refcount(pe);

        mode = get_mode_from_flags(info->flags);

        if (MODE_RDONLY != mode) {
                if (pentry_lock(pe)) {
                        ret = -1;
                        pentry_dec_refcount(pe);
                        goto err;
                }
        }

        info->fh = (uint64_t)pe;
        LOG(LOG_DEBUG, "path=%s, MODE=%d", path, mode);

        int (*fn[])(const char *, pentry_t *, int) = {
                [MODE_RDONLY] = open_rdonly,
                [MODE_WRONLY] = open_wronly,
                [MODE_RDWR]   = open_rdwr,
                [MODE_CREAT]  = open_creat,
        };
示例#2
0
    void display(VerbosityLevel lvl = VERBOSE_LEVEL_1) const
    {
        w_yel_lf("-> Elf_Phdr64:"); 
        std::cout << "    " << type_to_str(p_type) << " " << flags_to_str(p_flags) << std::endl;

        if(lvl > VERBOSE_LEVEL_1)
        {
            display_short_hex_2fields_lf(p_vaddr, p_filesz);
        }

        if(lvl > VERBOSE_LEVEL_2)
        {
            display_short_hex_2fields_lf(p_align, p_flags);
        }

        display_short_hex_2fields_lf(p_offset, p_paddr);
    }
示例#3
0
int
dfs_create(const char *path,
           mode_t mode,
           struct fuse_file_info *info)
{
        tfs_ctx *ctx = fuse_get_context()->private_data;
        int ret = -1;
        dpl_status_t rc = DPL_FAILURE;
        tpath_entry *pe = NULL;
        struct stat st;
        dpl_dict_t *usermd = NULL;
        int exclude;

        LOG(LOG_DEBUG, "%s, mode=0x%x, %s",
            path, (unsigned)mode, flags_to_str(info->flags));

        if (! S_ISREG(mode)) {
                LOG(LOG_ERR, "%s: not a regular file", path);
                ret = -1;
                goto err;
        }

        exclude = re_matcher(&ctx->conf->regex, path);

        if (-1 == dfs_open(path, info)) {
                ret = -1;
                goto err;
        }

        pe = (tpath_entry *) info->fh;
        if (! pe) {
                ret = -1;
                goto err;
        }

        pe->exclude = exclude;

        if (-1 == pe->fd) {
                ret = -1;
                goto err;
        }

        if (-1 == fchmod(pe->fd, mode)) {
                LOG(LOG_ERR, "fchmod(fd=%d): %s", pe->fd, strerror(errno));
                ret = -errno;
                goto err;
        }

        if (-1 == fstat(pe->fd, &st)) {
                LOG(LOG_ERR, "fstat(fd=%d): %s", pe->fd, strerror(errno));
                ret = -errno;
                goto err;
        }

        usermd = pe->usermd;
        if (! usermd) {
                usermd = dpl_dict_new(13);
                if (! usermd) {
                        LOG(LOG_ERR, "allocation failure");
                        ret = -1;
                        goto err;
                }
        }

        fill_metadata_from_stat(usermd, &st);

        assign_meta_to_dict(usermd, "scal_mode", (unsigned long) mode);

        pentry_md_lock(pe);
        pentry_set_usermd(pe, usermd);
        pentry_md_unlock(pe);

        if (! exclude) {
                rc = dfs_mknod_timeout(ctx, path);
                if (DPL_SUCCESS != rc) {
                        LOG(LOG_ERR, "dfs_mknod_timeout: %s", dpl_status_str(rc));
                        ret = -1;
                        goto err;
                }
        }

        ret = 0;
  err:
        if (usermd)
                dpl_dict_free(usermd);

        LOG(LOG_DEBUG, "path=%s ret=%s", path, dpl_status_str(ret));
        return ret;

}
示例#4
0
std::ostringstream& action_state_t::debug_str( std::ostringstream& s )
{
    s << std::showbase;
    std::streamsize ss = s.precision();

    s << action -> player -> name() << " " << action -> name() << " " << target -> name() << ":";

    s << std::hex;

    s << " snapshot_flags=";
    if ( action -> snapshot_flags > 0 )
    {
        s << "{ " << flags_to_str( action -> snapshot_flags ) << " }";;
    }
    else
    {
        s << action -> snapshot_flags;
    }
    s << " update_flags=";
    if ( action -> update_flags > 0 )
    {
        s << "{ " << flags_to_str( action -> update_flags ) << " }";
    }
    else
    {
        s << action -> update_flags;
    }

    s << " result=" << util::result_type_string( result );
    s << " type=" << util::amount_type_string( result_type );

    s << " proc_type=" << util::proc_type_string( proc_type() );
    s << " exec_proc_type=" << util::proc_type2_string( execute_proc_type2() );
    s << " impact_proc_type=" << util::proc_type2_string( impact_proc_type2() );

    s << std::dec;

    s << " n_targets=" << n_targets;
    s << " chain_target=" << chain_target;
    s << " original_x=" << original_x;
    s << " original_y=" << original_y;

    s << " raw_amount=" << result_raw;
    s << " total_amount=" << result_total;
    s << " mitigated_amount=" << result_mitigated;
    s << " absorbed_amount=" << result_absorbed;
    s << " actual_amount=" << result_amount;
    s << " only_blocked_damage=" << blocked_amount;
    s << " self_absorbed_damage=" << self_absorb_amount;
    s << " ap=" << attack_power;
    s << " sp=" << spell_power;

    s.precision( 4 );

    s << " haste=" << haste;
    s << " crit=" << crit;
    s << " tgt_crit=" << target_crit;
    s << " versatility=" << versatility;
    s << " da_mul=" << da_multiplier;
    s << " ta_mul=" << ta_multiplier;
    s << " per_mul=" << persistent_multiplier;
    s << " tgt_da_mul=" << target_da_multiplier;
    s << " tgt_ta_mul=" << target_ta_multiplier;
    s << " resolve=" << resolve;

    s << " tgt_mitg_da_mul=" << target_mitigation_da_multiplier;
    s << " tgt_mitg_ta_mul=" << target_mitigation_ta_multiplier;
    s << " target_armor=" << target_armor;

    s.precision( ss );

    return s;
}