File: empty_cgroup_v2.c

package info (click to toggle)
libcgroup 3.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,764 kB
  • sloc: ansic: 14,997; cpp: 9,957; python: 8,340; sh: 5,194; yacc: 470; makefile: 400; lex: 38
file content (40 lines) | stat: -rw-r--r-- 759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-License-Identifier: LGPL-2.1-only
/**
 * Simple program to add empty cgroup v2
 *
 * Copyright (c) 2022 Oracle and/or its affiliates.
 * Author: Kamalesh babulal <kamalesh.baulal@oracle.com>
 */

#include <libcgroup.h>

#include <stdlib.h>
#include <stdio.h>

#define CGRP_NAME "empty_cgrp"

int main(int argc, char **argv)
{
	struct cgroup *cgroup = NULL;
	int ret = 0;

	ret = cgroup_init();
	if (ret) {
		fprintf(stderr, "cgroup_init failed\n");
		exit(1);
	}

	cgroup = cgroup_new_cgroup(CGRP_NAME);
	if (!cgroup) {
		fprintf(stderr, "Failed to allocate cgroup %s\n", CGRP_NAME);
		exit(1);
	}

	ret = cgroup_create_cgroup(cgroup, 0);
	if (ret)
		fprintf(stderr, "Failed to create cgroup %s\n", CGRP_NAME);

	cgroup_free(&cgroup);

	return ret;
}