You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/03/26 00:34:32 UTC

[1/3] mesos git commit: Added FTS_PHYSICAL option to fts_open for rmdir.

Repository: mesos
Updated Branches:
  refs/heads/master 3927ba77a -> 2309ae913


Added FTS_PHYSICAL option to fts_open for rmdir.

According to the documentation for fts_open, either FTS_PHYSICAL or
FTS_LOGICAL SHOULD be provided. We need FTS_PHYSICAL for the case of
rmdir as we dont want to resolve the symlink targets while deleting
them.

Review: https://reviews.apache.org/r/45002/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d3252933
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d3252933
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d3252933

Branch: refs/heads/master
Commit: d3252933d57a570b5238535f4c3a198f04e0e093
Parents: 3927ba7
Author: Jojy Varghese <jo...@mesosphere.io>
Authored: Fri Mar 25 16:33:43 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Mar 25 16:33:43 2016 -0700

----------------------------------------------------------------------
 .../stout/include/stout/os/posix/rmdir.hpp      |  4 +-
 .../3rdparty/stout/tests/os/rmdir_tests.cpp     | 46 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d3252933/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp
index cbc9759..b7b4bd3 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp
@@ -47,7 +47,9 @@ inline Try<Nothing> rmdir(const std::string& directory, bool recursive = true)
 
     char* paths[] = {const_cast<char*>(directory.c_str()), NULL};
 
-    FTS* tree = fts_open(paths, FTS_NOCHDIR, NULL);
+    // Using `FTS_PHYSICAL` here because we need `FTSENT` for the
+    // symbolic link in the directory and not the target it links to.
+    FTS* tree = fts_open(paths, (FTS_NOCHDIR | FTS_PHYSICAL), NULL);
     if (tree == NULL) {
       return ErrnoError();
     }

http://git-wip-us.apache.org/repos/asf/mesos/blob/d3252933/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
index 5bd154e..922a392 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
@@ -229,3 +229,49 @@ TEST_F(RmdirTest, RemoveDirectoryWithNoTargetSymbolicLink)
 
   EXPECT_SOME(os::rmdir(newDirectory));
 }
+
+
+// This test verifies that `rmdir` will only remove the symbolic link and not
+// the target directory.
+TEST_F(RmdirTest, RemoveDirectoryWithSymbolicLinkTargetDirectory)
+{
+  const string newDirectory = path::join(os::getcwd(), "newDirectory");
+  ASSERT_SOME(os::mkdir(newDirectory));
+
+  const string link = path::join(newDirectory, "link");
+
+  const string targetDirectory = path::join(os::getcwd(), "targetDirectory");
+
+  ASSERT_SOME(os::mkdir(targetDirectory));
+
+  // Create a symlink that targets a directory outside the 'newDirectory'.
+  ASSERT_SOME(fs::symlink(targetDirectory, link));
+
+  EXPECT_SOME(os::rmdir(newDirectory));
+
+  // Verify that the target directory is not removed.
+  ASSERT_TRUE(os::exists(targetDirectory));
+}
+
+
+// This test verifies that `rmdir` will only remove the symbolic link and not
+// the target file.
+TEST_F(RmdirTest, RemoveDirectoryWithSymbolicLinkTargetFile)
+{
+  const string newDirectory = path::join(os::getcwd(), "newDirectory");
+  ASSERT_SOME(os::mkdir(newDirectory));
+
+  const string link = path::join(newDirectory, "link");
+
+  const string targetFile = path::join(os::getcwd(), "targetFile");
+
+  ASSERT_SOME(os::touch(targetFile));
+
+  // Create a symlink that targets a file outside the 'newDirectory'.
+  ASSERT_SOME(fs::symlink(targetFile, link));
+
+  EXPECT_SOME(os::rmdir(newDirectory));
+
+  // Verify that the target file is not removed.
+  ASSERT_TRUE(os::exists(targetFile));
+}


[2/3] mesos git commit: Fixed rmdir comment for FTS_SLNONE as per coding guidelines.

Posted by ji...@apache.org.
Fixed rmdir comment for FTS_SLNONE as per coding guidelines.

Review: https://reviews.apache.org/r/45003/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ffe147f1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ffe147f1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ffe147f1

Branch: refs/heads/master
Commit: ffe147f1d49a19573e385e7e77fa38305074754a
Parents: d325293
Author: Jojy Varghese <jo...@mesosphere.io>
Authored: Fri Mar 25 16:34:03 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Mar 25 16:34:03 2016 -0700

----------------------------------------------------------------------
 .../libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ffe147f1/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp
index b7b4bd3..44a59b8 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/rmdir.hpp
@@ -69,8 +69,8 @@ inline Try<Nothing> rmdir(const std::string& directory, bool recursive = true)
         case FTS_DEFAULT:
         case FTS_F:
         case FTS_SL:
-        // `FTS_SLNONE` should never be the case as we dont set
-        // FTS_COMFOLLOW. Adding here for completion.
+        // `FTS_SLNONE` should never be the case as we don't set
+        // `FTS_COMFOLLOW` or `FTS_LOGICAL`. Adding here for completion.
         case FTS_SLNONE:
           if (::unlink(node->fts_path) < 0 && errno != ENOENT) {
             Error error = ErrnoError();


[3/3] mesos git commit: Fixed newlines for include directives.

Posted by ji...@apache.org.
Fixed newlines for include directives.

Review: https://reviews.apache.org/r/45010/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2309ae91
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2309ae91
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2309ae91

Branch: refs/heads/master
Commit: 2309ae913c163cf117d859db9f7e33c58e7c0442
Parents: ffe147f
Author: Jojy Varghese <jo...@mesosphere.io>
Authored: Fri Mar 25 16:34:23 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Mar 25 16:34:23 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2309ae91/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
index 922a392..5466991 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os/rmdir_tests.cpp
@@ -16,10 +16,8 @@
 #include <string>
 
 #include <stout/fs.hpp>
-
-#include <stout/path.hpp>
-
 #include <stout/os.hpp>
+#include <stout/path.hpp>
 
 #include <stout/os/getcwd.hpp>
 #include <stout/os/ls.hpp>