Beispiel #1
0
int GIGAgetattr(const char *path, struct stat *statbuf)
{
    logMessage(LOG_TRACE, __func__,
               " ==> getattr(path=[%s], statbuf=0x%08x) ", path, statbuf);

    int ret = 0;
    char fpath[MAX_LEN] = {0};
    char dir[MAX_LEN] = {0};
    char file[MAX_LEN] = {0};
    int dir_id = 0;
   
    switch (giga_options_t.backend_type) {
        case BACKEND_LOCAL_FS: 
            get_full_path(fpath, path);
            ret = local_getattr(fpath, statbuf);
            ret = FUSE_ERROR(ret);
            break;
        case BACKEND_RPC_LEVELDB:
            parse_path_components(path, dir, file);
            //TODO: convert "dir" to "dir_id"
            ret = rpc_getattr(dir_id, file, statbuf);
            ret = FUSE_ERROR(ret);
            break;
        default:
            break;
    }

    return ret;
}
Beispiel #2
0
int GIGAmkdir(const char *path, mode_t mode)
{
    logMessage(LOG_TRACE, __func__, 
               " ==> mkdir(path=[%s], mode=[0%3o])", path, mode);

    int ret = 0;
    char fpath[MAX_LEN] = {0};
    char dir[MAX_LEN] = {0};
    char file[MAX_LEN] = {0};
    int dir_id = 0;

    switch (giga_options_t.backend_type) {
        case BACKEND_LOCAL_FS:
            get_full_path(fpath, path);
            ret = local_mkdir(fpath, mode);
            ret = FUSE_ERROR(ret);
            break;
        case BACKEND_RPC_LEVELDB:
            parse_path_components(path, dir, file);
            ret = rpc_mkdir(dir_id, path, mode);
            ret = FUSE_ERROR(ret);
            break;
        default:
            break;
    }

    return ret;
}
Beispiel #3
0
bool parse_url(const std::string url,
               parsed_url_type& parsed_url,
               bool parse_path,
               bool parse_query)
{
    if (!(parsed_url.path.empty() && parsed_url.path_components.empty())) {
        // Already parsed
        return true;
    }

    http_parser_url p;
    if (::http_parser_parse_url(url.c_str(), url.length(), false, &p)) return false;

    if (p.field_set & (1 << ::UF_SCHEMA)) {
        parsed_url.schema.assign(url.begin() + p.field_data[UF_SCHEMA].off,
                                 url.begin() + p.field_data[UF_SCHEMA].off
                                     + p.field_data[UF_SCHEMA].len);
    }
    if (p.field_set & (1 << ::UF_HOST)) {
        parsed_url.host.assign(url.begin() + p.field_data[UF_HOST].off,
                               url.begin() + p.field_data[UF_HOST].off + p.field_data[UF_HOST].len);
    }
    if (p.field_set & (1 << ::UF_PORT)) {
        parsed_url.port = p.port;
    }
    if (p.field_set & (1 << ::UF_PATH)) {
        parsed_url.path.assign(url.begin() + p.field_data[UF_PATH].off,
                               url.begin() + p.field_data[UF_PATH].off + p.field_data[UF_PATH].len);
        if (parse_path && !parse_path_components(parsed_url.path, parsed_url.path_components))
            return false;
    }
    if (p.field_set & (1 << ::UF_QUERY)) {
        parsed_url.query.assign(url.begin() + p.field_data[UF_QUERY].off,
                                url.begin() + p.field_data[UF_QUERY].off
                                    + p.field_data[UF_QUERY].len);
        if (parse_query && !parse_query_string(parsed_url.query, parsed_url.query_params))
            return false;
    }
    if (p.field_set & (1 << ::UF_FRAGMENT)) {
        parsed_url.fragment.assign(url.begin() + p.field_data[UF_FRAGMENT].off,
                                   url.begin() + p.field_data[UF_FRAGMENT].off
                                       + p.field_data[UF_FRAGMENT].len);
    }
    if (p.field_set & (1 << ::UF_USERINFO)) {
        parsed_url.userinfo.assign(url.begin() + p.field_data[UF_USERINFO].off,
                                   url.begin() + p.field_data[UF_USERINFO].off
                                       + p.field_data[UF_USERINFO].len);
    }
    return true;
}