From 4b046827b99480e0cfabeaa75e593db13445176e Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 13 Apr 2018 10:28:01 +0530 Subject: fuse: make sure the send lookup on root instead of getattr() This change was done in https://review.gluster.org/16945. While the changes added there were required, it was not necessary to remove the getattr part. As fuse's lookup on root(/) comes as getattr only, this change is very much required. The previous fix for this bug was to add the check for revalidation in lookup when it was sent on root. But I had removed the part where getattr is coming on root. The removing was not requried to fix the issue then. Added back this part of the code, to make sure we have proper validation of root inode in many places like acl, etc. updates: bz#1437780 Change-Id: I859c4ee1a3f407465cbf19f8934530848424ff50 Signed-off-by: Amar Tumballi --- xlators/mount/fuse/src/fuse-bridge.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'xlators') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 322b4deeffa..ed70f82f745 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -968,6 +968,7 @@ fuse_getattr (xlator_t *this, fuse_in_header_t *finh, void *msg, fuse_private_t *priv = NULL; #endif fuse_state_t *state; + int ret = -1; GET_STATE (this, finh, state); #if FUSE_KERNEL_MINOR_VERSION >= 9 @@ -975,6 +976,25 @@ fuse_getattr (xlator_t *this, fuse_in_header_t *finh, void *msg, if (priv->proto_minor >= 9 && fgi->getattr_flags & FUSE_GETATTR_FH) state->fd = fd_ref ((fd_t *)fgi->fh); #endif + if (finh->nodeid == 1) { + state->gfid[15] = 1; + + ret = fuse_loc_fill (&state->loc, state, finh->nodeid, 0, NULL); + if (ret < 0) { + gf_log ("glusterfs-fuse", GF_LOG_WARNING, + "%"PRIu64": GETATTR on / (fuse_loc_fill() failed)", + finh->unique); + send_fuse_err (this, finh, ENOENT); + free_fuse_state (state); + return; + } + + fuse_gfid_set (state); + + FUSE_FOP (state, fuse_root_lookup_cbk, GF_FOP_LOOKUP, + lookup, &state->loc, state->xdata); + return; + } if (state->fd) fuse_resolve_fd_init (state, &state->resolve, state->fd); -- cgit