You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by id...@apache.org on 2015/03/11 01:24:50 UTC
[08/10] mesos git commit: Add os::mknod() wrapper.
Add os::mknod() wrapper.
Review: https://reviews.apache.org/r/31441
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b37c1ba5
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b37c1ba5
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b37c1ba5
Branch: refs/heads/master
Commit: b37c1ba55a977cbc19bf1e2d9e418cb6a8d16169
Parents: 7d82bb7
Author: Ian Downes <id...@twitter.com>
Authored: Wed Feb 25 11:17:24 2015 -0800
Committer: Ian Downes <id...@twitter.com>
Committed: Tue Mar 10 17:18:25 2015 -0700
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/os.hpp | 13 ++++++++++++
.../3rdparty/stout/tests/os_tests.cpp | 22 ++++++++++++++++++++
2 files changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b37c1ba5/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index d95db43..02db3c5 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -585,6 +585,19 @@ inline Try<Nothing> chroot(const std::string& directory)
}
+inline Try<Nothing> mknod(
+ const std::string& path,
+ mode_t mode,
+ dev_t dev)
+{
+ if (::mknod(path.c_str(), mode, dev) < 0) {
+ return ErrnoError();
+ }
+
+ return Nothing();
+}
+
+
inline Result<uid_t> getuid(const Option<std::string>& user = None())
{
if (user.isNone()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/b37c1ba5/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
index 8a2d445..08bcfa9 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
@@ -898,3 +898,25 @@ TEST_F(OsTest, Libraries)
os::libraries::setPaths(originalLibraryPath);
EXPECT_EQ(os::libraries::paths(), originalLibraryPath);
}
+
+
+TEST_F(OsTest, Mknod)
+{
+ const string& device = "null";
+
+ const string& existing = path::join("/dev", device);
+ CHECK(os::exists(existing));
+
+ Try<mode_t> mode = os::stat::mode(existing);
+ CHECK_SOME(mode);
+
+ Try<dev_t> rdev = os::stat::rdev(existing);
+ CHECK_SOME(rdev);
+
+ const string& another = path::join(os::getcwd(), device);
+ CHECK(!os::exists(another));
+
+ EXPECT_SOME(os::mknod(another, mode.get(), rdev.get()));
+
+ EXPECT_SOME(os::rm(another));
+}