cgroup.h revision c2f1db8f83618e60dcded8303d14656d7d26b436
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen#pragma once
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen/***
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen This file is part of systemd.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen Copyright 2010 Lennart Poettering
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen systemd is free software; you can redistribute it and/or modify it
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen under the terms of the GNU Lesser General Public License as published by
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen the Free Software Foundation; either version 2.1 of the License, or
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen (at your option) any later version.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen systemd is distributed in the hope that it will be useful, but
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen WITHOUT ANY WARRANTY; without even the implied warranty of
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen Lesser General Public License for more details.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen You should have received a copy of the GNU Lesser General Public License
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen***/
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersentypedef struct CGroupBonding CGroupBonding;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen#include "unit.h"
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen/* Binds a cgroup to a name */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenstruct CGroupBonding {
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen char *controller;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen char *path;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen Unit *unit;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* For the Unit::cgroup_bondings list */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen LIST_FIELDS(CGroupBonding, by_unit);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* For the Manager::cgroup_bondings hashmap */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen LIST_FIELDS(CGroupBonding, by_path);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* When shutting down, remove cgroup? Are our own tasks the
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen * only ones in this group?*/
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen bool ours:1;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* If we cannot create this group, or add a process to it, is this fatal? */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen bool essential:1;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen /* This cgroup is realized */
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen bool realized:1;
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen};
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_realize(CGroupBonding *b);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_realize_list(CGroupBonding *first);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenvoid cgroup_bonding_free(CGroupBonding *b, bool trim);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenvoid cgroup_bonding_free_list(CGroupBonding *first, bool trim);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_install(CGroupBonding *b, pid_t pid, const char *suffix);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_install_list(CGroupBonding *first, pid_t pid, const char *suffix);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_set_group_access(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_set_group_access_list(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_set_task_access(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid, int sticky);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_set_task_access_list(CGroupBonding *b, mode_t mode, uid_t uid, gid_t gid, int sticky);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_kill(CGroupBonding *b, int sig, bool sigcont, bool rem, Set *s, const char *suffix);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_kill_list(CGroupBonding *first, int sig, bool sigcont, bool rem, Set *s, const char *suffix);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenvoid cgroup_bonding_trim(CGroupBonding *first, bool delete_root);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenvoid cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_is_empty(CGroupBonding *b);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_is_empty_list(CGroupBonding *first);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel AndersenCGroupBonding *cgroup_bonding_find_list(CGroupBonding *first, const char *controller);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenchar *cgroup_bonding_to_string(CGroupBonding *b);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
260ad50f5b4a9795032e3119c64f838a2d03370dThomas Hindoe Paaboel Andersenpid_t cgroup_bonding_search_main_pid(CGroupBonding *b);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenpid_t cgroup_bonding_search_main_pid_list(CGroupBonding *b);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen#include "manager.h"
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint manager_setup_cgroup(Manager *m);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenvoid manager_shutdown_cgroup(Manager *m, bool delete);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersenint cgroup_notify_empty(Manager *m, const char *group);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel AndersenUnit* cgroup_unit_by_pid(Manager *m, pid_t pid);
95ed3294c632f5606327149f10cef1eb34422862Thomas Hindoe Paaboel Andersen