Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
GamepadPlugin.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 2020 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 GAMEPADPLUGIN_H
21 #define GAMEPADPLUGIN_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 
37 {
38 public:
39  GamepadPlugin(std::shared_ptr<rt_dobby_schema> &containerConfig,
40  const std::shared_ptr<DobbyRdkPluginUtils> &utils,
41  const std::string &rootfsPath);
42 
43 public:
44  inline std::string name() const override
45  {
46  return mName;
47  };
48 
49  unsigned hookHints() const override;
50 
51 public:
52  bool postInstallation() override;
53 
54 public:
55  std::vector<std::string> getDependencies() const override;
56 
57 private:
58  void addDevices(int64_t major, int64_t minor, int numDevices, const std::string& type, const std::string& mode) const;
59  void addGidMapping(gid_t host_id, gid_t container_id) const;
60  void addAdditionalGid(gid_t gid) const;
61  gid_t getInputGroupId() const;
62 
63  const std::string mName;
64  std::shared_ptr<rt_dobby_schema> mContainerConfig;
65  const std::shared_ptr<DobbyRdkPluginUtils> mUtils;
66 };
67 
68 #endif // !defined(GAMEPADPLUGIN_H)
Dobby Gamepad plugin.
Definition: GamepadPlugin.h:37
gid_t getInputGroupId() const
Finds input group id in /etc/group file.
Definition: GamepadPlugin.cpp:182
void addGidMapping(gid_t host_id, gid_t container_id) const
Adds gid mapping to container_config->linux->gid_mappings.
Definition: GamepadPlugin.cpp:143
void addDevices(int64_t major, int64_t minor, int numDevices, const std::string &type, const std::string &mode) const
Adds devices to containe_config->linux->resources->devices.
Definition: GamepadPlugin.cpp:109
std::string name() const override
Should return the name of the plugin.
Definition: GamepadPlugin.h:44
unsigned hookHints() const override
Should return a bitfield of the hook points implemented by the plugin.
Definition: GamepadPlugin.cpp:38
bool postInstallation() override
Dobby Hook - run in host namespace once when container bundle is downloaded.
Definition: GamepadPlugin.cpp:48
std::vector< std::string > getDependencies() const override
Should return the names of the plugins this plugin depends on.
Definition: GamepadPlugin.cpp:81
void addAdditionalGid(gid_t gid) const
Adds additionalGid to container_config->process->user->additional_gids.
Definition: GamepadPlugin.cpp:165
Basic object that provides the default overrides for a plugin.
Definition: RdkPluginBase.h:34