lxcpp: provisioning implementation (part 1)
[platform/core/security/vasum.git] / libs / lxcpp / commands / provision.hpp
1 /*
2  *  Copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Lesser General Public
6  *  License version 2.1 as published by the Free Software Foundation.
7  *
8  *  This library is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  *  Lesser General Public License for more details.
12  *
13  *  You should have received a copy of the GNU Lesser General Public
14  *  License along with this library; if not, write to the Free Software
15  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
16  */
17
18 /**
19  * @file
20  * @author  Maciej Karpiuk (m.karpiuk2@samsung.com)
21  * @brief   Add new provisioned file/dir/link/mount command
22  */
23
24 #ifndef LXCPP_COMMAND_PROVISION_HPP
25 #define LXCPP_COMMAND_PROVISION_HPP
26
27 #include "lxcpp/commands/command.hpp"
28 #include "lxcpp/container-config.hpp"
29 #include "lxcpp/provision-config.hpp"
30
31 #include <sys/types.h>
32
33 namespace lxcpp {
34
35 class Provisions final: Command {
36 public:
37    /**
38     * Runs call in the container's context
39     *
40     * Add/remove all file/fifo/dir/mount/link provisions to/from the container
41     */
42     Provisions(ContainerConfig &config) : mConfig(config)
43     {
44     }
45
46     void execute();
47     void revert();
48
49 private:
50     ContainerConfig& mConfig;
51 };
52
53
54 class ProvisionFile final: Command {
55 public:
56    /**
57     * Runs call in the container's context
58     *
59     * Add/remove new file/fifo/dir provision to/from the container
60     */
61     ProvisionFile(ContainerConfig &config, const provision::File &file) :
62         mConfig(config), mFile(file)
63     {
64     }
65
66     void execute();
67     void revert();
68
69 private:
70     ContainerConfig& mConfig;
71     const provision::File& mFile;
72 };
73
74 class ProvisionMount final: Command {
75 public:
76    /**
77     * Runs call in the container's context
78     *
79     * Add/remove new mount provision to/from the container
80     */
81     ProvisionMount(ContainerConfig &config, const provision::Mount &mount) :
82         mConfig(config), mMount(mount)
83     {
84     }
85
86     void execute();
87     void revert();
88
89 private:
90     ContainerConfig& mConfig;
91     const provision::Mount& mMount;
92 };
93
94 class ProvisionLink final: Command {
95 public:
96    /**
97     * Runs call in the container's context
98     *
99     * Add/remove link provision to/from the container
100     */
101     ProvisionLink(ContainerConfig &config, const provision::Link &link) :
102         mConfig(config), mLink(link)
103     {
104     }
105
106     void execute();
107     void revert();
108
109 private:
110     ContainerConfig& mConfig;
111     const provision::Link& mLink;
112 };
113
114 } // namespace lxcpp
115
116 #endif // LXCPP_COMMAND_PROVISION_HPP