Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
DeviceMapper.h
1 /*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2021 Sky UK
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19 
20 #ifndef DEVICEMAPPER_H
21 #define DEVICEMAPPER_H
22 
23 #include <RdkPluginBase.h>
24 
25 #include <sys/types.h>
26 #include <netinet/in.h>
27 
28 #include <unistd.h>
29 #include <string>
30 #include <memory>
31 
33 {
34 public:
35  DeviceMapperPlugin(std::shared_ptr<rt_dobby_schema>& containerConfig,
36  const std::shared_ptr<DobbyRdkPluginUtils> &utils,
37  const std::string &rootfsPath);
38 
39 public:
40  inline std::string name() const override
41  {
42  return mName;
43  };
44  unsigned hookHints() const override;
45 
46 public:
47 
48  bool preCreation() override;
49 
50 public:
51  std::vector<std::string> getDependencies() const override;
52 
53 private:
54  struct DevNode
55  {
56  std::string path;
57  int64_t major;
58  int64_t minor;
59  int64_t configMajor;
60  int64_t configMinor;
61  mode_t mode;
62  };
63 
64  bool getDevNodeFromPath(const std::string& path, DevNode& node);
65 
66 private:
67  const std::string mName;
68  std::shared_ptr<rt_dobby_schema> mContainerConfig;
69  const std::string mRootfsPath;
70  const std::shared_ptr<DobbyRdkPluginUtils> mUtils;
71  bool mValid;
72 };
73 
74 #endif // !defined(DEVICEMAPPER_H)
75 
Definition: DeviceMapper.h:33
unsigned hookHints() const override
Set the bit flags for which hooks we're going to use.
Definition: DeviceMapper.cpp:57
std::string name() const override
Should return the name of the plugin.
Definition: DeviceMapper.h:40
bool preCreation() override
Dobby Hook - run in host namespace before container creation process.
Definition: DeviceMapper.cpp:65
bool getDevNodeFromPath(const std::string &path, DevNode &node)
Gets the actual details about the device node (major/minor ids) at a given path.
Definition: DeviceMapper.cpp:210
std::vector< std::string > getDependencies() const override
Should return the names of the plugins this plugin depends on.
Definition: DeviceMapper.cpp:239
Basic object that provides the default overrides for a plugin.
Definition: RdkPluginBase.h:34
Definition: DeviceMapper.h:55