From 60e54d6764989d880ea05191b8489d617013ffb8 Mon Sep 17 00:00:00 2001 From: Sam Lang Date: Mon, 5 Nov 2012 15:45:28 -0600 Subject: [PATCH] client: Fix path_walk() to support dir symlinks Additions to Sage's commits that replace the path walked so far with the symlinked directory path, rather than the remainder of the path to walk. This allows the dir symlink tests to succeed. Signed-off-by: Sam Lang --- src/client/Client.cc | 41 ++++++++++++++++++++++++++--------------- src/vstart.sh | 2 +- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index b551a3f1c52e6..f259182977941 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3729,23 +3729,34 @@ int Client::path_walk(const filepath& origpath, Inode **final, bool followsym) return r; // 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 - cur = root; + if (next && next->is_symlink()) { + if (i < path.depth() - 1) { + // dir symlink + // replace consumed components of path with symlink dir target + filepath resolved(next->symlink.c_str()); + resolved.append(path.postfixpath(i)); + path = resolved; i = 0; - } else { - filepath more(next->symlink.c_str()); - // we need to remove the symlink component from off of the path - // before adding the target that the symlink points to. remain - // at the same position in the path. - path.pop_dentry(); - path.append(more); + if (next->symlink[0] == '/') { + cur = root; + } + continue; + } else if (followsym) { + if (next->symlink[0] == '/') { + path = next->symlink.c_str(); + i = 0; + // reset position + cur = root; + } else { + filepath more(next->symlink.c_str()); + // we need to remove the symlink component from off of the path + // before adding the target that the symlink points to. remain + // at the same position in the path. + path.pop_dentry(); + path.append(more); + } + continue; } - continue; } cur = next; i++; diff --git a/src/vstart.sh b/src/vstart.sh index ce125bf8cabe0..0b24e4448ab82 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -219,7 +219,7 @@ fi test -d dev/osd0/. && test -e dev/sudo && SUDO="sudo" if [ "$start_all" -eq 1 ]; then - $SUDO ./init-ceph stop + $SUDO $CEPH_BIN/init-ceph stop fi $SUDO rm -f core* -- 2.39.5