Exemple #1
0
int attr_cache_add(struct file_stat *st)
{
    assert(st->ino != 0);
    struct file_stat *old = attr_cache_lookup(st->ino);
    if (old){
        /*if (st->parent_ino == FS_VROOT_INO) //split 后的*/
            

        old->size = st->size;
        old->mode = st->mode;
        old->pos_arr[0] = st ->pos_arr[0];
        old->pos_arr[1] = st ->pos_arr[1];
        old->name = strdup(st->name);
        old->version = cluster_get_current_version();
        log_file_stat("attr_cache update instead insert !", old);
    }else{
        assert(st->parent_ino != 0);
        st->version = cluster_get_current_version();
        hashtable_insert(attr_ht, &(st->ino), st);
        log_file_stat("attr_cache_ inserted: ", st);
    }


    return 0;
}
Exemple #2
0
int git_attr_cache__get(
	git_attr_file **out,
	git_repository *repo,
	git_attr_session *attr_session,
	git_attr_file_source source,
	const char *base,
	const char *filename,
	git_attr_file_parser parser)
{
	int error = 0;
	git_attr_cache *cache = git_repository_attr_cache(repo);
	git_attr_file_entry *entry = NULL;
	git_attr_file *file = NULL, *updated = NULL;

	if ((error = attr_cache_lookup(
			&file, &entry, repo, attr_session, source, base, filename)) < 0)
		return error;

	/* load file if we don't have one or if existing one is out of date */
	if (!file || (error = git_attr_file__out_of_date(repo, attr_session, file)) > 0)
		error = git_attr_file__load(&updated, repo, attr_session, entry, source, parser);

	/* if we loaded the file, insert into and/or update cache */
	if (updated) {
		if ((error = attr_cache_upsert(cache, updated)) < 0)
			git_attr_file__free(updated);
		else {
			git_attr_file__free(file); /* offset incref from lookup */
			file = updated;
		}
	}

	/* if file could not be loaded */
	if (error < 0) {
		/* remove existing entry */
		if (file) {
			attr_cache_remove(cache, file);
			git_attr_file__free(file); /* offset incref from lookup */
			file = NULL;
		}
		/* no error if file simply doesn't exist */
		if (error == GIT_ENOTFOUND) {
			giterr_clear();
			error = 0;
		}
	}

	*out = file;
	return error;
}
Exemple #3
0
static int corefs_getattr(const char *path, struct stat *stbuf)
{
    int res;

    // if we're not caching attributes or cache fails do the syscall.
    if ((! g_msp->cache_attr) || (! attr_cache_lookup(path, stbuf))) {
      res = mop.getattr(path, stbuf);
      if(res < 0)
        return res;
      if (g_msp->cache_attr) attr_cache_store(path, stbuf);
    }

    if (g_msp->spoof_uids) stbuf->st_uid=getuid();
    if (g_msp->spoof_gids) stbuf->st_gid=getgid();
    if (g_msp->spoof_perms) {
      stbuf->st_mode &= 0770000; // preserve directory, symlink, etc bits
      stbuf->st_mode |= g_msp->spoof_permbits; // add back in user bits
    }
    return 0;
}