Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
subsystem.hpp
Go to the documentation of this file.
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 
24 #ifndef LXCPP_CGROUPS_SUBSYSTEM_HPP
25 #define LXCPP_CGROUPS_SUBSYSTEM_HPP
26 
27 #include <sys/types.h>
28 
29 #include <string>
30 #include <vector>
31 
32 namespace lxcpp {
33 
34 class Subsystem {
35 public:
39  Subsystem(const std::string& name);
40 
41  const std::string& getName() const
42  {
43  return mName;
44  }
45 
50  bool isAvailable() const;
51 
56  bool isAttached() const;
57 
62  const std::string& getMountPoint() const;
63 
69  static void attach(const std::string& path, const std::vector<std::string>& subs);
70 
75  static void detach(const std::string& path);
76 
81  static std::vector<std::string> availableSubsystems();
82 
88  static std::vector<std::string> getCGroups(pid_t pid);
89 
90 private:
91  std::string mName;
92  std::string mPath;
93 };
94 
95 } //namespace lxcpp
96 
97 #endif // LXCPP_CGROUPS_SUBSYSTEM_HPP
static void attach(const std::string &path, const std::vector< std::string > &subs)
Attach subsystem hierarchy to filesystem Equivalent of: mount -t cgroup -o subs(coma-sep) cgroup path...
Definition: subsystem.cpp:99
static std::vector< std::string > availableSubsystems()
Get list of available subsytems.
Definition: subsystem.cpp:121
const std::string & getMountPoint() const
Get mount point of this subsystem.
Definition: subsystem.cpp:89
Definition: subsystem.hpp:34
Subsystem(const std::string &name)
Define subsystem object.
Definition: subsystem.cpp:40
static void detach(const std::string &path)
Detach subsstem hierarchy from filesystem Equivalent of: umount path.
Definition: subsystem.cpp:114
std::string mName
Definition: subsystem.hpp:91
bool isAvailable() const
Check if named subsystem is supported by the kernel.
Definition: subsystem.cpp:73
static std::vector< std::string > getCGroups(pid_t pid)
Get control groups list for a process (in format subsys_name:cgroup_name) eg.
Definition: subsystem.cpp:144
bool isAttached() const
Check if named subsystem is mounted (added to hierarchy)
Definition: subsystem.cpp:84
std::string mPath
Definition: subsystem.hpp:92
const std::string & getName() const
Definition: subsystem.hpp:41