gf_dirent_t * ida_dirent_dup(ida_local_t * local, gf_dirent_t * dirent) { gf_dirent_t * copy; int32_t error, len; len = strlen(dirent->d_name); if (len != dirent->d_len) { gf_log(local->xl->name, GF_LOG_WARNING, "Invalid d_len in dirent"); } copy = gf_dirent_for_name(dirent->d_name); if (unlikely(copy == NULL)) { return NULL; } memset(copy, 0, sizeof(gf_dirent_t)); INIT_LIST_HEAD(©->list); copy->d_ino = dirent->d_ino; copy->d_off = dirent->d_off; copy->d_len = len; copy->d_type = dirent->d_type; error = ida_iatt_assign(local, ©->d_stat, &dirent->d_stat); if (likely(error == 0)) { if (dirent->inode != NULL) { error = ida_inode_assign(local, ©->inode, dirent->inode); } } if (likely(error == 0)) { if (dirent->dict != NULL) { error = ida_dict_assign(local, ©->dict, dirent->dict); } } if (unlikely(error != 0)) { ida_dirent_wipe(copy); return NULL; } return copy; }
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; }