static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, struct nameidata *nd) { int err; struct fuse_entry_out outarg; struct inode *inode = NULL; struct dentry *newent; struct fuse_conn *fc = get_fuse_conn(dir); struct fuse_req *req; struct fuse_req *forget_req;
if (entry->d_name.len > FUSE_NAME_MAX) return ERR_PTR(-ENAMETOOLONG);
req = fuse_get_req(fc); if (IS_ERR(req)) return ERR_PTR(PTR_ERR(req));
forget_req = fuse_get_req(fc); if (IS_ERR(forget_req)) { fuse_put_request(fc, req); return ERR_PTR(PTR_ERR(forget_req)); }
fuse_lookup_init(req, dir, entry, &outarg); request_send(fc, req); err = req->out.h.error; fuse_put_request(fc, req); /* Zero nodeid is same as -ENOENT, but with valid timeout */ if (!err && outarg.nodeid && (invalid_nodeid(outarg.nodeid) || !fuse_valid_type(outarg.attr.mode))) err = -EIO; if (!err && outarg.nodeid) { inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, &outarg.attr); if (!inode) { fuse_send_forget(fc, forget_req, outarg.nodeid, 1); return ERR_PTR(-ENOMEM); } } fuse_put_request(fc, forget_req); if (err && err != -ENOENT) return ERR_PTR(err);
if (inode && S_ISDIR(inode->i_mode)) { mutex_lock(&fc->inst_mutex); newent = fuse_d_add_directory(entry, inode); mutex_unlock(&fc->inst_mutex); if (IS_ERR(newent)) { iput(inode); return newent; } } else newent = d_splice_alias(inode, entry);
entry = newent ? newent : entry; entry->d_op = &fuse_dentry_operations; if (!err) fuse_change_timeout(entry, &outarg); else fuse_invalidate_entry_cache(entry); return newent; }
|