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