From 80880eef6d45c401b76b99bebb5566f320effb96 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 4 Nov 2012 04:34:55 -0800 Subject: [PATCH] client: always follow non-trailing symlinks If we are walking /a/b/c and a or b is a symlink, follow it. It's only c that we don't follow when !followsym. Signed-off-by: Sage Weil --- src/client/Client.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index a699122ea6b09..b551a3f1c52e6 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3727,11 +3727,11 @@ int Client::path_walk(const filepath& origpath, Inode **final, bool followsym) int r = _lookup(cur, dname.c_str(), &next); if (r < 0) return r; - if (i == path.depth() - 1 && - followsym && - next && - next->is_symlink()) { - // resolve symlink + // only follow trailing symlink if followsym. always follow + // 'directory' symlinks. + if (next && + next->is_symlink() && + (followsym || i < path.depth() - 1)) { if (next->symlink[0] == '/') { path = next->symlink.c_str(); // reset position -- 2.39.5