libcgroup
Loading...
Searching...
No Matches
2. Group manipulation API

Data Structures

struct  cgroup
 
struct  cgroup_controller
 

Basic infrastructure

struct cgroup* is the heart of libcgroup API. The structure is opaque to applications, all access to the structure is through appropriate functions.

The most important information is that one struct cgroup* can represent zero, one or more real control groups in kernel. The struct cgroup* is identified by name of the group, which must be set by cgroup_new_cgroup(). Multiple controllers (aka subsystems) can be attached to one struct cgroup* using cgroup_add_controller(). These controllers can belong to different hierarchies.

This approach is different to the one in the Linux kernel - a control group must be part of exactly one hierarchy there. In libcgroup, a group can be part of multiple hierarchies, as long as the group name is the same.

Example:
Let there be following control groups:
cpu,cpuacct:/
cpu,cpuacct:/foo
cpu,cpuacct:/bar
freezer:/
freezer:/foo
I.e. there is cpu and cpuacct controller mounted together in one hierarchy, with foo and bar groups. In addition, freezer is mounted as separate hierarchy, with only one foo group.
Following code creates struct cgroup* structure, which represents one group cpu,cpuacct:/foo:
struct cgroup *foo = cgroup_new_cgroup("foo");
struct cgroup_controller * cgroup_add_controller(struct cgroup *cgrp, const char *name)
Definition wrapper.c:61
struct cgroup * cgroup_new_cgroup(const char *name)
Definition wrapper.c:43
Definition libcgroup-internal.h:121
Now, you can call e.g. cgroup_delete_cgroup() and the group is deleted from the hierarchy. You can note that it's enough to add only one controller to the group to fully identify a group in cpu,cpuacct hierarchy.
Following code creates struct cgroup* structure, which represents two groups, cpu,cpuacct:/foo and freezer:/foo:
struct cgroup *foo = cgroup_new_cgroup("foo");
cgroup_add_controller(foo, "freezer");
Now, if you call e.g. cgroup_delete_cgroup(), the group gets deleted from both hierarchies.
Todo
add some propaganda what's so great on this approach... I personally think it is broken and confusing (see TODOs below).

Following functions are provided to create/destroy various libcgroup structures. Please note that none of these functions actually create or delete a cgroup in kernel!

struct cgroupcgroup_new_cgroup (const char *name)
 
struct cgroup_controllercgroup_add_controller (struct cgroup *cgrp, const char *name)
 
int cgroup_add_all_controllers (struct cgroup *cgrp)
 
struct cgroup_controllercgroup_get_controller (struct cgroup *cgrp, const char *name)
 
void cgroup_free (struct cgroup **cgrp)
 
void cgroup_free_controllers (struct cgroup *cgrp)
 
#define NO_PERMS   (-1U)
 
#define NO_UID_GID   (-1U)
 

Group manipulation API

Using following functions you can create and remove control groups and change their parameters.

Note
All access to kernel is through previously mounted cgroup filesystems. libcgroup does not mount/unmount anything for you.
int cgroup_create_cgroup (struct cgroup *cgrp, int ignore_ownership)
 
int cgroup_create_cgroup_from_parent (struct cgroup *cgrp, int ignore_ownership)
 
int cgroup_modify_cgroup (struct cgroup *cgrp)
 
int cgroup_delete_cgroup (struct cgroup *cgrp, int ignore_migration)
 
int cgroup_delete_cgroup_ext (struct cgroup *cgrp, int flags)
 

Other functions

Helper functions to manipulate with control groups.

int cgroup_get_cgroup (struct cgroup *cgrp)
 
int cgroup_copy_cgroup (struct cgroup *dst, struct cgroup *src)
 
int cgroup_compare_cgroup (struct cgroup *cgrp_a, struct cgroup *cgrp_b)
 
int cgroup_compare_controllers (struct cgroup_controller *cgca, struct cgroup_controller *cgcb)
 
int cgroup_set_uid_gid (struct cgroup *cgrp, uid_t tasks_uid, gid_t tasks_gid, uid_t control_uid, gid_t control_gid)
 
int cgroup_get_uid_gid (struct cgroup *cgrp, uid_t *tasks_uid, gid_t *tasks_gid, uid_t *control_uid, gid_t *control_gid)
 
void cgroup_set_permissions (struct cgroup *cgrp, mode_t control_dperm, mode_t control_fperm, mode_t task_fperm)
 

Group parameters

These are functions can read or modify parameter of a group.

Note
All these functions read/write parameters to libcgorup internal structures. Use cgroup_get_cgroup() to load parameters from kernel to these internal structures and cgroup_modify_cgroup() or cgroup_create_cgroup() to write changes to kernel.
int cgroup_add_value_string (struct cgroup_controller *controller, const char *name, const char *value)
 
int cgroup_add_value_int64 (struct cgroup_controller *controller, const char *name, int64_t value)
 
int cgroup_add_value_uint64 (struct cgroup_controller *controller, const char *name, u_int64_t value)
 
int cgroup_add_value_bool (struct cgroup_controller *controller, const char *name, bool value)
 
int cgroup_get_value_string (struct cgroup_controller *controller, const char *name, char **value)
 
int cgroup_get_value_int64 (struct cgroup_controller *controller, const char *name, int64_t *value)
 
int cgroup_get_value_uint64 (struct cgroup_controller *controller, const char *name, u_int64_t *value)
 
int cgroup_get_value_bool (struct cgroup_controller *controller, const char *name, bool *value)
 
int cgroup_set_value_string (struct cgroup_controller *controller, const char *name, const char *value)
 
int cgroup_set_value_int64 (struct cgroup_controller *controller, const char *name, int64_t value)
 
int cgroup_set_value_uint64 (struct cgroup_controller *controller, const char *name, u_int64_t value)
 
int cgroup_set_value_bool (struct cgroup_controller *controller, const char *name, bool value)
 
int cgroup_get_value_name_count (struct cgroup_controller *controller)
 
char * cgroup_get_value_name (struct cgroup_controller *controller, int index)
 
int cgroup_get_procs (const char *name, const char *controller, pid_t **pids, int *size)
 
int cgroup_get_threads (const char *name, const char *controller, pid_t **pids, int *size)
 
int cg_chmod_recursive (struct cgroup *cgrp, mode_t dir_mode, int dirm_change, mode_t file_mode, int filem_change)
 
char * cgroup_get_cgroup_name (struct cgroup *cgrp)
 
int cgroup_convert_cgroup (struct cgroup *const out_cgrp, enum cg_version_t out_version, const struct cgroup *const in_cgrp, enum cg_version_t in_version)
 
int cgroup_list_mount_points (const enum cg_version_t cgrp_version, char ***mount_paths)
 
int cgroup_get_controller_version (const char *const controller, enum cg_version_t *const version)
 
enum cg_setup_mode_t cgroup_setup_mode (void)
 
int cgroup_get_controller_count (struct cgroup *cgrp)
 
struct cgroup_controllercgroup_get_controller_by_index (struct cgroup *cgrp, int index)
 
char * cgroup_get_controller_name (struct cgroup_controller *controller)
 
bool is_cgroup_mode_legacy (void)
 
bool is_cgroup_mode_hybrid (void)
 
bool is_cgroup_mode_unified (void)
 

Detailed Description

Macro Definition Documentation

◆ NO_PERMS

#define NO_PERMS   (-1U)

Uninitialized file/directory permissions used for task/control files.

◆ NO_UID_GID

#define NO_UID_GID   (-1U)

Uninitialized UID/GID used for task/control files.

Function Documentation

◆ cg_chmod_recursive()

int cg_chmod_recursive ( struct cgroup * cgrp,
mode_t dir_mode,
int dirm_change,
mode_t file_mode,
int filem_change )

Change permission of files and directories of given group

Parameters
cgrpThe cgroup which permissions should be changed
dir_modeThe permission mode of group directory
dirm_changeDenotes whether the directory change should be done
file_modeThe permission mode of group files
filem_changeDenotes whether the directory change should be done

◆ cgroup_add_all_controllers()

int cgroup_add_all_controllers ( struct cgroup * cgrp)

Attach all mounted controllers to given cgroup. This function just modifies internal libcgroup structure, not the kernel control group.

Parameters
cgrp
Returns
zero or error number

◆ cgroup_add_controller()

struct cgroup_controller * cgroup_add_controller ( struct cgroup * cgrp,
const char * name )

Attach new controller to cgroup. This function just modifies internal libcgroup structure, not the kernel control group.

Parameters
cgrp
nameThe name of the controller, e.g. "freezer".
Returns
Created controller or NULL on error.

◆ cgroup_add_value_bool()

int cgroup_add_value_bool ( struct cgroup_controller * controller,
const char * name,
bool value )

Add parameter and its value to internal libcgroup structures. Use cgroup_modify_cgroup() or cgroup_create_cgroup() to write it to kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_add_value_int64()

int cgroup_add_value_int64 ( struct cgroup_controller * controller,
const char * name,
int64_t value )

Add parameter and its value to internal libcgroup structures. Use cgroup_modify_cgroup() or cgroup_create_cgroup() to write it to kernel. Content of the value is copied to internal structures and is not needed after return from the function.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_add_value_string()

int cgroup_add_value_string ( struct cgroup_controller * controller,
const char * name,
const char * value )

Add parameter and its value to internal libcgroup structures. Use cgroup_modify_cgroup() or cgroup_create_cgroup() to write it to kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_add_value_uint64()

int cgroup_add_value_uint64 ( struct cgroup_controller * controller,
const char * name,
u_int64_t value )

Add parameter and its value to internal libcgroup structures. Use cgroup_modify_cgroup() or cgroup_create_cgroup() to write it to kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_compare_cgroup()

int cgroup_compare_cgroup ( struct cgroup * cgrp_a,
struct cgroup * cgrp_b )

Compare names, owners, controllers, parameters and values of two groups.

Parameters
cgrp_a
cgrp_b
Return values
0if the groups are the same.
ECGROUPNOTEQUALif the groups are not the same.
ECGCONTROLLERNOTEQUALif the only difference are controllers, parameters or their values.

◆ cgroup_compare_controllers()

int cgroup_compare_controllers ( struct cgroup_controller * cgca,
struct cgroup_controller * cgcb )

Compare names, parameters and values of two controllers.

Parameters
cgca
cgcb
Return values
0if the controllers are the same.
ECGCONTROLLERNOTEQUALif the controllers are not equal.

◆ cgroup_copy_cgroup()

int cgroup_copy_cgroup ( struct cgroup * dst,
struct cgroup * src )

Copy all controllers, their parameters and values. Group name, permissions and ownerships are not copied. All existing controllers in the source group are discarded.

Parameters
dstDestination group.
srcSource group.

@dst: Destination control group @src: Source from which values will be copied to dst

Create a duplicate copy of src in dst. This will be useful for those who that intend to create new instances based on an existing control group

◆ cgroup_create_cgroup()

int cgroup_create_cgroup ( struct cgroup * cgrp,
int ignore_ownership )

Physically create a control group in kernel. The group is created in all hierarchies, which cover controllers added by cgroup_add_controller(). All parameters set by cgroup_add_value_* functions are written. The created groups has owner which was set by cgroup_set_uid_gid() and permissions set by cgroup_set_permissions.

Parameters
cgrp
ignore_ownershipWhen nozero, all errors are ignored when setting owner of the group and/or its tasks file.
Todo
what is ignore_ownership good for?
Return values
ECGROUPNOTEQUALif not all specified controller parameters were successfully set.

cgroup_create_cgroup creates a new control group. struct cgroup *cgrp: The control group to be created

returns 0 on success. We recommend calling cg_delete_cgroup if this routine fails. That should do the cleanup operation. If ECGCANTSETVALUE is returned, the group was created successfully but not all controller parameters were successfully set.

◆ cgroup_create_cgroup_from_parent()

int cgroup_create_cgroup_from_parent ( struct cgroup * cgrp,
int ignore_ownership )

Physically create new control group in kernel, with all parameters and values copied from its parent group. The group is created in all hierarchies, where the parent group exists. I.e. following code creates subgroup in all hierarchies, because all of them have root (=parent) group.

struct cgroup *foo = cgroup_new_cgroup("foo");
int cgroup_create_cgroup_from_parent(struct cgroup *cgrp, int ignore_ownership)
Definition api.c:3321
Todo
what is this good for? Why the list of controllers added by cgroup_add_controller() is not used, like in cgroup_create_cgroup()? I can't create subgroup of root group in just one hierarchy with this function!
Parameters
cgrpThe cgroup to create. Only it's name is used, everything else is discarded.
ignore_ownershipWhen nozero, all errors are ignored when setting owner of the group and/or its tasks file.
Todo
what is ignore_ownership good for?
Return values
ECGROUPNOTEQUALif not all inherited controller parameters were successfully set (this is expected).

@cgrp: cgroup data structure to be filled with parent values and then passed down for creation @ignore_ownership: Ignore doing a chown on the newly created cgroup

Returns
0 on success, > 0 on failure. If ECGCANTSETVALUE is returned, the group was created successfully, but not all controller parameters were copied from the parent successfully; unfortunately, this is expected...

◆ cgroup_delete_cgroup()

int cgroup_delete_cgroup ( struct cgroup * cgrp,
int ignore_migration )

Physically remove a control group from kernel. The group is removed from all hierarchies, which cover controllers added by cgroup_add_controller() or cgroup_get_cgroup(). All tasks inside the group are automatically moved to parent group.

The group being removed must be empty, i.e. without subgroups. Use cgroup_delete_cgroup_ext() for recursive delete.

Parameters
cgrp
ignore_migrationWhen nozero, all errors are ignored when migrating tasks from the group to the parent group.
Todo
what is ignore_migration good for? rmdir() will fail if tasks were not moved.

cgroup_delete cgroup deletes a control group. struct cgroup *cgrp takes the group which is to be deleted.

returns 0 on success.

◆ cgroup_delete_cgroup_ext()

int cgroup_delete_cgroup_ext ( struct cgroup * cgrp,
int flags )

Physically remove a control group from kernel. All tasks are automatically moved to parent group. If CGFLAG_DELETE_IGNORE_MIGRATION flag is used, the errors that occurred during the task movement are ignored. CGFLAG_DELETE_RECURSIVE flag specifies that all subgroups should be removed too. If root group is being removed with this flag specified, all subgroups are removed but the root group itself is left undeleted.

See also
cgroup_delete_flag.
Parameters
cgrp
flagsCombination of CGFLAG_DELETE_* flags, which indicate what and how to delete.

◆ cgroup_free()

void cgroup_free ( struct cgroup ** cgrp)

Free internal cgroup structure. This function frees also all controllers attached to the cgroup, including all parameters and their values.

Parameters
cgrp

◆ cgroup_free_controllers()

void cgroup_free_controllers ( struct cgroup * cgrp)

Free internal list of controllers from the group.

Todo
should this function be public???
Parameters
cgrp

◆ cgroup_get_cgroup()

int cgroup_get_cgroup ( struct cgroup * cgrp)

Read all information regarding the group from kernel. Based on name of the group, list of controllers and all parameters and their values are read from all hierarchies, where a group with given name exists. All existing controllers are replaced. I.e. following code will fill root with controllers from all hierarchies, because the root group is available in all of them.

struct cgroup *root = cgroup_new_cgroup("/");
int cgroup_get_cgroup(struct cgroup *cgrp)
Definition api.c:3855
Todo
what is this function good for? Why is not considered only the list of controllers attached by cgroup_add_controller()? What owners will return cgroup_get_uid_gid() if the group is in multiple hierarchies, each with different owner of tasks file?
Parameters
cgrpThe cgroup to load. Only it's name is used, everything else is replaced.

◆ cgroup_get_cgroup_name()

char * cgroup_get_cgroup_name ( struct cgroup * cgrp)

Get the name of the cgroup from a given cgroup

Parameters
cgrpThe cgroup whose name is needed

◆ cgroup_get_controller()

struct cgroup_controller * cgroup_get_controller ( struct cgroup * cgrp,
const char * name )

Return appropriate controller from given group. The controller must be added before using cgroup_add_controller() or loaded from kernel using cgroup_get_cgroup().

Parameters
cgrp
nameThe name of the controller, e.g. "freezer".

◆ cgroup_get_controller_by_index()

struct cgroup_controller * cgroup_get_controller_by_index ( struct cgroup * cgrp,
int index )

Return requested controller from given group

Parameters
cgrp
indexThe index into the cgroup controller list

◆ cgroup_get_controller_count()

int cgroup_get_controller_count ( struct cgroup * cgrp)

Return the number of controllers for the specified cgroup in libcgroup internal structures.

Parameters
cgrp
Returns
Count of the controllers or -1 on error.

◆ cgroup_get_controller_name()

char * cgroup_get_controller_name ( struct cgroup_controller * controller)

Given a controller pointer, get the name of the controller

Parameters
controller
Returns
controller name string, NULL if there's an error

◆ cgroup_get_controller_version()

int cgroup_get_controller_version ( const char *const controller,
enum cg_version_t *const version )

Get the cgroup version of a controller. Version is set to CGROUP_UNK if the version cannot be determined.

Parameters
controllerThe controller of interest
versionThe version of the controller

◆ cgroup_get_procs()

int cgroup_get_procs ( const char * name,
const char * controller,
pid_t ** pids,
int * size )

Get the list of process in a cgroup. This list is guaranteed to be sorted. It is not necessary that it is unique.

Parameters
nameThe name of the cgroup
controllerThe name of the controller
pidsThe list of pids. Should be uninitialized when passed to the API. Should be freed by the caller using free.
sizeThe size of the pids array returned by the API.

◆ cgroup_get_threads()

int cgroup_get_threads ( const char * name,
const char * controller,
pid_t ** pids,
int * size )

Get the list of threads in a cgroup. This list is guaranteed to be sorted. It is not necessary that it is unique.

Parameters
nameThe name of the cgroup
controllerThe name of the controller
pidsThe list of pids. Should be uninitialized when passed to the API. Should be freed by the caller using free.
sizeThe size of the pids array returned by the API.

◆ cgroup_get_uid_gid()

int cgroup_get_uid_gid ( struct cgroup * cgrp,
uid_t * tasks_uid,
gid_t * tasks_gid,
uid_t * control_uid,
gid_t * control_gid )

Return owners of the group's tasks file and control files. The data is read from libcgroup internal cgroup structure, use cgroup_set_uid_gid() or cgroup_get_cgroup() to fill it.

◆ cgroup_get_value_bool()

int cgroup_get_value_bool ( struct cgroup_controller * controller,
const char * name,
bool * value )

Read a parameter value from libcgroup internal structures. Use cgroup_get_cgroup() to fill these structures with data from kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_get_value_int64()

int cgroup_get_value_int64 ( struct cgroup_controller * controller,
const char * name,
int64_t * value )

Read a parameter value from libcgroup internal structures. Use cgroup_get_cgroup() to fill these structures with data from kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_get_value_name()

char * cgroup_get_value_name ( struct cgroup_controller * controller,
int index )

Return the name of parameter of controller at given index. The index goes from 0 to cgroup_get_value_name_count()-1. Use this function to list all parameter of the controller.

Note
The returned value is pointer to internal libcgroup structure, do not free it.
Parameters
controller
indexThe index of the parameter.
Returns
Name of the parameter.

◆ cgroup_get_value_name_count()

int cgroup_get_value_name_count ( struct cgroup_controller * controller)

Return the number of variables for the specified controller in libcgroup internal structures. Use cgroup_get_cgroup() to fill these structures with data from kernel. Use this function together with cgroup_get_value_name() to list all parameters of a group.

Parameters
controller
Returns
Count of the parameters or -1 on error.

◆ cgroup_get_value_string()

int cgroup_get_value_string ( struct cgroup_controller * controller,
const char * name,
char ** value )

Read a parameter value from libcgroup internal structures. Use cgroup_get_cgroup() to fill these structures with data from kernel. It's up to the caller to free returned value.

This function works only for 'short' parameters. Use cgroup_read_stats_begin(), cgroup_read_stats_next() and cgroup_read_stats_end() to read stats parameter, which can be longer than libcgroup's internal buffers.

Todo
rephrase, it's too vague... How big is the buffer actually?
Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_get_value_uint64()

int cgroup_get_value_uint64 ( struct cgroup_controller * controller,
const char * name,
u_int64_t * value )

Read a parameter value from libcgroup internal structures. Use cgroup_get_cgroup() to fill these structures with data from kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_list_mount_points()

int cgroup_list_mount_points ( const enum cg_version_t cgrp_version,
char *** mount_paths )

List the mount paths, that matches the specified version

Parameters
cgrp_versionThe cgroup type/version
mount_pathsHolds the list of mount paths
Returns
0 success and list of mounts paths in mount_paths ECGOTHER on failure and mount_paths is NULL.

◆ cgroup_modify_cgroup()

int cgroup_modify_cgroup ( struct cgroup * cgrp)

Physically modify a control group in kernel. All parameters added by cgroup_add_value_ or cgroup_set_value_ are written. Currently it's not possible to change and owner of a group.

Parameters
cgrp

cgroup_modify_cgroup modifies the cgroup control files. struct cgroup *cgrp: The name will be the cgroup to be modified. The values will be the values to be modified, those not mentioned in the structure will not be modified.

The uids cannot be modified yet.

returns 0 on success.

◆ cgroup_new_cgroup()

struct cgroup * cgroup_new_cgroup ( const char * name)

Allocate new cgroup structure. This function itself does not create new control group in kernel, only new struct cgroup inside libcgroup!

Parameters
namePath to the group, relative from root group. Use "/" or "." for the root group itself and "/foo/bar/baz" or "foo/bar/baz" for subgroups.
Todo
suggest one preferred way, either "/foo" or "foo".
Returns
Created group or NULL on error.

◆ cgroup_set_permissions()

void cgroup_set_permissions ( struct cgroup * cgrp,
mode_t control_dperm,
mode_t control_fperm,
mode_t task_fperm )

Stores given file permissions of the group's control and tasks files into the cgroup data structure. Use NO_PERMS if permissions shouldn't be changed or a value which applicable to chmod(2). Please note that the given permissions are masked with the file owner's permissions. For example if a control file has permissions 640 and control_fperm is 471 the result will be 460.

Parameters
cgrp
control_dpermDirectory permission for the group.
control_fpermFile permission for the control files.
task_fpermFile permissions for task file.

◆ cgroup_set_uid_gid()

int cgroup_set_uid_gid ( struct cgroup * cgrp,
uid_t tasks_uid,
gid_t tasks_gid,
uid_t control_uid,
gid_t control_gid )

Set owner of the group control files and the tasks file. This function modifies only libcgroup internal cgroup structure, use cgroup_create_cgroup() afterwards to create the group with given owners.

Parameters
cgrp
tasks_uidUID of the owner of group's tasks file.
tasks_gidGID of the owner of group's tasks file.
control_uidUID of the owner of group's control files (i.e. parameters).
control_gidGID of the owner of group's control files (i.e. parameters).

◆ cgroup_set_value_bool()

int cgroup_set_value_bool ( struct cgroup_controller * controller,
const char * name,
bool value )

Set a parameter value in libcgroup internal structures. Use cgroup_modify_cgroup() or cgroup_create_cgroup() to write it to kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_set_value_int64()

int cgroup_set_value_int64 ( struct cgroup_controller * controller,
const char * name,
int64_t value )

Set a parameter value in libcgroup internal structures. Use cgroup_modify_cgroup() or cgroup_create_cgroup() to write it to kernel. Content of the value is copied to internal structures and is not needed after return from the function.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_set_value_string()

int cgroup_set_value_string ( struct cgroup_controller * controller,
const char * name,
const char * value )

Set a parameter value in libcgroup internal structures. Use cgroup_modify_cgroup() or cgroup_create_cgroup() to write it to kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_set_value_uint64()

int cgroup_set_value_uint64 ( struct cgroup_controller * controller,
const char * name,
u_int64_t value )

Set a parameter value in libcgroup internal structures. Use cgroup_modify_cgroup() or cgroup_create_cgroup() to write it to kernel.

Parameters
controller
nameThe name of the parameter.
value

◆ cgroup_setup_mode()

enum cg_setup_mode_t cgroup_setup_mode ( void )

Get the current group setup mode (legacy/unified/hybrid)

Returns
CGROUP_MODE_UNK on failure and setup mode on success

Finds the current cgroup setup mode (legacy/unified/hybrid). Returns unknown of failure and setup mode on success.

◆ is_cgroup_mode_hybrid()

bool is_cgroup_mode_hybrid ( void )

Return true if cgroup setup mode is cgroup v1/v2 (hybrid), else returns false.

◆ is_cgroup_mode_legacy()

bool is_cgroup_mode_legacy ( void )

Return true if cgroup setup mode is cgroup v1 (legacy), else returns false.

◆ is_cgroup_mode_unified()

bool is_cgroup_mode_unified ( void )

Return true if cgroup setup mode is cgroup v2 (unified), else returns false.