You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by tn...@apache.org on 2015/11/07 00:49:21 UTC
mesos git commit: Fixed Rootfs in tests to handle symlink directories.
Repository: mesos
Updated Branches:
refs/heads/master 39c385650 -> d3a2bdc96
Fixed Rootfs in tests to handle symlink directories.
Review: https://reviews.apache.org/r/40002
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d3a2bdc9
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d3a2bdc9
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d3a2bdc9
Branch: refs/heads/master
Commit: d3a2bdc963891e1c48079de6493dcf2069d57292
Parents: 39c3856
Author: Timothy Chen <tn...@apache.org>
Authored: Fri Nov 6 15:33:59 2015 -0800
Committer: Timothy Chen <tn...@apache.org>
Committed: Fri Nov 6 15:34:00 2015 -0800
----------------------------------------------------------------------
src/tests/containerizer/rootfs.hpp | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d3a2bdc9/src/tests/containerizer/rootfs.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/rootfs.hpp b/src/tests/containerizer/rootfs.hpp
index 2d3dbc4..edd0105 100644
--- a/src/tests/containerizer/rootfs.hpp
+++ b/src/tests/containerizer/rootfs.hpp
@@ -56,26 +56,27 @@ public:
return Error("Not an absolute path");
}
- // TODO(jieyu): Make sure 'path' is not under 'root'.
-
- if (os::stat::isdir(path)) {
- if (os::system("cp -r '" + path + "' '" + root + "'") != 0) {
- return ErrnoError("Failed to copy '" + path + "' to rootfs");
- }
- } else if (os::stat::isfile(path)) {
- std::string dirname = Path(path).dirname();
- std::string target = path::join(root, dirname);
+ std::string dirname = Path(path).dirname();
+ std::string target = path::join(root, dirname);
+ if (!os::exists(target)) {
Try<Nothing> mkdir = os::mkdir(target);
if (mkdir.isError()) {
- return Error("Failed to create directory in rootfs: " + mkdir.error());
+ return Error("Failed to create directory in rootfs: " +
+ mkdir.error());
}
+ }
- if (os::system("cp '" + path + "' '" + target + "'") != 0) {
+ // TODO(jieyu): Make sure 'path' is not under 'root'.
+
+ if (os::stat::isdir(path)) {
+ if (os::system("cp -r '" + path + "' '" + target + "'") != 0) {
return ErrnoError("Failed to copy '" + path + "' to rootfs");
}
} else {
- return Error("Unsupported file or directory");
+ if (os::system("cp '" + path + "' '" + target + "'") != 0) {
+ return ErrnoError("Failed to copy '" + path + "' to rootfs");
+ }
}
return Nothing();
@@ -125,6 +126,14 @@ public:
return Error("Failed to add '" + realpath.get() +
"' to rootfs: " + result.error());
}
+
+ if (os::stat::islink(directory)) {
+ result = rootfs->add(directory);
+ if (result.isError()) {
+ return Error("Failed to add '" + directory + "' to rootfs: " +
+ result.error());
+ }
+ }
}
directories = {