static int fuse_resolve_loc_touchup (fuse_state_t *state) { fuse_resolve_t *resolve = NULL; loc_t *loc = NULL; char *path = NULL; int ret = 0; resolve = state->resolve_now; loc = state->loc_now; if (!loc->path) { if (loc->parent && resolve->bname) { ret = inode_path (loc->parent, resolve->bname, &path); uuid_copy (loc->pargfid, loc->parent->gfid); loc->name = resolve->bname; } else if (loc->inode) { ret = inode_path (loc->inode, NULL, &path); uuid_copy (loc->gfid, loc->inode->gfid); } if (ret) gf_log (THIS->name, GF_LOG_TRACE, "return value inode_path %d", ret); loc->path = path; } return 0; }
int nfs_inode_loc_fill (inode_t *inode, loc_t *loc, int how) { char *resolvedpath = NULL; inode_t *parent = NULL; int ret = -EFAULT; if ((!inode) || (!loc)) return ret; /* If gfid is not null, then the inode is already linked to * the inode table, and not a newly created one. For newly * created inode, inode_path returns null gfid as the path. */ if (!gf_uuid_is_null (inode->gfid)) { ret = inode_path (inode, NULL, &resolvedpath); if (ret < 0) { gf_msg (GF_NFS, GF_LOG_ERROR, 0, NFS_MSG_PATH_RESOLVE_FAIL, "path resolution " "failed %s", resolvedpath); goto err; } } if (resolvedpath == NULL) { char tmp_path[GFID_STR_PFX_LEN + 1] = {0,}; snprintf (tmp_path, sizeof (tmp_path), "<gfid:%s>", uuid_utoa (loc->gfid)); resolvedpath = gf_strdup (tmp_path); } else { parent = inode_parent (inode, loc->pargfid, NULL); } ret = nfs_loc_fill (loc, inode, parent, resolvedpath); if (ret < 0) { gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_LOC_FILL_RESOLVE_FAIL, "loc fill resolution failed %s", resolvedpath); goto err; } ret = 0; err: if (parent) inode_unref (parent); GF_FREE (resolvedpath); return ret; }
static int resolve_loc_touchup (call_frame_t *frame) { server_state_t *state = NULL; server_resolve_t *resolve = NULL; loc_t *loc = NULL; char *path = NULL; int ret = 0; state = CALL_STATE (frame); resolve = state->resolve_now; loc = state->loc_now; if (!loc->path) { if (loc->parent && resolve->bname) { ret = inode_path (loc->parent, resolve->bname, &path); } else if (loc->inode) { ret = inode_path (loc->inode, NULL, &path); } if (!path) path = gf_strdup (resolve->path); loc->path = path; } loc->name = strrchr (loc->path, '/'); if (loc->name) loc->name++; if (!loc->parent && loc->inode) { loc->parent = inode_parent (loc->inode, 0, NULL); } return 0; }
int32_t ida_fd_to_loc(ida_local_t * local, loc_t * loc, fd_t * fd) { int32_t error; error = inode_path(fd->inode, NULL, (char **)&loc->path); if (unlikely(error < 0)) { return -error; } loc->name = strrchr(loc->path, '/'); if (loc->name != NULL) { loc->name++; } error = ida_inode_assign(local, &loc->inode, fd->inode); if (unlikely(error != 0)) { goto failed; } if (!uuid_is_null(loc->inode->gfid)) { uuid_copy(loc->gfid, loc->inode->gfid); } loc->parent = inode_parent(loc->inode, 0, NULL); if (loc->parent != NULL) { if (!uuid_is_null(loc->parent->gfid)) { uuid_copy(loc->pargfid, loc->parent->gfid); } } return 0; failed: GF_FREE((char *)loc->path); return ENOMEM; }
int nfs_parent_inode_loc_fill (inode_t *parent, inode_t *entryinode, char *entry, loc_t *loc) { int ret = -EFAULT; char *path = NULL; if ((!parent) || (!entry) || (!loc) || (!entryinode)) return ret; ret = inode_path (parent, entry, &path); if (ret < 0) { gf_msg (GF_NFS, GF_LOG_ERROR, -ret, NFS_MSG_PATH_RESOLVE_FAIL, "path resolution failed %s", path); goto err; } ret = nfs_loc_fill (loc, entryinode, parent, path); GF_FREE (path); err: return ret; }