Implement shutdown/start function in server, client and cli
[platform/core/security/vasum.git] / server / zone-provision.hpp
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Mateusz Malicki <m.malicki2@samsung.com>
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  */
18
19 /**
20  * @file
21  * @author  Mateusz Malicki (m.malicki2@samsung.com)
22  * @brief   Declaration of the class for managing zone provision
23  */
24
25
26 #ifndef SERVER_ZONE_PROVISION_HPP
27 #define SERVER_ZONE_PROVISION_HPP
28
29 #include "zone-provision-config.hpp"
30
31 #include <string>
32 #include <vector>
33
34 namespace vasum {
35
36
37 /**
38  * Class is responsible for prepare filesystem for zone
39  * It allows to create directories, files, mount points and copying files from host
40  */
41 class ZoneProvision {
42
43 public:
44     /**
45      * ZoneProvision constructor
46      * @param zonesPath directory where zones are defined (lxc configs, rootfs etc)
47      */
48     ZoneProvision(const std::string& zonePath,
49                   const std::vector<std::string>& validLinkPrefixes);
50
51     /**
52      * Declare file, directory or pipe that will be created while zone startup
53      */
54     void declareFile(const int32_t& type,
55                      const std::string& path,
56                      const int32_t& flags,
57                      const int32_t& mode);
58     /**
59      * Declare mount that will be created while zone startup
60      */
61     void declareMount(const std::string& source,
62                       const std::string& target,
63                       const std::string& type,
64                       const int64_t& flags,
65                       const std::string& data);
66     /**
67      * Declare link that will be created while zone startup
68      */
69     void declareLink(const std::string& source,
70                      const std::string& target);
71
72    /**
73      * Get zone root path
74      */
75     std::string getRootPath() const;
76
77     void start() noexcept;
78     void stop() noexcept;
79
80 private:
81     ZoneProvisioning mProvisioningConfig;
82     std::string mRootPath;
83     std::string mProvisionFile;
84     std::vector<std::string> mValidLinkPrefixes;
85
86     void mount(const ZoneProvisioning::Mount& config);
87     void umount(const ZoneProvisioning::Mount& config);
88     void file(const ZoneProvisioning::File& config);
89     void link(const ZoneProvisioning::Link& config);
90 };
91
92
93 } // namespace vasum
94
95 #endif // SERVER_ZONE_PROVISION_HPP