]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Fix state of symlink with absolute path
authorSam Lang <sam.lang@inktank.com>
Fri, 2 Nov 2012 01:12:34 +0000 (20:12 -0500)
committerSam Lang <sam.lang@inktank.com>
Fri, 2 Nov 2012 01:17:00 +0000 (20:17 -0500)
Symlinks that have an absolute path are not getting
properly dereferenced in path_walk() due to a bug
with the cur and next inode pointers, and because
the path position wasn't getting reset on the symlink
dereference.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/client/Client.cc

index 7ba8a992b594e3cd31be541e4db3556913ac18d4..92e794f168f4339915d4f98518caf0972fc0b172 100644 (file)
@@ -3729,9 +3729,11 @@ int Client::path_walk(const filepath& origpath, Inode **final, bool followsym)
     if (i == path.depth() - 1 && followsym &&
        next && next->is_symlink()) {
       // resolve symlink
-      if (cur->symlink[0] == '/') {
+      if (next->symlink[0] == '/') {
        path = next->symlink.c_str();
        next = root;
+       // reset position - will get incremented to 0
+       i = -1;
       } else {
        filepath more(next->symlink.c_str());
        // we need to remove the symlink component from off of the path
@@ -3956,7 +3958,7 @@ int Client::readlink(const char *relpath, char *buf, loff_t size)
 
   filepath path(relpath);
   Inode *in;
-  int r = path_walk(path, &in);
+  int r = path_walk(path, &in, false);
   if (r < 0)
     return r;