chiark / gitweb /
main: jointly mount more controllers
[elogind.git] / src / core / cgroup.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2010 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 typedef struct CGroupBonding CGroupBonding;
25
26 #include "unit.h"
27
28 /* Binds a cgroup to a name */
29 struct CGroupBonding {
30         char *controller;
31         char *path;
32
33         Unit *unit;
34
35         /* For the Unit::cgroup_bondings list */
36         LIST_FIELDS(CGroupBonding, by_unit);
37
38         /* For the Manager::cgroup_bondings hashmap */
39         LIST_FIELDS(CGroupBonding, by_path);
40
41         /* When shutting down, remove cgroup? Are our own tasks the
42          * only ones in this group?*/
43         bool ours:1;
44
45         /* If we cannot create this group, or add a process to it, is this fatal? */
46         bool essential:1;
47
48         /* This cgroup is realized */
49         bool realized:1;
50 };
51
52 int cgroup_bonding_realize(CGroupBonding *b);
53 int cgroup_bonding_realize_list(CGroupBonding *first);
54
55 void cgroup_bonding_free(CGroupBonding *b, bool trim);
56 void cgroup_bonding_free_list(CGroupBonding *first, bool trim);
57
58 int cgroup_bonding_install(CGroupBonding *b, pid_t pid, const char *suffix);
59 int cgroup_bonding_install_list(CGroupBonding *first, pid_t pid, const char *suffix);
60
61 int cgroup_bonding_set_group_access(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid);
62 int cgroup_bonding_set_group_access_list(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid);
63
64 int cgroup_bonding_set_task_access(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid, int sticky);
65 int cgroup_bonding_set_task_access_list(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid, int sticky);
66
67 int cgroup_bonding_kill(CGroupBonding *b, int sig, bool sigcont, bool rem, Set *s, const char *suffix);
68 int cgroup_bonding_kill_list(CGroupBonding *first, int sig, bool sigcont, bool rem, Set *s, const char *suffix);
69
70 void cgroup_bonding_trim(CGroupBonding *first, bool delete_root);
71 void cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root);
72
73 int cgroup_bonding_is_empty(CGroupBonding *b);
74 int cgroup_bonding_is_empty_list(CGroupBonding *first);
75
76 CGroupBonding *cgroup_bonding_find_list(CGroupBonding *first, const char *controller);
77
78 char *cgroup_bonding_to_string(CGroupBonding *b);
79
80 pid_t cgroup_bonding_search_main_pid(CGroupBonding *b);
81 pid_t cgroup_bonding_search_main_pid_list(CGroupBonding *b);
82
83 #include "manager.h"
84
85 int manager_setup_cgroup(Manager *m);
86 void manager_shutdown_cgroup(Manager *m, bool delete);
87
88 int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding);
89 int cgroup_notify_empty(Manager *m, const char *group);
90
91 Unit* cgroup_unit_by_pid(Manager *m, pid_t pid);