]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
3 years agotests: Update to the latest commit on libcgroup-tests release-2.0 77/head
Tom Hromatka [Wed, 8 Dec 2021 19:49:11 +0000 (12:49 -0700)] 
tests: Update to the latest commit on libcgroup-tests release-2.0

Reported-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoautomake: idiomatically mark test libraries as convenience libraries
Ross Burton [Fri, 3 Dec 2021 15:38:27 +0000 (08:38 -0700)] 
automake: idiomatically mark test libraries as convenience libraries

Instead of installing then deleting, mark the libraries which are only
used at build time and should not be installed as noinst, so they don't
get installed at all.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 1932bd3c46fc5f3532d6583ccc2ccd4c8d8530a2)

3 years agogithub: Run test 028 last
Tom Hromatka [Fri, 12 Nov 2021 18:32:03 +0000 (18:32 +0000)] 
github: Run test 028 last

A merge conflict moved the running of test 028 before
running `make check`.  Run test 028-cgclear-basic_cgclear.py
last because it is destructive to the cgroup hierarchy.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoautomake: Don't install testing libraries
Tom Hromatka [Fri, 12 Nov 2021 13:56:37 +0000 (06:56 -0700)] 
automake: Don't install testing libraries

libcgset and libcgfortesting are libraries that are used by the
unit test framework and are not intended to be installed when
`make install` is invoked.  Delete them from the install path.

Closes: https://github.com/libcgroup/libcgroup/issues/62
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 6c941e8b26fbd6613c96ed65e08290aa21ff33de)

3 years agoautomake: Link libcgset with libcgroup
Tom Hromatka [Fri, 12 Nov 2021 13:52:51 +0000 (06:52 -0700)] 
automake: Link libcgset with libcgroup

When linking with the -Wl,--no-undefined flag enabled, libcgset
fails due to undefined symbols.  Fix this by enabling this flag
and linking with libcgroup.la

Closes: https://github.com/libcgroup/libcgroup/issues/66
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit b4015e3f96fc430029a37e94edc151e16727e8f1)

3 years agoREADME: fix typos across the file
Kamalesh Babulal [Mon, 1 Nov 2021 20:28:59 +0000 (14:28 -0600)] 
README: fix typos across the file

Fix a couple of typos across the file.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit c171be33bce722d92566c78c3b5fefa8ac2a3d92)

3 years agocgclassify: fix error message
Kamalesh Babulal [Mon, 1 Nov 2021 20:28:42 +0000 (14:28 -0600)] 
cgclassify: fix error message

Fix the typo in the error message, while trying to parse the cgroup to
place the task.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ef2299a3edaadcfbb70bf741deea0ee4a3d510a4)

3 years agogithub: re-arrange workflow run commands
Kamalesh Babulal [Thu, 21 Oct 2021 21:25:55 +0000 (15:25 -0600)] 
github: re-arrange workflow run commands

The current workflow executes the functional tests from the make check
called at the top-level source directory. Though this runs the tests
case, it also has an unintended side effect of re-running gunit tests
for every functional test combination in the workflow. Fix it, by
re-arranging the function test run commands, to change into
tests/ftests directory before executing make check.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 348f50bed7bfab1a63a649b4a65120fb03a7d3c2)

3 years agoconfigure.ac: check for the library containing fts_open
Ross Burton [Fri, 10 Sep 2021 17:42:20 +0000 (11:42 -0600)] 
configure.ac: check for the library containing fts_open

The musl C library doesn't provide fts.h[1], so libcgroup doesn't
compile with musl. However, there is a standalone implementation of fts
for musl users[2] which can be used.

Use AC_SEARCH_LIBS to search for fts_open, which will check if it is part
of libc, and if not look in libfts, then set LIBS if needed.

[1] https://wiki.musl-libc.org/faq.html
[2] https://github.com/void-linux/musl-fts

Closes #61.

Signed-off-by: Ross Burton <ross.burton@arm.com>
[TJH: minor formatting changes to match existing configure.ac]
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 27ba904355575153308bdc0fa48344ef1be55ca1)

4 years agoMerge pull request #55 from drakenclimber/pull/46
Tom Hromatka [Tue, 6 Jul 2021 18:53:52 +0000 (12:53 -0600)] 
Merge pull request #55 from drakenclimber/pull/46

Replace __BEGIN_DECLS and __END_DECLS with extern "C".

4 years agoReplace __BEGIN_DECLS and __END_DECLS with extern "C". 55/head
Anthony G. Basile [Tue, 6 Jul 2021 18:42:54 +0000 (12:42 -0600)] 
Replace __BEGIN_DECLS and __END_DECLS with extern "C".

The macros __BEGIN_DECLS and __END_DECLS are a GNU-ism found in
glibc and uClibc, but not musl.  We replace them by the more general
extern "C" { ... } block exposed only if we have __cplusplus.

Forward ported from a patch by Anthony G. Basile <blueness@gentoo.org>.

Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 215974e67a24edf9097507e8707190b6a42c7207)

4 years agogithub: Run apt update before apt install
Tom Hromatka [Tue, 1 Jun 2021 18:25:10 +0000 (12:25 -0600)] 
github: Run apt update before apt install

Run apt update before apt install

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agobootstrap: Use release-2.0 branch
Tom Hromatka [Mon, 17 May 2021 13:11:50 +0000 (13:11 +0000)] 
bootstrap: Use release-2.0 branch

Checkout the libcgroup-tests release-2.0 branch.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoautomake: replace CPPFLAGS by AM_CPPFLAGS
Tomasz Kłoczko [Wed, 12 May 2021 20:36:17 +0000 (20:36 +0000)] 
automake: replace CPPFLAGS by AM_CPPFLAGS

To not interfere with env $CPPFLAGS it is better to use AM_CPPFLAGS

Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoautomake: build PAM module as unversioned DSO
Tomasz Kłoczko [Wed, 12 May 2021 20:36:02 +0000 (20:36 +0000)] 
automake: build PAM module as unversioned DSO

PAM modules should be build as unversioned DSO.
Add -avoid-version to pam_cgroup_la_LDFLAGS

Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoautomake: replace INCLUDES by CPPFLAGS
Tomasz Kłoczko [Wed, 12 May 2021 20:35:40 +0000 (20:35 +0000)] 
automake: replace INCLUDES by CPPFLAGS

automake shows warnings like below:

src/Makefile.am:16: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/Makefile.am: installing 'build-aux/depcomp'
src/bindings/Makefile.am:2: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/daemon/Makefile.am:3: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/pam/Makefile.am:1: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/tools/Makefile.am:3: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoUpdate version number to 2.0 v2.0
Tom Hromatka [Thu, 6 May 2021 14:14:30 +0000 (14:14 +0000)] 
Update version number to 2.0

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #42 from drakenclimber/issues/update-map
Tom Hromatka [Mon, 3 May 2021 21:15:50 +0000 (15:15 -0600)] 
Merge pull request #42 from drakenclimber/issues/update-map

libcgroup.map: Update version number

4 years agolibcgroup.map: Update version number 42/head
Tom Hromatka [Mon, 3 May 2021 21:02:04 +0000 (15:02 -0600)] 
libcgroup.map: Update version number

Update the version number for the most recent exported
functions.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #41 from drakenclimber/issues/fix-warnings
Tom Hromatka [Fri, 30 Apr 2021 13:47:10 +0000 (07:47 -0600)] 
Merge pull request #41 from drakenclimber/issues/fix-warnings

Fix warnings

4 years agoparse.y: Fix nonterminal %type warnings 41/head
Tom Hromatka [Tue, 27 Apr 2021 19:24:41 +0000 (19:24 +0000)] 
parse.y: Fix nonterminal %type warnings

Fix the following warnings in parse.y:

../parse.y:48.14-15: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
   48 | %type <name> ID DEFAULT group_name
      |              ^~
../parse.y:48.17-23: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
   48 | %type <name> ID DEFAULT group_name
      |                 ^~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agolscgroup: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 17:08:38 +0000 (17:08 +0000)] 
lscgroup: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncat’,
    inlined from ‘print_cgroup’ at lscgroup.c:149:4:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:136:10: warning: ‘__builtin___strncat_chk’ output
may be truncated copying between 0 and 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agolscgroup: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 17:07:31 +0000 (17:07 +0000)] 
lscgroup: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘display_controller_data’ at lscgroup.c:104:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agolscgroup: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 17:06:26 +0000 (17:06 +0000)] 
lscgroup: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘display_controller_data’ at lscgroup.c:99:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agolssubsys: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 17:04:21 +0000 (17:04 +0000)] 
lssubsys: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘print_all_controllers_in_hierarchy’ at lssubsys.c:131:4,
    inlined from ‘cgroup_list_all_controllers’ at lssubsys.c:225:9,
    inlined from ‘main’ at lssubsys.c:293:8:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agolssubsys: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 17:03:18 +0000 (17:03 +0000)] 
lssubsys: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘print_all_controllers_in_hierarchy’ at lssubsys.c:127:4,
    inlined from ‘cgroup_list_all_controllers’ at lssubsys.c:223:9,
    inlined from ‘main’ at lssubsys.c:291:8:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agolssubsys: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:58:12 +0000 (16:58 +0000)] 
lssubsys: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncat’,
    inlined from ‘print_all_controllers_in_hierarchy’ at lssubsys.c:134:4,
    inlined from ‘cgroup_list_all_controllers’ at lssubsys.c:222:9,
    inlined from ‘main’ at lssubsys.c:290:8:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:136:10: warning: ‘__builtin___strncat_chk’ output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgget: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:53:44 +0000 (16:53 +0000)] 
cgget: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncat’,
    inlined from ‘fill_empty_controller’ at cgget.c:584:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:136:10: warning: ‘__builtin___strncat_chk’ output may be truncated copying between 0 and 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agotools: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:50:53 +0000 (16:50 +0000)] 
tools: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘parse_cgroup_spec’ at ../tools/tools-common.c:92:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoconfig.c: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:48:33 +0000 (16:48 +0000)] 
config.c: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘cgroup_config_create_template_group’ at config.c:1850:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoconfig.c: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:46:24 +0000 (16:46 +0000)] 
config.c: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘cgroup_config_create_template_group’ at config.c:1844:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoconfig.c: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:42:41 +0000 (16:42 +0000)] 
config.c: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘cgroup_config_create_template_group’ at config.c:1841:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:40:39 +0000 (16:40 +0000)] 
api.c: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncat’,
    inlined from ‘cgroup_get_cgroup’ at api.c:3153:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:136:10: warning: ‘__builtin___strncat_chk’ output may be truncated copying between 0 and 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:35:46 +0000 (16:35 +0000)] 
api.c: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘cgroup_parse_rules_file’ at api.c:814:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:32:10 +0000 (16:32 +0000)] 
api.c: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘cgroup_parse_rules_file’ at api.c:798:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin___strncpy_chk’ output may be truncated copying between 0 and 255 bytes from a string of length 255 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Fix strncpy() truncation warning
Tom Hromatka [Tue, 27 Apr 2021 16:30:21 +0000 (16:30 +0000)] 
api.c: Fix strncpy() truncation warning

Fix the following strncpy() string truncation warning:

In function ‘strncpy’,
    inlined from ‘cgroup_parse_rules_file’ at api.c:676:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin___strncpy_chk’ output may be truncated copying between 0 and 255 bytes from a string of length 4352 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agodoc: Update github release process
Tom Hromatka [Mon, 26 Apr 2021 22:06:01 +0000 (22:06 +0000)] 
doc: Update github release process

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoUpdate version number to 2.0.rc1 v2.0.rc1
Tom Hromatka [Mon, 26 Apr 2021 21:16:26 +0000 (21:16 +0000)] 
Update version number to 2.0.rc1

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #40 from drakenclimber/issues/38
Tom Hromatka [Mon, 19 Apr 2021 14:43:21 +0000 (08:43 -0600)] 
Merge pull request #40 from drakenclimber/issues/38

cgget: Fix segfault when no flags provided

4 years agocgget: Fix segfault when no flags provided 40/head
Tom Hromatka [Wed, 14 Apr 2021 16:02:44 +0000 (10:02 -0600)] 
cgget: Fix segfault when no flags provided

Fix a segmentation fault when cgget is invoked in the
following form:
cgget CroupName

parse_opt_args() was erroneously expecting a previously
populated struct cgroup in this case, and we were indexing
out of bounds of the cg_list.

Fixes: 1b7d606fa12a ("cgget: Major refactor")
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #39 from drakenclimber/issues/fixwarnings
Tom Hromatka [Thu, 15 Apr 2021 20:42:02 +0000 (14:42 -0600)] 
Merge pull request #39 from drakenclimber/issues/fixwarnings

Fix compiler warnings

4 years agogithub: Convert all compiler warnings to errors 39/head
Tom Hromatka [Mon, 12 Apr 2021 15:51:12 +0000 (09:51 -0600)] 
github: Convert all compiler warnings to errors

For the continuous integration in Github Actions, convert
all compiler warnings to errors.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agowrapper.c: Fix fprintf argument warning
Tom Hromatka [Mon, 12 Apr 2021 15:25:00 +0000 (09:25 -0600)] 
wrapper.c: Fix fprintf argument warning

Fix a warning in cgroup_add_value_string() where '%d' was
being passed to fprintf when it should have been using '%ld'.

wrapper.c: In function ‘cgroup_add_value_string’:
wrapper.c:207:51: warning: format ‘%d’ expects argument of type ‘int’,
but argument 3 has type ‘long unsigned int’ [-Wformat=]
  207 |    fprintf(stderr, "value exceeds the maximum of %d
      characters\n",
      |                                                  ~^
      |                                                   |
      |                                                   int
      |                                                  %ld
  208 |     sizeof(cntl_value->value) - 1);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     |
      |     long unsigned int

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Fix string truncation warnings
Tom Hromatka [Mon, 12 Apr 2021 15:18:56 +0000 (09:18 -0600)] 
api.c: Fix string truncation warnings

Fix two snprintf string truncation warnings in
cg_build_path_locked().

api.c:1475:38: warning: ‘snprintf’ output may be truncated before the
last format character [-Wformat-truncation=]
 1475 |     snprintf(path, FILENAME_MAX, "%s/",
      |                                      ^
api.c:1475:5: note: ‘snprintf’ output between 2 and 4097 bytes into a
destination of size 4096
 1475 |     snprintf(path, FILENAME_MAX, "%s/",
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1476 |       cg_mount_table[i].mount.path);
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
api.c:1470:40: warning: ‘/’ directive output may be truncated writing 1
byte into a region of size between 0 and 4095 [-Wformat-truncation=]
 1470 |     snprintf(path, FILENAME_MAX, "%s/%s/",
      |                                        ^
api.c:1470:5: note: ‘snprintf’ output 3 or more bytes (assuming 4098)
into a destination of size 4096
 1470 |     snprintf(path, FILENAME_MAX, "%s/%s/",
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1471 |       cg_mount_table[i].mount.path,
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1472 |       cg_namespace_table[i]);
      |       ~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Fix incompatible pointer warning
Tom Hromatka [Mon, 12 Apr 2021 14:39:43 +0000 (08:39 -0600)] 
api.c: Fix incompatible pointer warning

Fix the following incompatible pointer warning:

api.c: In function ‘cgroup_delete_cgroup_ext’:
api.c:2888:24: warning: passing argument 4 of
‘cgroup_build_tasks_procs_path’ from incompatible pointer type
[-Wincompatible-pointer-types]
 2888 |      cgroup->controller[i]);
      |      ~~~~~~~~~~~~~~~~~~^~~
      |                        |
      |                        struct cgroup_controller *

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoconfigure: Rename configure.in to configure.ac
Tom Hromatka [Mon, 12 Apr 2021 14:27:57 +0000 (08:27 -0600)] 
configure: Rename configure.in to configure.ac

Fix automake warning that configure.in should be named
configure.ac.

automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #37 from drakenclimber/issues/lssubsys
Tom Hromatka [Thu, 8 Apr 2021 16:50:49 +0000 (10:50 -0600)] 
Merge pull request #37 from drakenclimber/issues/lssubsys

Add cgroup v2 support to lssubsys

4 years agolssubsys: Add cgroup v2 support 36/head 37/head
Tom Hromatka [Wed, 24 Mar 2021 16:38:22 +0000 (10:38 -0600)] 
lssubsys: Add cgroup v2 support

Ignore a hierarchy value of zero for cgroup v2 controllers.
This change adds minimal cgroup v2 support to lssubsys.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #35 from drakenclimber/issues/fixcgset
Tom Hromatka [Mon, 5 Apr 2021 15:21:05 +0000 (09:21 -0600)] 
Merge pull request #35 from drakenclimber/issues/fixcgset

Fix issue where cgset can't handle '=' in the value

4 years agocgset: Declare parse_r_flag() as STATIC 35/head
Tom Hromatka [Wed, 31 Mar 2021 16:55:51 +0000 (16:55 +0000)] 
cgset: Declare parse_r_flag() as STATIC

Declare parse_r_flag() as STATIC so that it can be
unit tested.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agotools: Create a cgset library for testing purposes
Tom Hromatka [Wed, 31 Mar 2021 16:44:11 +0000 (16:44 +0000)] 
tools: Create a cgset library for testing purposes

Create libcgset.la so that functions within cgset can be
unit tested.

A functional test would be preferable in this case, but I'm
looking to test a very specific scenario - where there's an
'=' sign in the value of a setting's name/value pair.  To the
best of my knowledge, only the rdma (v1) and io (v2)
controllers have settings that utilize an '=' in such a fashion.
I can't think of an easy way to test rdma across our test fleet,
and our automated systems don't support the v2 io controller
yet.  Thus a unit test for now.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgset: Fix parsing of name/values with an '=' in the value
Tom Hromatka [Tue, 30 Mar 2021 18:54:06 +0000 (18:54 +0000)] 
cgset: Fix parsing of name/values with an '=' in the value

Fix parsing of name/value pairs that contain an '='
character in the value string.  For example, the io.max
setting utilizes the '=' character:
cgset -r io.max="8:16 wbps=1024" foo

Fixes: https://github.com/libcgroup/libcgroup/issues/33
Reported-by: Santiago Ruano Rincón <santiago.ruano-rincon@imt-atlantique.fr>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agocgset: Refactor parsing of the '-r' flag
Tom Hromatka [Tue, 30 Mar 2021 18:40:11 +0000 (18:40 +0000)] 
cgset: Refactor parsing of the '-r' flag

Refactor parsing of the '-r' flag into its own function.
This is intended to be a nonfunctional change.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #34 from drakenclimber/issues/cgclear2
Tom Hromatka [Fri, 2 Apr 2021 17:30:10 +0000 (11:30 -0600)] 
Merge pull request #34 from drakenclimber/issues/cgclear2

Add cgroup v2 support to cgclear

4 years agoMerge pull request #32 from drakenclimber/issues/remove-libs
Tom Hromatka [Tue, 30 Mar 2021 14:11:59 +0000 (08:11 -0600)] 
Merge pull request #32 from drakenclimber/issues/remove-libs

build: Remove .libs from Makefile.am files.

4 years agobuild: Remove .libs from Makefile.am files. 32/head
Tom Hromatka [Tue, 30 Mar 2021 14:01:31 +0000 (08:01 -0600)] 
build: Remove .libs from Makefile.am files.

Remove .libs from Makefile.am files.  Suggested by
github user @orbea.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogithub: Run the cgclear functional test last 34/head
Tom Hromatka [Tue, 23 Mar 2021 16:18:04 +0000 (16:18 +0000)] 
github: Run the cgclear functional test last

Run the cgclear functional test last since it is destructive to the
cgroup hierarchy.  Note that this test is automatically skipped by
'make check'.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agobootstrap: github: Ignore systemd hierarchy
Tom Hromatka [Mon, 29 Mar 2021 16:46:52 +0000 (16:46 +0000)] 
bootstrap: github: Ignore systemd hierarchy

Ignore the "name=systemd" hierarchy by setting the autoconf
--enable-opaque-hierarchy flag equal to "name=systemd".  This
instructs libcgroup to ignore mounts named "name=systemd" and
thus these mounts aren't added to the cg_mount_table[].

Suggested-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoconfig.c: Add cgroup v2 support to cgclear
Tom Hromatka [Tue, 23 Mar 2021 14:57:28 +0000 (08:57 -0600)] 
config.c: Add cgroup v2 support to cgclear

When cgclear is invoked against a cgroup v2 controller,
do not attempt to unmount the v2 controller.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #30 from drakenclimber/issues/cgset-tests
Tom Hromatka [Mon, 29 Mar 2021 14:11:05 +0000 (08:11 -0600)] 
Merge pull request #30 from drakenclimber/issues/cgset-tests

api.c: Don't fail a recursive write if value isn't dirty

4 years agoapi.c: Don't fail a recursive write if value isn't dirty 30/head
Tom Hromatka [Wed, 10 Mar 2021 18:20:24 +0000 (18:20 +0000)] 
api.c: Don't fail a recursive write if value isn't dirty

When cgroup_modify_cgroup() invokes cgroup_set_values_recursive(),
some of the settings within the cgroup may not be writable.  Avoid
failing the entire write by ignoring write failures on settings that
do not explicitly have the dirty flag set.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agobootstrap: Use main branch of libcgroup-tests
Tom Hromatka [Mon, 1 Mar 2021 20:51:24 +0000 (13:51 -0700)] 
bootstrap: Use main branch of libcgroup-tests

The default branch of libcgroup-tests has been renamed to
main.  Utilize this branch.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #27 from drakenclimber/issues/daemoncodecov
Tom Hromatka [Mon, 1 Mar 2021 18:01:20 +0000 (11:01 -0700)] 
Merge pull request #27 from drakenclimber/issues/daemoncodecov

Makefile: Run code coverage on the daemon folder

4 years agoMakefile: Run code coverage on the daemon folder 27/head
Tom Hromatka [Mon, 22 Feb 2021 19:40:07 +0000 (19:40 +0000)] 
Makefile: Run code coverage on the daemon folder

Code coverage was not being gathered for src/daemon.
Add code coverage support for this directory.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #26 from drakenclimber/issues/cgget-refactor2
Tom Hromatka [Mon, 1 Mar 2021 17:44:05 +0000 (10:44 -0700)] 
Merge pull request #26 from drakenclimber/issues/cgget-refactor2

Refactor cgget

4 years agocgget: Major refactor 26/head
Tom Hromatka [Wed, 10 Feb 2021 17:25:10 +0000 (17:25 +0000)] 
cgget: Major refactor

Previously cgget used data structures unlike anywhere else
within libcgroup.  cgget had arrays of strings to hold the
list of controllers, settings, and values.

Update cgget to utilize struct cgroup and struct
cgroup_controller.

This patch is intended to have no functional changes.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agowrapper.c: Add support for empty values in cgroup_add_value_string()
Tom Hromatka [Mon, 8 Feb 2021 23:05:24 +0000 (16:05 -0700)] 
wrapper.c: Add support for empty values in cgroup_add_value_string()

cgroup_add_value_string() is the fundamental building block
for adding a name/value pair to a cgroup_controller struct.
Add support for a NULL value field.

Currently it only supports adding a valid value, but in a
subsequent commit, cgget will utilize this function to build
up a hierarchy of cgroups, controllers, and setting names.
The values are NULL at the time the struct are populated and
will be read from sysfs at a later time.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Expose cgroup_test_subsys_mounted() to users of libcgroup.la
Tom Hromatka [Wed, 10 Feb 2021 17:21:23 +0000 (17:21 +0000)] 
api.c: Expose cgroup_test_subsys_mounted() to users of libcgroup.la

Remove the static qualifier from cgroup_test_subsys_mounted().  As
part of the cgget refactor, cgget will utilize this function.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Expose cgroup_fill_cgc() to users of libcgroup.la
Tom Hromatka [Mon, 8 Feb 2021 22:58:44 +0000 (15:58 -0700)] 
api.c: Expose cgroup_fill_cgc() to users of libcgroup.la

Remove the static qualifier from cgroup_fill_cgc().  As part
of the cgget refactor, cgget will utilize this function.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi: Expose cg_build_path_locked() to users of libcgroup.la
Tom Hromatka [Mon, 8 Feb 2021 22:48:54 +0000 (15:48 -0700)] 
api: Expose cg_build_path_locked() to users of libcgroup.la

Remove the static qualifier from cg_build_path_locked().  As part
of the cgget refactor, cgget will utilize this function.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #25 from drakenclimber/issues/nocontainer
Tom Hromatka [Mon, 1 Mar 2021 16:27:57 +0000 (09:27 -0700)] 
Merge pull request #25 from drakenclimber/issues/nocontainer

Run tests outside of a container

4 years agogithub: Log the results of the non-containerized tests 25/head
Tom Hromatka [Mon, 1 Mar 2021 16:17:46 +0000 (16:17 +0000)] 
github: Log the results of the non-containerized tests

Log the results of the non-containerized tests.  The
non-containerized tests will be automatically invoked
by `make check`.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #23 from drakenclimber/issues/21
Tom Hromatka [Thu, 25 Feb 2021 15:19:46 +0000 (08:19 -0700)] 
Merge pull request #23 from drakenclimber/issues/21

api.c: Fix erroneous error handling in cgroup_set_values_recursive()

4 years agoapi.c: Fix erroneous error handling in cgroup_set_values_recursive() 23/head
Tom Hromatka [Tue, 23 Feb 2021 20:47:38 +0000 (13:47 -0700)] 
api.c: Fix erroneous error handling in cgroup_set_values_recursive()

Ignore the positive length returned by asprintf() and only act
upon the error code returned from cg_set_control_value().  Previously
cgroup_set_values_recursive() mishandled the error handling when
the value's dirty flag was set.

Reported-by: Bharani viswas <bharani.viswas@gmail.com>
Fixes: 092e4aeb0416f ("api.c: Refactor duplicate logic in cgroup modify and create")
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogithub: Always display test logs
Tom Hromatka [Wed, 23 Dec 2020 18:12:39 +0000 (11:12 -0700)] 
github: Always display test logs

Always display the test logs in the github actions
GUI.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #19 from drakenclimber/issues/cgsnapshot2
Tom Hromatka [Wed, 23 Dec 2020 15:23:17 +0000 (08:23 -0700)] 
Merge pull request #19 from drakenclimber/issues/cgsnapshot2

Add support for cgroup v2 cgsnapshot

4 years agocgsnapshot: Replace hardcoded "tasks" file 19/head
Tom Hromatka [Thu, 17 Dec 2020 18:39:11 +0000 (11:39 -0700)] 
cgsnapshot: Replace hardcoded "tasks" file

Replace the hardcoded building of the tasks path in
cgsnapshot with a call to cgroup_build_tasks_procs_path().
By calling cgroup_build_tasks_procs_path(), cgsnapshot
now supports both cgroup v1 and cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Dhaval Giani <dhaval.giani@oracle.com>
4 years agoapi.c: Export cgroup_build_tasks_procs_path()
Tom Hromatka [Thu, 17 Dec 2020 18:38:52 +0000 (11:38 -0700)] 
api.c: Export cgroup_build_tasks_procs_path()

Make cgroup_build_tasks_procs_path() available to
libcgroup.la library users (i.e. the libcgroup tools).

This change will be used in the next commit so that
cgsnapshot can properly read the tasks/procs file.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Dhaval Giani <dhaval.giani@oracle.com>
4 years agogithub: Display ftests.sh.log in the CI GUI
Tom Hromatka [Thu, 17 Dec 2020 18:24:13 +0000 (11:24 -0700)] 
github: Display ftests.sh.log in the CI GUI

Now that we invoke ftests.sh in the functional tests'
Makefile.am, test-suite.log isn't that useful.  Display
ftests.sh.log in the Github Actions GUI since
ftests.sh.log contains pass/fail info for each test.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #18 from drakenclimber/issues/betterlogs
Tom Hromatka [Thu, 17 Dec 2020 15:50:12 +0000 (08:50 -0700)] 
Merge pull request #18 from drakenclimber/issues/betterlogs

github: Improve logging and reporting

4 years agogithub: Improve logging and reporting 18/head
Tom Hromatka [Thu, 17 Dec 2020 15:03:32 +0000 (08:03 -0700)] 
github: Improve logging and reporting

Display the high-level log, test-suite.log, in
the github work for all jobs.  Also, archive the
functional test logs to facilitate debugging a
failed run.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoREADME.md: Update the coveralls badge
Tom Hromatka [Tue, 15 Dec 2020 22:11:01 +0000 (15:11 -0700)] 
README.md: Update the coveralls badge

The coveralls.io badge wasn't consistently updating
after a successful run.  Remove the "?branch=master"
parameter and switch to using a png rather than an
svg.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #17 from drakenclimber/issues/github_actions
Tom Hromatka [Tue, 15 Dec 2020 21:01:14 +0000 (14:01 -0700)] 
Merge pull request #17 from drakenclimber/issues/github_actions

Transition from Travis CI to Github Actions

4 years agoREADME.md: Transition from Travis CI to Github Actions 17/head
Tom Hromatka [Tue, 15 Dec 2020 20:46:58 +0000 (13:46 -0700)] 
README.md: Transition from Travis CI to Github Actions

Travis CI has now been disabled.  Delete the Travis CI
badge and display the Github Actions continuous integration
workflow badge.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogithub: Add continuous integration Github workflow
Tom Hromatka [Tue, 15 Dec 2020 20:46:21 +0000 (13:46 -0700)] 
github: Add continuous integration Github workflow

Add a Github Actions continuous integration workflow.  This
workflow runs the unit tests, the cgroup v1 functional tests,
and the cgroup v2 functional tests.  The code coverage results
from all of the runs are collated at coveralls.io.

Like Travis CI, Github Actions currently does not provide a
distro that natively runs cgroup v2.  (And it also doesn't
expose the kernel boot command line.)  So, like our previous
Travis CI solution, unmount the cpuset controller and enable
it in cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agogithub: Add a Github Action to setup the libcgroup directory
Tom Hromatka [Tue, 15 Dec 2020 20:45:46 +0000 (13:45 -0700)] 
github: Add a Github Action to setup the libcgroup directory

Add a Github Action to setup the libcgroup directory.
This action installs the required dependencies, run
bootstrap.sh, runs configure, and invokes make.

Since the action is invoked locally (and not via Github
Action's published action mechanism), the repository must
be git cloned prior to running this action.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agotravis: Disable Travis CI
Tom Hromatka [Tue, 15 Dec 2020 20:45:16 +0000 (13:45 -0700)] 
travis: Disable Travis CI

Disable the Travis CI build by deleting the
.travis.yml file.  Subsequent commits will transition
to using Github Actions instead.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #16 from drakenclimber/issues/ftests_cgv2
Tom Hromatka [Mon, 23 Nov 2020 17:14:37 +0000 (10:14 -0700)] 
Merge pull request #16 from drakenclimber/issues/ftests_cgv2

Add cgroup v2 support to the functional tests

4 years agotravis: Add test job on cgroup v2 Ubuntu 20.04 16/head
Tom Hromatka [Wed, 28 Oct 2020 14:57:09 +0000 (14:57 +0000)] 
travis: Add test job on cgroup v2 Ubuntu 20.04

Add a test job on Ubuntu 20.04.  Prior to running the tests, unmount
the cpuset cgroup controller and enable it in the cgroup v2 unified
hierarchy.  Once each job is complete, it notifies coveralls via a
REST call.

Unfortunately, Travis CI doesn't provide a cgroup v2 system image
and also doesn't allow us to modify the kernel boot parameters.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agotravis: Exclude lex.l and parse.y from code coverage
Tom Hromatka [Mon, 26 Oct 2020 16:48:31 +0000 (10:48 -0600)] 
travis: Exclude lex.l and parse.y from code coverage

Exclude lex.l and parse.y from code coverage numbers.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #14 from drakenclimber/issues/cgdelete
Tom Hromatka [Thu, 22 Oct 2020 18:13:27 +0000 (12:13 -0600)] 
Merge pull request #14 from drakenclimber/issues/cgdelete

api.c: Replace hardcoded "/tasks" in delete functions

4 years agoapi.c: Replace hardcoded "/tasks" in delete functions 14/head
Tom Hromatka [Thu, 15 Oct 2020 21:58:19 +0000 (15:58 -0600)] 
api.c: Replace hardcoded "/tasks" in delete functions

Replace the hardcoded building of the tasks path in
cg_delete_cgroup_controller() and cgroup_delete_cgroup_ext()
with a call to cgroup_build_tasks_procs_path().  By calling
cgroup_build_tasks_procs_path(), both delete functions now
support cgroup v1 and v2.

cgdelete now supports cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoMerge pull request #13 from drakenclimber/issues/cgclassify2
Tom Hromatka [Thu, 15 Oct 2020 20:03:23 +0000 (14:03 -0600)] 
Merge pull request #13 from drakenclimber/issues/cgclassify2

Add cgroup v2 support for cgclassify and cgexec

4 years agoapi.c: Verify if a controller is enabled for a v2 cgroup 13/head
Tom Hromatka [Wed, 23 Sep 2020 16:41:32 +0000 (10:41 -0600)] 
api.c: Verify if a controller is enabled for a v2 cgroup

Add a function, cgroupv2_controller_enabled(), that checks if the
requested cgroup v2 controller can be used for the specified path.
Again, in cgroup v2, to use a controller, it must be added to the
parent cgroup's cgroup.subtree_control file.

This check is required to ensure that the cgexec and cgclassify
operations will succeed.  And with this commit, cgexec and cgclassify
work on both cgroup v1 and cgroup v2 hierarchies.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Add function to read the cgroup.subtree_control file
Tom Hromatka [Wed, 23 Sep 2020 16:41:00 +0000 (10:41 -0600)] 
api.c: Add function to read the cgroup.subtree_control file

Add a function, cgroupv2_get_subtree_control(), that verifies
if a controller is enabled in the cgroup.subtree_control file
for the requested path.

This function will be used in the next commit - "api.c: Add function
to check if a controller is enabled for a cgroup v2 cgroup" - to
determine if the requested cgroup v2 controller is enabled for a
cgroup.  This is a required check to ensure that the
cgclassify/cgexec operation will succeed.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoapi.c: Add function to build tasks/procs path
Tom Hromatka [Wed, 23 Sep 2020 16:39:33 +0000 (10:39 -0600)] 
api.c: Add function to build tasks/procs path

Replace the inline logic in multiple functions that concatenates
the path and cgroup v1 tasks file with a function -
cgroup_build_tasks_procs_path() - that works for both cgroup v1
and v2.  In the v1 case, it appends tasks, and in the v2 case, it
appends cgroup.procs.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 years agoRevert "DO NOT COMMIT"
Tom Hromatka [Wed, 9 Sep 2020 16:23:45 +0000 (10:23 -0600)] 
Revert "DO NOT COMMIT"

This reverts commit 83d6205fc7711818bd2e4bf1890d7d157756182e.

4 years agoMerge pull request #11 from drakenclimber/issues/cgcreate
Tom Hromatka [Wed, 9 Sep 2020 16:02:44 +0000 (10:02 -0600)] 
Merge pull request #11 from drakenclimber/issues/cgcreate

Add cgroup v2 support to cgcreate

5 years agoapi.c: Add cgroup v2 support to cgroup_create_cgroup() 11/head
Tom Hromatka [Wed, 29 Jul 2020 16:52:49 +0000 (16:52 +0000)] 
api.c: Add cgroup v2 support to cgroup_create_cgroup()

This commit adds cgroup v2 support go cgroup_create_cgroup().
If the controller is mounted via cgroup v2, then the
subtree_control file in the parent directory will be updated
to enable the controller in children cgroups.  The tasks
file is only updated for cgroup v1 mounts.

Here's an example of creating a cgroup hierarchy in a single command:
sudo cgcreate -g io:a/b/c/d

The above cgcreate example is equivalent to:
mkdir -p {root_cg}/a/b/c/d
echo +io > {root_cg}/cgroup.subtree_control
echo +io > {root_cg}/a/cgroup.subtree_control
echo +io > {root_cg}/a/b/cgroup.subtree_control
echo +io > {root_cg}/a/b/c/cgroup.subtree_control

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 years agoapi.c: Add function to recursively manage the cgroup v2 subtree
Tom Hromatka [Wed, 29 Jul 2020 16:46:44 +0000 (16:46 +0000)] 
api.c: Add function to recursively manage the cgroup v2 subtree

This commit adds the function cgroupv2_subtree_control_recursive().
cgroupv2_subtree_control_recursive() creates a cgroup hierarchy with
the subtree_control enabled in each parent cgroup for the requested
cgroup controller.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>