]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: always follow non-trailing symlinks
authorSage Weil <sage@inktank.com>
Sun, 4 Nov 2012 12:34:55 +0000 (04:34 -0800)
committerSage Weil <sage@inktank.com>
Sun, 4 Nov 2012 12:34:55 +0000 (04:34 -0800)
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 <sage@inktank.com>
src/client/Client.cc

index a699122ea6b09b068762cf4a8200b099000256b2..b551a3f1c52e612e47dce03276c2aba6d2ceea85 100644 (file)
@@ -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