Apache Mesos
rootfs.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __TEST_ROOTFS_HPP__
18 #define __TEST_ROOTFS_HPP__
19 
20 #ifndef __linux__
21 #error "tests/containerizer/rootfs.hpp is only available on Linux systems"
22 #endif
23 
24 #include <string>
25 
26 #include <process/owned.hpp>
27 
28 #include <stout/nothing.hpp>
29 #include <stout/try.hpp>
30 
31 namespace mesos {
32 namespace internal {
33 namespace tests {
34 
35 class Rootfs {
36 public:
37  virtual ~Rootfs();
38 
39  // Add a host path to the root filesystem. If the given
40  // host path is a symlink, both the link target and the
41  // link itself will be copied into the root.
42  Try<Nothing> add(const std::string& path);
43 
44  const std::string root;
45 
46 protected:
47  Rootfs(const std::string& _root) : root(_root) {}
48 
49 private:
50  Try<Nothing> copyPath(
51  const std::string& source,
52  const std::string& destination);
53 };
54 
55 
56 class LinuxRootfs : public Rootfs
57 {
58 public:
59  static Try<process::Owned<Rootfs>> create(const std::string& root);
60 
61 protected:
62  LinuxRootfs(const std::string& root) : Rootfs(root) {}
63 };
64 
65 } // namespace tests {
66 } // namespace internal {
67 } // namespace mesos {
68 
69 #endif // __TEST_ROOTFS_HPP__
Definition: rootfs.hpp:35
Definition: path.hpp:26
Definition: rootfs.hpp:56
Definition: check.hpp:33
Rootfs(const std::string &_root)
Definition: rootfs.hpp:47
Try< Nothing > add(const std::string &path)
LinuxRootfs(const std::string &root)
Definition: rootfs.hpp:62
Definition: spec.hpp:26
Definition: attributes.hpp:24
const std::string root
Definition: rootfs.hpp:44
Try< Nothing > create(const std::string &hierarchy, const std::string &cgroup, bool recursive=false)